Make WordPress Core

Ticket #31354: 31354.5.patch

File 31354.5.patch, 11.4 KB (added by joedolson, 6 months ago)

Updated patch

  • src/wp-admin/css/edit.css

     
    13081308        outline: 2px solid transparent;
    13091309}
    13101310
     1311.options-discussion-php .indent-children ul,
    13111312#front-page-warning,
    13121313#front-static-pages ul,
    13131314ul.export-filters,
  • src/wp-admin/includes/options.php

     
    88 */
    99
    1010/**
    11  * Output JavaScript to toggle display of additional settings if avatars are disabled.
     11 * Output JavaScript for discussion options.
    1212 *
    13  * @since 4.2.0
     13 * @since 4.2.0 Added JavaScript to toggle additional settings if avatars are disabled.
     14 * @since 6.6.0 Added JavaScript to handle fields that are conditionally disabled.
    1415 */
    1516function options_discussion_add_js() {
    1617        ?>
    1718        <script>
    1819        (function($){
    19                 var parent = $( '#show_avatars' ),
    20                         children = $( '.avatar-settings' );
    21                 parent.on( 'change', function(){
    22                         children.toggleClass( 'hide-if-js', ! this.checked );
    23                 });
     20                function toggleEditableState(parentCheckboxId, childInputElement){
     21                        let $parentCheckbox = $(parentCheckboxId ),
     22                                $childrenInputs = $(childInputElement );
     23
     24                        // Set the initial state based on the checkbox state
     25                        $childrenInputs.find('input, select, textarea').each(function() {
     26                                $(this).prop( 'disabled', $parentCheckbox.prop( 'checked' ) );
     27                        });
     28                        // Update the disabled state of children on parent checkbox change
     29                        $parentCheckbox.on('change', function() {
     30                                let isChecked = this.checked;
     31                                $childrenInputs.each(function() {
     32                                        $(this).prop( 'disabled', ! isChecked );
     33                                });
     34                        });
     35                }
     36
     37                // Call function for each expandable section of discussion settings.
     38                toggleEditableState('#close_comments_for_old_posts', '.close-comments-setting' );
     39                toggleEditableState('#thread_comments', '.thread-comments-setting' );
     40                toggleEditableState('#page_comments', '.pagination-setting' );
     41                toggleEditableState('#show_avatars', '.avatar-settings input' );
    2442        })(jQuery);
    2543        </script>
    2644        <?php
  • src/wp-admin/options-discussion.php

     
    3939<div class="wrap">
    4040<h1><?php echo esc_html( $title ); ?></h1>
    4141
     42<!-- ARIA live region for screen readers -->
     43<div id="aria-live-region" aria-live="polite" class="screen-reader-text"></div>
     44
     45
    4246<form method="post" action="options.php">
    4347<?php settings_fields( 'discussion' ); ?>
    4448
    45 <table class="form-table" role="presentation">
     49<table class="form-table indent-children" role="presentation">
    4650<tr>
    4751<th scope="row"><?php _e( 'Default post settings' ); ?></th>
    4852<td><fieldset><legend class="screen-reader-text"><span>
     
    8690?>
    8791</label>
    8892<br />
    89 
    90 <label for="close_comments_for_old_posts">
    91 <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked( '1', get_option( 'close_comments_for_old_posts' ) ); ?> />
     93<input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked( '1', get_option( 'close_comments_for_old_posts' ) ); ?> /> <label for="close_comments_for_old_posts"><?php _e( 'Automatically close comments for old posts' ); ?></label>
     94<br />
    9295<?php
    93 printf(
    94         /* translators: %s: Number of days. */
    95         __( 'Automatically close comments on posts older than %s days' ),
    96         '</label> <label for="close_comments_days_old"><input name="close_comments_days_old" type="number" min="0" step="1" id="close_comments_days_old" value="' . esc_attr( get_option( 'close_comments_days_old' ) ) . '" class="small-text" />'
    97 );
     96        $close_comments_disabled = ( '1' === get_option( 'close_comments_for_old_posts' ) ) ? '' : ' disabled';
    9897?>
    99 </label>
    100 <br />
     98<ul>
     99        <li>
     100                <label for="close_comments_days_old"><?php _e( 'Number of days to keep old comments' ); ?></label>
     101                <input name="close_comments_days_old" type="number" step="1" min="0" id="close_comments_days_old" value="<?php echo esc_attr( get_option( 'close_comments_days_old' ) ); ?>" class="small-text close-comments-setting"<?php echo $close_comments_disabled; ?> />
     102        </li>
     103</ul>
    101104
    102 <label for="show_comments_cookies_opt_in">
    103105<input name="show_comments_cookies_opt_in" type="checkbox" id="show_comments_cookies_opt_in" value="1" <?php checked( '1', get_option( 'show_comments_cookies_opt_in' ) ); ?> />
    104 <?php _e( 'Show comments cookies opt-in checkbox, allowing comment author cookies to be set' ); ?>
    105 </label>
     106<label for="show_comments_cookies_opt_in"><?php _e( 'Show comments cookies opt-in checkbox, allowing comment author cookies to be set' ); ?></label>
    106107<br />
     108<input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked( '1', get_option( 'thread_comments' ) ); ?> />
     109<label for="thread_comments"><?php _e( 'Enable threaded (nested) comments' ); ?></label>
    107110
    108 <label for="thread_comments">
    109 <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked( '1', get_option( 'thread_comments' ) ); ?> />
    110111<?php
    111112/**
    112113 * Filters the maximum depth of threaded/nested comments.
     
    117118 */
    118119$maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
    119120
    120 $thread_comments_depth = '</label> <label for="thread_comments_depth"><select name="thread_comments_depth" id="thread_comments_depth">';
     121$thread_comments_disabled = ( '1' === get_option( 'thread_comments' ) ) ? '' : ' disabled';
     122$thread_comments_depth    = '<select name="thread_comments_depth" class="thread-comments-setting" id="thread_comments_depth"' . $thread_comments_disabled . '>';
    121123for ( $i = 2; $i <= $maxdeep; $i++ ) {
    122124        $thread_comments_depth .= "<option value='" . esc_attr( $i ) . "'";
    123125        if ( (int) get_option( 'thread_comments_depth' ) === $i ) {
     
    126128        $thread_comments_depth .= ">$i</option>";
    127129}
    128130$thread_comments_depth .= '</select>';
     131?>
     132<ul>
     133        <li>
     134                <label for="thread_comments_depth"><?php _e( 'Number of levels for threaded (nested) comments' ); ?></label>
     135                <?php echo $thread_comments_depth; ?>
     136        </li>
     137</ul>
     138</fieldset></td>
     139</tr>
    129140
    130 /* translators: %s: Number of levels. */
    131 printf( __( 'Enable threaded (nested) comments %s levels deep' ), $thread_comments_depth );
    132 
    133 ?>
    134 </label>
    135 <br />
    136 <label for="page_comments">
     141<tr>
     142<th scope="row"><?php _e( 'Comment Pagination' ); ?></th>
     143<td><fieldset><legend class="screen-reader-text"><span>
     144        <?php
     145        /* translators: Hidden accessibility text. */
     146        _e( 'Comment Pagination' );
     147        ?>
     148</span></legend>
    137149<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked( '1', get_option( 'page_comments' ) ); ?> />
     150<label for="page_comments"><?php _e( 'Break comments into pages' ); ?></label>
    138151<?php
    139 $default_comments_page = '</label> <label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
    140 if ( 'newest' === get_option( 'default_comments_page' ) ) {
    141         $default_comments_page .= ' selected="selected"';
    142 }
    143 $default_comments_page .= '>' . __( 'last' ) . '</option><option value="oldest"';
    144 if ( 'oldest' === get_option( 'default_comments_page' ) ) {
    145         $default_comments_page .= ' selected="selected"';
    146 }
    147 $default_comments_page .= '>' . __( 'first' ) . '</option></select>';
    148 printf(
    149         /* translators: 1: Form field control for number of top level comments per page, 2: Form field control for the 'first' or 'last' page. */
    150         __( 'Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default' ),
    151         '</label> <label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="' . esc_attr( get_option( 'comments_per_page' ) ) . '" class="small-text" />',
    152         $default_comments_page
    153 );
     152$comments_pagination_disabled = ( '1' === get_option( 'page_comments' ) ) ? '' : ' disabled';
    154153?>
    155 </label>
    156 <br />
    157 <label for="comment_order">
    158 <?php
    159 
    160 $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
    161 if ( 'asc' === get_option( 'comment_order' ) ) {
    162         $comment_order .= ' selected="selected"';
    163 }
    164 $comment_order .= '>' . __( 'older' ) . '</option><option value="desc"';
    165 if ( 'desc' === get_option( 'comment_order' ) ) {
    166         $comment_order .= ' selected="selected"';
    167 }
    168 $comment_order .= '>' . __( 'newer' ) . '</option></select>';
    169 
    170 /* translators: %s: Form field control for 'older' or 'newer' comments. */
    171 printf( __( 'Comments should be displayed with the %s comments at the top of each page' ), $comment_order );
    172 
    173 ?>
    174 </label>
     154<ul>
     155        <li>
     156                <label for="comments_per_page"><?php _e( 'Top level comments per page' ); ?></label>
     157                <input name="comments_per_page" type="number" step="1" min="0" class="pagination-setting" id="comments_per_page" value="<?php echo esc_attr( get_option( 'comments_per_page' ) ); ?>" class="small-text"<?php echo $comments_pagination_disabled; ?> />
     158        </li>
     159        <li>
     160                <label for="default_comments_page"><?php _e( 'Comments page to display by default' ); ?></label>
     161                <select name="default_comments_page" class="pagination-setting" id="default_comments_page"<?php echo $comments_pagination_disabled; ?>>
     162                        <option value="newest" <?php selected( 'newest', get_option( 'default_comments_page' ) ); ?>><?php _e( 'last page' ); ?></option>
     163                        <option value="oldest" <?php selected( 'oldest', get_option( 'default_comments_page' ) ); ?>><?php _e( 'first page' ); ?></option>
     164                </select>
     165        </li>
     166        <li>
     167                <label for="comment_order"><?php _e( 'Comments to display at the top of each page' ); ?></label>
     168                <select name="comment_order" class="pagination-setting" id="comment_order"<?php echo $comments_pagination_disabled; ?>>
     169                        <option value="asc" <?php selected( 'asc', get_option( 'comment_order' ) ); ?>><?php _e( 'older' ); ?></option>
     170                        <option value="desc" <?php selected( 'desc', get_option( 'comment_order' ) ); ?>><?php _e( 'newer' ); ?></option>
     171                </select>
     172        </li>
     173</ul>
    175174</fieldset></td>
    176175</tr>
     176
    177177<tr>
    178178<th scope="row"><?php _e( 'Email me whenever' ); ?></th>
    179179<td><fieldset><legend class="screen-reader-text"><span>
     
    186186<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked( '1', get_option( 'comments_notify' ) ); ?> />
    187187<?php _e( 'Anyone posts a comment' ); ?> </label>
    188188<br />
     189
    189190<label for="moderation_notify">
    190191<input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked( '1', get_option( 'moderation_notify' ) ); ?> />
    191192<?php _e( 'A comment is held for moderation' ); ?> </label>
     
    203204<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked( '1', get_option( 'comment_moderation' ) ); ?> />
    204205<?php _e( 'Comment must be manually approved' ); ?> </label>
    205206<br />
     207
    206208<label for="comment_previously_approved"><input type="checkbox" name="comment_previously_approved" id="comment_previously_approved" value="1" <?php checked( '1', get_option( 'comment_previously_approved' ) ); ?> /> <?php _e( 'Comment author must have a previously approved comment' ); ?></label>
    207209</fieldset></td>
    208210</tr>