|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * WordPress Options implementation for Discussion Settings. |
| 4 | + * |
| 5 | + * @package WordPress |
| 6 | + * @subpackage Administration |
| 7 | + * @since 4.8.0 |
| 8 | + */ |
| 9 | + |
| 10 | +/** |
| 11 | + * Adds default settings fields for the Discussion Settings page. |
| 12 | + * |
| 13 | + * @since 4.8.0 |
| 14 | + */ |
| 15 | +function add_settings_fields_options_discussion() { |
| 16 | + sae_add_settings_section( 'article', __( 'Default article settings' ), 'settings_section_article_before', 'discussion' ); |
| 17 | + |
| 18 | + sae_add_settings_field( 'default_pingback_flag', '', 'checkbox', 'discussion', 'article', array( |
| 19 | + 'skip_title' => true, |
| 20 | + 'label' => __( 'Attempt to notify any blogs linked to from the article' ), |
| 21 | + ) ); |
| 22 | + |
| 23 | + sae_add_settings_field( 'default_ping_status', '', 'checkbox', 'discussion', 'article', array( |
| 24 | + 'skip_title' => true, |
| 25 | + 'label' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles' ), |
| 26 | + ) ); |
| 27 | + |
| 28 | + sae_add_settings_field( 'default_comment_status', '', 'checkbox', 'discussion', 'article', array( |
| 29 | + 'skip_title' => true, |
| 30 | + 'label' => __( 'Allow people to post comments on new articles' ), |
| 31 | + ) ); |
| 32 | + |
| 33 | + sae_add_settings_section( 'comment', __( 'Other comment settings' ), null, 'discussion' ); |
| 34 | + |
| 35 | + sae_add_settings_field( 'require_name_email', '', 'checkbox', 'discussion', 'comment', array( |
| 36 | + 'skip_title' => true, |
| 37 | + 'label' => __( 'Comment author must fill out name and email' ), |
| 38 | + ) ); |
| 39 | + |
| 40 | + if ( ! get_option( 'users_can_register' ) && is_multisite() ) { |
| 41 | + sae_add_settings_field( 'comment_registration', '', 'checkbox', 'discussion', 'comment', array( |
| 42 | + 'skip_title' => true, |
| 43 | + 'label' => __( 'Users must be registered and logged in to comment' ), |
| 44 | + 'description' => __( 'Signup has been disabled. Only members of this site can comment.' ), |
| 45 | + ) ); |
| 46 | + } else { |
| 47 | + sae_add_settings_field( 'comment_registration', '', 'checkbox', 'discussion', 'comment', array( |
| 48 | + 'skip_title' => true, |
| 49 | + 'label' => __( 'Users must be registered and logged in to comment' ), |
| 50 | + ) ); |
| 51 | + } |
| 52 | + |
| 53 | + sae_add_settings_field( 'close_comments_for_old_posts', '', 'checkbox', 'discussion', 'comment', array( |
| 54 | + 'skip_title' => true, |
| 55 | + 'label' => __( 'Automatically close comments on old articles: enter the number of days in the field below' ), |
| 56 | + ) ); |
| 57 | + |
| 58 | + sae_add_settings_field( 'close_comments_days_old', __( 'Number of days after which comments will be automatically closed' ), 'number', 'discussion', 'comment', array( |
| 59 | + 'input_class' => 'small-text', |
| 60 | + 'min' => '0', |
| 61 | + 'step' => '1', |
| 62 | + ) ); |
| 63 | + |
| 64 | + sae_add_settings_field( 'thread_comments', '', 'checkbox', 'discussion', 'comment', array( |
| 65 | + 'skip_title' => true, |
| 66 | + 'label' => __( 'Enable threaded (nested) comments: set the number of levels in the field below' ), |
| 67 | + ) ); |
| 68 | + |
| 69 | + /** |
| 70 | + * Filters the maximum depth of threaded/nested comments. |
| 71 | + * |
| 72 | + * @since 2.7.0. |
| 73 | + * |
| 74 | + * @param int $max_depth The maximum depth of threaded comments. Default 10. |
| 75 | + */ |
| 76 | + $maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 ); |
| 77 | + |
| 78 | + for ( $depth_index = 2; $depth_index <= $maxdeep; $depth_index++ ) { |
| 79 | + $thread_comments_depth_choices[ $depth_index ] = $depth_index; |
| 80 | + } |
| 81 | + |
| 82 | + sae_add_settings_field( 'thread_comments_depth', __( 'Nested comments levels deep' ), 'select', 'discussion', 'comment', array( |
| 83 | + 'choices' => $thread_comments_depth_choices, |
| 84 | + ) ); |
| 85 | + |
| 86 | + sae_add_settings_field( 'page_comments', '', 'checkbox', 'discussion', 'comment', array( |
| 87 | + 'skip_title' => true, |
| 88 | + 'label' => __( 'Break comments into pages' ), |
| 89 | + ) ); |
| 90 | + |
| 91 | + sae_add_settings_field( 'comments_per_page', __( 'Number of top level comments per page' ), 'number', 'discussion', 'comment', array( |
| 92 | + 'input_class' => 'small-text', |
| 93 | + 'min' => '0', |
| 94 | + 'step' => '1', |
| 95 | + ) ); |
| 96 | + |
| 97 | + sae_add_settings_field( 'default_comments_page', __( 'Comments page displayed by default' ), 'select', 'discussion', 'comment', array( |
| 98 | + 'choices' => array( |
| 99 | + 'newest' => __( 'last page' ), |
| 100 | + 'oldest' => __( 'first page' ), |
| 101 | + ) |
| 102 | + ) ); |
| 103 | + |
| 104 | + sae_add_settings_field( 'comment_order', __( 'Comments to display at the top of each page' ), 'select', 'discussion', 'comment', array( |
| 105 | + 'choices' => array( |
| 106 | + 'asc' => __( 'older comments' ), |
| 107 | + 'desc' => __( 'newer comments' ), |
| 108 | + ) |
| 109 | + ) ); |
| 110 | + |
| 111 | + sae_add_settings_section( 'notifications', __( 'Notifications' ), null, 'discussion' ); |
| 112 | + |
| 113 | + sae_add_settings_field( 'comments_notify', '', 'checkbox', 'discussion', 'notifications', array( |
| 114 | + 'skip_title' => true, |
| 115 | + 'label' => __( 'Email me when anyone posts a comment' ), |
| 116 | + ) ); |
| 117 | + |
| 118 | + sae_add_settings_field( 'moderation_notify', '', 'checkbox', 'discussion', 'notifications', array( |
| 119 | + 'skip_title' => true, |
| 120 | + 'label' => __( 'Email me when a comment is held for moderation' ), |
| 121 | + ) ); |
| 122 | + |
| 123 | + sae_add_settings_section( 'moderation', __( 'Comment moderation' ), null, 'discussion' ); |
| 124 | + |
| 125 | + sae_add_settings_field( 'comment_moderation', '', 'checkbox', 'discussion', 'moderation', array( |
| 126 | + 'skip_title' => true, |
| 127 | + 'label' => __( 'Before a comment appears, it must be manually approved' ), |
| 128 | + ) ); |
| 129 | + |
| 130 | + sae_add_settings_field( 'comment_whitelist', '', 'checkbox', 'discussion', 'moderation', array( |
| 131 | + 'skip_title' => true, |
| 132 | + 'label' => __( 'Before a comment appears, the comment author must have a previously approved comment' ), |
| 133 | + ) ); |
| 134 | + |
| 135 | + sae_add_settings_field( 'comment_max_links', __( 'Number of links in a comment after which it will be held in the moderation queue' ), 'number', 'discussion', 'moderation', array( |
| 136 | + 'input_class' => 'small-text', |
| 137 | + 'min' => '0', |
| 138 | + 'step' => '1', |
| 139 | + 'description' => __( 'A common characteristic of comment spam is a large number of links.' ), |
| 140 | + ) ); |
| 141 | + |
| 142 | + sae_add_settings_field( 'moderation_keys', __( 'Moderation words' ), 'textarea', 'discussion', 'moderation', array( |
| 143 | + 'rows' => '10', |
| 144 | + 'cols' => '50', |
| 145 | + 'input_class' => 'large-text code', |
| 146 | + 'description' => sprintf( |
| 147 | + __( 'When a comment contains any of these words in its content, name, URL, email, or IP, it will be held in the %1$smoderation queue%2$s. One word or IP per line. It will match inside words, so “press” will match “WordPress”.' ), |
| 148 | + '<a href="edit-comments.php?comment_status=moderated">', |
| 149 | + '</a>' |
| 150 | + ), |
| 151 | + ) ); |
| 152 | + |
| 153 | + sae_add_settings_field( 'blacklist_keys', __( 'Comment blacklist' ), 'textarea', 'discussion', 'moderation', array( |
| 154 | + 'rows' => '10', |
| 155 | + 'cols' => '50', |
| 156 | + 'input_class' => 'large-text code', |
| 157 | + 'description' => __( 'When a comment contains any of these words in its content, name, URL, email, or IP, it will be put in the trash. One word or IP per line. It will match inside words, so “press” will match “WordPress”.' ) |
| 158 | + ) ); |
| 159 | +} |
| 160 | + |
| 161 | +/** |
| 162 | + * Settings section callback for the 'thumbnail_size' section. |
| 163 | + * |
| 164 | + * @since 4.8.0 |
| 165 | + */ |
| 166 | +function settings_section_article_before() { |
| 167 | + echo '<p>' . __( 'These settings may be overridden for individual articles.' ) . '</p>'; |
| 168 | +} |
0 commit comments