options-discussion.php 15 KB

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