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


PHP WP_Styles::add_inline_style方法代码示例

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


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

示例1: wp_add_inline_style

/**
 * Adds extra CSS.
 *
 * Works only if the stylesheet has already been added.
 * Accepts a string $data containing the CSS. If two or more CSS code blocks are
 * added to the same stylesheet $handle, they will be printed in the order
 * they were added, i.e. the latter added styles can redeclare the previous.
 *
 * @since 3.3.0
 * @see WP_Scripts::add_inline_style()
 */
function wp_add_inline_style($handle, $data)
{
    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>init</code>'), '3.3');
        }
        $wp_styles = new WP_Styles();
    }
    return $wp_styles->add_inline_style($handle, $data);
}
开发者ID:jawandsingh,项目名称:wordpress_with_sql_azure,代码行数:22,代码来源:functions.wp-styles.php

示例2: wp_add_inline_style

/**
 * Add extra CSS styles to a registered stylesheet.
 *
 * Styles will only be added if the stylesheet in already in the queue.
 * Accepts a string $data containing the CSS. If two or more CSS code blocks
 * are added to the same stylesheet $handle, they will be printed in the order
 * they were added, i.e. the latter added styles can redeclare the previous.
 *
 * @see WP_Styles::add_inline_style()
 * @global WP_Styles $wp_styles The WP_Styles object for printing styles.
 *
 * @since 3.3.0
 *
 * @param string $handle Name of the stylesheet to add the extra styles to. Must be lowercase.
 * @param string $data   String containing the CSS styles to be added.
 * @return bool True on success, false on failure.
 */
function wp_add_inline_style($handle, $data)
{
    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();
    }
    if (false !== stripos($data, '</style>')) {
        _doing_it_wrong(__FUNCTION__, __('Do not pass style tags to wp_add_inline_style().'), '3.7');
        $data = trim(preg_replace('#<style[^>]*>(.*)</style>#is', '$1', $data));
    }
    return $wp_styles->add_inline_style($handle, $data);
}
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:32,代码来源:functions.wp-styles.php


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