Skip to:
Content

bbPress.org

Changeset 5886


Ignore:
Timestamp:
08/06/2015 11:29:43 PM (6 years ago)
Author:
johnjamesjacoby
Message:

Topics: First pass at metabox for replies in single-topic edit

  • Includes topic-replies list-table class
  • Includes helper functions for hooking things in
  • Todo: cap checks or row-actions, maybe bulk-actions, formatting clean-up

See #2842.

Location:
trunk/src/includes/admin
Files:
2 added
2 edited

Legend:

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

    r5868 r5886  
    548548}
    549549
     550/**
     551 * Output the topic replies metabox
     552 *
     553 * @since bbPress (r5886)
     554 *
     555 * @param type $topic
     556 *
     557 * @return type
     558 */
     559function bbp_topic_replies_metabox( $topic = false ) {
     560
     561    // Bail if no topic to load replies for
     562    if ( empty( $topic ) ) {
     563        return;
     564    }
     565
     566    // Pull in the list table class
     567    if ( ! class_exists( 'BBP_Topic_Replies_List_Table' ) ) {
     568        include_once bbpress()->admin->admin_dir . '/list-tables/topic-replies.php';
     569    }
     570
     571    // Load up the list table
     572    $replies_list_table = new BBP_Topic_Replies_List_Table();
     573    $replies_list_table->prepare_items( $topic->ID ); ?>
     574
     575    <form id="bbp-topic-replies" method="get">
     576        <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
     577
     578        <?php $replies_list_table->display(); ?>
     579    </form>
     580
     581    <?php
     582}
     583
    550584/** Users *********************************************************************/
    551585
  • trunk/src/includes/admin/topics.php

    r5868 r5886  
    7979        add_action( 'admin_notices',  array( $this, 'toggle_topic_notice' ) );
    8080
    81         // Anonymous metabox actions
    82         add_action( 'add_meta_boxes', array( $this, 'author_metabox'      ) );
     81        // Metabox actions
     82        add_action( 'add_meta_boxes', array( $this, 'author_metabox'  ) );
     83        add_action( 'add_meta_boxes', array( $this, 'replies_metabox' ) );
    8384
    8485        // Add ability to filter topics and replies per forum
     
    390391
    391392    /**
     393     * Add the replies metabox
     394     *
     395     * Allows viewing & moderating of replies to a topic, based on the way
     396     * comments are visible on a blog post.
     397     *
     398     * @since bbPress (r5886)
     399     *
     400     * @uses bbp_get_topic() To get the topic
     401     * @uses bbp_get_reply() To get the reply
     402     * @uses bbp_get_topic_post_type() To get the topic post type
     403     * @uses bbp_get_reply_post_type() To get the reply post type
     404     * @uses add_meta_box() To add the metabox
     405     * @uses do_action() Calls 'bbp_author_metabox' with the topic/reply
     406     *                    id
     407     */
     408    public function replies_metabox() {
     409
     410        if ( $this->bail() ) {
     411            return;
     412        }
     413
     414        // Bail if post_type is not a reply
     415        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     416            return;
     417        }
     418
     419        // Add the metabox
     420        add_meta_box(
     421            'bbp_topic_replies_metabox',
     422            __( 'Replies', 'bbpress' ),
     423            'bbp_topic_replies_metabox',
     424            $this->post_type,
     425            'normal',
     426            'high'
     427        );
     428
     429        do_action( 'bbp_topic_replies_metabox', get_the_ID() );
     430    }
     431
     432    /**
    392433     * Add some general styling to the admin area
    393434     *
     
    412453                display: inline-block;
    413454                width: 60px;
     455            }
     456
     457            .column-bbp_topic_reply_author,
     458            .column-bbp_forum_topic_author {
     459                width: 25% !important;
     460            }
     461
     462            .column-bbp_topic_reply_author .avatar,
     463            .column-bbp_forum_topic_author .avatar {
     464                float: left;
     465                margin-right: 10px;
    414466            }
    415467
Note: See TracChangeset for help on using the changeset viewer.