Ticket #65070: 65070.patch
| File 65070.patch, 12.8 KB (added by , 7 weeks ago) |
|---|
-
Gruntfile.js
diff --git a/Gruntfile.js b/Gruntfile.js index 5f9109fac3..076176a0ba 100644
a b module.exports = function(grunt) { 449 449 [ WORKING_DIR + 'wp-admin/js/tags.js' ]: [ './src/js/_enqueues/admin/tags.js' ], 450 450 [ WORKING_DIR + 'wp-admin/js/site-health.js' ]: [ './src/js/_enqueues/admin/site-health.js' ], 451 451 [ WORKING_DIR + 'wp-admin/js/site-icon.js' ]: [ './src/js/_enqueues/admin/site-icon.js' ], 452 [ WORKING_DIR + 'wp-admin/js/options.js' ]: [ './src/js/_enqueues/admin/options.js' ], 452 453 [ WORKING_DIR + 'wp-admin/js/privacy-tools.js' ]: [ './src/js/_enqueues/admin/privacy-tools.js' ], 453 454 [ WORKING_DIR + 'wp-admin/js/theme-plugin-editor.js' ]: [ './src/js/_enqueues/wp/theme-plugin-editor.js' ], 454 455 [ WORKING_DIR + 'wp-admin/js/theme.js' ]: [ './src/js/_enqueues/wp/theme.js' ], -
src/wp-admin/includes/deprecated.php
diff --git a/src/wp-admin/includes/deprecated.php b/src/wp-admin/includes/deprecated.php index 86524fb897..80566b46ec 100644
a b function image_attachment_fields_to_save( $post, $attachment ) { 1589 1589 1590 1590 return $post; 1591 1591 } 1592 1593 /** 1594 * Output JavaScript to toggle display of additional settings if avatars are disabled. 1595 * 1596 * @since 4.2.0 1597 * @deprecated 7.1.0 Inline JavaScript has been moved to wp-admin/js/options.js, 1598 * enqueued via {@see wp_enqueue_script()}. 1599 */ 1600 function options_discussion_add_js() { 1601 _deprecated_function( __FUNCTION__, '7.1.0' ); 1602 } 1603 1604 /** 1605 * Display JavaScript on the General Settings screen. 1606 * 1607 * @since 3.5.0 1608 * @deprecated 7.1.0 Inline JavaScript has been moved to wp-admin/js/options.js, 1609 * enqueued via {@see wp_enqueue_script()}. 1610 */ 1611 function options_general_add_js() { 1612 _deprecated_function( __FUNCTION__, '7.1.0' ); 1613 } 1614 1615 /** 1616 * Display JavaScript on the Reading Settings screen. 1617 * 1618 * @since 3.5.0 1619 * @deprecated 7.1.0 Inline JavaScript has been moved to wp-admin/js/options.js, 1620 * enqueued via {@see wp_enqueue_script()}. 1621 */ 1622 function options_reading_add_js() { 1623 _deprecated_function( __FUNCTION__, '7.1.0' ); 1624 } -
src/wp-admin/includes/options.php
diff --git a/src/wp-admin/includes/options.php b/src/wp-admin/includes/options.php index 5742e3ccc1..5891298546 100644
a b 7 7 * @since 4.4.0 8 8 */ 9 9 10 /**11 * Output JavaScript to toggle display of additional settings if avatars are disabled.12 *13 * @since 4.2.014 */15 function options_discussion_add_js() {16 ?>17 <script>18 (function($){19 var parent = $( '#show_avatars' ),20 children = $( '.avatar-settings' );21 parent.on( 'change', function(){22 children.toggleClass( 'hide-if-js', ! this.checked );23 });24 })(jQuery);25 </script>26 <?php27 }28 29 /**30 * Display JavaScript on the page.31 *32 * @since 3.5.033 */34 function options_general_add_js() {35 ?>36 <script>37 jQuery( function($) {38 var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),39 $siteIconPreview = $('#site-icon-preview-site-title'),40 homeURL = ( <?php echo wp_json_encode( get_home_url(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );41 42 $( '#blogname' ).on( 'input', function() {43 var title = $.trim( $( this ).val() ) || homeURL;44 45 // Truncate to 40 characters.46 if ( 40 < title.length ) {47 title = title.substring( 0, 40 ) + '\u2026';48 }49 50 $siteName.text( title );51 $siteIconPreview.text( title );52 });53 54 $( 'input[name="date_format"]' ).on( 'click', function() {55 if ( 'date_format_custom_radio' !== $(this).attr( 'id' ) )56 $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );57 });58 59 $( 'input[name="date_format_custom"]' ).on( 'click input', function() {60 $( '#date_format_custom_radio' ).prop( 'checked', true );61 });62 63 $( 'input[name="time_format"]' ).on( 'click', function() {64 if ( 'time_format_custom_radio' !== $(this).attr( 'id' ) )65 $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );66 });67 68 $( 'input[name="time_format_custom"]' ).on( 'click input', function() {69 $( '#time_format_custom_radio' ).prop( 'checked', true );70 });71 72 $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {73 var format = $( this ),74 fieldset = format.closest( 'fieldset' ),75 example = fieldset.find( '.example' ),76 spinner = fieldset.find( '.spinner' );77 78 // Debounce the event callback while users are typing.79 clearTimeout( $.data( this, 'timer' ) );80 $( this ).data( 'timer', setTimeout( function() {81 // If custom date is not empty.82 if ( format.val() ) {83 spinner.addClass( 'is-active' );84 85 $.post( ajaxurl, {86 action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format',87 date : format.val()88 }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );89 }90 }, 500 ) );91 } );92 93 var languageSelect = $( '#WPLANG' );94 $( 'form' ).on( 'submit', function() {95 /*96 * Don't show a spinner for English and installed languages,97 * as there is nothing to download.98 */99 if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {100 $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );101 }102 });103 } );104 </script>105 <?php106 }107 108 /**109 * Display JavaScript on the page.110 *111 * @since 3.5.0112 */113 function options_reading_add_js() {114 ?>115 <script>116 jQuery( function($) {117 var section = $('#front-static-pages'),118 staticPage = section.find('input:radio[value="page"]'),119 selects = section.find('select'),120 check_disabled = function(){121 selects.prop( 'disabled', ! staticPage.prop('checked') );122 };123 check_disabled();124 section.find( 'input:radio' ).on( 'change', check_disabled );125 } );126 </script>127 <?php128 }129 130 10 /** 131 11 * Render the site charset setting. 132 12 * -
src/wp-admin/options-discussion.php
diff --git a/src/wp-admin/options-discussion.php b/src/wp-admin/options-discussion.php index 0c350475fe..59d5d4c397 100644
a b if ( ! current_user_can( 'manage_options' ) ) { 16 16 $title = __( 'Discussion Settings' ); 17 17 $parent_file = 'options-general.php'; 18 18 19 add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' );19 wp_enqueue_script( 'options' ); 20 20 21 21 get_current_screen()->add_help_tab( 22 22 array( -
src/wp-admin/options-general.php
diff --git a/src/wp-admin/options-general.php b/src/wp-admin/options-general.php index 969065b700..77a9883a3a 100644
a b $parent_file = 'options-general.php'; 22 22 /* translators: Date and time format for exact current time, mainly about timezones, see https://www.php.net/manual/datetime.format.php */ 23 23 $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' ); 24 24 25 add_action( 'admin_head', 'options_general_add_js' ); 25 wp_enqueue_script( 'options' ); 26 wp_localize_script( 'options', 'optionsL10n', array( 'homeURL' => get_home_url() ) ); 26 27 27 28 $options_help = '<p>' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '</p>' . 28 29 '<p>' . __( 'Most themes show the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. Many themes also show the tagline.' ) . '</p>'; -
src/wp-admin/options-reading.php
diff --git a/src/wp-admin/options-reading.php b/src/wp-admin/options-reading.php index 31facac7ed..74461b4292 100644
a b if ( ! current_user_can( 'manage_options' ) ) { 17 17 $title = __( 'Reading Settings' ); 18 18 $parent_file = 'options-general.php'; 19 19 20 add_action( 'admin_head', 'options_reading_add_js' );20 wp_enqueue_script( 'options' ); 21 21 22 22 get_current_screen()->add_help_tab( 23 23 array( -
src/wp-includes/script-loader.php
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 42d42b3f87..2bb65a8751 100644
a b function wp_default_scripts( $scripts ) { 1485 1485 $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-api-request', 'wp-url', 'wp-i18n', 'wp-hooks' ), false, 1 ); 1486 1486 $scripts->set_translations( 'site-health' ); 1487 1487 1488 $scripts->add( 'options', "/wp-admin/js/options$suffix.js", array( 'jquery' ), false, 1 ); 1489 1488 1490 $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); 1489 1491 $scripts->set_translations( 'privacy-tools' ); 1490 1492 -
new file src/js/_enqueues/admin/options.js
warning: in the working copy of 'src/js/_enqueues/admin/options.js', LF will be replaced by CRLF the next time Git touches it diff --git a/src/js/_enqueues/admin/options.js b/src/js/_enqueues/admin/options.js new file mode 100644 index 0000000000..bbfeebf6ad
- + 1 /** 2 * Scripts for the options/settings administration screens. 3 * 4 * @output wp-admin/js/options.js 5 */ 6 7 /* global ajaxurl */ 8 9 jQuery( function( $ ) { 10 var $showAvatars = $( '#show_avatars' ), 11 $avatarSettings = $( '.avatar-settings' ), 12 $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(), 13 $siteIconPreview = $( '#site-icon-preview-site-title' ), 14 $languageSelect = $( '#WPLANG' ), 15 $frontStaticPages = $( '#front-static-pages' ), 16 homeURL = ( ( window.optionsL10n && window.optionsL10n.homeURL ) || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' ); 17 18 // options-discussion.php: Toggle avatar settings when 'Show Avatars' is changed. 19 $showAvatars.on( 'change', function() { 20 $avatarSettings.toggleClass( 'hide-if-js', ! this.checked ); 21 } ); 22 23 // options-general.php: Update admin bar site name and site icon preview on title input. 24 $( '#blogname' ).on( 'input', function() { 25 var title = $.trim( $( this ).val() ) || homeURL; 26 27 // Truncate to 40 characters. 28 if ( 40 < title.length ) { 29 title = title.substring( 0, 40 ) + '\u2026'; 30 } 31 32 $siteName.text( title ); 33 $siteIconPreview.text( title ); 34 } ); 35 36 // options-general.php: Date and time format pickers. 37 $( 'input[name="date_format"]' ).on( 'click', function() { 38 if ( 'date_format_custom_radio' !== $( this ).attr( 'id' ) ) { 39 $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); 40 } 41 } ); 42 43 $( 'input[name="date_format_custom"]' ).on( 'click input', function() { 44 $( '#date_format_custom_radio' ).prop( 'checked', true ); 45 } ); 46 47 $( 'input[name="time_format"]' ).on( 'click', function() { 48 if ( 'time_format_custom_radio' !== $( this ).attr( 'id' ) ) { 49 $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); 50 } 51 } ); 52 53 $( 'input[name="time_format_custom"]' ).on( 'click input', function() { 54 $( '#time_format_custom_radio' ).prop( 'checked', true ); 55 } ); 56 57 $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() { 58 var format = $( this ), 59 fieldset = format.closest( 'fieldset' ), 60 example = fieldset.find( '.example' ), 61 spinner = fieldset.find( '.spinner' ); 62 63 // Debounce the event callback while users are typing. 64 clearTimeout( $.data( this, 'timer' ) ); 65 $( this ).data( 'timer', setTimeout( function() { 66 // If custom date is not empty. 67 if ( format.val() ) { 68 spinner.addClass( 'is-active' ); 69 70 $.post( ajaxurl, { 71 action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format', 72 date: format.val() 73 }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } ); 74 } 75 }, 500 ) ); 76 } ); 77 78 // options-general.php: Language install spinner. 79 $( 'form' ).on( 'submit', function() { 80 /* 81 * Don't show a spinner for English and installed languages, 82 * as there is nothing to download. 83 */ 84 if ( $languageSelect.length && ! $languageSelect.find( 'option:selected' ).data( 'installed' ) ) { 85 $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' ); 86 } 87 } ); 88 89 // options-reading.php: Enable/disable page selects based on 'Your homepage displays' radio. 90 if ( $frontStaticPages.length ) { 91 var $staticPage = $frontStaticPages.find( 'input:radio[value="page"]' ), 92 $selects = $frontStaticPages.find( 'select' ), 93 checkDisabled = function() { 94 $selects.prop( 'disabled', ! $staticPage.prop( 'checked' ) ); 95 }; 96 checkDisabled(); 97 $frontStaticPages.find( 'input:radio' ).on( 'change', checkDisabled ); 98 } 99 } );