mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 05:10:18 +00:00
Script Loader: Include the script or style handle in _wp_scripts_maybe_doing_it_wrong() message.
This makes the message more helpful and allows for easier debugging. Props janthiel. Fixes #50406. git-svn-id: https://develop.svn.wordpress.org/trunk@48070 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -19,9 +19,11 @@
|
||||
*/
|
||||
function wp_styles() {
|
||||
global $wp_styles;
|
||||
|
||||
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
|
||||
$wp_styles = new WP_Styles();
|
||||
}
|
||||
|
||||
return $wp_styles;
|
||||
}
|
||||
|
||||
@@ -40,6 +42,8 @@ function wp_styles() {
|
||||
* @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;
|
||||
}
|
||||
@@ -55,7 +59,6 @@ function wp_print_styles( $handles = false ) {
|
||||
|
||||
_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.
|
||||
@@ -82,7 +85,7 @@ function wp_print_styles( $handles = false ) {
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
function wp_add_inline_style( $handle, $data ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
|
||||
|
||||
if ( false !== stripos( $data, '</style>' ) ) {
|
||||
_doing_it_wrong(
|
||||
@@ -124,7 +127,7 @@ function wp_add_inline_style( $handle, $data ) {
|
||||
* @return bool Whether the style has been registered. True on success, false on failure.
|
||||
*/
|
||||
function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
|
||||
|
||||
return wp_styles()->add( $handle, $src, $deps, $ver, $media );
|
||||
}
|
||||
@@ -139,7 +142,7 @@ function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media
|
||||
* @param string $handle Name of the stylesheet to be removed.
|
||||
*/
|
||||
function wp_deregister_style( $handle ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
|
||||
|
||||
wp_styles()->remove( $handle );
|
||||
}
|
||||
@@ -168,7 +171,7 @@ function wp_deregister_style( $handle ) {
|
||||
* '(orientation: portrait)' and '(max-width: 640px)'.
|
||||
*/
|
||||
function wp_enqueue_style( $handle, $src = '', $deps = array(), $ver = false, $media = 'all' ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
|
||||
|
||||
$wp_styles = wp_styles();
|
||||
|
||||
@@ -176,6 +179,7 @@ function wp_enqueue_style( $handle, $src = '', $deps = array(), $ver = false, $m
|
||||
$_handle = explode( '?', $handle );
|
||||
$wp_styles->add( $_handle[0], $src, $deps, $ver, $media );
|
||||
}
|
||||
|
||||
$wp_styles->enqueue( $handle );
|
||||
}
|
||||
|
||||
@@ -189,7 +193,7 @@ function wp_enqueue_style( $handle, $src = '', $deps = array(), $ver = false, $m
|
||||
* @param string $handle Name of the stylesheet to be removed.
|
||||
*/
|
||||
function wp_dequeue_style( $handle ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
|
||||
|
||||
wp_styles()->dequeue( $handle );
|
||||
}
|
||||
@@ -205,7 +209,7 @@ function wp_dequeue_style( $handle ) {
|
||||
* @return bool Whether style is queued.
|
||||
*/
|
||||
function wp_style_is( $handle, $list = 'enqueued' ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
|
||||
|
||||
return (bool) wp_styles()->query( $handle, $list );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user