Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/04/2012 02:17:31 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Admin:

  • Add nonce checks and additional sanity checks to converter, to prevent it being loaded or accessed outside of the converter screen.
  • Use 'load-' actions to conditionally load admin components on their respective screens.
  • Remove post_type checks that are no longer needed as a result of conditionally loading each component.
  • Use get_current_screen() to fill in any extra post_type checks.
  • Sweep through converter, make output more clean, add output method, and store last query in the DB in case of failure.
File:
1 edited

Legend:

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

    r4034 r4053  
    2626     * @var The post type of this admin component
    2727     */
    28     var $post_type = '';
     28    private $post_type = '';
    2929
    3030    /** Functions *************************************************************/
     
    102102    public function edit_help() {
    103103
    104         $current_screen = get_current_screen();
    105         $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
    106 
    107         // Bail if current screen could not be found
    108         if ( empty( $current_screen ) )
    109             return;
    110 
    111         // Bail if not the forum post type
    112         if ( $post_type != $this->post_type )
    113             return;
    114 
    115104        // Overview
    116         $current_screen->add_help_tab( array(
     105        get_current_screen()->add_help_tab( array(
    117106            'id'        => 'overview',
    118107            'title'     => __( 'Overview', 'bbpress' ),
     
    122111
    123112        // Screen Content
    124         $current_screen->add_help_tab( array(
     113        get_current_screen()->add_help_tab( array(
    125114            'id'        => 'screen-content',
    126115            'title'     => __( 'Screen Content', 'bbpress' ),
     
    136125
    137126        // Available Actions
    138         $current_screen->add_help_tab( array(
     127        get_current_screen()->add_help_tab( array(
    139128            'id'        => 'action-links',
    140129            'title'     => __( 'Available Actions', 'bbpress' ),
     
    151140
    152141        // Bulk Actions
    153         $current_screen->add_help_tab( array(
     142        get_current_screen()->add_help_tab( array(
    154143            'id'        => 'bulk-actions',
    155144            'title'     => __( 'Bulk Actions', 'bbpress' ),
     
    160149
    161150        // Help Sidebar
    162         $current_screen->set_help_sidebar(
     151        get_current_screen()->set_help_sidebar(
    163152            '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    164153            '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
     
    175164    public function new_help() {
    176165
    177         $current_screen = get_current_screen();
    178         $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
    179 
    180         // Bail if current screen could not be found
    181         if ( empty( $current_screen ) )
    182             return;
    183 
    184         // Bail if not the forum post type
    185         if ( $post_type != $this->post_type )
    186             return;
    187 
    188166        $customize_display = '<p>' . __( 'The title field and the big forum 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>';
    189167
    190         $current_screen->add_help_tab( array(
     168        get_current_screen()->add_help_tab( array(
    191169            'id'      => 'customize-display',
    192170            'title'   => __( 'Customizing This Display', 'bbpress' ),
     
    194172        ) );
    195173
    196         $current_screen->add_help_tab( array(
     174        get_current_screen()->add_help_tab( array(
    197175            'id'      => 'title-forum-editor',
    198176            'title'   => __( 'Title and Forum Editor', 'bbpress' ),
     
    212190        }
    213191
    214         $current_screen->add_help_tab( array(
     192        get_current_screen()->add_help_tab( array(
    215193            'id'      => 'forum-attributes',
    216194            'title'   => __( 'Forum Attributes', 'bbpress' ),
     
    226204        ) );
    227205
    228         $current_screen->add_help_tab( array(
     206        get_current_screen()->add_help_tab( array(
    229207            'id'      => 'publish-box',
    230208            'title'   => __( 'Publish Box', 'bbpress' ),
     
    232210        ) );
    233211
    234         $current_screen->add_help_tab( array(
     212        get_current_screen()->add_help_tab( array(
    235213            'id'      => 'discussion-settings',
    236214            'title'   => __( 'Discussion Settings', 'bbpress' ),
     
    240218        ) );
    241219
    242         $current_screen->set_help_sidebar(
     220        get_current_screen()->set_help_sidebar(
    243221            '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    244222            '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
     
    309287            return $forum_id;
    310288
    311         // Bail if post_type is not a topic or reply
    312         if ( get_post_type( $forum_id ) != $this->post_type )
    313             return $forum_id;
    314 
    315289        // Parent ID
    316290        $parent_id = ( !empty( $_POST['parent_id'] ) && is_numeric( $_POST['parent_id'] ) ) ? (int) $_POST['parent_id'] : 0;
     
    339313     */
    340314    function admin_head() {
    341 
    342         if ( get_post_type() == $this->post_type ) : ?>
    343 
    344             <style type="text/css" media="screen">
    345             /*<![CDATA[*/
    346 
    347                 #misc-publishing-actions,
    348                 #save-post {
    349                     display: none;
    350                 }
    351 
    352                 strong.label {
    353                     display: inline-block;
    354                     width: 60px;
    355                 }
    356 
    357                 #bbp_forum_attributes hr {
    358                     border-style: solid;
    359                     border-width: 1px;
    360                     border-color: #ccc #fff #fff #ccc;
    361                 }
    362 
    363                 .column-bbp_forum_topic_count,
    364                 .column-bbp_forum_reply_count,
    365                 .column-bbp_topic_reply_count,
    366                 .column-bbp_topic_voice_count {
    367                     width: 8% !important;
    368                 }
    369 
    370                 .column-author,
    371                 .column-bbp_reply_author,
    372                 .column-bbp_topic_author {
    373                     width: 10% !important;
    374                 }
    375 
    376                 .column-bbp_topic_forum,
    377                 .column-bbp_reply_forum,
    378                 .column-bbp_reply_topic {
    379                     width: 10% !important;
    380                 }
    381 
    382                 .column-bbp_forum_freshness,
    383                 .column-bbp_topic_freshness {
    384                     width: 10% !important;
    385                 }
    386 
    387                 .column-bbp_forum_created,
    388                 .column-bbp_topic_created,
    389                 .column-bbp_reply_created {
    390                     width: 15% !important;
    391                 }
    392 
    393                 .status-closed {
    394                     background-color: #eaeaea;
    395                 }
    396 
    397                 .status-spam {
    398                     background-color: #faeaea;
    399                 }
    400 
    401             /*]]>*/
    402             </style>
    403 
    404         <?php endif; ?>
     315        ?>
     316
     317        <style type="text/css" media="screen">
     318        /*<![CDATA[*/
     319
     320            #misc-publishing-actions,
     321            #save-post {
     322                display: none;
     323            }
     324
     325            strong.label {
     326                display: inline-block;
     327                width: 60px;
     328            }
     329
     330            #bbp_forum_attributes hr {
     331                border-style: solid;
     332                border-width: 1px;
     333                border-color: #ccc #fff #fff #ccc;
     334            }
     335
     336            .column-bbp_forum_topic_count,
     337            .column-bbp_forum_reply_count,
     338            .column-bbp_topic_reply_count,
     339            .column-bbp_topic_voice_count {
     340                width: 8% !important;
     341            }
     342
     343            .column-author,
     344            .column-bbp_reply_author,
     345            .column-bbp_topic_author {
     346                width: 10% !important;
     347            }
     348
     349            .column-bbp_topic_forum,
     350            .column-bbp_reply_forum,
     351            .column-bbp_reply_topic {
     352                width: 10% !important;
     353            }
     354
     355            .column-bbp_forum_freshness,
     356            .column-bbp_topic_freshness {
     357                width: 10% !important;
     358            }
     359
     360            .column-bbp_forum_created,
     361            .column-bbp_topic_created,
     362            .column-bbp_reply_created {
     363                width: 15% !important;
     364            }
     365
     366            .status-closed {
     367                background-color: #eaeaea;
     368            }
     369
     370            .status-spam {
     371                background-color: #faeaea;
     372            }
     373
     374        /*]]>*/
     375        </style>
    405376
    406377        <?php
     
    495466     */
    496467    function row_actions( $actions, $forum ) {
    497         if ( $forum->post_type == $this->post_type ) {
    498             unset( $actions['inline hide-if-no-js'] );
    499 
    500             // simple hack to show the forum description under the title
    501             bbp_forum_content( $forum->ID );
    502         }
     468        unset( $actions['inline hide-if-no-js'] );
     469
     470        // simple hack to show the forum description under the title
     471        bbp_forum_content( $forum->ID );
    503472
    504473        return $actions;
     
    511480     *
    512481     * @global int $post_ID
    513      * @uses get_post_type()
    514482     * @uses bbp_get_forum_permalink()
    515483     * @uses wp_post_revision_title()
     
    523491    function updated_messages( $messages ) {
    524492        global $post_ID;
    525 
    526         if ( get_post_type( $post_ID ) != $this->post_type )
    527             return $messages;
    528493
    529494        // URL for the current forum
     
    583548 * Setup bbPress Forums Admin
    584549 *
     550 * This is currently here to make hooking and unhooking of the admin UI easy.
     551 * It could use dependency injection in the future, but for now this is easier.
     552 *
    585553 * @since bbPress (r2596)
    586554 *
     
    588556 */
    589557function bbp_admin_forums() {
     558    global $typenow;
     559
     560    if ( bbp_get_forum_post_type() != $typenow )
     561        return;
     562
    590563    bbpress()->admin->forums = new BBP_Forums_Admin();
    591564}
Note: See TracChangeset for help on using the changeset viewer.