Stop recommending the init hook in the _doing_it_wrong() message for too-early scripts and styles. Instead, recommend the three _enqueue_scripts hooks. If they're noticing they are doing it wrong, let's push them to 100% correct, not partly correct.
see #22896. git-svn-id: http://core.svn.wordpress.org/trunk@23377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cbabdafbed
commit
dcb573103c
|
@ -27,7 +27,7 @@ function wp_print_scripts( $handles = false ) {
|
||||||
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
|
|
||||||
if ( !$handles )
|
if ( !$handles )
|
||||||
return array(); // No need to instantiate if nothing is there.
|
return array(); // No need to instantiate if nothing is there.
|
||||||
|
@ -54,7 +54,7 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_f
|
||||||
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_scripts = new WP_Scripts();
|
$wp_scripts = new WP_Scripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ function wp_localize_script( $handle, $object_name, $l10n ) {
|
||||||
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ function wp_deregister_script( $handle ) {
|
||||||
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_scripts = new WP_Scripts();
|
$wp_scripts = new WP_Scripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false
|
||||||
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_scripts = new WP_Scripts();
|
$wp_scripts = new WP_Scripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ function wp_dequeue_script( $handle ) {
|
||||||
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_scripts = new WP_Scripts();
|
$wp_scripts = new WP_Scripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ function wp_script_is( $handle, $list = 'enqueued' ) {
|
||||||
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_scripts = new WP_Scripts();
|
$wp_scripts = new WP_Scripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ function wp_print_styles( $handles = false ) {
|
||||||
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
|
|
||||||
if ( !$handles )
|
if ( !$handles )
|
||||||
return array(); // No need to instantiate if nothing is there.
|
return array(); // No need to instantiate if nothing is there.
|
||||||
|
@ -55,7 +55,7 @@ function wp_add_inline_style( $handle, $data ) {
|
||||||
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_styles = new WP_Styles();
|
$wp_styles = new WP_Styles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media
|
||||||
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_styles = new WP_Styles();
|
$wp_styles = new WP_Styles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ function wp_deregister_style( $handle ) {
|
||||||
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_styles = new WP_Styles();
|
$wp_styles = new WP_Styles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false,
|
||||||
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_styles = new WP_Styles();
|
$wp_styles = new WP_Styles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ function wp_dequeue_style( $handle ) {
|
||||||
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_styles = new WP_Styles();
|
$wp_styles = new WP_Styles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ function wp_style_is( $handle, $list = 'enqueued' ) {
|
||||||
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
|
||||||
if ( ! did_action( 'init' ) )
|
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.' ),
|
_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' );
|
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
|
||||||
$wp_styles = new WP_Styles();
|
$wp_styles = new WP_Styles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue