Making WordPress.org

Changeset 5300


Ignore:
Timestamp:
04/09/2017 08:31:01 AM (8 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Move Hooks::admin_links() to Moderators class.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r5291 r5300  
    1111        add_filter( 'pre_option__bbp_edit_lock',      array( $this, 'increase_edit_lock_time' ) );
    1212        add_filter( 'redirect_canonical',             array( $this, 'disable_redirect_guess_404_permalink' ) );
    13 
    14         // Display-related filters and actions.
    15         add_filter( 'bbp_topic_admin_links', array( $this, 'admin_links' ), 10, 3 );
    16         add_filter( 'bbp_reply_admin_links', array( $this, 'admin_links' ), 10, 3 );
    1713
    1814        // Gravatar suppression on lists of topics and revision logs.
     
    9793
    9894        return $redirect_url;
    99     }
    100 
    101     /**
    102      * Remove some unneeded or redundant admin links for topics and replies,
    103      * move less commonly used inline quick links to 'Topic Admin' sidebar section.
    104      *
    105      * @param array $r       Admin links array.
    106      * @param int   $post_id Topic or reply ID.
    107      * @return array Filtered admin links array.
    108      */
    109     public function admin_links( $r, $post_id ) {
    110         /*
    111          * Remove 'Trash' from admin links. Trashing a topic or reply will eventually
    112          * permanently delete it when the trash is emptied. Better to mark it as pending or spam.
    113          */
    114         unset( $r['trash'] );
    115 
    116         /*
    117          * Remove 'Reply' link. The theme adds its own 'Reply to Topic' sidebar link
    118          * for quick access to reply form, making the default inline link redundant.
    119          */
    120         unset( $r['reply'] );
    121 
    122         /*
    123          * The following actions are removed from inline quick links as less commonly used,
    124          * but are still available via 'Topic Admin' sidebar section.
    125          */
    126         if ( ! did_action( 'wporg_compat_single_topic_sidebar_pre' ) ) {
    127             // Remove 'Merge' link.
    128             unset( $r['merge'] );
    129 
    130             // Remove 'Stick' link for moderators, but keep it for plugin/theme authors and contributors.
    131             if ( current_user_can( 'moderate', $post_id ) ) {
    132                 unset( $r['stick'] );
    133             }
    134         }
    135 
    136         return $r;
    13795    }
    13896
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

    r5299 r5300  
    2929        add_filter( 'bbp_after_has_topics_parse_args',  array( $this, 'add_post_status_to_query' ) );
    3030        add_filter( 'bbp_after_has_replies_parse_args', array( $this, 'add_post_status_to_query' ) );
     31
     32        // Adjust the list of admin links for topics and replies.
    3133        add_filter( 'bbp_topic_admin_links',            array( $this, 'admin_links' ), 10, 2 );
    3234        add_filter( 'bbp_reply_admin_links',            array( $this, 'admin_links' ), 10, 2 );
     
    245247    }
    246248
     249    /**
     250     * Remove some unneeded or redundant admin links for topics and replies,
     251     * move less commonly used inline quick links to 'Topic Admin' sidebar section.
     252     *
     253     * @param array $r       Admin links array.
     254     * @param int   $post_id Topic or reply ID.
     255     * @return array Filtered admin links array.
     256     */
    247257    public function admin_links( $r, $post_id ) {
     258        /*
     259         * Remove 'Trash' from admin links. Trashing a topic or reply will eventually
     260         * permanently delete it when the trash is emptied. Better to mark it as pending or spam.
     261         */
     262        unset( $r['trash'] );
     263
     264        /*
     265         * Remove 'Reply' link. The theme adds its own 'Reply to Topic' sidebar link
     266         * for quick access to reply form, making the default inline link redundant.
     267         */
     268        unset( $r['reply'] );
     269
     270        /*
     271         * The following actions are removed from inline quick links as less commonly used,
     272         * but are still available via 'Topic Admin' sidebar section.
     273         */
     274        if ( ! did_action( 'wporg_compat_single_topic_sidebar_pre' ) ) {
     275            // Remove 'Merge' link.
     276            unset( $r['merge'] );
     277
     278            // Remove 'Stick' link for moderators, but keep it for plugin/theme authors and contributors.
     279            if ( current_user_can( 'moderate', $post_id ) ) {
     280                unset( $r['stick'] );
     281            }
     282        }
     283
     284        // Add 'Archive' link.
    248285        $r['archive'] = $this->get_archive_link( array( 'post_id' => $post_id ) );
     286
    249287        return $r;
    250288    }
Note: See TracChangeset for help on using the changeset viewer.