Ticket #31354: 31354.5.patch
File 31354.5.patch, 11.4 KB (added by , 6 months ago) |
---|
-
src/wp-admin/css/edit.css
1308 1308 outline: 2px solid transparent; 1309 1309 } 1310 1310 1311 .options-discussion-php .indent-children ul, 1311 1312 #front-page-warning, 1312 1313 #front-static-pages ul, 1313 1314 ul.export-filters, -
src/wp-admin/includes/options.php
8 8 */ 9 9 10 10 /** 11 * Output JavaScript to toggle display of additional settings if avatars are disabled.11 * Output JavaScript for discussion options. 12 12 * 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. 14 15 */ 15 16 function options_discussion_add_js() { 16 17 ?> 17 18 <script> 18 19 (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' ); 24 42 })(jQuery); 25 43 </script> 26 44 <?php -
src/wp-admin/options-discussion.php
39 39 <div class="wrap"> 40 40 <h1><?php echo esc_html( $title ); ?></h1> 41 41 42 <!-- ARIA live region for screen readers --> 43 <div id="aria-live-region" aria-live="polite" class="screen-reader-text"></div> 44 45 42 46 <form method="post" action="options.php"> 43 47 <?php settings_fields( 'discussion' ); ?> 44 48 45 <table class="form-table " role="presentation">49 <table class="form-table indent-children" role="presentation"> 46 50 <tr> 47 51 <th scope="row"><?php _e( 'Default post settings' ); ?></th> 48 52 <td><fieldset><legend class="screen-reader-text"><span> … … 86 90 ?> 87 91 </label> 88 92 <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 /> 92 95 <?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'; 98 97 ?> 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> 101 104 102 <label for="show_comments_cookies_opt_in">103 105 <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> 106 107 <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> 107 110 108 <label for="thread_comments">109 <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked( '1', get_option( 'thread_comments' ) ); ?> />110 111 <?php 111 112 /** 112 113 * Filters the maximum depth of threaded/nested comments. … … 117 118 */ 118 119 $maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 ); 119 120 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 . '>'; 121 123 for ( $i = 2; $i <= $maxdeep; $i++ ) { 122 124 $thread_comments_depth .= "<option value='" . esc_attr( $i ) . "'"; 123 125 if ( (int) get_option( 'thread_comments_depth' ) === $i ) { … … 126 128 $thread_comments_depth .= ">$i</option>"; 127 129 } 128 130 $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> 129 140 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> 137 149 <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> 138 151 <?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'; 154 153 ?> 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> 175 174 </fieldset></td> 176 175 </tr> 176 177 177 <tr> 178 178 <th scope="row"><?php _e( 'Email me whenever' ); ?></th> 179 179 <td><fieldset><legend class="screen-reader-text"><span> … … 186 186 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked( '1', get_option( 'comments_notify' ) ); ?> /> 187 187 <?php _e( 'Anyone posts a comment' ); ?> </label> 188 188 <br /> 189 189 190 <label for="moderation_notify"> 190 191 <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked( '1', get_option( 'moderation_notify' ) ); ?> /> 191 192 <?php _e( 'A comment is held for moderation' ); ?> </label> … … 203 204 <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked( '1', get_option( 'comment_moderation' ) ); ?> /> 204 205 <?php _e( 'Comment must be manually approved' ); ?> </label> 205 206 <br /> 207 206 208 <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> 207 209 </fieldset></td> 208 210 </tr>