WordPress.org

Making WordPress.org


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.