Ticket #5344: 5344-limit-topic-creation.patch
File 5344-limit-topic-creation.patch, 1.8 KB (added by , 3 years ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
21 21 add_action( 'template_redirect', array( $this, 'redirect_legacy_user_structure' ) ); 22 22 add_filter( 'wp_insert_post_data', array( $this, 'set_post_date_gmt_for_pending_posts' ) ); 23 23 add_action( 'wp_print_footer_scripts', array( $this, 'replace_quicktags_blockquote_button' ) ); 24 add_filter( 'pre_insert_term', array( $this, 'limit_topic_tag_creation' ), 10, 2 ); 24 25 25 26 // Add bbPress support to the WordPress.org SEO plugin. 26 27 add_filter( 'wporg_canonical_base_url', array( $this, 'wporg_canonical_base_url' ) ); … … 128 129 add_filter( 'bbp_subscription_mail_message', array( $this, 'bbp_subscription_mail_message'), 5, 3 ); 129 130 } 130 131 132 /** 133 * Limit the creation of new tags to moderators or above. 134 * 135 * This curates the list of tags, keeping the tag list short and relevant. 136 * 137 * @param string $term The new tag to add. 138 * @param string $taxonomy Taxonomy to add a new tag to. 139 * 140 * @return \WP_Error|string The term if capabilities allow, otherwise a `WP_Error`. 141 */ 142 public function limit_topic_tag_creation( $term, $taxonomy ) { 143 if ( 'topic-tag' !== $taxonomy ) { 144 return $term; 145 } 146 147 if ( ! current_user_can( 'moderate' ) ) { 148 return new \WP_Error( 'limit_topic_tag_creation' ); 149 } 150 151 return $term; 152 } 153 131 154 /** 132 155 * Check "Notify me of follow-up replies via email" box for new topics by default. 133 156 *