wp_print_styles

The timeline below displays how wordpress function wp_print_styles has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Displays 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 string[] On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array.
 */
function wp_print_styles($handles = false)
{
    global $wp_styles;
    if ('' === $handles) {
        // For 'wp_head'.
        $handles = false;
    }
    if (!$handles) {
        /**
         * Fires before styles in the $handles queue are printed.
         *
         * @since 2.6.0
         */
        do_action('wp_print_styles');
    }
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    if (!$wp_styles instanceof WP_Styles) {
        if (!$handles) {
            return array();
            // No need to instantiate if nothing is there.
        }
    }
    return wp_styles()->do_items($handles);
}

WordPress Version: 5.5

/**
 * 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 string[] On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array.
 */
function wp_print_styles($handles = false)
{
    global $wp_styles;
    if ('' === $handles) {
        // For 'wp_head'.
        $handles = false;
    }
    if (!$handles) {
        /**
         * Fires before styles in the $handles queue are printed.
         *
         * @since 2.6.0
         */
        do_action('wp_print_styles');
    }
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    if (!$wp_styles instanceof WP_Styles) {
        if (!$handles) {
            return array();
            // No need to instantiate if nothing is there.
        }
    }
    return wp_styles()->do_items($handles);
}

WordPress Version: 5.4

/**
 * 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 string[] On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array.
 */
function wp_print_styles($handles = false)
{
    if ('' === $handles) {
        // For 'wp_head'.
        $handles = false;
    }
    if (!$handles) {
        /**
         * Fires before styles in the $handles queue are printed.
         *
         * @since 2.6.0
         */
        do_action('wp_print_styles');
    }
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    global $wp_styles;
    if (!$wp_styles instanceof WP_Styles) {
        if (!$handles) {
            return array();
            // No need to instantiate if nothing is there.
        }
    }
    return wp_styles()->do_items($handles);
}

WordPress Version: 4.2

/**
 * 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');
    }
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    global $wp_styles;
    if (!$wp_styles instanceof WP_Styles) {
        if (!$handles) {
            return array();
            // No need to instantiate if nothing is there.
        }
    }
    return wp_styles()->do_items($handles);
}

WordPress Version: 4.1

/**
 * BackPress Styles Procedural API
 *
 * @since 2.6.0
 *
 * @package WordPress
 * @subpackage BackPress
 */
/**
 * 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);
}

WordPress Version: 3.8

/**
 * BackPress Styles Procedural API
 *
 * @since 2.6.0
 *
 * @package WordPress
 * @subpackage BackPress
 */
/**
 * 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 array|bool $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);
}

WordPress Version: 3.7

/**
 * BackPress Styles Procedural API
 *
 * @since 2.6.0
 *
 * @package WordPress
 * @subpackage BackPress
 */
/**
 * 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.
 *
 * @see do_action() Calls 'wp_print_styles' hook.
 * @global WP_Styles $wp_styles The WP_Styles object for printing styles.
 *
 * @since 2.6.0
 *
 * @param array|bool $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;
    }
    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);
}