当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Styles::remove方法代码示例

本文整理汇总了PHP中WP_Styles::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Styles::remove方法的具体用法?PHP WP_Styles::remove怎么用?PHP WP_Styles::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Styles的用法示例。


在下文中一共展示了WP_Styles::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_deregister_style

/**
 * Remove a registered CSS file.
 *
 * @since r79
 * @see WP_Styles::remove() For additional information.
 * @global object $wp_styles The WP_Styles object for printing styles.
 *
 * @param string $handle Name of the stylesheet.
 */
function wp_deregister_style($handle)
{
    global $wp_styles;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    $wp_styles->remove($handle);
}
开发者ID:Tucev,项目名称:Glot-O-Matic,代码行数:17,代码来源:functions.wp-styles.php

示例2: sp_combine_plugin_css_files

function sp_combine_plugin_css_files()
{
    global $sp_plugin_styles, $spDevice;
    if (!is_a($sp_plugin_styles, 'WP_Styles')) {
        $sp_plugin_styles = new WP_Styles();
    }
    # save copy of styles in case of failure writing
    $saved_styles = clone $sp_plugin_styles;
    # check for standard theme or mobile
    if ($spDevice == 'mobile') {
        $option = 'sp_css_concat_mobile';
    } else {
        if ($spDevice == 'tablet') {
            $option = 'sp_css_concat_tablet';
        } else {
            $option = 'sp_css_concat';
        }
    }
    $css_concat = sp_get_option($option);
    if (!is_array($css_concat)) {
        $css_concat = array();
    }
    $css_files_modify = array();
    $css_files = array();
    if (is_array($sp_plugin_styles->queue)) {
        # is there anything in the queue?
        $sp_plugin_styles->all_deps($sp_plugin_styles->queue);
        # preparing the queue taking dependencies into account
        foreach ($css_concat as $css => $value) {
            # going through all the already found css files, checking that they are still required
            if (!in_array(substr($css, 4), $sp_plugin_styles->to_do) && substr($css, 0, 4) == 'css-') {
                # if the css is not queued, rewrite the file
                $css_media = $value['type'];
                $css_files_modify[$css_media] = true;
                unset($css_concat[$css]);
            }
        }
        foreach ($sp_plugin_styles->to_do as $css) {
            $css_src = $sp_plugin_styles->registered[$css]->src;
            $css_media = $sp_plugin_styles->registered[$css]->args;
            # is the css is hosted localy AND is a css file?
            if ((!(strpos($css_src, get_bloginfo('url')) === false) || substr($css_src, 0, 1) === '/' || substr($css_src, 0, 1) === '.') && (substr($css_src, strrpos($css_src, '.'), 4) == '.css' || substr($css_src, strrpos($css_src, '.'), 4) == '.php')) {
                if (!is_array($css_files) || !array_key_exists($css_media, $css_files)) {
                    $css_files[$css_media] = array();
                }
                if (strpos($css_src, get_bloginfo('url')) === false) {
                    $css_relative_url = substr($css_src, 1);
                } else {
                    $css_relative_url = substr($css_src, strlen(get_bloginfo('url')) + 1);
                }
                if (strpos($css_relative_url, '?')) {
                    $css_relative_url = substr($css_relative_url, 0, strpos($css_relative_url, '?'));
                }
                # removing parameters
                $css_m_time = null;
                @($css_m_time = filemtime($css_relative_url));
                # getting the mofified time of the css file. extracting the file's dir
                if ($css_m_time) {
                    # only add the file if it's accessible
                    # check for php theme file indicating main theme file and save whole url vs just relative
                    if (substr($css_src, strrpos($css_src, '.'), 4) == '.php') {
                        array_push($css_files[$css_media], $css_src);
                    } else {
                        array_push($css_files[$css_media], $css_relative_url);
                    }
                    if (!file_exists(SP_COMBINED_CACHE_DIR . SP_COMBINED_CSS_BASE_NAME . $css_media . '.css') || isset($css_concat['css-' . $css]) && ($css_m_time != $css_concat['css-' . $css]['modified'] || $css_concat['css-' . $css]['type'] != $css_media) || !isset($css_concat['css-' . $css])) {
                        # css file is first identified
                        $css_files_modify[$css_media] = true;
                        # the combined file containing this media type css should be changed
                        if (isset($css_concat['css-' . $css]) && $css_concat['css-' . $css]['type'] != $css_media) {
                            # if the media type changed - rewrite both css files
                            $tmp = $css_concat['css-' . $css]['type'];
                            $css_files_modify[$tmp] = true;
                        }
                        if (!is_array($css_concat['css-' . $css])) {
                            $css_concat['css-' . $css] = array();
                        }
                        $css_concat['css-' . $css]['modified'] = $css_m_time;
                        # write the new modified date
                        $css_concat['css-' . $css]['type'] = $css_media;
                    }
                    $sp_plugin_styles->remove($css);
                    # removes the css file from the queue
                }
            }
        }
    }
    foreach ($css_files_modify as $key => $value) {
        $combined_file = fopen(SP_COMBINED_CACHE_DIR . SP_COMBINED_CSS_BASE_NAME . $key . '.css', 'w');
        if ($combined_file) {
            $css_content = '';
            if (is_array($css_files[$key])) {
                foreach ($css_files[$key] as $css_src) {
                    $css_content .= "\n" . sp_get_css_content($css_src) . "\n";
                }
            }
            if (!isset($css_concat['ver'][$key])) {
                $css_concat['ver'][$key] = 0;
            }
            $css_concat['ver'][$key]++;
//.........这里部分代码省略.........
开发者ID:bself,项目名称:nuimage-wp,代码行数:101,代码来源:sp-api-plugins.php

示例3: wp_deregister_style

/**
 * Remove a registered stylesheet.
 *
 * @see WP_Dependencies::remove()
 * @global WP_Styles $wp_styles The WP_Styles object for printing styles.
 *
 * @since 2.1.0
 *
 * @param string $handle Name of the stylesheet to be removed.
 */
function wp_deregister_style($handle)
{
    global $wp_styles;
    if (!is_a($wp_styles, 'WP_Styles')) {
        if (!did_action('init')) {
            _doing_it_wrong(__FUNCTION__, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>'), '3.3');
        }
        $wp_styles = new WP_Styles();
    }
    $wp_styles->remove($handle);
}
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:21,代码来源:functions.wp-styles.php


注:本文中的WP_Styles::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。