From dcb573103c9afab8ca87f9c8fcd99b47a57c772d Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 2 Feb 2013 02:42:09 +0000 Subject: [PATCH] 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 --- wp-includes/functions.wp-scripts.php | 14 +++++++------- wp-includes/functions.wp-styles.php | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php index 49b760f04a..591f050803 100644 --- a/wp-includes/functions.wp-scripts.php +++ b/wp-includes/functions.wp-scripts.php @@ -27,7 +27,7 @@ function wp_print_scripts( $handles = false ) { if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { 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. @@ -54,7 +54,7 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_f if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { 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_scripts = new WP_Scripts(); } @@ -88,7 +88,7 @@ function wp_localize_script( $handle, $object_name, $l10n ) { if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { 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' ); return false; } @@ -107,7 +107,7 @@ function wp_deregister_script( $handle ) { if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { 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_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 ( ! 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_scripts = new WP_Scripts(); } @@ -151,7 +151,7 @@ function wp_dequeue_script( $handle ) { if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { 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_scripts = new WP_Scripts(); } @@ -177,7 +177,7 @@ function wp_script_is( $handle, $list = 'enqueued' ) { if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { 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_scripts = new WP_Scripts(); } diff --git a/wp-includes/functions.wp-styles.php b/wp-includes/functions.wp-styles.php index 49095f3b7a..ab3f2e02f3 100644 --- a/wp-includes/functions.wp-styles.php +++ b/wp-includes/functions.wp-styles.php @@ -28,7 +28,7 @@ function wp_print_styles( $handles = 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' ); if ( !$handles ) 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 ( ! 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(); } @@ -83,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(); } @@ -104,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(); } @@ -135,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(); } @@ -157,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(); } @@ -184,7 +184,7 @@ function wp_style_is( $handle, $list = 'enqueued' ) { 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(); }