/**
 * Display styles that are in the $handles queue.
 *
 * Passing an empty array to $handles prints the queue,
 * passing an array with one string prints that style,
 * and passing an array of strings prints those styles.
 *
 * @global WP_Styles $wp_styles The WP_Styles object for printing styles.
 *
 * @since 2.6.0
 *
 * @param string|bool|array $handles Styles to be printed. Default 'false'.
 * @return array On success, a processed array of WP_Dependencies items; otherwise, an empty array.
 */
function wp_print_styles($handles = false)
{
    if ('' === $handles) {
        // for wp_head
        $handles = false;
    }
    /**
     * Fires before styles in the $handles queue are printed.
     *
     * @since 2.6.0
     */
    if (!$handles) {
        do_action('wp_print_styles');
    }
    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');
        }
        if (!$handles) {
            return array();
        } else {
            $wp_styles = new WP_Styles();
        }
    }
    return $wp_styles->do_items($handles);
}
Example #2
0
 static function do_styles($handles)
 {
     self::do_scripts('jquery');
     global $wp_styles;
     if (!is_a($wp_styles, 'WP_Styles')) {
         $wp_styles = new WP_Styles();
     }
     ob_start();
     $wp_styles->do_items((array) $handles);
     $content = str_replace(array("'", "\n"), array('"', ''), ob_get_clean());
     echo "<script type='text/javascript'>\n";
     echo "jQuery(function (\$) { \$('head').prepend('{$content}'); });\n";
     echo "</script>";
 }
/**
 * Display styles that are in the queue or part of $handles.
 *
 * @since r79
 * @uses do_action() Calls 'wp_print_styles' hook.
 * @global object $wp_styles The WP_Styles object for printing styles.
 *
 * @param array|bool $handles Styles to be printed. An empty array prints the queue,
 *  an array with one string prints that style, and an array of strings prints those styles.
 * @return bool True on success, false on failure.
 */
function wp_print_styles($handles = false)
{
    do_action('wp_print_styles');
    if ('' === $handles) {
        // for wp_head
        $handles = false;
    }
    global $wp_styles;
    if (!is_a($wp_styles, 'WP_Styles')) {
        if (!$handles) {
            return array();
        } else {
            $wp_styles = new WP_Styles();
        }
    }
    return $wp_styles->do_items($handles);
}
/**
 * Display styles that are in the queue or part of $handles.
 *
 * @since r79
 * @uses do_action() Calls 'wp_print_styles' hook.
 * @global object $wp_styles The WP_Styles object for printing styles.
 *
 * @param array|bool $handles Styles to be printed. An empty array prints the queue,
 *  an array with one string prints that style, and an array of strings prints those styles.
 * @return bool True on success, false on failure.
 */
function wp_print_styles( $handles = false ) {
	do_action( 'wp_print_styles' );
	if ( '' === $handles ) // for wp_head
		$handles = false;

	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' );

		if ( !$handles )
			return array(); // No need to instantiate if nothing is there.
		else
			$wp_styles = new WP_Styles();
	}

	return $wp_styles->do_items( $handles );
}
/**
 * Prints the styles queue in the HTML head on admin pages.
 *
 * @since 2.8
 */
function print_admin_styles()
{
    global $wp_styles, $concatenate_scripts, $compress_css;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $zip = $compress_css ? 1 : 0;
    if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) {
        $zip = 'gzip';
    }
    $wp_styles->do_items(false);
    if (apply_filters('print_admin_styles', true)) {
        _print_styles();
    }
    $wp_styles->reset();
    return $wp_styles->done;
}
Example #6
0
/**
 * Prints the styles queue in the HTML head on admin pages.
 *
 * @since 2.8.0
 */
function print_admin_styles()
{
    global $wp_styles, $concatenate_scripts;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $wp_styles->do_items(false);
    /**
     * Filter whether to print the admin styles.
     *
     * @since 2.8.0
     *
     * @param bool $print Whether to print the admin styles. Default true.
     */
    if (apply_filters('print_admin_styles', true)) {
        _print_styles();
    }
    $wp_styles->reset();
    return $wp_styles->done;
}
function print_admin_styles()
{
    global $wp_styles, $concatenate_scripts, $compress_css;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $zip = $compress_css ? 1 : 0;
    if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) {
        $zip = 'gzip';
    }
    $wp_styles->do_items(false);
    if (apply_filters('print_admin_styles', true)) {
        if (!empty($wp_styles->concat)) {
            $dir = $wp_styles->text_direction;
            $ver = md5("{$wp_styles->concat_version}{$dir}");
            $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver={$ver}";
            echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
        }
        if (!empty($wp_styles->print_html)) {
            echo $wp_styles->print_html;
        }
    }
    $wp_styles->do_concat = false;
    $wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = '';
    return $wp_styles->done;
}
Example #8
0
/**
 * Prints the styles queue in the HTML head on admin pages.
 *
 * @since 2.8.0
 */
function print_admin_styles()
{
    global $wp_styles, $concatenate_scripts, $compress_css;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $zip = $compress_css ? 1 : 0;
    if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) {
        $zip = 'gzip';
    }
    $wp_styles->do_items(false);
    /**
     * Filter whether to print the admin styles.
     *
     * @since 2.8.0
     *
     * @param bool $print Whether to print the admin styles. Default true.
     */
    if (apply_filters('print_admin_styles', true)) {
        _print_styles();
    }
    $wp_styles->reset();
    return $wp_styles->done;
}
Example #9
0
 /**
  * Prints specific styles.
  *
  * @param string|array $print A string, or an array of specific handles to print.
  */
 public function print_styles($print)
 {
     $this->check_arg_types(array('string', 'array'), func_get_args());
     $print = (array) $print;
     // Force an array value.
     global $wp_styles;
     // Global object reference.
     if (!$wp_styles instanceof \WP_Styles) {
         $wp_styles = new \WP_Styles();
     }
     foreach ($print = array_unique($print) as $_key => $_handle) {
         if (!$this->©string->is_not_empty($_handle) || !wp_style_is($_handle, 'registered')) {
             unset($print[$_key]);
         }
     }
     // Remove (NOT a handle, or NOT registered).
     unset($_key, $_handle);
     // Housekeeping.
     if ($print) {
         // Still have something to print?
         $wp_styles->do_items($print);
     }
 }