]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/options-discussion.php
WordPress 4.2
[autoinstalls/wordpress.git] / wp-admin / options-discussion.php
1 <?php
2 /**
3  * Discussion settings administration panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8 /** WordPress Administration Bootstrap */
9 require_once( dirname( __FILE__ ) . '/admin.php' );
10
11 if ( ! current_user_can( 'manage_options' ) )
12         wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
13
14 $title = __('Discussion Settings');
15 $parent_file = 'options-general.php';
16
17 /**
18  * Output JavaScript to toggle display of additional settings if avatars are disabled.
19  *
20  * @since 4.2.0
21  */
22 function options_discussion_add_js() {
23 ?>
24         <script>
25         (function($){
26                 var parent = $( '#show_avatars' ),
27                         children = $( '.avatar-settings' );
28                 parent.change(function(){
29                         children.toggleClass( 'hide-if-js', ! this.checked );
30                 });
31         })(jQuery);
32         </script>
33 <?php
34 }
35 add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' );
36
37 get_current_screen()->add_help_tab( array(
38         'id'      => 'overview',
39         'title'   => __('Overview'),
40         'content' => '<p>' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won&#8217;t all fit here! :) Use the documentation links to get information on what each discussion setting does.') . '</p>' .
41                 '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
42 ) );
43
44 get_current_screen()->set_help_sidebar(
45         '<p><strong>' . __('For more information:') . '</strong></p>' .
46         '<p>' . __('<a href="https://codex.wordpress.org/Settings_Discussion_Screen" target="_blank">Documentation on Discussion Settings</a>') . '</p>' .
47         '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
48 );
49
50 include( ABSPATH . 'wp-admin/admin-header.php' );
51 ?>
52
53 <div class="wrap">
54 <h2><?php echo esc_html( $title ); ?></h2>
55
56 <form method="post" action="options.php">
57 <?php settings_fields('discussion'); ?>
58
59 <table class="form-table">
60 <tr>
61 <th scope="row"><?php _e('Default article settings'); ?></th>
62 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Default article settings'); ?></span></legend>
63 <label for="default_pingback_flag">
64 <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
65 <?php _e('Attempt to notify any blogs linked to from the article'); ?></label>
66 <br />
67 <label for="default_ping_status">
68 <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
69 <?php _e('Allow link notifications from other blogs (pingbacks and trackbacks)'); ?></label>
70 <br />
71 <label for="default_comment_status">
72 <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
73 <?php _e('Allow people to post comments on new articles'); ?></label>
74 <br />
75 <p class="description"><?php echo '(' . __( 'These settings may be overridden for individual articles.' ) . ')'; ?></p>
76 </fieldset></td>
77 </tr>
78 <tr>
79 <th scope="row"><?php _e('Other comment settings'); ?></th>
80 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Other comment settings'); ?></span></legend>
81 <label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail'); ?></label>
82 <br />
83 <label for="comment_registration">
84 <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
85 <?php _e('Users must be registered and logged in to comment'); ?>
86 <?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?>
87 </label>
88 <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')); ?> />
92 <?php printf( __('Automatically close comments on articles older than %s days'), '</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" />'); ?>
93 </label>
94 <br />
95 <label for="thread_comments">
96 <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
97 <?php
98 /**
99  * Filter the maximum depth of threaded/nested comments.
100  *
101  * @since 2.7.0.
102  *
103  * @param int $max_depth The maximum depth of threaded comments. Default 10.
104  */
105 $maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
106
107 $thread_comments_depth = '</label><label for="thread_comments_depth"><select name="thread_comments_depth" id="thread_comments_depth">';
108 for ( $i = 2; $i <= $maxdeep; $i++ ) {
109         $thread_comments_depth .= "<option value='" . esc_attr($i) . "'";
110         if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
111         $thread_comments_depth .= ">$i</option>";
112 }
113 $thread_comments_depth .= '</select>';
114
115 printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
116
117 ?></label>
118 <br />
119 <label for="page_comments">
120 <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> />
121 <?php
122
123 $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
124 if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
125 $default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
126 if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
127 $default_comments_page .= '>' . __('first') . '</option></select>';
128
129 printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</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" />', $default_comments_page );
130
131 ?></label>
132 <br />
133 <label for="comment_order"><?php
134
135 $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
136 if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
137 $comment_order .= '>' . __('older') . '</option><option value="desc"';
138 if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
139 $comment_order .= '>' . __('newer') . '</option></select>';
140
141 printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order );
142
143 ?></label>
144 </fieldset></td>
145 </tr>
146 <tr>
147 <th scope="row"><?php _e('E-mail me whenever'); ?></th>
148 <td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever'); ?></span></legend>
149 <label for="comments_notify">
150 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
151 <?php _e('Anyone posts a comment'); ?> </label>
152 <br />
153 <label for="moderation_notify">
154 <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />
155 <?php _e('A comment is held for moderation'); ?> </label>
156 </fieldset></td>
157 </tr>
158 <tr>
159 <th scope="row"><?php _e('Before a comment appears'); ?></th>
160 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears'); ?></span></legend>
161 <label for="comment_moderation">
162 <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
163 <?php _e('Comment must be manually approved'); ?> </label>
164 <br />
165 <label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment'); ?></label>
166 </fieldset></td>
167 </tr>
168 <tr>
169 <th scope="row"><?php _e('Comment Moderation'); ?></th>
170 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation'); ?></span></legend>
171 <p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="number" step="1" min="0" id="comment_max_links" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ); ?></label></p>
172
173 <p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
174 <p>
175 <textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea>
176 </p>
177 </fieldset></td>
178 </tr>
179 <tr>
180 <th scope="row"><?php _e('Comment Blacklist'); ?></th>
181 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist'); ?></span></legend>
182 <p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
183 <p>
184 <textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
185 </p>
186 </fieldset></td>
187 </tr>
188 <?php do_settings_fields('discussion', 'default'); ?>
189 </table>
190
191 <h3 class="title"><?php _e('Avatars'); ?></h3>
192
193 <p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
194
195 <?php
196 // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that?
197
198 $show_avatars = get_option( 'show_avatars' );
199 ?>
200
201 <table class="form-table">
202 <tr>
203 <th scope="row"><?php _e('Avatar Display'); ?></th>
204 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
205         <label for="show_avatars">
206                 <input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked( $show_avatars, 1 ); ?> />
207                 <?php _e( 'Show Avatars' ); ?>
208         </label>
209 </fieldset></td>
210 </tr>
211 <tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>">
212 <th scope="row"><?php _e('Maximum Rating'); ?></th>
213 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
214
215 <?php
216 $ratings = array(
217         /* translators: Content suitability rating: http://bit.ly/89QxZA */
218         'G' => __('G &#8212; Suitable for all audiences'),
219         /* translators: Content suitability rating: http://bit.ly/89QxZA */
220         'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'),
221         /* translators: Content suitability rating: http://bit.ly/89QxZA */
222         'R' => __('R &#8212; Intended for adult audiences above 17'),
223         /* translators: Content suitability rating: http://bit.ly/89QxZA */
224         'X' => __('X &#8212; Even more mature than above')
225 );
226 foreach ($ratings as $key => $rating) :
227         $selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : '';
228         echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
229 endforeach;
230 ?>
231
232 </fieldset></td>
233 </tr>
234 <tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>">
235 <th scope="row"><?php _e('Default Avatar'); ?></th>
236 <td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
237
238 <?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
239
240 <?php
241 $avatar_defaults = array(
242         'mystery' => __('Mystery Person'),
243         'blank' => __('Blank'),
244         'gravatar_default' => __('Gravatar Logo'),
245         'identicon' => __('Identicon (Generated)'),
246         'wavatar' => __('Wavatar (Generated)'),
247         'monsterid' => __('MonsterID (Generated)'),
248         'retro' => __('Retro (Generated)')
249 );
250 /**
251  * Filter the default avatars.
252  *
253  * Avatars are stored in key/value pairs, where the key is option value,
254  * and the name is the displayed avatar name.
255  *
256  * @since 2.6.0
257  *
258  * @param array $avatar_defaults Array of default avatars.
259  */
260 $avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults );
261 $default = get_option('avatar_default');
262 if ( empty($default) )
263         $default = 'mystery';
264 $size = 32;
265 $avatar_list = '';
266
267 // Force avatars on to display these choices
268 add_filter( 'pre_option_show_avatars', '__return_true', 100 );
269
270 foreach ( $avatar_defaults as $default_key => $default_name ) {
271         $selected = ($default == $default_key) ? 'checked="checked" ' : '';
272         $avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key) . "' {$selected}/> ";
273
274         $avatar = get_avatar( $user_email, $size, $default_key );
275         $avatar = preg_replace( "/src='(.+?)'/", "src='\$1&amp;forcedefault=1'", $avatar );
276         $avatar = preg_replace( "/srcset='(.+?) 2x'/", "srcset='\$1&amp;forcedefault=1 2x'", $avatar );
277         $avatar_list .= $avatar;
278
279         $avatar_list .= ' ' . $default_name . '</label>';
280         $avatar_list .= '<br />';
281 }
282
283 remove_filter( 'pre_option_show_avatars', '__return_true', 100 );
284
285 /**
286  * Filter the HTML output of the default avatar list.
287  *
288  * @since 2.6.0
289  *
290  * @param string $avatar_list HTML markup of the avatar list.
291  */
292 echo apply_filters( 'default_avatar_select', $avatar_list );
293 ?>
294
295 </fieldset></td>
296 </tr>
297 <?php do_settings_fields('discussion', 'avatars'); ?>
298 </table>
299
300 <?php do_settings_sections('discussion'); ?>
301
302 <?php submit_button(); ?>
303 </form>
304 </div>
305
306 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>