Making WordPress.org

Ticket #5708: 5708.diff

File 5708.diff, 1.2 KB (added by alexstine, 3 years ago)
  • wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-report-topic.php

    diff --git a/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-report-topic.php b/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-report-topic.php
    index 170ac0333..134f03f04 100644
    a b class Report_Topic { 
    99
    1010                add_action( 'set_object_terms', array( $this, 'detect_manual_modlook' ), 10, 6 );
    1111
     12                // Only allow moderators to remove modlook tag.
     13                add_action( 'pre_delete_term', array( $this, 'prevent_modlook_removal_non_moderator' ), 10, 2 );
     14
    1215                add_action( 'init', array( $this, 'capture_topic_report' ) );
    1316        }
    1417
    class Report_Topic { 
    8588
    8689        }
    8790
     91        public function prevent_modlook_removal_non_moderator( $term_id, $taxonomy ) {
     92                $term = get_term( $term_id, $taxonomy );
     93                if ( ( ! empty( $term->slug ) && 'modlook' === $term->slug && ! user_can( 'moderate', get_current_user_id() ) ) ) {
     94                        wp_die( __( 'You cannot remove the modlook tag.' ) );
     95                }
     96        }
     97
    8898        public function capture_topic_report() {
    8999                // Do not process anything if the user is not logged in.
    90100                if ( ! is_user_logged_in() ) {