mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 20:24:26 +00:00
Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -38,13 +38,15 @@ function _wp_scripts_maybe_doing_it_wrong( $function ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_doing_it_wrong( $function, sprintf(
|
||||
/* translators: 1: wp_enqueue_scripts, 2: admin_enqueue_scripts, 3: login_enqueue_scripts */
|
||||
__( '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>login_enqueue_scripts</code>'
|
||||
), '3.3.0' );
|
||||
_doing_it_wrong(
|
||||
$function, sprintf(
|
||||
/* translators: 1: wp_enqueue_scripts, 2: admin_enqueue_scripts, 3: login_enqueue_scripts */
|
||||
__( '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>login_enqueue_scripts</code>'
|
||||
), '3.3.0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,12 +110,14 @@ function wp_add_inline_script( $handle, $data, $position = 'after' ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
|
||||
if ( false !== stripos( $data, '</script>' ) ) {
|
||||
_doing_it_wrong( __FUNCTION__, sprintf(
|
||||
/* translators: 1: <script>, 2: wp_add_inline_script() */
|
||||
__( 'Do not pass %1$s tags to %2$s.' ),
|
||||
'<code><script></code>',
|
||||
'<code>wp_add_inline_script()</code>'
|
||||
), '4.5.0' );
|
||||
_doing_it_wrong(
|
||||
__FUNCTION__, sprintf(
|
||||
/* translators: 1: <script>, 2: wp_add_inline_script() */
|
||||
__( 'Do not pass %1$s tags to %2$s.' ),
|
||||
'<code><script></code>',
|
||||
'<code>wp_add_inline_script()</code>'
|
||||
), '4.5.0'
|
||||
);
|
||||
$data = trim( preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) );
|
||||
}
|
||||
|
||||
@@ -167,7 +171,6 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_f
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @see WP_Dependencies::localize()
|
||||
* @link https://core.trac.wordpress.org/ticket/11520
|
||||
* @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
|
||||
@@ -216,12 +219,31 @@ function wp_deregister_script( $handle ) {
|
||||
( 'wp-login.php' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter )
|
||||
) {
|
||||
$no = array(
|
||||
'jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion',
|
||||
'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog',
|
||||
'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse',
|
||||
'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable',
|
||||
'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs',
|
||||
'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone',
|
||||
'jquery',
|
||||
'jquery-core',
|
||||
'jquery-migrate',
|
||||
'jquery-ui-core',
|
||||
'jquery-ui-accordion',
|
||||
'jquery-ui-autocomplete',
|
||||
'jquery-ui-button',
|
||||
'jquery-ui-datepicker',
|
||||
'jquery-ui-dialog',
|
||||
'jquery-ui-draggable',
|
||||
'jquery-ui-droppable',
|
||||
'jquery-ui-menu',
|
||||
'jquery-ui-mouse',
|
||||
'jquery-ui-position',
|
||||
'jquery-ui-progressbar',
|
||||
'jquery-ui-resizable',
|
||||
'jquery-ui-selectable',
|
||||
'jquery-ui-slider',
|
||||
'jquery-ui-sortable',
|
||||
'jquery-ui-spinner',
|
||||
'jquery-ui-tabs',
|
||||
'jquery-ui-tooltip',
|
||||
'jquery-ui-widget',
|
||||
'underscore',
|
||||
'backbone',
|
||||
);
|
||||
|
||||
if ( in_array( $handle, $no ) ) {
|
||||
@@ -266,7 +288,6 @@ function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $
|
||||
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
|
||||
|
||||
if ( $src || $in_footer ) {
|
||||
$_handle = explode( '?', $handle );
|
||||
|
||||
@@ -331,6 +352,6 @@ function wp_script_is( $handle, $list = 'enqueued' ) {
|
||||
* @param mixed $value String containing the data to be added.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
function wp_script_add_data( $handle, $key, $value ){
|
||||
function wp_script_add_data( $handle, $key, $value ) {
|
||||
return wp_scripts()->add_data( $handle, $key, $value );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user