| 442 | if ( $converter->convert_topic_stickies( $start ) ) { |
| 443 | update_option( '_bbp_converter_step', $step + 1 ); |
| 444 | update_option( '_bbp_converter_start', 0 ); |
| 445 | if ( empty( $start ) ) { |
| 446 | $this->converter_output( __( 'No stickies to stick', 'bbpress' ) ); |
| 447 | } |
| 448 | } else { |
| 449 | update_option( '_bbp_converter_start', $max + 1 ); |
| 450 | $this->converter_output( sprintf( __( 'Calculating topic stickies (%1$s - %2$s)', 'bbpress' ), $min, $max ) ); |
| 451 | } |
| 452 | |
| 453 | break; |
| 454 | |
| 455 | // STEP 8. Stick to front topics (Super Sicky). |
| 456 | case 8 : |
| 457 | if ( $converter->convert_topic_super_stickies( $start ) ) { |
| 458 | update_option( '_bbp_converter_step', $step + 1 ); |
| 459 | update_option( '_bbp_converter_start', 0 ); |
| 460 | if ( empty( $start ) ) { |
| 461 | $this->converter_output( __( 'No super stickies to stick', 'bbpress' ) ); |
| 462 | } |
| 463 | } else { |
| 464 | update_option( '_bbp_converter_start', $max + 1 ); |
| 465 | $this->converter_output( sprintf( __( 'Calculating topic super stickies (%1$s - %2$s)', 'bbpress' ), $min, $max ) ); |
| 466 | } |
| 467 | |
| 468 | break; |
| 469 | |
| 470 | // STEP 9. Convert tags. |
| 471 | case 9 : |
| 1070 | * This method converts old topic stickies to new bbPress stickies. |
| 1071 | * |
| 1072 | * @since bbPress (r) |
| 1073 | * |
| 1074 | * @uses WPDB $wpdb |
| 1075 | * @uses bbp_stick_topic() to set the imported topic as sticky |
| 1076 | * |
| 1077 | */ |
| 1078 | public function convert_topic_stickies( $start ) { |
| 1079 | |
| 1080 | $has_update = false; |
| 1081 | |
| 1082 | if ( !empty( $this->sync_table ) ) { |
| 1083 | $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "sticky" LIMIT ' . $start . ', ' . $this->max_rows; |
| 1084 | } else { |
| 1085 | $query = 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "sticky" LIMIT ' . $start . ', ' . $this->max_rows; |
| 1086 | } |
| 1087 | |
| 1088 | update_option( '_bbp_converter_query', $query ); |
| 1089 | |
| 1090 | $sticky_array = $this->wpdb->get_results( $query ); |
| 1091 | |
| 1092 | foreach ( (array) $sticky_array as $row ) { |
| 1093 | bbp_stick_topic( $row->value_id ); |
| 1094 | $has_update = true; |
| 1095 | } |
| 1096 | |
| 1097 | return ! $has_update; |
| 1098 | } |
| 1099 | |
| 1100 | /** |
| 1101 | * This method converts old topic super stickies to new bbPress super stickies. |
| 1102 | * |
| 1103 | * @since bbPress (r) |
| 1104 | * |
| 1105 | * @uses WPDB $wpdb |
| 1106 | * @uses bbp_stick_topic() to set the imported topic as super sticky |
| 1107 | * |
| 1108 | */ |
| 1109 | public function convert_topic_super_stickies( $start ) { |
| 1110 | |
| 1111 | $has_update = false; |
| 1112 | |
| 1113 | if ( !empty( $this->sync_table ) ) { |
| 1114 | $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "super-sticky" LIMIT ' . $start . ', ' . $this->max_rows; |
| 1115 | } else { |
| 1116 | $query = 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "super-sticky" LIMIT ' . $start . ', ' . $this->max_rows; |
| 1117 | } |
| 1118 | |
| 1119 | update_option( '_bbp_converter_query', $query ); |
| 1120 | |
| 1121 | $sticky_array = $this->wpdb->get_results( $query ); |
| 1122 | |
| 1123 | foreach ( (array) $sticky_array as $row ) { |
| 1124 | $super = true; |
| 1125 | bbp_stick_topic( $row->value_id, $super ); |
| 1126 | $has_update = true; |
| 1127 | } |
| 1128 | |
| 1129 | return ! $has_update; |
| 1130 | } |
| 1131 | |
| 1132 | /** |