Changeset 6514
- Timestamp:
- 06/09/2017 10:34:16 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
-
bbpress.php (modified) (1 diff)
-
includes/admin/admin.php (modified) (5 diffs)
-
includes/admin/assets/css/admin.css (modified) (1 diff)
-
includes/admin/assets/js/converter.js (modified) (5 diffs)
-
includes/admin/classes/class-bbp-converter-base.php (modified) (6 diffs)
-
includes/admin/classes/class-bbp-converter.php (modified) (10 diffs)
-
includes/admin/settings.php (modified) (21 diffs)
-
includes/core/options.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bbpress.php
r6510 r6514 205 205 /** Versions **********************************************************/ 206 206 207 $this->version = '2.6-rc-65 09';207 $this->version = '2.6-rc-6513'; 208 208 $this->db_version = '261'; 209 209 -
trunk/src/includes/admin/admin.php
r6500 r6514 369 369 } 370 370 371 // Toggle the section if core integration is on372 if ( ( 'deep' === $settings_integration ) && ! empty( $section['page']) ) {371 // Overload the converter page 372 if ( ! empty( $section['page'] ) && ( ( 'converter' === $section['page'] ) || ( 'deep' === $settings_integration ) ) ) { 373 373 $page = $section['page']; 374 374 } else { … … 412 412 switch ( $cap ) { 413 413 414 // BuddyPress 415 case 'bbp_settings_buddypress' : 416 if ( ( is_plugin_active( 'buddypress/bp-loader.php' ) && defined( 'BP_VERSION' ) && bp_is_root_blog() ) && is_super_admin() ) { 417 $caps = array( bbpress()->admin->minimum_capability ); 418 } else { 419 $caps = array( 'do_not_allow' ); 420 } 421 422 break; 423 424 // Akismet 425 case 'bbp_settings_akismet' : 426 if ( ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) && is_super_admin() ) { 427 $caps = array( bbpress()->admin->minimum_capability ); 428 } else { 429 $caps = array( 'do_not_allow' ); 430 } 431 432 break; 433 434 // bbPress 414 // Pages 435 415 case 'bbp_about_page' : // About and Credits 436 416 case 'bbp_tools_page' : // Tools Page … … 440 420 case 'bbp_tools_reset_page' : // Tools - Reset Page 441 421 case 'bbp_settings_page' : // Settings Page 422 423 // Converter Sections 424 case 'bbp_converter_connection' : // Converter - Connection 425 case 'bbp_converter_options' : // Converter - Options 426 427 // Settings Sections 442 428 case 'bbp_settings_users' : // Settings - Users 443 429 case 'bbp_settings_features' : // Settings - Features … … 450 436 $caps = array( bbpress()->admin->minimum_capability ); 451 437 break; 438 439 // Extend - BuddyPress 440 case 'bbp_settings_buddypress' : 441 if ( ( is_plugin_active( 'buddypress/bp-loader.php' ) && defined( 'BP_VERSION' ) && bp_is_root_blog() ) && is_super_admin() ) { 442 $caps = array( bbpress()->admin->minimum_capability ); 443 } else { 444 $caps = array( 'do_not_allow' ); 445 } 446 447 break; 448 449 // Extend - Akismet 450 case 'bbp_settings_akismet' : 451 if ( ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) && is_super_admin() ) { 452 $caps = array( bbpress()->admin->minimum_capability ); 453 } else { 454 $caps = array( 'do_not_allow' ); 455 } 456 457 break; 452 458 } 453 459 … … 564 570 public function enqueue_scripts() { 565 571 566 // Enqueue suggest for forum/topic/reply autoc mopletes572 // Enqueue suggest for forum/topic/reply autocompletes 567 573 wp_enqueue_script( 'suggest' ); 568 574 -
trunk/src/includes/admin/assets/css/admin.css
r6475 r6514 361 361 display: none; 362 362 } 363 364 #bbp-converter-timer { 365 position: absolute; 366 right: 10px; 367 top: 4px; 368 padding: 5px; 369 border: 1px solid #ddd; 370 background-color: #fafafa; 371 } -
trunk/src/includes/admin/assets/js/converter.js
r6474 r6514 9 9 start = $( '#bbp-converter-start' ), 10 10 restart = $( '#_bbp_converter_restart' ), 11 settings = $( '#bbp-converter-settings' ); 11 timer = $( '#bbp-converter-timer' ), 12 settings = $( '#bbp-converter-settings' ), 13 14 // Prefetch the settings 15 options = bbp_converter_settings(); 12 16 13 17 /** … … 184 188 } 185 189 186 $.post( ajaxurl, bbp_converter_settings(), function( response ) { 190 // Check if the settings have changed 191 options = bbp_converter_settings(); 192 193 $.post( ajaxurl, options, function( response ) { 187 194 188 195 if ( 'bbp_converter_db_connection_failed' === response ) { … … 203 210 */ 204 211 function bbp_converter_next() { 212 bbp_converter_timer(); 213 205 214 clearTimeout( BBP_Converter.running ); 206 215 … … 223 232 start.val( button ).show(); 224 233 stop.hide(); 234 timer.text( BBP_Converter.strings.timer_stopped ); 225 235 226 236 if ( log ) { … … 234 244 235 245 /** 246 * Update the timer 247 * 248 * @since 2.6.0 bbPress (r6513) 249 * 250 * @returns {void} 251 */ 252 function bbp_converter_timer() { 253 var remaining = BBP_Converter.delay / 1000; 254 255 timer.text( BBP_Converter.strings.timer_counting.replace( '%s', remaining ) ); 256 257 clearInterval( BBP_Converter.timer ); 258 259 BBP_Converter.timer = setInterval( function() { 260 remaining--; 261 timer.text( BBP_Converter.strings.timer_counting.replace( '%s', remaining ) ); 262 263 if ( remaining <= 0 ) { 264 clearInterval( BBP_Converter.timer ); 265 timer.text( BBP_Converter.strings.timer_waiting ); 266 } 267 }, 1000 ); 268 } 269 270 /** 236 271 * Prepend some text to the import monitor 237 272 * -
trunk/src/includes/admin/classes/class-bbp-converter-base.php
r6499 r6514 68 68 * @var str This is the charset for your wp database. 69 69 */ 70 public $charset ;70 public $charset = ''; 71 71 72 72 /** … … 78 78 * @var str Sync table name. 79 79 */ 80 public $sync_table_name ;80 public $sync_table_name = ''; 81 81 82 82 /** … … 103 103 /** Sanitize Options **************************************************/ 104 104 105 $this->convert_users = ! empty( $_POST['_bbp_converter_convert_users'] ) 106 ? true 107 : false; 105 $this->convert_users = (bool) get_option( '_bbp_converter_convert_users', false ); 106 $this->max_rows = (int) get_option( '_bbp_converter_rows', 100 ); 108 107 109 108 /** Sanitize Connection ***********************************************/ 110 109 111 $db_user = ! empty( $_POST['_bbp_converter_db_user'] ) 112 ? sanitize_text_field( $_POST['_bbp_converter_db_user'] ) 113 : DB_USER; 114 115 $db_pass = ! empty( $_POST['_bbp_converter_db_pass'] ) 116 ? sanitize_text_field( $_POST['_bbp_converter_db_pass'] ) 117 : DB_PASSWORD; 118 119 $db_name = ! empty( $_POST['_bbp_converter_db_name'] ) 120 ? sanitize_text_field( $_POST['_bbp_converter_db_name'] ) 121 : DB_NAME; 122 123 $db_port = ! empty( $_POST['_bbp_converter_db_port'] ) 124 ? (int) sanitize_text_field( $_POST['_bbp_converter_db_port'] ) 125 : ''; 126 127 $db_server = ! empty( $_POST['_bbp_converter_db_server'] ) 128 ? sanitize_text_field( $_POST['_bbp_converter_db_server'] ) 129 : DB_HOST; 130 131 $db_prefix = ! empty( $_POST['_bbp_converter_db_prefix'] ) 132 ? sanitize_text_field( $_POST['_bbp_converter_db_prefix'] ) 133 : ''; 134 135 $db_rows = ! empty( $_POST['_bbp_converter_rows'] ) 136 ? (int) $_POST['_bbp_converter_rows'] 137 : 100; 110 $db_user = get_option( '_bbp_converter_db_user', DB_USER ); 111 $db_pass = get_option( '_bbp_converter_db_pass', DB_PASSWORD ); 112 $db_name = get_option( '_bbp_converter_db_name', DB_NAME ); 113 $db_host = get_option( '_bbp_converter_db_server', DB_HOST ); 114 $db_port = get_option( '_bbp_converter_db_port', '' ); 115 $db_prefix = get_option( '_bbp_converter_db_prefix', '' ); 138 116 139 117 // Maybe add port to server 140 if ( ! empty( $db_port ) && ! empty( $db_ server ) && ! strstr( $db_server, ':' ) ) {141 $db_ server = $db_server. ':' . $db_port;118 if ( ! empty( $db_port ) && ! empty( $db_host ) && ! strstr( $db_host, ':' ) ) { 119 $db_host = $db_host . ':' . $db_port; 142 120 } 143 121 … … 145 123 146 124 // Setup WordPress Database 147 $this->wpdb = bbp_db(); 148 $this->max_rows = $db_rows; 125 $this->wpdb = bbp_db(); 149 126 150 127 // Control WPDB db_connect() bailing … … 152 129 153 130 // Setup old forum Database 154 $this->opdb = new wpdb( $db_user, $db_pass, $db_name, $db_ server);131 $this->opdb = new wpdb( $db_user, $db_pass, $db_name, $db_host ); 155 132 156 133 // Connection failed … … 172 149 */ 173 150 $this->sync_table_name = $this->wpdb->prefix . 'bbp_converter_translator'; 174 if ( $this->wpdb->get_var( "SHOW TABLES LIKE '" . $this->sync_table_name . "'" ) === $this->sync_table_name ) { 175 $this->sync_table = true; 176 } else { 177 $this->sync_table = false; 178 } 151 $this->sync_table = $this->sync_table_name === $this->wpdb->get_var( "SHOW TABLES LIKE '{$this->sync_table_name}'" ) 152 ? true 153 : false; 179 154 180 155 /** 181 156 * Character set 182 157 */ 183 if ( empty( $this->wpdb->charset ) ) { 184 $this->charset = 'UTF8'; 185 } else { 186 $this->charset = $this->wpdb->charset; 187 } 158 $this->charset = ! empty( $this->wpdb->charset ) 159 ? $this->wpdb->charset 160 : 'UTF8'; 188 161 189 162 /** -
trunk/src/includes/admin/classes/class-bbp-converter.php
r6491 r6514 44 44 45 45 /** 46 * @var int Maximum number of converter steps 47 */ 48 public $max_steps = 17; 49 50 /** 46 51 * The main bbPress Converter loader 47 52 * … … 67 72 add_action( 'admin_head-tools_page_bbp-converter', array( $this, 'admin_head' ) ); 68 73 69 // Attach the bbConverter admin settings action to the WordPress admin init action.70 add_action( 'load-tools_page_bbp-converter', array( $this, 'register_admin_settings' ) );71 72 74 // Attach to the admin ajax request to process cycles 73 75 add_action( 'wp_ajax_bbp_converter_process', array( $this, 'process_callback' ) ); 74 }75 76 /**77 * Register the settings78 *79 * @since 2.1.0 bbPress (r3813)80 *81 * @uses add_settings_section() To add our own settings section82 * @uses add_settings_field() To add various settings fields83 * @uses register_setting() To register various settings84 */85 public function register_admin_settings() {86 87 // Add the main section88 add_settings_section( 'bbpress_converter_main', esc_html__( 'Database Settings', 'bbpress' ), 'bbp_converter_setting_callback_main_section', 'bbpress_converter' );89 90 // System Select91 add_settings_field( '_bbp_converter_platform', esc_html__( 'Select Platform', 'bbpress' ), 'bbp_converter_setting_callback_platform', 'bbpress_converter', 'bbpress_converter_main' );92 register_setting ( 'bbpress_converter_main', '_bbp_converter_platform', 'sanitize_title' );93 94 // Database Server95 add_settings_field( '_bbp_converter_db_server', esc_html__( 'Database Server', 'bbpress' ), 'bbp_converter_setting_callback_dbserver', 'bbpress_converter', 'bbpress_converter_main' );96 register_setting ( 'bbpress_converter_main', '_bbp_converter_db_server', 'sanitize_title' );97 98 // Database Server Port99 add_settings_field( '_bbp_converter_db_port', esc_html__( 'Database Port', 'bbpress' ), 'bbp_converter_setting_callback_dbport', 'bbpress_converter', 'bbpress_converter_main' );100 register_setting ( 'bbpress_converter_main', '_bbp_converter_db_port', 'sanitize_title' );101 102 // Database Name103 add_settings_field( '_bbp_converter_db_name', esc_html__( 'Database Name', 'bbpress' ), 'bbp_converter_setting_callback_dbname', 'bbpress_converter', 'bbpress_converter_main' );104 register_setting ( 'bbpress_converter_main', '_bbp_converter_db_name', 'sanitize_title' );105 106 // Database User107 add_settings_field( '_bbp_converter_db_user', esc_html__( 'Database User', 'bbpress' ), 'bbp_converter_setting_callback_dbuser', 'bbpress_converter', 'bbpress_converter_main' );108 register_setting ( 'bbpress_converter_main', '_bbp_converter_db_user', 'sanitize_title' );109 110 // Database Pass111 add_settings_field( '_bbp_converter_db_pass', esc_html__( 'Database Password', 'bbpress' ), 'bbp_converter_setting_callback_dbpass', 'bbpress_converter', 'bbpress_converter_main' );112 register_setting ( 'bbpress_converter_main', '_bbp_converter_db_pass', 'sanitize_title' );113 114 // Database Prefix115 add_settings_field( '_bbp_converter_db_prefix', esc_html__( 'Table Prefix', 'bbpress' ), 'bbp_converter_setting_callback_dbprefix', 'bbpress_converter', 'bbpress_converter_main' );116 register_setting ( 'bbpress_converter_main', '_bbp_converter_db_prefix', 'sanitize_title' );117 118 // Add the options section119 add_settings_section( 'bbpress_converter_opt', esc_html__( 'Options', 'bbpress' ), 'bbp_converter_setting_callback_options_section', 'bbpress_converter' );120 121 // Rows Limit122 add_settings_field( '_bbp_converter_rows', esc_html__( 'Rows Limit', 'bbpress' ), 'bbp_converter_setting_callback_rows', 'bbpress_converter', 'bbpress_converter_opt' );123 register_setting ( 'bbpress_converter_opt', '_bbp_converter_rows', 'intval' );124 125 // Delay Time126 add_settings_field( '_bbp_converter_delay_time', esc_html__( 'Delay Time', 'bbpress' ), 'bbp_converter_setting_callback_delay_time', 'bbpress_converter', 'bbpress_converter_opt' );127 register_setting ( 'bbpress_converter_opt', '_bbp_converter_delay_time', 'intval' );128 129 // Convert Users ?130 add_settings_field( '_bbp_converter_convert_users', esc_html__( 'Convert Users', 'bbpress' ), 'bbp_converter_setting_callback_convert_users', 'bbpress_converter', 'bbpress_converter_opt' );131 register_setting ( 'bbpress_converter_opt', '_bbp_converter_convert_users', 'intval' );132 133 // Restart134 add_settings_field( '_bbp_converter_restart', esc_html__( 'Start Over', 'bbpress' ), 'bbp_converter_setting_callback_restart', 'bbpress_converter', 'bbpress_converter_opt' );135 register_setting ( 'bbpress_converter_opt', '_bbp_converter_restart', 'intval' );136 137 // Clean138 add_settings_field( '_bbp_converter_clean', esc_html__( 'Purge Previous Import', 'bbpress' ), 'bbp_converter_setting_callback_clean', 'bbpress_converter', 'bbpress_converter_opt' );139 register_setting ( 'bbpress_converter_opt', '_bbp_converter_clean', 'intval' );140 76 } 141 77 … … 157 93 wp_enqueue_script( 'postbox' ); 158 94 wp_enqueue_script( 'dashboard' ); 159 wp_enqueue_script( 'bbp-converter', $bbp->admin->js_url . 'converter' . $suffix . '.js', array( 'jquery', 'postbox' ), $bbp-> asset_version );95 wp_enqueue_script( 'bbp-converter', $bbp->admin->js_url . 'converter' . $suffix . '.js', array( 'jquery', 'postbox' ), $bbp->version ); 160 96 161 97 // Localize JS … … 165 101 'ajax_nonce' => wp_create_nonce( 'bbp_converter_process' ), 166 102 'halt' => (bool) defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY, 167 'started' => (bool) get_option( '_bbp_converter_step', false ), 103 'started' => (bool) get_option( '_bbp_converter_step', false ), 104 'delay' => (int) get_option( '_bbp_converter_delay_time', 1 ), 168 105 'running' => false, 169 106 'complete' => false, 170 ' delay' => 0,107 'timer' => false, 171 108 172 109 // Strings … … 187 124 'import_error_db' => esc_html__( 'Database Connection Failed', 'bbpress' ), 188 125 'import_error_halt' => esc_html__( 'Import Halted (Error)', 'bbpress' ), 126 127 // Timer 128 'timer_stopped' => esc_html__( 'Timer: Stopped', 'bbpress' ), 129 'timer_waiting' => esc_html__( 'Timer: Waiting...', 'bbpress' ), 130 'timer_counting' => esc_html__( 'Timer: %s', 'bbpress' ) 189 131 ) 190 132 ) ); … … 257 199 // Save step and count so that it can be restarted. 258 200 if ( ! get_option( '_bbp_converter_step' ) || ! empty( $_POST['_bbp_converter_restart'] ) ) { 259 update_option( '_bbp_converter_step', 0 ); 260 update_option( '_bbp_converter_start', 0 ); 261 262 $this->step = 0; 201 $this->maybe_update_options(); 202 $this->step = 1; 263 203 $this->start = 0; 264 204 } 265 205 } 266 206 207 private function maybe_update_options() { 208 209 // Get the default options & values 210 $defaults = bbp_get_default_options(); 211 212 // Default options 213 $options = array( 214 215 // Step & Start 216 '_bbp_converter_step' => 1, 217 '_bbp_converter_start' => 0, 218 219 // Rows 220 '_bbp_converter_rows' => ! empty( $_POST['_bbp_converter_rows'] ) 221 ? (int) $_POST['_bbp_converter_rows'] 222 : 0, 223 224 // Platform 225 '_bbp_converter_platform' => ! empty( $_POST['_bbp_converter_platform' ] ) 226 ? sanitize_text_field( $_POST['_bbp_converter_platform' ] ) 227 : '', 228 229 // Convert Users 230 '_bbp_converter_convert_users' => ! empty( $_POST['_bbp_converter_convert_users'] ) 231 ? (bool) $_POST['_bbp_converter_convert_users'] 232 : false, 233 234 // DB User 235 '_bbp_converter_db_user' => ! empty( $_POST['_bbp_converter_db_user'] ) 236 ? sanitize_text_field( $_POST['_bbp_converter_db_user'] ) 237 : '', 238 239 // DB Password 240 '_bbp_converter_db_pass' => ! empty( $_POST['_bbp_converter_db_pass'] ) 241 ? sanitize_text_field( $_POST['_bbp_converter_db_pass'] ) 242 : '', 243 244 // DB Name 245 '_bbp_converter_db_name' => ! empty( $_POST['_bbp_converter_db_name'] ) 246 ? sanitize_text_field( $_POST['_bbp_converter_db_name'] ) 247 : '', 248 249 // DB Server 250 '_bbp_converter_db_server' => ! empty( $_POST['_bbp_converter_db_server'] ) 251 ? sanitize_text_field( $_POST['_bbp_converter_db_server'] ) 252 : '', 253 254 // DB Port 255 '_bbp_converter_db_port' => ! empty( $_POST['_bbp_converter_db_port'] ) 256 ? (int) sanitize_text_field( $_POST['_bbp_converter_db_port'] ) 257 : '', 258 259 // DB Table Prefix 260 '_bbp_converter_db_prefix' => ! empty( $_POST['_bbp_converter_db_prefix'] ) 261 ? sanitize_text_field( $_POST['_bbp_converter_db_prefix'] ) 262 : '' 263 ); 264 265 // Update/delete options 266 foreach ( $options as $key => $value ) { 267 268 // Default 269 $default = $defaults[ $key ]; 270 271 // Update or save 272 ! empty( $value ) && ( $default !== $value ) 273 ? update_option( $key, $value ) 274 : delete_option( $key ); 275 } 276 } 277 267 278 /** 268 279 * Setup converter options … … 272 283 private function setup_options() { 273 284 274 // Get starting point 275 $this->step = (int) get_option( '_bbp_converter_step', 1 ); 276 $this->min = (int) get_option( '_bbp_converter_start', 0 ); 277 278 // Number of rows 279 $this->rows = ! empty( $_POST['_bbp_converter_rows'] ) 280 ? (int) $_POST['_bbp_converter_rows'] 281 : 100; 285 // Get starting point & rows 286 $this->step = (int) get_option( '_bbp_converter_step', 1 ); 287 $this->min = (int) get_option( '_bbp_converter_start', 0 ); 288 $this->rows = (int) get_option( '_bbp_converter_rows', 100 ); 282 289 283 290 // Get boundaries … … 286 293 287 294 // Look for platform 288 $platform = ! empty( $_POST['_bbp_converter_platform' ] ) 289 ? sanitize_text_field( $_POST['_bbp_converter_platform' ] ) 290 : get_option( '_bbp_converter_platform' ); 295 $platform = get_option( '_bbp_converter_platform' ); 291 296 292 297 // Maybe include the appropriate converter. … … 354 359 switch ( $this->step ) { 355 360 356 // STEP 1.Clean all tables.361 // Clean all tables. 357 362 case 1 : 358 if ( ! empty( $_POST['_bbp_converter_clean'] ) ) { 359 if ( $this->converter->clean( $this->start ) ) { 360 $this->sync_table( true ); 361 $this->bump_step(); 362 363 if ( empty( $this->start ) ) { 364 $this->converter_output( esc_html__( 'Recreating sync-table', 'bbpress' ) ); 365 } 366 } else { 367 $this->converter_output( sprintf( esc_html__( 'Deleting previously converted data (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 368 $this->bump_start(); 369 } 370 } else { 371 $this->converter_output( esc_html__( 'Skipping sync-table clean-up', 'bbpress' ) ); 372 $this->sync_table( false ); 373 $this->bump_step(); 374 } 375 376 break; 377 378 // STEP 2. Convert users. 363 $this->step_sync_table(); 364 break; 365 366 // Convert users. 379 367 case 2 : 380 if ( true === $this->converter->convert_users ) { 381 if ( $this->converter->convert_users( $this->start ) ) { 382 $this->bump_step(); 383 384 if ( empty( $this->start ) ) { 385 $this->converter_output( esc_html__( 'No users to import', 'bbpress' ) ); 386 } 387 } else { 388 $this->bump_start(); 389 $this->converter_output( sprintf( esc_html__( 'Converting users (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 390 } 391 } else { 392 $this->bump_step(); 393 $this->converter_output( esc_html__( 'Skipping user clean-up', 'bbpress' ) ); 394 } 395 396 break; 397 398 // STEP 3. Clean passwords. 368 $this->step_users(); 369 break; 370 371 // Clean passwords. 399 372 case 3 : 400 if ( true === $this->converter->convert_users ) { 401 if ( $this->converter->clean_passwords( $this->start ) ) { 402 $this->bump_step(); 403 404 if ( empty( $this->start ) ) { 405 $this->converter_output( esc_html__( 'No passwords to clear', 'bbpress' ) ); 406 } 407 } else { 408 $this->bump_start(); 409 $this->converter_output( sprintf( esc_html__( 'Delete users WordPress default passwords (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 410 } 411 } else { 412 $this->bump_step(); 413 $this->converter_output( esc_html__( 'Skipping password clean-up', 'bbpress' ) ); 414 } 415 416 break; 417 418 // STEP 4. Convert forums. 373 $this->step_passwords(); 374 break; 375 376 // Convert forums. 419 377 case 4 : 420 if ( $this->converter->convert_forums( $this->start ) ) { 421 $this->bump_step(); 422 423 if ( empty( $this->start ) ) { 424 $this->converter_output( esc_html__( 'No forums to import', 'bbpress' ) ); 425 } 426 } else { 427 $this->bump_start(); 428 $this->converter_output( sprintf( esc_html__( 'Converting forums (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 429 } 430 431 break; 432 433 // STEP 5. Convert forum parents. 378 $this->step_forums(); 379 break; 380 381 // Convert forum parents. 434 382 case 5 : 435 if ( $this->converter->convert_forum_parents( $this->start ) ) { 436 $this->bump_step(); 437 438 if ( empty( $this->start ) ) { 439 $this->converter_output( esc_html__( 'No forum parents to import', 'bbpress' ) ); 440 } 441 } else { 442 $this->bump_start(); 443 $this->converter_output( sprintf( esc_html__( 'Calculating forum hierarchy (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 444 } 445 446 break; 447 448 // STEP 6. Convert forum subscriptions. 383 $this->step_forum_hierarchy(); 384 break; 385 386 // Convert forum subscriptions. 449 387 case 6 : 450 if ( $this->converter->convert_forum_subscriptions( $this->start ) ) { 451 $this->bump_step(); 452 453 if ( empty( $this->start ) ) { 454 $this->converter_output( esc_html__( 'No forum subscriptions to import', 'bbpress' ) ); 455 } 456 } else { 457 $this->bump_start(); 458 $this->converter_output( sprintf( esc_html__( 'Converting forum subscriptions (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 459 } 460 461 break; 462 463 // STEP 7. Convert topics. 388 $this->step_forum_subscriptions(); 389 break; 390 391 // Convert topics. 464 392 case 7 : 465 if ( $this->converter->convert_topics( $this->start ) ) { 466 $this->bump_step(); 467 468 if ( empty( $this->start ) ) { 469 $this->converter_output( esc_html__( 'No topics to import', 'bbpress' ) ); 470 } 471 } else { 472 $this->bump_start(); 473 $this->converter_output( sprintf( esc_html__( 'Converting topics (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 474 } 475 476 break; 477 478 // STEP 8. Convert anonymous topic authors. 393 $this->step_topics(); 394 break; 395 396 // Convert topic authors. 479 397 case 8 : 480 if ( $this->converter->convert_anonymous_topic_authors( $this->start ) ) { 481 $this->bump_step(); 482 483 if ( empty( $this->start ) ) { 484 $this->converter_output( esc_html__( 'No anonymous topic authors to import', 'bbpress' ) ); 485 } 486 } else { 487 $this->bump_start(); 488 $this->converter_output( sprintf( esc_html__( 'Converting anonymous topic authors (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 489 } 490 491 break; 492 493 // STEP 9. Stick topics. 398 $this->step_topics_authors(); 399 break; 400 401 // Sticky topics. 494 402 case 9 : 495 if ( $this->converter->convert_topic_stickies( $this->start ) ) { 496 $this->bump_step(); 497 498 if ( empty( $this->start ) ) { 499 $this->converter_output( esc_html__( 'No stickies to stick', 'bbpress' ) ); 500 } 501 } else { 502 $this->bump_start(); 503 $this->converter_output( sprintf( esc_html__( 'Calculating topic stickies (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 504 } 505 506 break; 507 508 // STEP 10. Stick to front topics (Super Sicky). 403 $this->step_stickies(); 404 break; 405 406 // Stick to front topics (Super Sicky). 509 407 case 10 : 510 if ( $this->converter->convert_topic_super_stickies( $this->start ) ) { 511 $this->bump_step(); 512 513 if ( empty( $this->start ) ) { 514 $this->converter_output( esc_html__( 'No super stickies to stick', 'bbpress' ) ); 515 } 516 } else { 517 $this->bump_start(); 518 $this->converter_output( sprintf( esc_html__( 'Calculating topic super stickies (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 519 } 520 521 break; 522 523 // STEP 11. Closed topics. 408 $this->step_super_stickies(); 409 break; 410 411 // Closed topics. 524 412 case 11 : 525 if ( $this->converter->convert_topic_closed_topics( $this->start ) ) { 526 $this->bump_step(); 527 528 if ( empty( $this->start ) ) { 529 $this->converter_output( esc_html__( 'No closed topics to close', 'bbpress' ) ); 530 } 531 } else { 532 $this->bump_start(); 533 $this->converter_output( sprintf( esc_html__( 'Calculating closed topics (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 534 } 535 536 break; 537 538 // STEP 12. Convert topic tags. 413 $this->step_closed_topics(); 414 break; 415 416 // Convert topic tags. 539 417 case 12 : 540 if ( $this->converter->convert_tags( $this->start ) ) { 541 $this->bump_step(); 542 543 if ( empty( $this->start ) ) { 544 $this->converter_output( esc_html__( 'No topic tags to import', 'bbpress' ) ); 545 } 546 } else { 547 $this->bump_start(); 548 $this->converter_output( sprintf( esc_html__( 'Converting topic tags (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 549 } 550 551 break; 552 553 // STEP 13. Convert topic subscriptions. 418 $this->step_topic_tags(); 419 break; 420 421 // Convert topic subscriptions. 554 422 case 13 : 555 if ( $this->converter->convert_topic_subscriptions( $this->start ) ) { 556 $this->bump_step(); 557 558 if ( empty( $this->start ) ) { 559 $this->converter_output( esc_html__( 'No topic subscriptions to import', 'bbpress' ) ); 560 } 561 } else { 562 $this->bump_start(); 563 $this->converter_output( sprintf( esc_html__( 'Converting topic subscriptions (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 564 } 565 566 break; 567 568 // STEP 14. Convert topic favorites. 423 $this->step_topic_subscriptions(); 424 break; 425 426 // Convert topic favorites. 569 427 case 14 : 570 if ( $this->converter->convert_favorites( $this->start ) ) { 571 $this->bump_step(); 572 573 if ( empty( $this->start ) ) { 574 $this->converter_output( esc_html__( 'No favorites to import', 'bbpress' ) ); 575 } 576 } else { 577 $this->bump_start(); 578 $this->converter_output( sprintf( esc_html__( 'Converting favorites (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 579 } 580 581 break; 582 583 // STEP 15. Convert replies. 428 $this->step_topic_favorites(); 429 break; 430 431 // Convert replies. 584 432 case 15 : 585 if ( $this->converter->convert_replies( $this->start ) ) { 586 $this->bump_step(); 587 588 if ( empty( $this->start ) ) { 589 $this->converter_output( esc_html__( 'No replies to import', 'bbpress' ) ); 590 } 591 } else { 592 $this->bump_start(); 593 $this->converter_output( sprintf( esc_html__( 'Converting replies (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 594 } 595 596 break; 597 598 // STEP 16. Convert anonymous reply authors. 433 $this->step_replies(); 434 break; 435 436 // Convert reply authors. 599 437 case 16 : 600 if ( $this->converter->convert_anonymous_reply_authors( $this->start ) ) { 601 $this->bump_step(); 602 603 if ( empty( $this->start ) ) { 604 $this->converter_output( esc_html__( 'No anonymous reply authors to import', 'bbpress' ) ); 605 } 606 } else { 607 $this->bump_start(); 608 $this->converter_output( sprintf( esc_html__( 'Converting anonymous reply authors (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 609 } 610 611 break; 612 613 // STEP 17. Convert threaded replies parents. 438 $this->step_reply_authors(); 439 break; 440 441 // Convert threaded reply hierarchy. 614 442 case 17 : 615 if ( $this->converter->convert_reply_to_parents( $this->start ) ) { 616 $this->bump_step(); 617 618 if ( empty( $this->start ) ) { 619 $this->converter_output( esc_html__( 'No threaded replies to import', 'bbpress' ) ); 620 } 621 } else { 622 $this->bump_start(); 623 $this->converter_output( sprintf( esc_html__( 'Calculating threaded replies parents (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 624 } 625 443 $this->step_reply_hierarchy(); 626 444 break; 627 445 628 446 // Done 629 447 default : 630 $this->reset(); 631 $this->converter_output( esc_html__( 'Import Finished', 'bbpress' ) ); 632 633 break; 634 } 635 } 448 $this->step_done(); 449 break; 450 } 451 } 452 453 /** Steps *****************************************************************/ 454 455 /** 456 * Clean the sync table 457 * 458 * @since 2.6.0 bbPress (r6513) 459 */ 460 private function step_sync_table() { 461 if ( ! empty( $_POST['_bbp_converter_clean'] ) ) { 462 if ( $this->converter->clean( $this->start ) ) { 463 $this->sync_table( true ); 464 $this->bump_step(); 465 466 if ( empty( $this->start ) ) { 467 $this->converter_output( esc_html__( 'Recreating sync-table', 'bbpress' ) ); 468 } 469 } else { 470 $this->converter_output( sprintf( esc_html__( 'Deleting previously converted data (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 471 $this->bump_start(); 472 } 473 } else { 474 $this->converter_output( esc_html__( 'Skipping sync-table clean-up', 'bbpress' ) ); 475 $this->sync_table( false ); 476 $this->bump_step(); 477 } 478 } 479 480 /** 481 * Maybe convert users 482 * 483 * @since 2.6.0 bbPress (r6513) 484 */ 485 private function step_users() { 486 if ( true === $this->converter->convert_users ) { 487 if ( $this->converter->convert_users( $this->start ) ) { 488 $this->bump_step(); 489 490 if ( empty( $this->start ) ) { 491 $this->converter_output( esc_html__( 'No users to import', 'bbpress' ) ); 492 } 493 } else { 494 $this->bump_start(); 495 $this->converter_output( sprintf( esc_html__( 'Converting users (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 496 } 497 } else { 498 $this->bump_step(); 499 $this->converter_output( esc_html__( 'Skipping user clean-up', 'bbpress' ) ); 500 } 501 } 502 503 /** 504 * Maybe clean up passwords 505 * 506 * @since 2.6.0 bbPress (r6513) 507 */ 508 private function step_passwords() { 509 if ( true === $this->converter->convert_users ) { 510 if ( $this->converter->clean_passwords( $this->start ) ) { 511 $this->bump_step(); 512 513 if ( empty( $this->start ) ) { 514 $this->converter_output( esc_html__( 'No passwords to clear', 'bbpress' ) ); 515 } 516 } else { 517 $this->bump_start(); 518 $this->converter_output( sprintf( esc_html__( 'Delete users WordPress default passwords (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 519 } 520 } else { 521 $this->bump_step(); 522 $this->converter_output( esc_html__( 'Skipping password clean-up', 'bbpress' ) ); 523 } 524 } 525 526 /** 527 * Maybe convert forums 528 * 529 * @since 2.6.0 bbPress (r6513) 530 */ 531 private function step_forums() { 532 if ( $this->converter->convert_forums( $this->start ) ) { 533 $this->bump_step(); 534 535 if ( empty( $this->start ) ) { 536 $this->converter_output( esc_html__( 'No forums to import', 'bbpress' ) ); 537 } 538 } else { 539 $this->bump_start(); 540 $this->converter_output( sprintf( esc_html__( 'Converting forums (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 541 } 542 } 543 544 /** 545 * Maybe walk the forum hierarchy 546 * 547 * @since 2.6.0 bbPress (r6513) 548 */ 549 private function step_forum_hierarchy() { 550 if ( $this->converter->convert_forum_parents( $this->start ) ) { 551 $this->bump_step(); 552 553 if ( empty( $this->start ) ) { 554 $this->converter_output( esc_html__( 'No forum parents to import', 'bbpress' ) ); 555 } 556 } else { 557 $this->bump_start(); 558 $this->converter_output( sprintf( esc_html__( 'Calculating forum hierarchy (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 559 } 560 } 561 562 /** 563 * Maybe convert forum subscriptions 564 * 565 * @since 2.6.0 bbPress (r6513) 566 */ 567 private function step_forum_subscriptions() { 568 if ( $this->converter->convert_forum_subscriptions( $this->start ) ) { 569 $this->bump_step(); 570 571 if ( empty( $this->start ) ) { 572 $this->converter_output( esc_html__( 'No forum subscriptions to import', 'bbpress' ) ); 573 } 574 } else { 575 $this->bump_start(); 576 $this->converter_output( sprintf( esc_html__( 'Converting forum subscriptions (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 577 } 578 } 579 580 /** 581 * Maybe convert topics 582 * 583 * @since 2.6.0 bbPress (r6513) 584 */ 585 private function step_topics() { 586 if ( $this->converter->convert_topics( $this->start ) ) { 587 $this->bump_step(); 588 589 if ( empty( $this->start ) ) { 590 $this->converter_output( esc_html__( 'No topics to import', 'bbpress' ) ); 591 } 592 } else { 593 $this->bump_start(); 594 $this->converter_output( sprintf( esc_html__( 'Converting topics (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 595 } 596 } 597 598 /** 599 * Maybe convert topic authors (anonymous) 600 * 601 * @since 2.6.0 bbPress (r6513) 602 */ 603 private function step_topics_authors() { 604 if ( $this->converter->convert_anonymous_topic_authors( $this->start ) ) { 605 $this->bump_step(); 606 607 if ( empty( $this->start ) ) { 608 $this->converter_output( esc_html__( 'No anonymous topic authors to import', 'bbpress' ) ); 609 } 610 } else { 611 $this->bump_start(); 612 $this->converter_output( sprintf( esc_html__( 'Converting anonymous topic authors (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 613 } 614 } 615 616 /** 617 * Maybe convert sticky topics (not super stickies) 618 * 619 * @since 2.6.0 bbPress (r6513) 620 */ 621 private function step_stickies() { 622 if ( $this->converter->convert_topic_stickies( $this->start ) ) { 623 $this->bump_step(); 624 625 if ( empty( $this->start ) ) { 626 $this->converter_output( esc_html__( 'No stickies to stick', 'bbpress' ) ); 627 } 628 } else { 629 $this->bump_start(); 630 $this->converter_output( sprintf( esc_html__( 'Calculating topic stickies (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 631 } 632 } 633 634 /** 635 * Maybe convert super-sticky topics (not per-forum) 636 * 637 * @since 2.6.0 bbPress (r6513) 638 */ 639 private function step_super_stickies() { 640 if ( $this->converter->convert_topic_super_stickies( $this->start ) ) { 641 $this->bump_step(); 642 643 if ( empty( $this->start ) ) { 644 $this->converter_output( esc_html__( 'No super stickies to stick', 'bbpress' ) ); 645 } 646 } else { 647 $this->bump_start(); 648 $this->converter_output( sprintf( esc_html__( 'Calculating topic super stickies (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 649 } 650 } 651 652 /** 653 * Maybe close converted topics 654 * 655 * @since 2.6.0 bbPress (r6513) 656 */ 657 private function step_closed_topics() { 658 if ( $this->converter->convert_topic_closed_topics( $this->start ) ) { 659 $this->bump_step(); 660 661 if ( empty( $this->start ) ) { 662 $this->converter_output( esc_html__( 'No closed topics to close', 'bbpress' ) ); 663 } 664 } else { 665 $this->bump_start(); 666 $this->converter_output( sprintf( esc_html__( 'Calculating closed topics (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 667 } 668 } 669 670 /** 671 * Maybe convert topic tags 672 * 673 * @since 2.6.0 bbPress (r6513) 674 */ 675 private function step_topic_tags() { 676 if ( $this->converter->convert_tags( $this->start ) ) { 677 $this->bump_step(); 678 679 if ( empty( $this->start ) ) { 680 $this->converter_output( esc_html__( 'No topic tags to import', 'bbpress' ) ); 681 } 682 } else { 683 $this->bump_start(); 684 $this->converter_output( sprintf( esc_html__( 'Converting topic tags (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 685 } 686 } 687 688 /** 689 * Maybe convert topic subscriptions 690 * 691 * @since 2.6.0 bbPress (r6513) 692 */ 693 private function step_topic_subscriptions() { 694 if ( $this->converter->convert_topic_subscriptions( $this->start ) ) { 695 $this->bump_step(); 696 697 if ( empty( $this->start ) ) { 698 $this->converter_output( esc_html__( 'No topic subscriptions to import', 'bbpress' ) ); 699 } 700 } else { 701 $this->bump_start(); 702 $this->converter_output( sprintf( esc_html__( 'Converting topic subscriptions (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 703 } 704 } 705 706 /** 707 * Maybe convert topic favorites 708 * 709 * @since 2.6.0 bbPress (r6513) 710 */ 711 private function step_topic_favorites() { 712 if ( $this->converter->convert_favorites( $this->start ) ) { 713 $this->bump_step(); 714 715 if ( empty( $this->start ) ) { 716 $this->converter_output( esc_html__( 'No favorites to import', 'bbpress' ) ); 717 } 718 } else { 719 $this->bump_start(); 720 $this->converter_output( sprintf( esc_html__( 'Converting favorites (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 721 } 722 } 723 724 /** 725 * Maybe convert replies 726 * 727 * @since 2.6.0 bbPress (r6513) 728 */ 729 private function step_replies() { 730 if ( $this->converter->convert_replies( $this->start ) ) { 731 $this->bump_step(); 732 733 if ( empty( $this->start ) ) { 734 $this->converter_output( esc_html__( 'No replies to import', 'bbpress' ) ); 735 } 736 } else { 737 $this->bump_start(); 738 $this->converter_output( sprintf( esc_html__( 'Converting replies (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 739 } 740 } 741 742 /** 743 * Maybe convert reply authors (anonymous) 744 * 745 * @since 2.6.0 bbPress (r6513) 746 */ 747 private function step_reply_authors() { 748 if ( $this->converter->convert_anonymous_reply_authors( $this->start ) ) { 749 $this->bump_step(); 750 751 if ( empty( $this->start ) ) { 752 $this->converter_output( esc_html__( 'No anonymous reply authors to import', 'bbpress' ) ); 753 } 754 } else { 755 $this->bump_start(); 756 $this->converter_output( sprintf( esc_html__( 'Converting anonymous reply authors (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 757 } 758 } 759 760 /** 761 * Maybe convert the threaded reply hierarchy 762 * 763 * @since 2.6.0 bbPress (r6513) 764 */ 765 private function step_reply_hierarchy() { 766 if ( $this->converter->convert_reply_to_parents( $this->start ) ) { 767 $this->bump_step(); 768 769 if ( empty( $this->start ) ) { 770 $this->converter_output( esc_html__( 'No threaded replies to import', 'bbpress' ) ); 771 } 772 } else { 773 $this->bump_start(); 774 $this->converter_output( sprintf( esc_html__( 'Calculating threaded replies parents (%1$s - %2$s)', 'bbpress' ), $this->min, $this->max ) ); 775 } 776 } 777 778 /** 779 * Done! 780 * 781 * @since 2.6.0 bbPress (r6513) 782 */ 783 private function step_done() { 784 $this->reset(); 785 $this->converter_output( esc_html__( 'Import Finished', 'bbpress' ) ); 786 } 787 788 /** Helper Table **********************************************************/ 636 789 637 790 /** … … 640 793 * @since 2.1.0 bbPress (r3813) 641 794 */ 642 public function sync_table( $drop = false ) {795 public static function sync_table( $drop = false ) { 643 796 644 797 // Setup DB -
trunk/src/includes/admin/settings.php
r6498 r6514 24 24 // Filter & return 25 25 return (array) apply_filters( 'bbp_admin_get_settings_sections', array( 26 27 // Settings 26 28 'bbp_settings_users' => array( 27 29 'title' => esc_html__( 'Forum User Settings', 'bbpress' ), … … 64 66 'page' => 'permalink', 65 67 ), 68 69 // Extend 66 70 'bbp_settings_buddypress' => array( 67 71 'title' => esc_html__( 'Forum Integration for BuddyPress', 'bbpress' ), … … 73 77 'callback' => 'bbp_admin_setting_callback_akismet_section', 74 78 'page' => 'discussion' 79 ), 80 81 // Converter 82 'bbp_converter_connection' => array( 83 'title' => esc_html__( 'Database Settings', 'bbpress' ), 84 'callback' => 'bbp_converter_setting_callback_main_section', 85 'page' => 'converter' 86 ), 87 'bbp_converter_options' => array( 88 'title' => esc_html__( 'Options', 'bbpress' ), 89 'callback' => 'bbp_converter_setting_callback_options_section', 90 'page' => 'converter' 75 91 ) 76 92 ) ); … … 454 470 'title' => esc_html__( 'Use Akismet', 'bbpress' ), 455 471 'callback' => 'bbp_admin_setting_callback_akismet', 472 'sanitize_callback' => 'intval', 473 'args' => array() 474 ) 475 ), 476 477 /** Converter Page ****************************************************/ 478 479 // Connection 480 'bbp_converter_connection' => array( 481 482 // System Select 483 '_bbp_converter_platform' => array( 484 'title' => esc_html__( 'Select Platform', 'bbpress' ), 485 'callback' => 'bbp_converter_setting_callback_platform', 486 'sanitize_callback' => 'sanitize_text_field', 487 'args' => array() 488 ), 489 490 // Database Server 491 '_bbp_converter_db_server' => array( 492 'title' => esc_html__( 'Database Server', 'bbpress' ), 493 'callback' => 'bbp_converter_setting_callback_dbserver', 494 'sanitize_callback' => 'sanitize_text_field', 495 'args' => array() 496 ), 497 498 // Database Server Port 499 '_bbp_converter_db_port' => array( 500 'title' => esc_html__( 'Database Port', 'bbpress' ), 501 'callback' => 'bbp_converter_setting_callback_dbport', 502 'sanitize_callback' => 'intval', 503 'args' => array() 504 ), 505 506 // Database Name 507 '_bbp_converter_db_name' => array( 508 'title' => esc_html__( 'Database Name', 'bbpress' ), 509 'callback' => 'bbp_converter_setting_callback_dbname', 510 'sanitize_callback' => 'sanitize_text_field', 511 'args' => array() 512 ), 513 514 // Database User 515 '_bbp_converter_db_user' => array( 516 'title' => esc_html__( 'Database User', 'bbpress' ), 517 'callback' => 'bbp_converter_setting_callback_dbuser', 518 'sanitize_callback' => 'sanitize_text_field', 519 'args' => array() 520 ), 521 522 // Database User 523 '_bbp_converter_db_pass' => array( 524 'title' => esc_html__( 'Database Password', 'bbpress' ), 525 'callback' => 'bbp_converter_setting_callback_dbpass', 526 'sanitize_callback' => 'sanitize_text_field', 527 'args' => array() 528 ), 529 530 // Database User 531 '_bbp_converter_db_prefix' => array( 532 'title' => esc_html__( 'Table Prefix', 'bbpress' ), 533 'callback' => 'bbp_converter_setting_callback_dbprefix', 534 'sanitize_callback' => 'sanitize_text_field', 535 'args' => array() 536 ) 537 ), 538 539 // Options 540 'bbp_converter_options' => array( 541 542 // Rows Limit 543 '_bbp_converter_rows' => array( 544 'title' => esc_html__( 'Rows Limit', 'bbpress' ), 545 'callback' => 'bbp_converter_setting_callback_rows', 546 'sanitize_callback' => 'intval', 547 'args' => array() 548 ), 549 550 // Delay Time 551 '_bbp_converter_delay_time' => array( 552 'title' => esc_html__( 'Delay Time', 'bbpress' ), 553 'callback' => 'bbp_converter_setting_callback_delay_time', 554 'sanitize_callback' => 'intval', 555 'args' => array() 556 ), 557 558 // Convert Users 559 '_bbp_converter_convert_users' => array( 560 'title' => esc_html__( 'Convert Users', 'bbpress' ), 561 'callback' => 'bbp_converter_setting_callback_convert_users', 562 'sanitize_callback' => 'intval', 563 'args' => array() 564 ), 565 566 // Restart 567 '_bbp_converter_restart' => array( 568 'title' => esc_html__( 'Start Over', 'bbpress' ), 569 'callback' => 'bbp_converter_setting_callback_restart', 570 'sanitize_callback' => 'intval', 571 'args' => array() 572 ), 573 574 // Clean 575 '_bbp_converter_clean' => array( 576 'title' => esc_html__( 'Purge Previous Import', 'bbpress' ), 577 'callback' => 'bbp_converter_setting_callback_clean', 456 578 'sanitize_callback' => 'intval', 457 579 'args' => array() … … 1316 1438 ?> 1317 1439 1318 <input name="_bbp_enable_group_forums" id="_bbp_enable_group_forums" type="checkbox" value="1" <?php checked( bbp_is_group_forums_active( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_enable_group_forums' ); ?> />1440 <input name="_bbp_enable_group_forums" id="_bbp_enable_group_forums" type="checkbox" value="1" <?php checked( bbp_is_group_forums_active( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_enable_group_forums' ); ?> /> 1319 1441 <label for="_bbp_enable_group_forums"><?php esc_html_e( 'Allow BuddyPress Groups to have their own forums', 'bbpress' ); ?></label> 1320 1442 … … 1402 1524 ?> 1403 1525 1404 <input name="_bbp_enable_akismet" id="_bbp_enable_akismet" type="checkbox" value="1" <?php checked( bbp_is_akismet_active( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_enable_akismet' ); ?> />1526 <input name="_bbp_enable_akismet" id="_bbp_enable_akismet" type="checkbox" value="1" <?php checked( bbp_is_akismet_active( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_enable_akismet' ); ?> /> 1405 1527 <label for="_bbp_enable_akismet"><?php esc_html_e( 'Allow Akismet to actively prevent forum spam.', 'bbpress' ); ?></label> 1406 1528 … … 1464 1586 1465 1587 // Converters 1588 $current = get_option( '_bbp_converter_platform' ); 1466 1589 $converters = bbp_get_converters(); 1467 1590 $options = ''; … … 1469 1592 // Put options together 1470 1593 foreach ( $converters as $name => $file ) { 1471 $options .= '<option value="' . esc_attr( $name ) . '" >' . esc_html( $name ) . '</option>';1594 $options .= '<option value="' . esc_attr( $name ) . '"' . selected( $name, $current, false ) . '>' . esc_html( $name ) . '</option>'; 1472 1595 } ?> 1473 1596 … … 1486 1609 ?> 1487 1610 1488 <input name="_bbp_converter_db_server" id="_bbp_converter_db_server" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>" class="medium-text"/>1611 <input name="_bbp_converter_db_server" id="_bbp_converter_db_server" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_server' ); ?> /> 1489 1612 <label for="_bbp_converter_db_server"><?php esc_html_e( 'Use default "localhost" if on the same server, otherwise IP or hostname', 'bbpress' ); ?></label> 1490 1613 … … 1500 1623 ?> 1501 1624 1502 <input name="_bbp_converter_db_port" id="_bbp_converter_db_port" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>" class="small-text"/>1625 <input name="_bbp_converter_db_port" id="_bbp_converter_db_port" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_port' ); ?> /> 1503 1626 <label for="_bbp_converter_db_port"><?php esc_html_e( 'Use default "3306" if unsure', 'bbpress' ); ?></label> 1504 1627 … … 1514 1637 ?> 1515 1638 1516 <input name="_bbp_converter_db_user" id="_bbp_converter_db_user" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_user' ); ?>" class="medium-text"/>1639 <input name="_bbp_converter_db_user" id="_bbp_converter_db_user" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_user' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_user' ); ?> /> 1517 1640 <label for="_bbp_converter_db_user"><?php esc_html_e( 'User to acces the database', 'bbpress' ); ?></label> 1518 1641 … … 1528 1651 ?> 1529 1652 1530 <input name="_bbp_converter_db_pass" id="_bbp_converter_db_pass" type="password" class="code" value="<?php bbp_form_option( '_bbp_converter_db_pass' ); ?>" class="medium-text" autocomplete="off"/>1653 <input name="_bbp_converter_db_pass" id="_bbp_converter_db_pass" type="password" class="code" value="<?php bbp_form_option( '_bbp_converter_db_pass' ); ?>" autocomplete="off" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_pass' ); ?> /> 1531 1654 <label for="_bbp_converter_db_pass"><?php esc_html_e( 'Password of the above database user', 'bbpress' ); ?></label> 1532 1655 … … 1542 1665 ?> 1543 1666 1544 <input name="_bbp_converter_db_name" id="_bbp_converter_db_name" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_name' ); ?>" class="medium-text"/>1667 <input name="_bbp_converter_db_name" id="_bbp_converter_db_name" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_name' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_name' ); ?> /> 1545 1668 <label for="_bbp_converter_db_name"><?php esc_html_e( 'Name of the database with your old forum data', 'bbpress' ); ?></label> 1546 1669 … … 1569 1692 ?> 1570 1693 1571 <input name="_bbp_converter_db_prefix" id="_bbp_converter_db_prefix" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_prefix' ); ?>" class="medium-text"/>1694 <input name="_bbp_converter_db_prefix" id="_bbp_converter_db_prefix" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_prefix' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_prefix' ); ?> /> 1572 1695 <label for="_bbp_converter_db_prefix"><?php esc_html_e( '(If converting from BuddyPress Forums, use "wp_bb_" or your custom prefix)', 'bbpress' ); ?></label> 1573 1696 … … 1583 1706 ?> 1584 1707 1585 <input name="_bbp_converter_rows" id="_bbp_converter_rows" type="number" min="1" max="5000" value="<?php bbp_form_option( '_bbp_converter_rows', '100' ); ?>" class="small-text"/>1708 <input name="_bbp_converter_rows" id="_bbp_converter_rows" type="number" min="1" max="5000" value="<?php bbp_form_option( '_bbp_converter_rows', '100' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_rows' ); ?> /> 1586 1709 <label for="_bbp_converter_rows"><?php esc_html_e( 'rows to process at a time', 'bbpress' ); ?></label> 1587 1710 <p class="description"><?php esc_html_e( 'Keep this low if you experience out-of-memory issues.', 'bbpress' ); ?></p> … … 1598 1721 ?> 1599 1722 1600 <input name="_bbp_converter_delay_time" id="_bbp_converter_delay_time" type="number" min=" 1" max="3600" value="<?php bbp_form_option( '_bbp_converter_delay_time', '1' ); ?>" class="small-text"/>1723 <input name="_bbp_converter_delay_time" id="_bbp_converter_delay_time" type="number" min="2" max="3600" value="<?php bbp_form_option( '_bbp_converter_delay_time', '2' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_delay_time' ); ?> /> 1601 1724 <label for="_bbp_converter_delay_time"><?php esc_html_e( 'second(s) delay between each group of rows', 'bbpress' ); ?></label> 1602 1725 <p class="description"><?php esc_html_e( 'Keep this high to prevent too-many-connection issues.', 'bbpress' ); ?></p> … … 1643 1766 ?> 1644 1767 1645 <input name="_bbp_converter_convert_users" id="_bbp_converter_convert_users" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_convert_users', false ) ); ?> />1768 <input name="_bbp_converter_convert_users" id="_bbp_converter_convert_users" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_convert_users', false ) ); ?> <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_convert_users' ); ?> /> 1646 1769 <label for="_bbp_converter_convert_users"><?php esc_html_e( 'Attempt to import user accounts from previous forums', 'bbpress' ); ?></label> 1647 1770 <p class="description"><?php esc_html_e( 'Non-bbPress passwords cannot be automatically converted. They will be converted as each user logs in.', 'bbpress' ); ?></p> … … 1655 1778 * The main settings page 1656 1779 * 1780 * @since 2.1.0 bbPress (r3186) 1781 * 1657 1782 * @uses settings_fields() To output the hidden fields for the form 1658 1783 * @uses do_settings_sections() To output the settings sections … … 1661 1786 1662 1787 // Status 1663 $step = (int) get_option( '_bbp_converter_step', 0);1664 $max = 17; // Filter?1788 $step = (int) get_option( '_bbp_converter_step', 0 ); 1789 $max = (int) bbpress()->admin->converter->max_steps; 1665 1790 1666 1791 // Starting or continuing? … … 1679 1804 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( esc_html__( 'Import Forums', 'bbpress' ) ); ?></h2> 1680 1805 1681 <form action="#" method="post" id="bbp-converter-settings"> 1682 1683 <?php settings_fields( 'bbpress_converter' ); ?> 1684 1685 <?php do_settings_sections( 'bbpress_converter' ); ?> 1806 <form action="#" method="post" id="bbp-converter-settings"><?php 1807 1808 // Fields 1809 settings_fields( 'converter' ); 1810 1811 // Sections 1812 do_settings_sections( 'converter' ); 1813 1814 ?> 1686 1815 1687 1816 <p class="submit"> … … 1700 1829 <span class="toggle-indicator" aria-hidden="true"></span> 1701 1830 </button> 1702 <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Import Monitor', 'bbpress' ); ?></span></h2> 1831 <h2 class="hndle ui-sortable-handle"> 1832 <span><?php esc_html_e( 'Import Monitor', 'bbpress' ); ?></span> 1833 </h2> 1703 1834 <div class="inside"> 1835 <div id="bbp-converter-timer"><?php esc_html_e( 'Timer: Stopped', 'bbpress' ); ?></div> 1704 1836 <div id="bbp-converter-message" class="bbp-converter-log"> 1705 1837 <p><?php echo esc_html( $status_text ); ?></p> -
trunk/src/includes/core/options.php
r6442 r6514 111 111 /** Akismet ***********************************************************/ 112 112 113 '_bbp_enable_akismet' => 1 // Users from all sites can post 114 113 '_bbp_enable_akismet' => 1, // Users from all sites can post 114 115 /** Converter *********************************************************/ 116 117 // Connection 118 '_bbp_converter_db_user' => '', // Database User 119 '_bbp_converter_db_pass' => '', // Database Password 120 '_bbp_converter_db_name' => '', // Database Name 121 '_bbp_converter_db_port' => 3306, // Database Port 122 '_bbp_converter_db_server' => 'localhost', // Database Server/IP 123 '_bbp_converter_db_prefix' => '', // Database table prefix 124 125 // Options 126 '_bbp_converter_rows' => 100, // Number of rows to query 127 '_bbp_converter_delay_time' => 2, // Seconds to wait between queries 128 '_bbp_converter_step' => 1, // Current converter step 129 '_bbp_converter_start' => 1, // Step to start at 130 '_bbp_converter_platform' => '', // Which platform to use 131 '_bbp_converter_query' => '' // Last query 115 132 ) ); 116 133 }
Note: See TracChangeset
for help on using the changeset viewer.