當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。