Пример #1
0
function wp_enqueue_style($handle, $src = false, $deps = array(), $ver = false, $media = false)
{
    global $wp_styles;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    if ($src) {
        $_handle = explode('?', $handle);
        $wp_styles->add($_handle[0], $src, $deps, $ver, $media);
    }
    $wp_styles->enqueue($handle);
}
Пример #2
0
function sp_plugin_enqueue_style($handle, $src, $deps = array(), $ver = false)
{
    global $sp_plugin_styles;
    if (empty($src)) {
        return;
    }
    if (!is_a($sp_plugin_styles, 'WP_Styles')) {
        $sp_plugin_styles = new WP_Styles();
    }
    if ($src) {
        $_handle = explode('?', $handle);
        global $spDevice;
        $media = 'all';
        if ($spDevice == 'mobile') {
            $media = 'mobile';
        }
        if ($spDevice == 'tablet') {
            $media = 'tablet';
        }
        $sp_plugin_styles->add($_handle[0], $src, $deps, $ver, $media);
    }
    $sp_plugin_styles->enqueue($handle);
}
Пример #3
0
/**
 * Enqueue a CSS stylesheet.
 *
 * Registers the style if source provided (does NOT overwrite) and enqueues.
 *
 * @see WP_Dependencies::add(), WP_Dependencies::enqueue()
 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
 * @global WP_Styles $wp_styles The WP_Styles object for printing styles.
 *
 * @since 2.6.0
 *
 * @param string      $handle Name of the stylesheet.
 * @param string|bool $src    Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
 * @param array       $deps   An array of registered style handles this stylesheet depends on. Default empty array.
 * @param string|bool $ver    String specifying the stylesheet version number, if it has one. This parameter is used
 *                            to ensure that the correct version is sent to the client regardless of caching, and so
 *                            should be included if a version number is available and makes sense for the stylesheet.
 * @param string      $media  Optional. The media for which this stylesheet has been defined.
 *                            Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
 *                            'screen', 'tty', or 'tv'.
 */
function wp_enqueue_style($handle, $src = false, $deps = array(), $ver = false, $media = 'all')
{
    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 ($src) {
        $_handle = explode('?', $handle);
        $wp_styles->add($_handle[0], $src, $deps, $ver, $media);
    }
    $wp_styles->enqueue($handle);
}