2008-05-21 01:56:04 -04:00
|
|
|
<?php
|
2008-09-27 06:06:18 -04:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Dependencies API: WP_Styles class
|
2008-09-27 06:06:18 -04:00
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @since 2.6.0
|
2008-09-27 06:06:18 -04:00
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Dependencies
|
2008-09-27 06:06:18 -04:00
|
|
|
*/
|
2008-05-21 01:56:04 -04:00
|
|
|
|
2008-09-27 06:06:18 -04:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Core class used to register styles.
|
2008-09-27 06:06:18 -04:00
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @since 2.6.0
|
2017-07-01 12:58:42 -04:00
|
|
|
*
|
|
|
|
* @see WP_Dependencies
|
2008-09-27 06:06:18 -04:00
|
|
|
*/
|
2008-05-21 01:56:04 -04:00
|
|
|
class WP_Styles extends WP_Dependencies {
|
2016-02-26 09:39:26 -05:00
|
|
|
/**
|
|
|
|
* Base URL for styles.
|
|
|
|
*
|
|
|
|
* Full URL with trailing slash.
|
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $base_url;
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* URL of the content directory.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $content_url;
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Default version string for stylesheets.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $default_version;
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* The current text direction.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $text_direction = 'ltr';
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Holds a list of style handles which will be concatenated.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $concat = '';
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Holds a string which contains style handles and their version.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
2016-02-27 15:34:29 -05:00
|
|
|
* @deprecated 3.4.0
|
2016-02-26 09:39:26 -05:00
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $concat_version = '';
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Whether to perform concatenation.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
* @var bool
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $do_concat = false;
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Holds HTML markup of styles and additional data if concatenation
|
|
|
|
* is enabled.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $print_html = '';
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Holds inline styles if concatenation is enabled.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 3.3.0
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $print_code = '';
|
2016-02-26 09:39:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* List of default directories.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
* @var array
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public $default_dirs;
|
|
|
|
|
2019-09-18 10:50:56 -04:00
|
|
|
/**
|
|
|
|
* Holds a string which contains the type attribute for style tag.
|
|
|
|
*
|
|
|
|
* If the current theme does not declare HTML5 support for 'style',
|
|
|
|
* then it initializes as `type='text/css'`.
|
|
|
|
*
|
|
|
|
* @since 5.3.0
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $type_attr = '';
|
|
|
|
|
2016-02-26 09:39:26 -05:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public function __construct() {
|
2019-09-23 22:56:57 -04:00
|
|
|
if (
|
|
|
|
function_exists( 'is_admin' ) && ! is_admin()
|
|
|
|
&&
|
|
|
|
function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'style' )
|
|
|
|
) {
|
2019-09-18 18:42:55 -04:00
|
|
|
$this->type_attr = " type='text/css'";
|
|
|
|
}
|
|
|
|
|
2014-03-28 17:24:14 -04:00
|
|
|
/**
|
|
|
|
* Fires when the WP_Styles instance is initialized.
|
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*
|
2017-10-02 18:03:33 -04:00
|
|
|
* @param WP_Styles $this WP_Styles instance (passed by reference).
|
2014-03-28 17:24:14 -04:00
|
|
|
*/
|
2017-11-30 18:11:00 -05:00
|
|
|
do_action_ref_array( 'wp_default_styles', array( &$this ) );
|
2008-05-21 01:56:04 -04:00
|
|
|
}
|
|
|
|
|
2014-11-30 20:34:24 -05:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Processes a style dependency.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @see WP_Dependencies::do_item()
|
|
|
|
*
|
|
|
|
* @param string $handle The style's registered handle.
|
|
|
|
* @return bool True on success, false on failure.
|
2014-11-30 20:34:24 -05:00
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public function do_item( $handle ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! parent::do_item( $handle ) ) {
|
2008-05-21 01:56:04 -04:00
|
|
|
return false;
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2008-05-21 01:56:04 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$obj = $this->registered[ $handle ];
|
2018-08-11 13:42:24 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( null === $obj->ver ) {
|
2009-12-27 19:48:20 -05:00
|
|
|
$ver = '';
|
2017-11-30 18:11:00 -05:00
|
|
|
} else {
|
2011-07-24 20:36:06 -04:00
|
|
|
$ver = $obj->ver ? $obj->ver : $this->default_version;
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2009-12-27 19:48:20 -05:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $this->args[ $handle ] ) ) {
|
|
|
|
$ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ];
|
|
|
|
}
|
2008-05-21 01:56:04 -04:00
|
|
|
|
2018-08-11 13:42:24 -04:00
|
|
|
$src = $obj->src;
|
2019-07-02 19:42:58 -04:00
|
|
|
$cond_before = '';
|
|
|
|
$cond_after = '';
|
2018-08-11 13:42:24 -04:00
|
|
|
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
|
|
|
|
|
|
|
|
if ( $conditional ) {
|
|
|
|
$cond_before = "<!--[if {$conditional}]>\n";
|
|
|
|
$cond_after = "<![endif]-->\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$inline_style = $this->print_inline_style( $handle, false );
|
|
|
|
|
|
|
|
if ( $inline_style ) {
|
2019-09-18 10:50:56 -04:00
|
|
|
$inline_style_tag = sprintf(
|
|
|
|
"<style id='%s-inline-css'%s>\n%s\n</style>\n",
|
|
|
|
esc_attr( $handle ),
|
|
|
|
$this->type_attr,
|
|
|
|
$inline_style
|
|
|
|
);
|
2018-08-11 13:42:24 -04:00
|
|
|
} else {
|
|
|
|
$inline_style_tag = '';
|
|
|
|
}
|
|
|
|
|
2009-01-14 09:18:51 -05:00
|
|
|
if ( $this->do_concat ) {
|
2018-08-11 13:42:24 -04:00
|
|
|
if ( $this->in_default_dir( $src ) && ! $conditional && ! isset( $obj->extra['alt'] ) ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->concat .= "$handle,";
|
2009-01-26 07:59:10 -05:00
|
|
|
$this->concat_version .= "$handle$ver";
|
2011-07-24 20:36:06 -04:00
|
|
|
|
2018-08-11 13:42:24 -04:00
|
|
|
$this->print_code .= $inline_style;
|
2011-07-24 20:36:06 -04:00
|
|
|
|
2009-01-14 09:18:51 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $obj->args ) ) {
|
2011-07-24 20:36:06 -04:00
|
|
|
$media = esc_attr( $obj->args );
|
2017-11-30 18:11:00 -05:00
|
|
|
} else {
|
2008-05-21 01:56:04 -04:00
|
|
|
$media = 'all';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2008-05-21 01:56:04 -04:00
|
|
|
|
2016-02-17 12:11:26 -05:00
|
|
|
// A single item may alias a set of items, by having dependencies, but no source.
|
2018-08-11 13:42:24 -04:00
|
|
|
if ( ! $src ) {
|
|
|
|
if ( $inline_style_tag ) {
|
2016-02-17 12:11:26 -05:00
|
|
|
if ( $this->do_concat ) {
|
2018-08-11 13:42:24 -04:00
|
|
|
$this->print_html .= $inline_style_tag;
|
2016-02-17 12:11:26 -05:00
|
|
|
} else {
|
2018-08-11 13:42:24 -04:00
|
|
|
echo $inline_style_tag;
|
2016-02-17 12:11:26 -05:00
|
|
|
}
|
|
|
|
}
|
2018-08-11 13:42:24 -04:00
|
|
|
|
2014-03-12 12:12:15 -04:00
|
|
|
return true;
|
|
|
|
}
|
2016-02-17 12:11:26 -05:00
|
|
|
|
2018-08-11 13:42:24 -04:00
|
|
|
$href = $this->_css_href( $src, $ver, $handle );
|
2016-02-19 15:34:26 -05:00
|
|
|
if ( ! $href ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
|
2019-09-18 10:50:56 -04:00
|
|
|
$title = isset( $obj->extra['title'] ) ? sprintf( "title='%s'", esc_attr( $obj->extra['title'] ) ) : '';
|
|
|
|
|
|
|
|
$tag = sprintf(
|
|
|
|
"<link rel='%s' id='%s-css' %s href='%s'%s media='%s' />\n",
|
|
|
|
$rel,
|
|
|
|
$handle,
|
|
|
|
$title,
|
|
|
|
$href,
|
|
|
|
$this->type_attr,
|
|
|
|
$media
|
|
|
|
);
|
2019-09-10 15:23:55 -04:00
|
|
|
|
2014-03-28 17:24:14 -04:00
|
|
|
/**
|
2016-05-22 14:50:28 -04:00
|
|
|
* Filters the HTML link tag of an enqueued style.
|
2014-03-28 17:24:14 -04:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
2015-06-21 15:35:26 -04:00
|
|
|
* @since 4.3.0 Introduced the `$href` parameter.
|
2016-02-19 16:05:26 -05:00
|
|
|
* @since 4.5.0 Introduced the `$media` parameter.
|
2014-03-28 17:24:14 -04:00
|
|
|
*
|
2015-07-13 17:03:24 -04:00
|
|
|
* @param string $html The link tag for the enqueued style.
|
2014-03-28 17:24:14 -04:00
|
|
|
* @param string $handle The style's registered handle.
|
2015-06-21 15:35:26 -04:00
|
|
|
* @param string $href The stylesheet's source URL.
|
2016-02-19 16:05:26 -05:00
|
|
|
* @param string $media The stylesheet's media attribute.
|
2014-03-28 17:24:14 -04:00
|
|
|
*/
|
2019-09-10 15:23:55 -04:00
|
|
|
$tag = apply_filters( 'style_loader_tag', $tag, $handle, $href, $media );
|
2018-08-11 13:42:24 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( 'rtl' === $this->text_direction && isset( $obj->extra['rtl'] ) && $obj->extra['rtl'] ) {
|
2013-11-12 16:19:15 -05:00
|
|
|
if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
$suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : '';
|
2018-08-11 13:42:24 -04:00
|
|
|
$rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $src, $ver, "$handle-rtl" ) );
|
2010-02-23 18:46:07 -05:00
|
|
|
} else {
|
2011-07-24 20:36:06 -04:00
|
|
|
$rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" );
|
2010-02-23 18:46:07 -05:00
|
|
|
}
|
2008-05-21 01:56:04 -04:00
|
|
|
|
2019-09-18 10:50:56 -04:00
|
|
|
$rtl_tag = sprintf(
|
|
|
|
"<link rel='%s' id='%s-rtl-css' %s href='%s'%s media='%s' />\n",
|
|
|
|
$rel,
|
|
|
|
$handle,
|
|
|
|
$title,
|
|
|
|
$rtl_href,
|
|
|
|
$this->type_attr,
|
|
|
|
$media
|
|
|
|
);
|
|
|
|
|
2014-04-25 02:29:14 -04:00
|
|
|
/** This filter is documented in wp-includes/class.wp-styles.php */
|
2019-09-10 15:23:55 -04:00
|
|
|
$rtl_tag = apply_filters( 'style_loader_tag', $rtl_tag, $handle, $rtl_href, $media );
|
2013-11-12 16:19:15 -05:00
|
|
|
|
2020-02-09 11:55:09 -05:00
|
|
|
if ( 'replace' === $obj->extra['rtl'] ) {
|
2013-11-12 16:19:15 -05:00
|
|
|
$tag = $rtl_tag;
|
|
|
|
} else {
|
|
|
|
$tag .= $rtl_tag;
|
|
|
|
}
|
2008-05-21 19:24:23 -04:00
|
|
|
}
|
|
|
|
|
2011-07-24 20:36:06 -04:00
|
|
|
if ( $this->do_concat ) {
|
2018-08-11 13:42:24 -04:00
|
|
|
$this->print_html .= $cond_before;
|
2009-01-14 09:18:51 -05:00
|
|
|
$this->print_html .= $tag;
|
2018-08-11 13:42:24 -04:00
|
|
|
if ( $inline_style_tag ) {
|
|
|
|
$this->print_html .= $inline_style_tag;
|
2015-01-02 23:10:21 -05:00
|
|
|
}
|
2018-08-11 13:42:24 -04:00
|
|
|
$this->print_html .= $cond_after;
|
2011-07-24 20:36:06 -04:00
|
|
|
} else {
|
2018-08-11 13:42:24 -04:00
|
|
|
echo $cond_before;
|
2009-01-14 09:18:51 -05:00
|
|
|
echo $tag;
|
2013-10-15 10:35:09 -04:00
|
|
|
$this->print_inline_style( $handle );
|
2018-08-11 13:42:24 -04:00
|
|
|
echo $cond_after;
|
2011-07-24 20:36:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-30 20:34:24 -05:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Adds extra CSS styles to a registered stylesheet.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 3.3.0
|
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @param string $handle The style's registered handle.
|
|
|
|
* @param string $code String containing the CSS styles to be added.
|
|
|
|
* @return bool True on success, false on failure.
|
2014-11-30 20:34:24 -05:00
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public function add_inline_style( $handle, $code ) {
|
2014-10-18 13:58:19 -04:00
|
|
|
if ( ! $code ) {
|
2011-07-24 20:36:06 -04:00
|
|
|
return false;
|
2014-10-18 13:58:19 -04:00
|
|
|
}
|
2011-07-24 20:36:06 -04:00
|
|
|
|
2011-07-28 14:24:00 -04:00
|
|
|
$after = $this->get_data( $handle, 'after' );
|
2014-10-18 13:58:19 -04:00
|
|
|
if ( ! $after ) {
|
2011-07-28 14:24:00 -04:00
|
|
|
$after = array();
|
2014-10-18 13:58:19 -04:00
|
|
|
}
|
2011-07-24 20:36:06 -04:00
|
|
|
|
2011-07-28 14:24:00 -04:00
|
|
|
$after[] = $code;
|
|
|
|
|
|
|
|
return $this->add_data( $handle, 'after', $after );
|
2011-07-24 20:36:06 -04:00
|
|
|
}
|
|
|
|
|
2014-11-30 20:34:24 -05:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Prints extra CSS styles of a registered stylesheet.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 3.3.0
|
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @param string $handle The style's registered handle.
|
2020-02-02 19:19:03 -05:00
|
|
|
* @param bool $echo Optional. Whether to echo the inline style
|
|
|
|
* instead of just returning it. Default true.
|
|
|
|
* @return string|bool False if no data exists, inline styles if `$echo` is true,
|
|
|
|
* true otherwise.
|
2014-11-30 20:34:24 -05:00
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public function print_inline_style( $handle, $echo = true ) {
|
2011-07-28 14:24:00 -04:00
|
|
|
$output = $this->get_data( $handle, 'after' );
|
|
|
|
|
2014-10-18 13:58:19 -04:00
|
|
|
if ( empty( $output ) ) {
|
2011-07-24 20:36:06 -04:00
|
|
|
return false;
|
2014-10-18 13:58:19 -04:00
|
|
|
}
|
2011-07-24 20:36:06 -04:00
|
|
|
|
2011-07-28 14:24:00 -04:00
|
|
|
$output = implode( "\n", $output );
|
2011-07-24 20:36:06 -04:00
|
|
|
|
2014-10-18 13:58:19 -04:00
|
|
|
if ( ! $echo ) {
|
2011-07-24 20:36:06 -04:00
|
|
|
return $output;
|
2014-10-18 13:58:19 -04:00
|
|
|
}
|
2008-05-21 01:56:04 -04:00
|
|
|
|
2019-09-18 10:50:56 -04:00
|
|
|
printf(
|
|
|
|
"<style id='%s-inline-css'%s>\n%s\n</style>\n",
|
|
|
|
esc_attr( $handle ),
|
|
|
|
$this->type_attr,
|
|
|
|
$output
|
|
|
|
);
|
2008-05-21 01:56:04 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-30 20:34:24 -05:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Determines style dependencies.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @see WP_Dependencies::all_deps()
|
|
|
|
*
|
2020-02-02 19:19:03 -05:00
|
|
|
* @param string|string[] $handles Item handle (string) or item handles (array of strings).
|
|
|
|
* @param bool $recursion Optional. Internal flag that function is calling itself.
|
|
|
|
* Default false.
|
|
|
|
* @param int|false $group Optional. Group level: level (int), no groups (false).
|
|
|
|
* Default false.
|
2016-02-27 15:34:29 -05:00
|
|
|
* @return bool True on success, false on failure.
|
2014-11-30 20:34:24 -05:00
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public function all_deps( $handles, $recursion = false, $group = false ) {
|
2016-03-06 14:50:27 -05:00
|
|
|
$r = parent::all_deps( $handles, $recursion, $group );
|
2016-02-27 15:34:29 -05:00
|
|
|
if ( ! $recursion ) {
|
2014-03-28 17:24:14 -04:00
|
|
|
/**
|
2016-05-22 14:50:28 -04:00
|
|
|
* Filters the array of enqueued styles before processing for output.
|
2014-03-28 17:24:14 -04:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*
|
2018-03-25 15:33:31 -04:00
|
|
|
* @param string[] $to_do The list of enqueued style handles about to be processed.
|
2014-03-28 17:24:14 -04:00
|
|
|
*/
|
2008-05-21 01:56:04 -04:00
|
|
|
$this->to_do = apply_filters( 'print_styles_array', $this->to_do );
|
2014-03-28 17:24:14 -04:00
|
|
|
}
|
2008-05-21 01:56:04 -04:00
|
|
|
return $r;
|
|
|
|
}
|
2008-05-21 19:24:23 -04:00
|
|
|
|
2014-11-30 20:34:24 -05:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Generates an enqueued style's fully-qualified URL.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*
|
2020-02-02 19:19:03 -05:00
|
|
|
* @param string $src The source of the enqueued style.
|
|
|
|
* @param string $ver The version of the enqueued style.
|
2016-02-27 15:34:29 -05:00
|
|
|
* @param string $handle The style's registered handle.
|
|
|
|
* @return string Style's fully-qualified URL.
|
2014-11-30 20:34:24 -05:00
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public function _css_href( $src, $ver, $handle ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! is_bool( $src ) && ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) {
|
2008-05-21 19:24:23 -04:00
|
|
|
$src = $this->base_url . $src;
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! empty( $ver ) ) {
|
|
|
|
$src = add_query_arg( 'ver', $ver, $src );
|
|
|
|
}
|
2014-03-28 17:24:14 -04:00
|
|
|
|
|
|
|
/**
|
2016-05-22 14:50:28 -04:00
|
|
|
* Filters an enqueued style's fully-qualified URL.
|
2014-03-28 17:24:14 -04:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*
|
|
|
|
* @param string $src The source URL of the enqueued style.
|
|
|
|
* @param string $handle The style's registered handle.
|
|
|
|
*/
|
2008-05-21 19:24:23 -04:00
|
|
|
$src = apply_filters( 'style_loader_src', $src, $handle );
|
2009-05-18 12:00:33 -04:00
|
|
|
return esc_url( $src );
|
2008-05-21 19:24:23 -04:00
|
|
|
}
|
|
|
|
|
2014-11-30 20:34:24 -05:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Whether a handle's source is in a default directory.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @param string $src The source of the enqueued style.
|
|
|
|
* @return bool True if found, false if not.
|
2014-11-30 20:34:24 -05:00
|
|
|
*/
|
2016-02-26 09:39:26 -05:00
|
|
|
public function in_default_dir( $src ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! $this->default_dirs ) {
|
2009-01-14 09:18:51 -05:00
|
|
|
return true;
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2009-01-14 09:18:51 -05:00
|
|
|
|
|
|
|
foreach ( (array) $this->default_dirs as $test ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( 0 === strpos( $src, $test ) ) {
|
2009-01-14 09:18:51 -05:00
|
|
|
return true;
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2009-01-14 09:18:51 -05:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-07-28 14:24:00 -04:00
|
|
|
|
2015-05-24 01:05:26 -04:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Processes items and dependencies for the footer group.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* HTML 5 allows styles in the body, grab late enqueued items and output them in the footer.
|
|
|
|
*
|
|
|
|
* @since 3.3.0
|
|
|
|
*
|
2016-02-27 15:34:29 -05:00
|
|
|
* @see WP_Dependencies::do_items()
|
|
|
|
*
|
2019-11-05 16:27:02 -05:00
|
|
|
* @return string[] Handles of items that have been processed.
|
2015-05-24 01:05:26 -04:00
|
|
|
*/
|
2016-02-26 09:39:26 -05:00
|
|
|
public function do_footer_items() {
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->do_items( false, 1 );
|
2011-07-21 12:32:01 -04:00
|
|
|
return $this->done;
|
|
|
|
}
|
2009-01-14 09:18:51 -05:00
|
|
|
|
2015-05-29 17:37:24 -04:00
|
|
|
/**
|
2016-02-27 15:34:29 -05:00
|
|
|
* Resets class properties.
|
2016-02-26 09:39:26 -05:00
|
|
|
*
|
|
|
|
* @since 3.3.0
|
2015-05-29 17:37:24 -04:00
|
|
|
*/
|
2014-05-19 02:17:14 -04:00
|
|
|
public function reset() {
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->do_concat = false;
|
|
|
|
$this->concat = '';
|
2011-07-21 12:32:01 -04:00
|
|
|
$this->concat_version = '';
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->print_html = '';
|
2011-07-21 12:32:01 -04:00
|
|
|
}
|
2008-05-21 01:56:04 -04:00
|
|
|
}
|