X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/5aa86a9053fb0fa15846bb60aac2fb8fdfff524a..11be15bd505d66a91e2c80062190b13e315a04a9:/wp-includes/functions.wp-styles.php diff --git a/wp-includes/functions.wp-styles.php b/wp-includes/functions.wp-styles.php index 8a887e8e..617fd824 100644 --- a/wp-includes/functions.wp-styles.php +++ b/wp-includes/functions.wp-styles.php @@ -18,15 +18,17 @@ * @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; + 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.' ), - 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'init' ), '3.3' ); + 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); if ( !$handles ) return array(); // No need to instantiate if nothing is there. @@ -45,7 +47,7 @@ function wp_print_styles( $handles = false ) { * 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 + * @since 3.3.0 * @see WP_Scripts::add_inline_style() */ function wp_add_inline_style( $handle, $data ) { @@ -53,7 +55,7 @@ function wp_add_inline_style( $handle, $data ) { 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.' ), - 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'init' ), '3.3' ); + 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); $wp_styles = new WP_Styles(); } @@ -72,7 +74,7 @@ function wp_add_inline_style( $handle, $data ) { * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'. * @param array $deps Array of handles of any stylesheet that this stylesheet depends on. * (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies. - * @param string|bool $ver String specifying the stylesheet version number. Set to NULL to disable. + * @param string|bool $ver String specifying the stylesheet version number. Set to null to disable. * Used to ensure that the correct version is sent to the client regardless of caching. * @param string $media The media for which this stylesheet has been defined. */ @@ -81,7 +83,7 @@ function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media 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.' ), - 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'init' ), '3.3' ); + 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); $wp_styles = new WP_Styles(); } @@ -102,7 +104,7 @@ function wp_deregister_style( $handle ) { 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.' ), - 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'init' ), '3.3' ); + 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); $wp_styles = new WP_Styles(); } @@ -133,7 +135,7 @@ function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, 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.' ), - 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'init' ), '3.3' ); + 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); $wp_styles = new WP_Styles(); } @@ -155,7 +157,7 @@ function wp_dequeue_style( $handle ) { 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.' ), - 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'init' ), '3.3' ); + 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); $wp_styles = new WP_Styles(); } @@ -165,28 +167,52 @@ function wp_dequeue_style( $handle ) { /** * Check whether style has been added to WordPress Styles. * - * The values for list defaults to 'queue', which is the same as wp_enqueue_style(). + * By default, checks if the style has been enqueued. You can also + * pass 'registered' to $list, to see if the style is registered, + * and you can check processing statuses with 'to_do' and 'done'. * * @since WP unknown; BP unknown * @global object $wp_styles The WP_Styles object for printing styles. * * @param string $handle Name of the stylesheet. - * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'. - * @return bool True on success, false on failure. + * @param string $list Optional. Defaults to 'enqueued'. Values are + * 'registered', 'enqueued' (or 'queue'), 'to_do', and 'done'. + * @return bool Whether style is in the list. */ -function wp_style_is( $handle, $list = 'queue' ) { +function wp_style_is( $handle, $list = 'enqueued' ) { 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.' ), - 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'init' ), '3.3' ); + 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); $wp_styles = new WP_Styles(); } - $query = $wp_styles->query( $handle, $list ); - - if ( is_object( $query ) ) - return true; + return (bool) $wp_styles->query( $handle, $list ); +} - return $query; +/** + * Add metadata to CSS style files. + * + * Works only if the stylesheet has already been added. + * Possible values for $key and $value: + * + * conditional string comments for IE 6, lte IE 7 etc. + * rtl bool|string to declare an RTL stylesheet + * suffix string optional suffix, used in combination with RTL + * alt bool for rel="alternate stylesheet" + * title string for preferred/alternate stylesheets + * + * @since 3.6.0 + * @see WP_Dependencies::add_data() + * + * @param string $handle Script name. + * @param string $key Name of data point for which we're storing a value. + * Values are 'conditional', 'rtl', and 'suffix', and 'alt', 'title'. + * @param mixed $data + * @return bool True on success, false on failure. + */ +function wp_style_add_data( $handle, $key, $value ) { + global $wp_styles; + return $wp_styles->add_data( $handle, $key, $value ); }