Skip to:
Content

bbPress.org


Ignore:
Timestamp:
12/29/2016 04:25:54 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Metaboxes: Add metaboxes for viewing favorites & subscriptions of topics & replies.

  • New functions for outputting avatars of users who have favved or subbed
  • Use the $post parameter that's passed in, rather than using get_the_ID() again
  • Use require_once as a language construct vs. include_once() as a function
  • Pass $post object through to metabox subsequent filters vs just the ID

See #2959.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/topics.php

    r6190 r6197  
    8181
    8282        // Topic metabox actions
    83         add_action( 'add_meta_boxes', array( $this, 'attributes_metabox' ) );
    84         add_action( 'add_meta_boxes', array( $this, 'author_metabox'     ) );
    85         add_action( 'add_meta_boxes', array( $this, 'replies_metabox'    ) );
    86         add_action( 'add_meta_boxes', array( $this, 'comments_metabox'   ) );
    87         add_action( 'save_post',      array( $this, 'save_meta_boxes'    ) );
     83        add_action( 'add_meta_boxes', array( $this, 'attributes_metabox'    ) );
     84        add_action( 'add_meta_boxes', array( $this, 'author_metabox'        ) );
     85        add_action( 'add_meta_boxes', array( $this, 'replies_metabox'       ) );
     86        add_action( 'add_meta_boxes', array( $this, 'favorites_metabox'     ) );
     87        add_action( 'add_meta_boxes', array( $this, 'subscriptions_metabox' ) );
     88        add_action( 'add_meta_boxes', array( $this, 'comments_metabox'      ) );
     89        add_action( 'save_post',      array( $this, 'save_meta_boxes'       ) );
    8890
    8991        // Check if there are any bbp_toggle_topic_* requests on admin_init, also have a message displayed
     
    343345     */
    344346    public function attributes_metabox() {
    345 
    346347        add_meta_box(
    347348            'bbp_topic_attributes',
     
    352353            'high'
    353354        );
    354 
    355         do_action( 'bbp_topic_attributes_metabox' );
    356355    }
    357356
     
    361360     * @since 2.0.0 bbPress (r2828)
    362361     *
    363      * @uses bbp_get_topic() To get the topic
    364      * @uses bbp_get_reply() To get the reply
    365      * @uses bbp_get_topic_post_type() To get the topic post type
    366      * @uses bbp_get_reply_post_type() To get the reply post type
    367362     * @uses add_meta_box() To add the metabox
    368      * @uses do_action() Calls 'bbp_author_metabox' with the topic/reply
    369      *                    id
    370363     */
    371364    public function author_metabox() {
     
    385378            'high'
    386379        );
    387 
    388         do_action( 'bbp_author_metabox', get_the_ID() );
    389380    }
    390381
     
    421412            'high'
    422413        );
    423 
    424         do_action( 'bbp_topic_replies_metabox', get_the_ID() );
     414    }
     415
     416    /**
     417     * Add the favorites metabox
     418     *
     419     * Allows viewing of users who have favorited a topic.
     420     *
     421     * @since 2.6.0 bbPress (r6179)
     422     *
     423     * @uses add_meta_box() To add the metabox
     424     */
     425    public function favorites_metabox() {
     426
     427        // Bail if post_type is not a reply
     428        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     429            return;
     430        }
     431
     432        // Bail if no favorites
     433        if ( ! bbp_is_favorites_active() ) {
     434            return;
     435        }
     436
     437        // Add the metabox
     438        add_meta_box(
     439            'bbp_topic_favorites_metabox',
     440            __( 'Favorites', 'bbpress' ),
     441            'bbp_topic_favorites_metabox',
     442            $this->post_type,
     443            'normal',
     444            'high'
     445        );
     446    }
     447
     448    /**
     449     * Add the subscriptions metabox
     450     *
     451     * Allows viewing of users who have subscribed to a topic.
     452     *
     453     * @since 2.6.0 bbPress (r6179)
     454     *
     455     * @uses add_meta_box() To add the metabox
     456     */
     457    public function subscriptions_metabox() {
     458
     459        // Bail if post_type is not a reply
     460        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     461            return;
     462        }
     463
     464        // Bail if no subscriptions
     465        if ( ! bbp_is_subscriptions_active() ) {
     466            return;
     467        }
     468
     469        // Add the metabox
     470        add_meta_box(
     471            'bbp_topic_subscriptions_metabox',
     472            __( 'Subscriptions', 'bbpress' ),
     473            'bbp_topic_subscriptions_metabox',
     474            $this->post_type,
     475            'normal',
     476            'high'
     477        );
    425478    }
    426479
Note: See TracChangeset for help on using the changeset viewer.