Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/08/2012 08:55:34 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Admin:

  • Introduce bail() method to forum/topic/reply components.
  • Bail out of other methods if post_type doesn't match.
  • Fixes issue where meta-box and styling were not always available on all appropriate screens.
  • Also reverts some perfomance improvements implimented in r4053.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-topics.php

    r4053 r4070  
    3939     * @uses BBP_Topics_Admin::setup_help() Setup the help text
    4040     */
    41     function __construct() {
     41    public function __construct() {
    4242        $this->setup_globals();
    4343        $this->setup_actions();
     
    5656     * @uses bbp_get_reply_post_type() To get the reply post type
    5757     */
    58     function setup_actions() {
     58    private function setup_actions() {
    5959
    6060        // Add some general styling to the admin area
     
    9393
    9494    /**
     95     * Should we bail out of this method?
     96     *
     97     * @since bbPress (r4067)
     98     * @return boolean
     99     */
     100    private function bail() {
     101        if ( $this->post_type != get_current_screen()->post_type )
     102            return true;
     103
     104        return false;
     105    }
     106
     107    /**
    95108     * Admin globals
    96109     *
     
    98111     * @access private
    99112     */
    100     function setup_globals() {
    101 
    102         // Setup the post type for this admin component
     113    private function setup_globals() {
    103114        $this->post_type = bbp_get_topic_post_type();
    104115    }
     
    113124     */
    114125    public function edit_help() {
     126
     127        if ( $this->bail() ) return;
    115128
    116129        // Overview
     
    176189    public function new_help() {
    177190
     191        if ( $this->bail() ) return;
     192
    178193        $customize_display = '<p>' . __( 'The title field and the big topic editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ) . '</p>';
    179194
     
    243258     * @uses do_action() Calls 'bbp_topic_attributes_metabox'
    244259     */
    245     function attributes_metabox() {
     260    public function attributes_metabox() {
     261
     262        if ( $this->bail() ) return;
     263
    246264        add_meta_box (
    247265            'bbp_topic_attributes',
     
    268286     * @return int Parent id
    269287     */
    270     function attributes_metabox_save( $topic_id ) {
     288    public function attributes_metabox_save( $topic_id ) {
    271289       
     290        if ( $this->bail() ) return $topic_id;
     291
    272292        // Bail if doing an autosave
    273293        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
     
    335355     *                    id
    336356     */
    337     function author_metabox() {
     357    public function author_metabox() {
     358
     359        if ( $this->bail() ) return;
    338360
    339361        // Bail if post_type is not a topic
     
    370392     * @return int Topic or reply id
    371393     */
    372     function author_metabox_save( $post_id ) {
     394    public function author_metabox_save( $post_id ) {
     395
     396        if ( $this->bail() ) return $post_id;
    373397
    374398        // Bail if no post_id
     
    410434     * @uses do_action() Calls 'bbp_admin_head'
    411435     */
    412     function admin_head() {
     436    public function admin_head() {
     437
     438        if ( $this->bail() ) return;
     439
    413440        ?>
    414441
     
    489516     * @uses wp_safe_redirect() Redirect the page to custom url
    490517     */
    491     function toggle_topic() {
     518    public function toggle_topic() {
     519
     520        if ( $this->bail() ) return;
    492521
    493522        // Only proceed if GET is a topic toggle action
     
    568597     *                        message, topic id, notice and is it a failure
    569598     */
    570     function toggle_topic_notice() {
     599    public function toggle_topic_notice() {
     600
     601        if ( $this->bail() ) return;
    571602
    572603        // Only proceed if GET is a topic toggle action
     
    640671     * @return array $columns bbPress topic columns
    641672     */
    642     function topics_column_headers( $columns ) {
     673    public function topics_column_headers( $columns ) {
     674
     675        if ( $this->bail() ) return $columns;
     676
    643677        $columns = array(
    644678            'cb'                    => '<input type="checkbox" />',
     
    682716    function topics_column_data( $column, $topic_id ) {
    683717
     718        if ( $this->bail() ) return;
     719
    684720        // Get topic forum ID
    685721        $forum_id = bbp_get_topic_forum_id( $topic_id );
     
    778814     * @return array $actions Actions
    779815     */
    780     function topics_row_actions( $actions, $topic ) {
     816    public function topics_row_actions( $actions, $topic ) {
     817
     818        if ( $this->bail() ) return $actions;
    781819
    782820        unset( $actions['inline hide-if-no-js'] );
     
    850888     * @return bool False. If post type is not topic or reply
    851889     */
    852     function filter_dropdown() {
     890    public function filter_dropdown() {
     891
     892        if ( $this->bail() ) return;
    853893
    854894        // Add Empty Spam button
     
    882922    function filter_post_rows( $query_vars ) {
    883923
     924        if ( $this->bail() ) return $query_vars;
     925
    884926        // Add post_parent query_var if one is present
    885927        if ( !empty( $_GET['bbp_forum_id'] ) ) {
     
    907949     * @return array
    908950     */
    909     function updated_messages( $messages ) {
     951    public function updated_messages( $messages ) {
    910952        global $post_ID;
     953
     954        if ( $this->bail() ) return $messages;
    911955
    912956        // URL for the current topic
     
    9741018 */
    9751019function bbp_admin_topics() {
    976     global $typenow;
    977 
    978     if ( bbp_get_topic_post_type() != $typenow )
    979         return;
    980 
    9811020    bbpress()->admin->topics = new BBP_Topics_Admin();
    9821021}
Note: See TracChangeset for help on using the changeset viewer.