Skip to:
Content

bbPress.org

Changeset 4053


Ignore:
Timestamp:
07/04/2012 02:17:31 AM (14 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.
Location:
branches/plugin/bbp-admin
Files:
8 edited

Legend:

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

    r3966 r4053  
    4949
    5050// Hook on to admin_init
    51 add_action( 'bbp_admin_init', 'bbp_admin_forums',             9 );
    52 add_action( 'bbp_admin_init', 'bbp_admin_topics',             9 );
    53 add_action( 'bbp_admin_init', 'bbp_admin_replies',            9 );
     51add_action( 'bbp_admin_init', 'bbp_admin_forums'                );
     52add_action( 'bbp_admin_init', 'bbp_admin_topics'                );
     53add_action( 'bbp_admin_init', 'bbp_admin_replies'              );
    5454add_action( 'bbp_admin_init', 'bbp_setup_updater',          999 );
    5555add_action( 'bbp_admin_init', 'bbp_register_importers'          );
  • branches/plugin/bbp-admin/bbp-admin.php

    r4052 r4053  
    7777
    7878        /**
    79          * Setup the admin hooks, actions and filters
     79         * Admin globals
    8080         *
    8181         * @since bbPress (r2646)
    8282         * @access private
    83          *
    84          * @uses add_action() To add various actions
    85          * @uses add_filter() To add various filters
    86          */
    87         private function setup_actions() {
    88 
    89                 /** General Actions ***************************************************/
    90 
    91                 // Add menu item to settings menu
    92                 add_action( 'bbp_admin_menu',              array( $this, 'admin_menus'             ) );
    93 
    94                 // Add some general styling to the admin area
    95                 add_action( 'bbp_admin_head',              array( $this, 'admin_head'              ) );
    96 
    97                 // Add notice if not using a bbPress theme
    98                 add_action( 'bbp_admin_notices',           array( $this, 'activation_notice'       ) );
    99 
    100                 // Add green admin style
    101                 add_action( 'bbp_register_admin_style',    array( $this, 'register_admin_style'    ) );
    102 
    103                 // Add settings
    104                 add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings' ) );
    105 
    106                 // Add menu item to settings menu
    107                 add_action( 'bbp_activation',              array( $this, 'new_install'             ) );
    108 
    109                 // Forums 'Right now' Dashboard widget
    110                 add_action( 'wp_dashboard_setup',  array( $this, 'dashboard_widget_right_now' ) );
    111 
    112                 /** Filters ***********************************************************/
    113 
    114                 // Add link to settings page
    115                 add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
    116 
    117                 /** Network Admin *****************************************************/
    118 
    119                 // Add menu item to settings menu
    120                 add_action( 'network_admin_menu',  array( $this, 'network_admin_menus' ) );
    121 
    122                 /** Dependencies ******************************************************/
    123 
    124                 // Allow plugins to modify these actions
    125                 do_action_ref_array( 'bbp_admin_loaded', array( &$this ) );
     83         */
     84        private function setup_globals() {
     85                $bbp = bbpress();
     86                $this->admin_dir  = trailingslashit( $bbp->plugin_dir . 'bbp-admin' ); // Admin path
     87                $this->admin_url  = trailingslashit( $bbp->plugin_url . 'bbp-admin' ); // Admin url
     88                $this->images_url = trailingslashit( $this->admin_url . 'images'    ); // Admin images URL
     89                $this->styles_url = trailingslashit( $this->admin_url . 'styles'    ); // Admin styles URL
    12690        }
    12791
    … …  
    144108
    145109        /**
    146          * Admin globals
     110         * Setup the admin hooks, actions and filters
    147111         *
    148112         * @since bbPress (r2646)
    149113         * @access private
    150          */
    151         private function setup_globals() {
    152                 $bbp = bbpress();
    153                 $this->admin_dir  = trailingslashit( $bbp->plugin_dir . 'bbp-admin' ); // Admin url
    154                 $this->admin_url  = trailingslashit( $bbp->plugin_url . 'bbp-admin' ); // Admin url
    155                 $this->images_url = trailingslashit( $this->admin_url . 'images'    ); // Admin images URL
    156                 $this->styles_url = trailingslashit( $this->admin_url . 'styles'    ); // Admin styles URL
     114         *
     115         * @uses add_action() To add various actions
     116         * @uses add_filter() To add various filters
     117         */
     118        private function setup_actions() {
     119
     120                /** General Actions ***************************************************/
     121
     122                add_action( 'bbp_admin_menu',              array( $this, 'admin_menus'                ) ); // Add menu item to settings menu
     123                add_action( 'bbp_admin_head',              array( $this, 'admin_head'                 ) ); // Add some general styling to the admin area
     124                add_action( 'bbp_admin_notices',           array( $this, 'activation_notice'          ) ); // Add notice if not using a bbPress theme
     125                add_action( 'bbp_register_admin_style',    array( $this, 'register_admin_style'       ) ); // Add green admin style
     126                add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings'    ) ); // Add settings
     127                add_action( 'bbp_activation',              array( $this, 'new_install'                ) ); // Add menu item to settings menu
     128                add_action( 'wp_dashboard_setup',          array( $this, 'dashboard_widget_right_now' ) ); // Forums 'Right now' Dashboard widget
     129
     130                /** Filters ***********************************************************/
     131
     132                // Add link to settings page
     133                add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
     134
     135                /** Network Admin *****************************************************/
     136
     137                // Add menu item to settings menu
     138                add_action( 'network_admin_menu',  array( $this, 'network_admin_menus' ) );
     139
     140                /** Dependencies ******************************************************/
     141
     142                // Allow plugins to modify these actions
     143                do_action_ref_array( 'bbp_admin_loaded', array( &$this ) );
    157144        }
    158145
    … …  
    660647                wp_admin_css_color( 'bbpress', __( 'Green', 'bbpress' ), $css_file, array( '#222222', '#006600', '#deece1', '#6eb469' ) );
    661648        }
     649
     650        /** Updaters **************************************************************/
    662651
    663652        /**
  • branches/plugin/bbp-admin/bbp-converter.php

    r4007 r4053  
    2626         */
    2727        public function __construct() {
     28
     29                // Bail if request is not correct
     30                switch ( strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
     31
     32                        // Converter is converting
     33                        case 'POST' :
     34                                if ( ( empty( $_POST['action'] ) || ( 'bbconverter_process' !=  $_POST['action'] ) ) )
     35                                        return;
     36
     37                                break;
     38
     39                        // Some other admin page
     40                        case 'GET'  :
     41                                if ( ( empty( $_GET['page'] ) || ( 'bbp-converter' !=  $_GET['page'] ) ) )
     42                                        return;
     43
     44                                break;
     45                }
     46
     47                // Proceed with the actions
    2848                $this->setup_actions();
    2949        }
    … …  
    6181
    6282                // Add the main section
    63                 add_settings_section( 'bbpress_converter_main',     __( 'Main Settings',    'bbpress' ),  'bbp_converter_setting_callback_main_section', 'bbpress_converter' );
     83                add_settings_section( 'bbpress_converter_main',     __( 'Database Settings', 'bbpress' ),  'bbp_converter_setting_callback_main_section', 'bbpress_converter' );
    6484
    6585                // System Select
    … …  
    140160                                border-color: #E6DB55;
    141161                                font-family: monospace;
     162                                font-weight: bold;
    142163                        }
    143164
    … …  
    145166                                margin: 0.5em 0;
    146167                                padding: 2px;
    147                         }
    148 
    149                         div.bbp-converter-updated p strong.loading {
    150                                 padding: 2px 20px 2px 0;
     168                                float: left;
     169                                clear: left;
     170                        }
     171
     172                        div.bbp-converter-updated p.loading {
     173                                padding: 2px 20px 2px 2px;
    151174                                background-image: url('<?php echo admin_url(); ?>images/wpspin_light.gif');
    152175                                background-repeat: no-repeat;
    … …  
    186209
    187210                                values['action'] = 'bbconverter_process';
     211                                values['_ajax_nonce'] = '<?php echo  wp_create_nonce( 'bbp_converter_process' ); ?>';
     212
    188213                                return values;
    189214                        }
    … …  
    195220                                        jQuery('#bbp-converter-stop').show();
    196221                                        jQuery('#bbp-converter-progress').show();
    197                                         bbconverter_log( "Starting Conversion..." );
     222                                        bbconverter_log( '<p class="loading"><?php _e( 'Starting Conversion', 'bbpress' ); ?></p>' );
    198223                                        bbconverter_run();
    199224                                }
    … …  
    209234
    210235                        function bbconverter_stop() {
     236                                jQuery('#bbp-converter-start').show();
     237                                jQuery('#bbp-converter-stop').hide();
     238                                jQuery('#bbp-converter-progress').hide();
     239                                jQuery('#bbp-converter-message p').removeClass( 'loading' );
    211240                                bbconverter_is_running = false;
    212                                 jQuery('#bbp-converter-message strong').removeClass( 'loading' );
     241                                clearTimeout( bbconverter_run_timer );
    213242                        }
    214243
    … …  
    216245                                bbconverter_log(response);
    217246
    218                                 if ( response == 'Conversion Complete' || response.indexOf('error') > -1 ) {
    219                                         bbconverter_log('<b>Repair any missing information: <a href="<?php echo admin_url(); ?>tools.php?page=bbp-repair">Continue</a></b>');
    220                                         jQuery('#bbp-converter-start').show();
    221                                         jQuery('#bbp-converter-stop').hide();
    222                                         jQuery('#bbp-converter-progress').hide();
     247                                if ( response == '<p class="loading"><?php _e( 'Conversion Complete', 'bbpress' ); ?></p>' || response.indexOf('error') > -1 ) {
     248                                        bbconverter_log('<p>Repair any missing information: <a href="<?php echo admin_url(); ?>tools.php?page=bbp-repair">Continue</a></p>');
    223249                                        bbconverter_stop();
    224                                         clearTimeout( bbconverter_run_timer );
    225250                                } else if( bbconverter_is_running ) { // keep going
    226251                                        jQuery('#bbp-converter-progress').show();
    … …  
    228253                                        bbconverter_run_timer = setTimeout( 'bbconverter_run()', bbconverter_delay_time );
    229254                                } else {
    230                                         jQuery('#bbp-converter-start').show();
    231                                         jQuery('#bbp-converter-stop').hide();
    232                                         jQuery('#bbp-converter-progress').hide();
    233                                         clearTimeout( bbconverter_run_timer );
     255                                        bbconverter_stop();
    234256                                }
    235257                        }
    … …  
    240262                                }
    241263                                if ( text ) {
    242                                         jQuery('#bbp-converter-message strong').removeClass( 'loading' );
    243                                         jQuery('#bbp-converter-message').prepend('<p><strong class="loading">' + text + '</strong></p>');
     264                                        jQuery('#bbp-converter-message p').removeClass( 'loading' );
     265                                        jQuery('#bbp-converter-message').prepend( text );
    244266                                }
    245267                        }
    … …  
    251273
    252274        /**
     275         * Wrap the converter output in paragraph tags, so styling can be applied
     276         *
     277         * @since bbPress (r4052)
     278         *
     279         * @param string $output
     280         */
     281        private static function converter_output( $output = '' ) {
     282
     283                // Get the last query
     284                $before = '<p class="loading">';
     285                $after  = '</p>';
     286                $query  = get_option( '_bbp_converter_query' );
     287
     288                if ( ! empty( $query ) )
     289                        $before = '<p class="loading" title="' . esc_attr( $query ) . '">';
     290
     291                echo $before . $output . $after;
     292        }
     293
     294        /**
    253295         * Callback processor
    254296         *
    … …  
    256298         */
    257299        public function process_callback() {
     300
     301                // Verify intent
     302                check_ajax_referer( 'bbp_converter_process' );
    258303
    259304                if ( ! ini_get( 'safe_mode' ) ) {
    … …  
    294339                                                $this->sync_table();
    295340                                                if ( empty( $start ) ) {
    296                                                         _e( 'No data to clean', 'bbpress' );
     341                                                        $this->converter_output( __( 'No data to clean', 'bbpress' ) );
    297342                                                }
    298343                                        } else {
    299344                                                update_option( '_bbp_converter_start', $max + 1 );
    300                                                 printf( __( 'Deleting previously converted data (%1$s - %2$s)', 'bbpress' ), $min, $max );
     345                                                $this->converter_output( sprintf( __( 'Deleting previously converted data (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    301346                                        }
    302347                                } else {
    … …  
    314359                                                update_option( '_bbp_converter_start', 0         );
    315360                                                if ( empty( $start ) ) {
    316                                                         _e( 'No users to convert', 'bbpress' );
     361                                                        $this->converter_output( __( 'No users to convert', 'bbpress' ) );
    317362                                                }
    318363                                        } else {
    319364                                                update_option( '_bbp_converter_start', $max + 1 );
    320                                                 printf( __( 'Converting users (%1$s - %2$s)', 'bbpress' ), $min, $max );
     365                                                $this->converter_output( sprintf(  __( 'Converting users (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    321366                                        }
    322367                                } else {
    … …  
    334379                                                update_option( '_bbp_converter_start', 0         );
    335380                                                if ( empty( $start ) ) {
    336                                                         _e( 'No passwords to clear', 'bbpress' );
     381                                                        $this->converter_output( __( 'No passwords to clear', 'bbpress' ) );
    337382                                                }
    338383                                        } else {
    339384                                                update_option( '_bbp_converter_start', $max + 1 );
    340                                                 printf( __( 'Delete users wordpress default passwords (%1$s - %2$s)', 'bbpress' ), $min, $max );
     385                                                $this->converter_output( sprintf( __( 'Delete users wordpress default passwords (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    341386                                        }
    342387                                } else {
    … …  
    353398                                        update_option( '_bbp_converter_start', 0         );
    354399                                        if ( empty( $start ) ) {
    355                                                 _e( 'No forums to convert', 'bbpress' );
     400                                                $this->converter_output( __( 'No forums to convert', 'bbpress' ) );
    356401                                        }
    357402                                } else {
    358403                                        update_option( '_bbp_converter_start', $max + 1 );
    359                                         printf( __( 'Converting forums (%1$s - %2$s)', 'bbpress' ), $min, $max );
     404                                        $this->converter_output( sprintf( __( 'Converting forums (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    360405                                }
    361406
    … …  
    364409                        // STEP 5. Convert forum parents.
    365410                        case 5 :
    366 
    367411                                if ( $converter->convert_forum_parents( $start ) ) {
    368412                                        update_option( '_bbp_converter_step',  $step + 1 );
    369413                                        update_option( '_bbp_converter_start', 0         );
    370414                                        if ( empty( $start ) ) {
    371                                                 _e( 'No forum parents to convert', 'bbpress' );
     415                                                $this->converter_output( __( 'No forum parents to convert', 'bbpress' ) );
    372416                                        }
    373417                                } else {
    374418                                        update_option( '_bbp_converter_start', $max + 1 );
    375                                         printf( __( 'Calculating forum hierarchy (%1$s - %2$s)', 'bbpress' ), $min, $max );
     419                                        $this->converter_output( sprintf( __( 'Calculating forum hierarchy (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    376420                                }
    377421
    … …  
    380424                        // STEP 6. Convert topics.
    381425                        case 6 :
    382 
    383426                                if ( $converter->convert_topics( $start ) ) {
    384427                                        update_option( '_bbp_converter_step',  $step + 1 );
    385428                                        update_option( '_bbp_converter_start', 0         );
    386429                                        if ( empty( $start ) ) {
    387                                                 _e( 'No topics to convert', 'bbpress' );
     430                                                $this->converter_output( __( 'No topics to convert', 'bbpress' ) );
    388431                                        }
    389432                                } else {
    390433                                        update_option( '_bbp_converter_start', $max + 1 );
    391                                         printf( __( 'Converting topics (%1$s - %2$s)', 'bbpress' ), $min, $max );
     434                                        $this->converter_output( sprintf( __( 'Converting topics (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    392435                                }
    393436
    … …  
    396439                        // STEP 7. Convert tags.
    397440                        case 7 :
    398 
    399441                                if ( $converter->convert_tags( $start ) ) {
    400442                                        update_option( '_bbp_converter_step',  $step + 1 );
    401443                                        update_option( '_bbp_converter_start', 0         );
    402444                                        if ( empty( $start ) ) {
    403                                                 _e( 'No tags to convert', 'bbpress' );
     445                                                $this->converter_output( __( 'No tags to convert', 'bbpress' ) );
    404446                                        }
    405447                                } else {
    406448                                        update_option( '_bbp_converter_start', $max + 1 );
    407                                         printf( __( 'Converting topic tags (%1$s - %2$s)', 'bbpress' ), $min, $max );
     449                                        $this->converter_output( sprintf( __( 'Converting topic tags (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    408450                                }
    409451
    … …  
    416458                                        update_option( '_bbp_converter_start', 0         );
    417459                                        if ( empty( $start ) ) {
    418                                                 _e( 'No replies to convert', 'bbpress' );
     460                                                $this->converter_output( __( 'No replies to convert', 'bbpress' ) );
    419461                                        }
    420462                                } else {
    421463                                        update_option( '_bbp_converter_start', $max + 1 );
    422                                         printf( __( 'Converting replies (%1$s - %2$s)', 'bbpress' ), $min, $max );
     464                                        $this->converter_output( sprintf( __( 'Converting replies (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
    423465                                }
    424466
    … …  
    426468
    427469                        default :
    428                                 delete_option( '_bbp_converter_step' );
     470                                delete_option( '_bbp_converter_step'  );
    429471                                delete_option( '_bbp_converter_start' );
    430 
    431                                 _e( 'Conversion Complete', 'bbpress' );
     472                                delete_option( '_bbp_converter_query' );
     473
     474                                $this->converter_output( __( 'Conversion Complete', 'bbpress' ) );
    432475
    433476                                break;
    434 
    435477                }
    436478        }
    … …  
    813855                        $forum_array = $this->opdb->get_results( $forum_query, ARRAY_A );
    814856
    815                         // Output the query, for better debugging
    816                         printf( __( '<span title="%s">View Query</span>%s', 'bbpress' ), esc_attr( $forum_query ), '<br />' );
     857                        // Set this query as the last one ran
     858                        update_option( '_bbp_converter_query', $forum_query );
    817859
    818860                        // Query returned some results
    … …  
    9581000
    9591001        public function convert_forum_parents( $start ) {
     1002
    9601003                $has_update = false;
    9611004
    962                 if ( !empty( $this->sync_table ) ) {
    963                         $forum_array = $this->wpdb->get_results( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_forum_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows );
    964                 } else {
    965                         $forum_array = $this->wpdb->get_results( 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . ' WHERE meta_key = "_bbp_forum_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows );
    966                 }
     1005                if ( !empty( $this->sync_table ) )
     1006                        $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_forum_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows;
     1007                else
     1008                        $query = 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . ' WHERE meta_key = "_bbp_forum_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows;
     1009
     1010                update_option( '_bbp_converter_query', $query );
     1011
     1012                $forum_array = $this->wpdb->get_results( $query );
    9671013
    9681014                foreach ( (array) $forum_array as $row ) {
    … …  
    9791025         */
    9801026        public function clean( $start ) {
     1027
    9811028                $start      = 0;
    9821029                $has_delete = false;
    … …  
    9841031                /** Delete bbconverter topics/forums/posts ****************************/
    9851032
    986                 if ( true === $this->sync_table ) {
    987                         $bbconverter = $this->wpdb->get_results( 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->posts . ' ON(value_id = ID) WHERE meta_key LIKE "_bbp_%" AND value_type = "post" GROUP BY value_id ORDER BY value_id DESC LIMIT ' . $this->max_rows, ARRAY_A );
    988                 } else {
    989                         $bbconverter = $this->wpdb->get_results( 'SELECT post_id AS value_id FROM ' . $this->wpdb->postmeta . ' WHERE meta_key LIKE "_bbp_%" GROUP BY post_id ORDER BY post_id DESC LIMIT ' . $this->max_rows, ARRAY_A );
    990                 }
    991 
    992                 if ( !empty( $bbconverter ) ) {
    993                         foreach ( (array) $bbconverter as $value ) {
     1033                if ( true === $this->sync_table )
     1034                        $query = 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->posts . ' ON(value_id = ID) WHERE meta_key LIKE "_bbp_%" AND value_type = "post" GROUP BY value_id ORDER BY value_id DESC LIMIT ' . $this->max_rows;
     1035                else
     1036                        $query = 'SELECT post_id AS value_id FROM ' . $this->wpdb->postmeta . ' WHERE meta_key LIKE "_bbp_%" GROUP BY post_id ORDER BY post_id DESC LIMIT ' . $this->max_rows;
     1037
     1038                update_option( '_bbp_converter_query', $query );
     1039
     1040                $posts = $this->wpdb->get_results( $query, ARRAY_A );
     1041
     1042                if ( !empty( $posts ) ) {
     1043                        foreach ( (array) $posts as $value ) {
    9941044                                wp_delete_post( $value['value_id'], true );
    9951045                        }
    … …  
    9991049                /** Delete bbconverter users ******************************************/
    10001050
    1001                 if ( true === $this->sync_table ) {
    1002                         $bbconverter = $this->wpdb->get_results( 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->users . ' ON(value_id = ID) WHERE meta_key = "_bbp_user_id" AND value_type = "user" LIMIT ' . $this->max_rows, ARRAY_A );
    1003                 } else {
    1004                         $bbconverter = $this->wpdb->get_results( 'SELECT user_id AS value_id FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbp_user_id" LIMIT ' . $this->max_rows, ARRAY_A );
    1005                 }
    1006 
    1007                 if ( !empty( $bbconverter ) ) {
    1008                         foreach ( $bbconverter as $value ) {
     1051                if ( true === $this->sync_table )
     1052                        $query = 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->users . ' ON(value_id = ID) WHERE meta_key = "_bbp_user_id" AND value_type = "user" LIMIT ' . $this->max_rows;
     1053                else
     1054                        $query = 'SELECT user_id AS value_id FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbp_user_id" LIMIT ' . $this->max_rows;
     1055
     1056                update_option( '_bbp_converter_query', $query );
     1057
     1058                $users = $this->wpdb->get_results( $query, ARRAY_A );
     1059
     1060                if ( !empty( $users ) ) {
     1061                        foreach ( $users as $value ) {
    10091062                                wp_delete_user( $value['value_id'] );
    10101063                        }
    … …  
    10121065                }
    10131066
     1067                unset( $posts );
     1068                unset( $users );
     1069
    10141070                return ! $has_delete;
    10151071        }
    … …  
    10211077         */
    10221078        public function clean_passwords( $start ) {
     1079
    10231080                $has_delete = false;
    10241081
    10251082                /** Delete bbconverter passwords **************************************/
    10261083
    1027                 $bbconverter = $this->wpdb->get_results( 'SELECT user_id, meta_value FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbp_password" LIMIT ' . $start . ', ' . $this->max_rows, ARRAY_A );
     1084                $query       = 'SELECT user_id, meta_value FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbp_password" LIMIT ' . $start . ', ' . $this->max_rows;
     1085                update_option( '_bbp_converter_query', $query );
     1086
     1087                $bbconverter = $this->wpdb->get_results( $query, ARRAY_A );
     1088
    10281089                if ( !empty( $bbconverter ) ) {
    10291090
    … …  
    10381099                        $has_delete = true;
    10391100                }
     1101
    10401102                return ! $has_delete;
    10411103        }
  • 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}
  • branches/plugin/bbp-admin/bbp-replies.php

    r4034 r4053  
    2626         * @var The post type of this admin component
    2727         */
    28         var $post_type = '';
     28        private $post_type = '';
    2929
    3030        /** Functions *************************************************************/
    … …  
    7676
    7777                // Check if there are any bbp_toggle_reply_* requests on admin_init, also have a message displayed
    78                 add_action( 'bbp_admin_init', array( $this, 'toggle_reply'        ) );
     78                add_action( 'load-edit.php', array( $this, 'toggle_reply'        ) );
    7979                add_action( 'admin_notices',  array( $this, 'toggle_reply_notice' ) );
    8080
    … …  
    114114        public function edit_help() {
    115115
    116                 $current_screen = get_current_screen();
    117                 $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
    118 
    119                 // Bail if current screen could not be found
    120                 if ( empty( $current_screen ) )
    121                         return;
    122 
    123                 // Bail if not the reply post type
    124                 if ( $post_type != $this->post_type )
    125                         return;
    126 
    127116                // Overview
    128                 $current_screen->add_help_tab( array(
     117                get_current_screen()->add_help_tab( array(
    129118                        'id'            => 'overview',
    130119                        'title'         => __( 'Overview', 'bbpress' ),
    … …  
    134123
    135124                // Screen Content
    136                 $current_screen->add_help_tab( array(
     125                get_current_screen()->add_help_tab( array(
    137126                        'id'            => 'screen-content',
    138127                        'title'         => __( 'Screen Content', 'bbpress' ),
    … …  
    148137
    149138                // Available Actions
    150                 $current_screen->add_help_tab( array(
     139                get_current_screen()->add_help_tab( array(
    151140                        'id'            => 'action-links',
    152141                        'title'         => __( 'Available Actions', 'bbpress' ),
    … …  
    163152
    164153                // Bulk Actions
    165                 $current_screen->add_help_tab( array(
     154                get_current_screen()->add_help_tab( array(
    166155                        'id'            => 'bulk-actions',
    167156                        'title'         => __( 'Bulk Actions', 'bbpress' ),
    … …  
    172161
    173162                // Help Sidebar
    174                 $current_screen->set_help_sidebar(
     163                get_current_screen()->set_help_sidebar(
    175164                        '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    176165                        '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
    … …  
    187176        public function new_help() {
    188177
    189                 $current_screen = get_current_screen();
    190                 $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
    191 
    192                 // Bail if current screen could not be found
    193                 if ( empty( $current_screen ) )
    194                         return;
    195 
    196                 // Bail if not the reply post type
    197                 if ( $post_type != $this->post_type )
    198                         return;
    199 
    200178                $customize_display = '<p>' . __( 'The title field and the big reply 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>';
    201179
    202                 $current_screen->add_help_tab( array(
     180                get_current_screen()->add_help_tab( array(
    203181                        'id'      => 'customize-display',
    204182                        'title'   => __( 'Customizing This Display', 'bbpress' ),
    … …  
    206184                ) );
    207185
    208                 $current_screen->add_help_tab( array(
     186                get_current_screen()->add_help_tab( array(
    209187                        'id'      => 'title-reply-editor',
    210188                        'title'   => __( 'Title and Reply Editor', 'bbpress' ),
    … …  
    224202                }
    225203
    226                 $current_screen->add_help_tab( array(
     204                get_current_screen()->add_help_tab( array(
    227205                        'id'      => 'reply-attributes',
    228206                        'title'   => __( 'Reply Attributes', 'bbpress' ),
    … …  
    235213                ) );
    236214
    237                 $current_screen->add_help_tab( array(
     215                get_current_screen()->add_help_tab( array(
    238216                        'id'      => 'publish-box',
    239217                        'title'   => __( 'Publish Box', 'bbpress' ),
    … …  
    241219                ) );
    242220
    243                 $current_screen->add_help_tab( array(
     221                get_current_screen()->add_help_tab( array(
    244222                        'id'      => 'discussion-settings',
    245223                        'title'   => __( 'Discussion Settings', 'bbpress' ),
    … …  
    249227                ) );
    250228
    251                 $current_screen->set_help_sidebar(
     229                get_current_screen()->set_help_sidebar(
    252230                        '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    253231                        '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
    … …  
    308286                        return $reply_id;
    309287
    310                 // Bail if post_type is not a reply
    311                 if ( get_post_type( $reply_id ) != $this->post_type )
    312                         return $reply_id;
    313 
    314288                // Current user cannot edit this reply
    315289                if ( !current_user_can( 'edit_reply', $reply_id ) )
    … …  
    347321
    348322                // Bail if post_type is not a reply
    349                 if ( ( empty( $_GET['action'] ) || ( 'edit' != $_GET['action'] ) ) || ( get_post_type() != $this->post_type ) )
     323                if ( empty( $_GET['action'] ) || ( 'edit' != $_GET['action'] ) )
    350324                        return;
    351325
    … …  
    393367                        return $post_id;
    394368
    395                 // Bail if post_type is not a topic or reply
    396                 if ( get_post_type( $post_id ) != $this->post_type )
    397                         return;
    398 
    399369                // Bail if user cannot edit replies or reply is not anonymous
    400370                if ( !current_user_can( 'edit_reply', $post_id ) )
    … …  
    424394         */
    425395        function admin_head() {
    426 
    427                 if ( get_post_type() == $this->post_type ) : ?>
    428 
    429                         <style type="text/css" media="screen">
    430                         /*<![CDATA[*/
    431 
    432                                 .column-bbp_forum_topic_count,
    433                                 .column-bbp_forum_reply_count,
    434                                 .column-bbp_topic_reply_count,
    435                                 .column-bbp_topic_voice_count {
    436                                         width: 8% !important;
    437                                 }
    438 
    439                                 .column-author,
    440                                 .column-bbp_reply_author,
    441                                 .column-bbp_topic_author {
    442                                         width: 10% !important;
    443                                 }
    444 
    445                                 .column-bbp_topic_forum,
    446                                 .column-bbp_reply_forum,
    447                                 .column-bbp_reply_topic {
    448                                         width: 10% !important;
    449                                 }
    450 
    451                                 .column-bbp_forum_freshness,
    452                                 .column-bbp_topic_freshness {
    453                                         width: 10% !important;
    454                                 }
    455 
    456                                 .column-bbp_forum_created,
    457                                 .column-bbp_topic_created,
    458                                 .column-bbp_reply_created {
    459                                         width: 15% !important;
    460                                 }
    461 
    462                                 .status-closed {
    463                                         background-color: #eaeaea;
    464                                 }
    465 
    466                                 .status-spam {
    467                                         background-color: #faeaea;
    468                                 }
    469 
    470                         /*]]>*/
    471                         </style>
    472 
    473                 <?php endif;
    474 
     396                ?>
     397
     398                <style type="text/css" media="screen">
     399                /*<![CDATA[*/
     400
     401                        .column-bbp_forum_topic_count,
     402                        .column-bbp_forum_reply_count,
     403                        .column-bbp_topic_reply_count,
     404                        .column-bbp_topic_voice_count {
     405                                width: 8% !important;
     406                        }
     407
     408                        .column-author,
     409                        .column-bbp_reply_author,
     410                        .column-bbp_topic_author {
     411                                width: 10% !important;
     412                        }
     413
     414                        .column-bbp_topic_forum,
     415                        .column-bbp_reply_forum,
     416                        .column-bbp_reply_topic {
     417                                width: 10% !important;
     418                        }
     419
     420                        .column-bbp_forum_freshness,
     421                        .column-bbp_topic_freshness {
     422                                width: 10% !important;
     423                        }
     424
     425                        .column-bbp_forum_created,
     426                        .column-bbp_topic_created,
     427                        .column-bbp_reply_created {
     428                                width: 15% !important;
     429                        }
     430
     431                        .status-closed {
     432                                background-color: #eaeaea;
     433                        }
     434
     435                        .status-spam {
     436                                background-color: #faeaea;
     437                        }
     438
     439                /*]]>*/
     440                </style>
     441
     442                <?php
    475443        }
    476444
    … …  
    815783        function filter_dropdown() {
    816784
    817                 // Bail if not viewing the topics list
    818                 if (
    819                                 // post_type exists in _GET
    820                                 empty( $_GET['post_type'] ) ||
    821 
    822                                 // post_type is reply or topic type
    823                                 ( $_GET['post_type'] != $this->post_type )
    824                         )
    825                         return;
    826 
    827785                // Add Empty Spam button
    828786                if ( !empty( $_GET['post_status'] ) && ( bbp_get_spam_status_id() == $_GET['post_status'] ) && current_user_can( 'moderate' ) ) {
    … …  
    856814                global $pagenow;
    857815
    858                 // Avoid poisoning other requests
    859                 if (
    860                                 // Only look in admin
    861                                 !is_admin()                 ||
    862 
    863                                 // Make sure the current page is for post rows
    864                                 ( 'edit.php' != $pagenow  ) ||
    865 
    866                                 // Make sure we're looking for a post_type
    867                                 empty( $_GET['post_type'] ) ||
    868 
    869                                 // Make sure we're looking at bbPress topics
    870                                 ( $_GET['post_type'] != $this->post_type )
    871                         )
    872 
    873                         // We're in no shape to filter anything, so return
    874                         return $query_vars;
    875 
    876816                // Add post_parent query_var if one is present
    877817                if ( !empty( $_GET['bbp_forum_id'] ) ) {
    … …  
    890830         *
    891831         * @global int $post_ID
    892          * @uses get_post_type()
    893832         * @uses bbp_get_topic_permalink()
    894833         * @uses wp_post_revision_title()
    … …  
    902841        function updated_messages( $messages ) {
    903842                global $post_ID;
    904 
    905                 if ( get_post_type( $post_ID ) != $this->post_type )
    906                         return $messages;
    907843
    908844                // URL for the current topic
    … …  
    962898 * Setup bbPress Replies Admin
    963899 *
     900 * This is currently here to make hooking and unhooking of the admin UI easy.
     901 * It could use dependency injection in the future, but for now this is easier.
     902 *
    964903 * @since bbPress (r2596)
    965904 *
    … …  
    967906 */
    968907function bbp_admin_replies() {
     908        global $typenow;
     909
     910        if ( bbp_get_reply_post_type() == $typenow )
     911                return;
     912
    969913        bbpress()->admin->replies = new BBP_Replies_Admin();
    970914}
  • branches/plugin/bbp-admin/bbp-settings.php

    r4048 r4053  
    11461146
    11471147        <input id="_bbp_converter_restart" name="_bbp_converter_restart" type="checkbox" id="_bbp_converter_restart" value="1" <?php checked( get_option( '_bbp_converter_restart', false ) ); ?> />
    1148         <label for="_bbp_converter_restart"><?php _e( 'Restart the conversion process', 'bbpress' ); ?></label>
     1148        <label for="_bbp_converter_restart"><?php _e( 'Restart conversion from the beginning', 'bbpress' ); ?></label>
    11491149        <p class="description"><?php _e( 'The importer keeps track of where it left off in the event of failure.', 'bbpress' ); ?></p>
    11501150
  • branches/plugin/bbp-admin/bbp-topics.php

    r4034 r4053  
    2626         * @var The post type of this admin component
    2727         */
    28         var $post_type = '';
     28        private $post_type = '';
    2929
    3030        /** Functions *************************************************************/
    … …  
    7676
    7777                // Check if there are any bbp_toggle_topic_* requests on admin_init, also have a message displayed
    78                 add_action( 'bbp_admin_init', array( $this, 'toggle_topic'        ) );
     78                add_action( 'load-edit.php', array( $this, 'toggle_topic'        ) );
    7979                add_action( 'admin_notices',  array( $this, 'toggle_topic_notice' ) );
    8080
    … …  
    114114        public function edit_help() {
    115115
    116                 $current_screen = get_current_screen();
    117                 $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
    118 
    119                 // Bail if current screen could not be found
    120                 if ( empty( $current_screen ) )
    121                         return;
    122 
    123                 // Bail if not the topic post type
    124                 if ( $post_type != $this->post_type )
    125                         return;
    126 
    127116                // Overview
    128                 $current_screen->add_help_tab( array(
     117                get_current_screen()->add_help_tab( array(
    129118                        'id'            => 'overview',
    130119                        'title'         => __( 'Overview', 'bbpress' ),
    … …  
    134123
    135124                // Screen Content
    136                 $current_screen->add_help_tab( array(
     125                get_current_screen()->add_help_tab( array(
    137126                        'id'            => 'screen-content',
    138127                        'title'         => __( 'Screen Content', 'bbpress' ),
    … …  
    148137
    149138                // Available Actions
    150                 $current_screen->add_help_tab( array(
     139                get_current_screen()->add_help_tab( array(
    151140                        'id'            => 'action-links',
    152141                        'title'         => __( 'Available Actions', 'bbpress' ),
    … …  
    163152
    164153                // Bulk Actions
    165                 $current_screen->add_help_tab( array(
     154                get_current_screen()->add_help_tab( array(
    166155                        'id'            => 'bulk-actions',
    167156                        'title'         => __( 'Bulk Actions', 'bbpress' ),
    … …  
    172161
    173162                // Help Sidebar
    174                 $current_screen->set_help_sidebar(
     163                get_current_screen()->set_help_sidebar(
    175164                        '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    176165                        '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
    … …  
    187176        public function new_help() {
    188177
    189                 $current_screen = get_current_screen();
    190                 $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
    191 
    192                 // Bail if current screen could not be found
    193                 if ( empty( $current_screen ) )
    194                         return;
    195 
    196                 // Bail if not the topic post type
    197                 if ( $post_type != $this->post_type )
    198                         return;
    199 
    200178                $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>';
    201179
    202                 $current_screen->add_help_tab( array(
     180                get_current_screen()->add_help_tab( array(
    203181                        'id'      => 'customize-display',
    204182                        'title'   => __( 'Customizing This Display', 'bbpress' ),
    … …  
    206184                ) );
    207185
    208                 $current_screen->add_help_tab( array(
     186                get_current_screen()->add_help_tab( array(
    209187                        'id'      => 'title-topic-editor',
    210188                        'title'   => __( 'Title and Topic Editor', 'bbpress' ),
    … …  
    224202                }
    225203
    226                 $current_screen->add_help_tab( array(
     204                get_current_screen()->add_help_tab( array(
    227205                        'id'      => 'topic-attributes',
    228206                        'title'   => __( 'Topic Attributes', 'bbpress' ),
    … …  
    235213                ) );
    236214
    237                 $current_screen->add_help_tab( array(
     215                get_current_screen()->add_help_tab( array(
    238216                        'id'      => 'publish-box',
    239217                        'title'   => __( 'Publish Box', 'bbpress' ),
    … …  
    241219                ) );
    242220
    243                 $current_screen->add_help_tab( array(
     221                get_current_screen()->add_help_tab( array(
    244222                        'id'      => 'discussion-settings',
    245223                        'title'   => __( 'Discussion Settings', 'bbpress' ),
    … …  
    249227                ) );
    250228
    251                 $current_screen->set_help_sidebar(
     229                get_current_screen()->set_help_sidebar(
    252230                        '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    253231                        '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
    … …  
    304282                        return $topic_id;
    305283
    306                 // Bail if post_type is not a topic
    307                 if ( get_post_type( $topic_id ) != $this->post_type )
    308                         return $topic_id;
    309 
    310284                // Bail if current user cannot edit this topic
    311285                if ( !current_user_can( 'edit_topic', $topic_id ) )
    … …  
    364338
    365339                // Bail if post_type is not a topic
    366                 if ( ( empty( $_GET['action'] ) || ( 'edit' != $_GET['action'] ) ) || ( get_post_type() != $this->post_type ) )
     340                if ( empty( $_GET['action'] ) || ( 'edit' != $_GET['action'] ) )
    367341                        return;
    368342
    … …  
    410384                        return $post_id;
    411385
    412                 // Bail if post_type is not a topic or reply
    413                 if ( get_post_type( $post_id ) != $this->post_type )
    414                         return;
    415 
    416386                // Bail if user cannot edit replies
    417387                if ( !current_user_can( 'edit_topic', $post_id ) )
    … …  
    441411         */
    442412        function admin_head() {
    443 
    444                 if ( get_post_type() == $this->post_type ) : ?>
    445 
    446                         <style type="text/css" media="screen">
    447                         /*<![CDATA[*/
    448 
    449                                 .column-bbp_forum_topic_count,
    450                                 .column-bbp_forum_reply_count,
    451                                 .column-bbp_topic_reply_count,
    452                                 .column-bbp_topic_voice_count {
    453                                         width: 8% !important;
    454                                 }
    455 
    456                                 .column-author,
    457                                 .column-bbp_reply_author,
    458                                 .column-bbp_topic_author {
    459                                         width: 10% !important;
    460                                 }
    461 
    462                                 .column-bbp_topic_forum,
    463                                 .column-bbp_reply_forum,
    464                                 .column-bbp_reply_topic {
    465                                         width: 10% !important;
    466                                 }
    467 
    468                                 .column-bbp_forum_freshness,
    469                                 .column-bbp_topic_freshness {
    470                                         width: 10% !important;
    471                                 }
    472 
    473                                 .column-bbp_forum_created,
    474                                 .column-bbp_topic_created,
    475                                 .column-bbp_reply_created {
    476                                         width: 15% !important;
    477                                 }
    478 
    479                                 .status-closed {
    480                                         background-color: #eaeaea;
    481                                 }
    482 
    483                                 .status-spam {
    484                                         background-color: #faeaea;
    485                                 }
    486 
    487                         /*]]>*/
    488                         </style>
    489 
    490                 <?php endif;
    491 
     413                ?>
     414
     415                <style type="text/css" media="screen">
     416                /*<![CDATA[*/
     417
     418                        .column-bbp_forum_topic_count,
     419                        .column-bbp_forum_reply_count,
     420                        .column-bbp_topic_reply_count,
     421                        .column-bbp_topic_voice_count {
     422                                width: 8% !important;
     423                        }
     424
     425                        .column-author,
     426                        .column-bbp_reply_author,
     427                        .column-bbp_topic_author {
     428                                width: 10% !important;
     429                        }
     430
     431                        .column-bbp_topic_forum,
     432                        .column-bbp_reply_forum,
     433                        .column-bbp_reply_topic {
     434                                width: 10% !important;
     435                        }
     436
     437                        .column-bbp_forum_freshness,
     438                        .column-bbp_topic_freshness {
     439                                width: 10% !important;
     440                        }
     441
     442                        .column-bbp_forum_created,
     443                        .column-bbp_topic_created,
     444                        .column-bbp_reply_created {
     445                                width: 15% !important;
     446                        }
     447
     448                        .status-closed {
     449                                background-color: #eaeaea;
     450                        }
     451
     452                        .status-spam {
     453                                background-color: #faeaea;
     454                        }
     455
     456                /*]]>*/
     457                </style>
     458
     459                <?php
    492460        }
    493461
    … …  
    812780        function topics_row_actions( $actions, $topic ) {
    813781
    814                 if ( $topic->post_type == $this->post_type ) {
    815                         unset( $actions['inline hide-if-no-js'] );
    816 
    817                         // Show view link if it's not set, the topic is trashed and the user can view trashed topics
    818                         if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() == $topic->post_status ) && current_user_can( 'view_trash' ) )
    819                                 $actions['view'] = '<a href="' . bbp_get_topic_permalink( $topic->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . __( 'View', 'bbpress' ) . '</a>';
    820 
    821                         // Only show the actions if the user is capable of viewing them :)
    822                         if ( current_user_can( 'moderate', $topic->ID ) ) {
    823 
    824                                 // Close
    825                                 // Show the 'close' and 'open' link on published and closed posts only
    826                                 if ( in_array( $topic->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) {
    827                                         $close_uri = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'close-topic_' . $topic->ID ) );
    828                                         if ( bbp_is_topic_open( $topic->ID ) )
    829                                                 $actions['closed'] = '<a href="' . $close_uri . '" title="' . esc_attr__( 'Close this topic', 'bbpress' ) . '">' . _x( 'Close', 'Close a Topic', 'bbpress' ) . '</a>';
    830                                         else
    831                                                 $actions['closed'] = '<a href="' . $close_uri . '" title="' . esc_attr__( 'Open this topic',  'bbpress' ) . '">' . _x( 'Open',  'Open a Topic',  'bbpress' ) . '</a>';
     782                unset( $actions['inline hide-if-no-js'] );
     783
     784                // Show view link if it's not set, the topic is trashed and the user can view trashed topics
     785                if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() == $topic->post_status ) && current_user_can( 'view_trash' ) )
     786                        $actions['view'] = '<a href="' . bbp_get_topic_permalink( $topic->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . __( 'View', 'bbpress' ) . '</a>';
     787
     788                // Only show the actions if the user is capable of viewing them :)
     789                if ( current_user_can( 'moderate', $topic->ID ) ) {
     790
     791                        // Close
     792                        // Show the 'close' and 'open' link on published and closed posts only
     793                        if ( in_array( $topic->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) {
     794                                $close_uri = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'close-topic_' . $topic->ID ) );
     795                                if ( bbp_is_topic_open( $topic->ID ) )
     796                                        $actions['closed'] = '<a href="' . $close_uri . '" title="' . esc_attr__( 'Close this topic', 'bbpress' ) . '">' . _x( 'Close', 'Close a Topic', 'bbpress' ) . '</a>';
     797                                else
     798                                        $actions['closed'] = '<a href="' . $close_uri . '" title="' . esc_attr__( 'Open this topic',  'bbpress' ) . '">' . _x( 'Open',  'Open a Topic',  'bbpress' ) . '</a>';
     799                        }
     800
     801                        // Dont show sticky if topic links is spam or trash
     802                        if ( !bbp_is_topic_spam( $topic->ID ) && !bbp_is_topic_trash( $topic->ID ) ) {
     803
     804                                // Sticky
     805                                $stick_uri  = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID ) );
     806                                if ( bbp_is_topic_sticky( $topic->ID ) ) {
     807                                        $actions['stick'] = '<a href="' . $stick_uri . '" title="' . esc_attr__( 'Unstick this topic', 'bbpress' ) . '">' . __( 'Unstick', 'bbpress' ) . '</a>';
     808                                } else {
     809                                        $super_uri        = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID ) );
     810                                        $actions['stick'] = '<a href="' . $stick_uri . '" title="' . esc_attr__( 'Stick this topic to its forum', 'bbpress' ) . '">' . __( 'Stick', 'bbpress' ) . '</a> (<a href="' . $super_uri . '" title="' . esc_attr__( 'Stick this topic to front', 'bbpress' ) . '">' . __( 'to front', 'bbpress' ) . '</a>)';
    832811                                }
    833 
    834                                 // Dont show sticky if topic links is spam or trash
    835                                 if ( !bbp_is_topic_spam( $topic->ID ) && !bbp_is_topic_trash( $topic->ID ) ) {
    836 
    837                                         // Sticky
    838                                         $stick_uri  = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID ) );
    839                                         if ( bbp_is_topic_sticky( $topic->ID ) ) {
    840                                                 $actions['stick'] = '<a href="' . $stick_uri . '" title="' . esc_attr__( 'Unstick this topic', 'bbpress' ) . '">' . __( 'Unstick', 'bbpress' ) . '</a>';
    841                                         } else {
    842                                                 $super_uri        = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID ) );
    843                                                 $actions['stick'] = '<a href="' . $stick_uri . '" title="' . esc_attr__( 'Stick this topic to its forum', 'bbpress' ) . '">' . __( 'Stick', 'bbpress' ) . '</a> (<a href="' . $super_uri . '" title="' . esc_attr__( 'Stick this topic to front', 'bbpress' ) . '">' . __( 'to front', 'bbpress' ) . '</a>)';
    844                                         }
    845                                 }
    846 
    847                                 // Spam
    848                                 $spam_uri  = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_'  . $topic->ID ) );
    849                                 if ( bbp_is_topic_spam( $topic->ID ) )
    850                                         $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . __( 'Not spam', 'bbpress' ) . '</a>';
    851                                 else
    852                                         $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark this topic as spam',    'bbpress' ) . '">' . __( 'Spam',     'bbpress' ) . '</a>';
    853 
    854                         }
    855 
    856                         // Do not show trash links for spam topics, or spam links for trashed topics
    857                         if ( current_user_can( 'delete_topic', $topic->ID ) ) {
    858                                 if ( bbp_get_trash_status_id() == $topic->post_status ) {
    859                                         $post_type_object   = get_post_type_object( bbp_get_topic_post_type() );
    860                                         $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . wp_nonce_url( add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $topic->ID ) ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>";
    861                                 } elseif ( EMPTY_TRASH_DAYS ) {
    862                                         $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $topic->ID ) ) . "'>" . __( 'Trash', 'bbpress' ) . "</a>";
    863                                 }
    864 
    865                                 if ( bbp_get_trash_status_id() == $topic->post_status || !EMPTY_TRASH_DAYS ) {
    866                                         $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $topic->ID, '', true ) ) . "'>" . __( 'Delete Permanently', 'bbpress' ) . "</a>";
    867                                 } elseif ( bbp_get_spam_status_id() == $topic->post_status ) {
    868                                         unset( $actions['trash'] );
    869                                 }
     812                        }
     813
     814                        // Spam
     815                        $spam_uri  = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_'  . $topic->ID ) );
     816                        if ( bbp_is_topic_spam( $topic->ID ) )
     817                                $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . __( 'Not spam', 'bbpress' ) . '</a>';
     818                        else
     819                                $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark this topic as spam',    'bbpress' ) . '">' . __( 'Spam',     'bbpress' ) . '</a>';
     820
     821                }
     822
     823                // Do not show trash links for spam topics, or spam links for trashed topics
     824                if ( current_user_can( 'delete_topic', $topic->ID ) ) {
     825                        if ( bbp_get_trash_status_id() == $topic->post_status ) {
     826                                $post_type_object   = get_post_type_object( bbp_get_topic_post_type() );
     827                                $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . wp_nonce_url( add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $topic->ID ) ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>";
     828                        } elseif ( EMPTY_TRASH_DAYS ) {
     829                                $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $topic->ID ) ) . "'>" . __( 'Trash', 'bbpress' ) . "</a>";
     830                        }
     831
     832                        if ( bbp_get_trash_status_id() == $topic->post_status || !EMPTY_TRASH_DAYS ) {
     833                                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $topic->ID, '', true ) ) . "'>" . __( 'Delete Permanently', 'bbpress' ) . "</a>";
     834                        } elseif ( bbp_get_spam_status_id() == $topic->post_status ) {
     835                                unset( $actions['trash'] );
    870836                        }
    871837                }
    … …  
    885851         */
    886852        function filter_dropdown() {
    887 
    888                 // Bail if not viewing the topics list
    889                 if (
    890                                 // post_type exists in _GET
    891                                 empty( $_GET['post_type'] ) ||
    892 
    893                                 // post_type is not topic type
    894                                 ( $_GET['post_type'] != $this->post_type )
    895                         )
    896                         return;
    897853
    898854                // Add Empty Spam button
    … …  
    925881         */
    926882        function filter_post_rows( $query_vars ) {
    927                 global $pagenow;
    928 
    929                 // Avoid poisoning other requests
    930                 if (
    931                                 // Only look in admin
    932                                 !is_admin()                 ||
    933 
    934                                 // Make sure the current page is for post rows
    935                                 ( 'edit.php' != $pagenow  ) ||
    936 
    937                                 // Make sure we're looking for a post_type
    938                                 empty( $_GET['post_type'] ) ||
    939 
    940                                 // Make sure we're looking at bbPress topics
    941                                 ( $_GET['post_type'] != $this->post_type )
    942                         )
    943 
    944                         // We're in no shape to filter anything, so return
    945                         return $query_vars;
    946883
    947884                // Add post_parent query_var if one is present
    … …  
    961898         *
    962899         * @global int $post_ID
    963          * @uses get_post_type()
    964900         * @uses bbp_get_topic_permalink()
    965901         * @uses wp_post_revision_title()
    … …  
    973909        function updated_messages( $messages ) {
    974910                global $post_ID;
    975 
    976                 if ( get_post_type( $post_ID ) != $this->post_type )
    977                         return $messages;
    978911
    979912                // URL for the current topic
    … …  
    1033966 * Setup bbPress Topics Admin
    1034967 *
     968 * This is currently here to make hooking and unhooking of the admin UI easy.
     969 * It could use dependency injection in the future, but for now this is easier.
     970 *
    1035971 * @since bbPress (r2596)
    1036972 *
    … …  
    1038974 */
    1039975function bbp_admin_topics() {
     976        global $typenow;
     977
     978        if ( bbp_get_topic_post_type() != $typenow )
     979                return;
     980
    1040981        bbpress()->admin->topics = new BBP_Topics_Admin();
    1041982}
  • branches/plugin/bbp-admin/bbp-users.php

    r3966 r4053  
    100100}
    101101endif; // class exists
    102 
    103 /**
    104  * Setup bbPress Users Admin
    105  *
    106  * @since bbPress (r2596)
    107  *
    108  * @uses BBP_Replies_Admin
    109  */
    110 function bbp_users_admin() {
    111         bbpress()->admin->users = new BBP_Users_Admin();
    112 }
Note: See TracChangeset for help on using the changeset viewer.