Ticket #12009: async_defer_scripts.patch
File async_defer_scripts.patch, 6.4 KB (added by , 8 years ago) |
---|
-
src/wp-admin/css/install.css
448 448 display: none; 449 449 } 450 450 451 #toggle-password { 452 display: inline-block; 453 padding-top: 10px; 454 } 455 451 456 /** 452 457 * HiDPI Displays 453 458 */ -
src/wp-admin/js/setup-config.js
1 /** 2 * Adds show/hide toggle for the setup config password 3 */ 4 5 (function() { 6 var toggle, status, input, icon, label; 7 toggle = document.getElementById('toggle-password'); 8 toggle.classList.remove('hide-if-no-js'); 9 10 toggle.addEventListener( 'click', togglePassword ); 11 12 function togglePassword() { 13 status = toggle.getAttribute( 'data-toggle' ); 14 console.log(status); 15 input = document.getElementById( 'pwd' ); 16 icon = toggle.getElementsByClassName('dashicons')[0]; 17 label = toggle.getElementsByClassName('text')[0]; 18 19 if( status == 0 ) { 20 toggle.setAttribute( 'data-toggle', 1 ); 21 input.setAttribute( 'type', 'text' ); 22 icon.classList.remove('dashicons-visibility'); 23 icon.classList.add('dashicons-hidden'); 24 label.innerHTML = setupConfigL10n.hide; 25 toggle.setAttribute( 'aria-label', setupConfigL10n.ariaShow ); 26 } else { 27 toggle.setAttribute( 'data-toggle', 0 ); 28 input.setAttribute( 'type', 'password' ); 29 icon.classList.remove('dashicons-hidden'); 30 icon.classList.add('dashicons-visibility'); 31 label.innerHTML = setupConfigL10n.show; 32 toggle.setAttribute( 'aria-label', setupConfigL10n.ariaHide ); 33 } 34 } 35 })(); 36 No newline at end of file -
src/wp-admin/setup-config.php
199 199 </tr> 200 200 <tr> 201 201 <th scope="row"><label for="pwd"><?php _e( 'Password' ); ?></label></th> 202 <td><input name="pwd" id="pwd" type="text" size="25" value="<?php echo htmlspecialchars( _x( 'password', 'example password' ), ENT_QUOTES ); ?>" autocomplete="off" /></td> 203 <td><?php _e( 'Your database password.' ); ?></td> 202 <td> 203 <input name="pwd" id="pwd" type="password" size="25" placeholder="<?php echo htmlspecialchars( _x( 'password', 'example password' ), ENT_QUOTES ); ?>" autocomplete="off" /> 204 <button id="toggle-password" type="button" class="button button-secondary wp-toggle-pw hide-if-no-js" data-toggle="0" aria-label="Show password"> 205 <span class="dashicons dashicons-visibility"></span> 206 <span class="text"><?php _e( 'Show' ); ?></span> 207 </button> 208 </td> 209 <td><?php _e( '…and your MySQL password.' ); ?></td> 204 210 </tr> 205 211 <tr> 206 212 <th scope="row"><label for="dbhost"><?php _e( 'Database Host' ); ?></label></th> -
src/wp-includes/class.wp-scripts.php
276 276 $before_handle = $this->print_inline_script( $handle, 'before', false ); 277 277 $after_handle = $this->print_inline_script( $handle, 'after', false ); 278 278 279 echo '<pre>'; 280 print_r( $obj ); 281 echo '</pre>'; 282 279 283 if ( $before_handle ) { 280 284 $before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle ); 281 285 } … … 336 340 if ( ! empty( $ver ) ) 337 341 $src = add_query_arg( 'ver', $ver, $src ); 338 342 343 $async = isset( $obj->extra['async'] ) ? 'async' : ''; 344 $defer = isset( $obj->extra['defer'] ) ? 'defer' : ''; 345 339 346 /** This filter is documented in wp-includes/class.wp-scripts.php */ 340 347 $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); 341 348 … … 342 349 if ( ! $src ) 343 350 return true; 344 351 345 $tag = "{$cond_before}{$before_handle}<script type='text/javascript' src='$src' ></script>\n{$after_handle}{$cond_after}";352 $tag = "{$cond_before}{$before_handle}<script type='text/javascript' src='$src'{$async} {$defer}></script>\n{$after_handle}{$cond_after}"; 346 353 347 354 /** 348 355 * Filters the HTML script tag of an enqueued script. -
src/wp-includes/functions.wp-scripts.php
254 254 * If set to null, no version is added. 255 255 * @param bool $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>. 256 256 * Default 'false'. 257 * @param bool $async Optional. Adds the async tag to the script. 258 * @param bool $defer Optional. Adds the defer tag to the script. 257 259 */ 258 function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {260 function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false, $async = false, $defer = false ) { 259 261 $wp_scripts = wp_scripts(); 260 262 261 263 _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); … … 271 273 if ( $in_footer ) { 272 274 $wp_scripts->add_data( $_handle[0], 'group', 1 ); 273 275 } 276 277 if ( $async ) { 278 $wp_scripts->add_data( $_handle[0], 'async', 1 ); 279 } 280 281 if ( $defer ) { 282 $wp_scripts->add_data( $_handle[0], 'defer', 1 ); 283 } 274 284 } 275 285 276 286 $wp_scripts->enqueue( $handle ); -
src/wp-includes/script-loader.php
397 397 'ariaHide' => esc_attr__( 'Hide password' ), 398 398 ) ); 399 399 400 $scripts->add( 'setup-config', "/wp-admin/js/setup-config$suffix.js", array(), false, 1 ); 401 did_action( 'init' ) && $scripts->localize( 'setup-config', 'setupConfigL10n', array( 402 'show' => __( 'Show' ), 403 'hide' => __( 'Hide' ), 404 'ariaShow' => esc_attr__( 'Show password' ), 405 'ariaHide' => esc_attr__( 'Hide password' ), 406 ) ); 407 400 408 $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 ); 401 409 402 410 $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );