PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.18 2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 All 73 releases
← All changes | includes/admin/converters/bbPress1.php +262 -63 2.22.6.17 View file →
@@ -1,10 +1,19 @@
1 1 <?php
2 2
3 3 /**
4 + * bbPress 1.x Converter
5 + *
6 + * @package bbPress
7 + * @subpackage Converters
8 + */
9 +
10 +/**
4 11 * bbPress 1.1 Converter
5 12 *
6 - * @since bbPress (rxxxx)
13 + * @since 2.1.0 bbPress (r3816)
14 + *
15 + * @link Codex Docs https://codex.bbpress.org/import-forums/bbpress-1-x-buddypress-group-forums
7 16 */
8 17 class bbPress1 extends BBP_Converter_Base {
9 18
10 19 /**
@@ -9,13 +18,11 @@
9 18
10 19 /**
11 20 * Main constructor
12 21 *
13 - * @uses bbPress1::setup_globals()
14 22 */
15 - function __construct() {
23 + public function __construct() {
16 24 parent::__construct();
17 - $this->setup_globals();
18 25 }
19 26
20 27 /**
21 28 * Sets up the field mappings
@@ -21,24 +28,30 @@
21 28 * Sets up the field mappings
22 29 */
23 30 public function setup_globals() {
24 31
32 + // Setup smiley URL & path
33 + $this->bbcode_parser_properties = array(
34 + 'smiley_url' => false,
35 + 'smiley_dir' => false
36 + );
37 +
25 38 /** Forum Section *****************************************************/
26 39
27 - // Forum id (Stored in postmeta)
40 + // Old forum id (Stored in postmeta)
28 41 $this->field_map[] = array(
29 42 'from_tablename' => 'forums',
30 43 'from_fieldname' => 'forum_id',
31 44 'to_type' => 'forum',
32 - 'to_fieldname' => '_bbp_forum_id'
45 + 'to_fieldname' => '_bbp_old_forum_id'
33 46 );
34 47
35 - // Forum parent id (If no parent, 0. Stored in postmeta)
48 + // Forum parent id (If no parent, then 0. Stored in postmeta)
36 49 $this->field_map[] = array(
37 50 'from_tablename' => 'forums',
38 51 'from_fieldname' => 'forum_parent',
39 52 'to_type' => 'forum',
40 - 'to_fieldname' => '_bbp_forum_parent_id'
53 + 'to_fieldname' => '_bbp_old_forum_parent_id'
41 54 );
42 55
43 56 // Forum topic count (Stored in postmeta)
44 57 $this->field_map[] = array(
@@ -55,9 +68,9 @@
55 68 'to_type' => 'forum',
56 69 'to_fieldname' => '_bbp_reply_count'
57 70 );
58 71
59 - // Forum topic count (Stored in postmeta)
72 + // Forum total topic count (Stored in postmeta)
60 73 $this->field_map[] = array(
61 74 'from_tablename' => 'forums',
62 75 'from_fieldname' => 'topics',
63 76 'to_type' => 'forum',
@@ -63,9 +76,9 @@
63 76 'to_type' => 'forum',
64 77 'to_fieldname' => '_bbp_total_topic_count'
65 78 );
66 79
67 - // Forum reply count (Stored in postmeta)
80 + // Forum total reply count (Stored in postmeta)
68 81 $this->field_map[] = array(
69 82 'from_tablename' => 'forums',
70 83 'from_fieldname' => 'posts',
71 84 'to_type' => 'forum',
@@ -105,41 +118,66 @@
105 118 'to_type' => 'forum',
106 119 'to_fieldname' => 'menu_order'
107 120 );
108 121
122 + // Forum type (bbPress v1.x Forum > 0 or Category = 0, Stored in postmeta)
123 + $this->field_map[] = array(
124 + 'from_tablename' => 'meta',
125 + 'from_fieldname' => 'meta_value',
126 + 'join_tablename' => 'forums',
127 + 'join_type' => 'LEFT',
128 + 'join_expression' => 'ON meta.object_id = forums.forum_id AND meta.meta_key = "forum_is_category"',
129 + 'to_type' => 'forum',
130 + 'to_fieldname' => '_bbp_forum_type',
131 + 'callback_method' => 'callback_forum_type'
132 + );
133 +
134 + // Forum status (Set a default value 'open', Stored in postmeta)
135 + $this->field_map[] = array(
136 + 'to_type' => 'forum',
137 + 'to_fieldname' => '_bbp_status',
138 + 'default' => 'open'
139 + );
140 +
109 141 // Forum dates.
110 142 $this->field_map[] = array(
111 143 'to_type' => 'forum',
112 144 'to_fieldname' => 'post_date',
113 - 'default' => date('Y-m-d H:i:s')
145 + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
114 146 );
115 147 $this->field_map[] = array(
116 148 'to_type' => 'forum',
117 149 'to_fieldname' => 'post_date_gmt',
118 - 'default' => date('Y-m-d H:i:s')
150 + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
119 151 );
120 152 $this->field_map[] = array(
121 153 'to_type' => 'forum',
122 154 'to_fieldname' => 'post_modified',
123 - 'default' => date('Y-m-d H:i:s')
155 + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
124 156 );
125 157 $this->field_map[] = array(
126 158 'to_type' => 'forum',
127 159 'to_fieldname' => 'post_modified_gmt',
128 - 'default' => date('Y-m-d H:i:s')
160 + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
129 161 );
130 162
163 + /** Forum Subscriptions Section ***************************************/
164 +
165 + /**
166 + * bbPress 1.x Forums do not support forum subscriptions
167 + */
168 +
131 169 /** Topic Section *****************************************************/
132 170
133 - // Topic id (Stored in postmeta)
171 + // Old topic id (Stored in postmeta)
134 172 $this->field_map[] = array(
135 173 'from_tablename' => 'topics',
136 174 'from_fieldname' => 'topic_id',
137 175 'to_type' => 'topic',
138 - 'to_fieldname' => '_bbp_topic_id'
176 + 'to_fieldname' => '_bbp_old_topic_id'
139 177 );
140 178
141 - // Reply count (Stored in postmeta)
179 + // Topic reply count (Stored in postmeta)
142 180 $this->field_map[] = array(
143 181 'from_tablename' => 'topics',
144 182 'from_fieldname' => 'topic_posts',
145 183 'to_type' => 'topic',
@@ -146,11 +184,20 @@
146 184 'to_fieldname' => '_bbp_reply_count',
147 185 'callback_method' => 'callback_topic_reply_count'
148 186 );
149 187
150 - // Forum id (Stored in postmeta)
188 + // Topic total reply count (Includes unpublished replies, Stored in postmeta)
151 189 $this->field_map[] = array(
152 190 'from_tablename' => 'topics',
191 + 'from_fieldname' => 'topic_posts',
192 + 'to_type' => 'topic',
193 + 'to_fieldname' => '_bbp_total_reply_count',
194 + 'callback_method' => 'callback_topic_reply_count'
195 + );
196 +
197 + // Topic parent forum id (If no parent, then 0. Stored in postmeta)
198 + $this->field_map[] = array(
199 + 'from_tablename' => 'topics',
153 200 'from_fieldname' => 'forum_id',
154 201 'to_type' => 'topic',
155 202 'to_fieldname' => '_bbp_forum_id',
156 203 'callback_method' => 'callback_forumid'
@@ -175,9 +222,9 @@
175 222
176 223 // Topic slug (Clean name to avoid conflicts)
177 224 $this->field_map[] = array(
178 225 'from_tablename' => 'topics',
179 - 'from_fieldname' => 'topic_title',
226 + 'from_fieldname' => 'topic_slug',
180 227 'to_type' => 'topic',
181 228 'to_fieldname' => 'post_name',
182 229 'callback_method' => 'callback_slug'
183 230 );
@@ -182,9 +229,9 @@
182 229 'callback_method' => 'callback_slug'
183 230 );
184 231
185 232 // Topic content.
186 - // Note: We join the posts table because topics do not have content.
233 + // Note: We join the 'posts' table because 'topics' table does not include content.
187 234 $this->field_map[] = array(
188 235 'from_tablename' => 'posts',
189 236 'from_fieldname' => 'post_text',
190 237 'join_tablename' => 'topics',
@@ -194,10 +241,9 @@
194 241 'to_fieldname' => 'post_content',
195 242 'callback_method' => 'callback_html'
196 243 );
197 244
198 - // Topic status.
199 - // Note: post_status is more accurate than topic_status
245 + // Topic status (Spam, Trash or Publish, bbPress v1.x publish = 0, trash = 1 & spam = 2)
200 246 $this->field_map[] = array(
201 247 'from_tablename' => 'posts',
202 248 'from_fieldname' => 'post_status',
203 249 'join_tablename' => 'topics',
@@ -207,10 +253,20 @@
207 253 'to_fieldname' => 'post_status',
208 254 'callback_method' => 'callback_status'
209 255 );
210 256
211 - // Author ip.
257 + // Topic status (Publish or Closed to new replies)
212 258 $this->field_map[] = array(
259 + 'from_tablename' => 'topics',
260 + 'from_fieldname' => 'topic_open',
261 + 'to_type' => 'topic',
262 + 'to_fieldname' => '_bbp_old_closed_status_id',
263 + 'callback_method' => 'callback_topic_status'
264 + );
265 +
266 + // Topic author ip (Stored in postmeta)
267 + // Note: We join the 'posts' table because 'topics' table does not include author ip.
268 + $this->field_map[] = array(
213 269 'from_tablename' => 'posts',
214 270 'from_fieldname' => 'poster_ip',
215 271 'join_tablename' => 'topics',
216 272 'join_type' => 'INNER',
@@ -218,9 +274,9 @@
218 274 'to_type' => 'topic',
219 275 'to_fieldname' => '_bbp_author_ip'
220 276 );
221 277
222 - // Forum id (If no parent, 0)
278 + // Topic parent forum id (If no parent, then 0)
223 279 $this->field_map[] = array(
224 280 'from_tablename' => 'topics',
225 281 'from_fieldname' => 'forum_id',
226 282 'to_type' => 'topic',
@@ -227,8 +283,17 @@
227 283 'to_fieldname' => 'post_parent',
228 284 'callback_method' => 'callback_forumid'
229 285 );
230 286
287 + // Sticky status (Stored in postmeta)
288 + $this->field_map[] = array(
289 + 'from_tablename' => 'topics',
290 + 'from_fieldname' => 'topic_sticky',
291 + 'to_type' => 'topic',
292 + 'to_fieldname' => '_bbp_old_sticky_status_id',
293 + 'callback_method' => 'callback_sticky_status'
294 + );
295 +
231 296 // Topic dates.
232 297 $this->field_map[] = array(
233 298 'from_tablename' => 'topics',
234 299 'from_fieldname' => 'topic_start_time',
@@ -281,8 +346,20 @@
281 346 'to_type' => 'tags',
282 347 'to_fieldname' => 'taxonomy'
283 348 );
284 349
350 + // Term description.
351 + $this->field_map[] = array(
352 + 'from_tablename' => 'term_taxonomy',
353 + 'from_fieldname' => 'description',
354 + 'join_tablename' => 'term_relationships',
355 + 'join_type' => 'INNER',
356 + 'join_expression' => 'USING (term_taxonomy_id)',
357 + 'to_type' => 'tags',
358 + 'to_fieldname' => 'description',
359 + 'callback_method' => 'callback_html'
360 + );
361 +
285 362 // Term text.
286 363 $this->field_map[] = array(
287 364 'from_tablename' => 'terms',
288 365 'from_fieldname' => 'name',
@@ -287,33 +364,103 @@
287 364 'from_tablename' => 'terms',
288 365 'from_fieldname' => 'name',
289 366 'join_tablename' => 'term_taxonomy',
290 367 'join_type' => 'INNER',
291 - 'join_expression' => 'USING (term_id)',
368 + 'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_topic_tag"',
292 369 'to_type' => 'tags',
293 370 'to_fieldname' => 'name'
294 371 );
295 372
373 + // Term slug.
374 + $this->field_map[] = array(
375 + 'from_tablename' => 'terms',
376 + 'from_fieldname' => 'slug',
377 + 'join_tablename' => 'term_taxonomy',
378 + 'join_type' => 'INNER',
379 + 'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_topic_tag"',
380 + 'to_type' => 'tags',
381 + 'to_fieldname' => 'slug',
382 + 'callback_method' => 'callback_slug'
383 + );
384 +
385 + /** Topic Subscriptions Section ***************************************/
386 +
387 + // Subscribed user ID (Stored in usermeta)
388 + $this->field_map[] = array(
389 + 'from_tablename' => 'term_relationships',
390 + 'from_fieldname' => 'user_id',
391 + 'to_type' => 'topic_subscriptions',
392 + 'to_fieldname' => 'user_id',
393 + 'callback_method' => 'callback_userid'
394 + );
395 +
396 + // Join the 'term_taxonomy' table to link 'terms' 'term_relationships' tables
397 + $this->field_map[] = array(
398 + 'from_tablename' => 'term_taxonomy',
399 + 'from_fieldname' => 'term_taxonomy_id',
400 + 'join_tablename' => 'term_relationships',
401 + 'join_type' => 'INNER',
402 + 'join_expression' => 'USING (term_taxonomy_id)',
403 + 'to_type' => 'topic_subscriptions'
404 + );
405 +
406 + // Subscribed topic ID (Stored in usermeta)
407 + $this->field_map[] = array(
408 + 'from_tablename' => 'terms',
409 + 'from_fieldname' => 'name',
410 + 'join_tablename' => 'term_taxonomy',
411 + 'join_type' => 'INNER',
412 + 'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_subscribe"',
413 + 'to_type' => 'topic_subscriptions',
414 + 'to_fieldname' => '_bbp_subscriptions',
415 + 'callback_method' => 'callback_topic_subscriptions'
416 + );
417 +
418 + /** Favorites Section *************************************************/
419 +
420 + // Favorited topic ID (Stored in usermeta)
421 + $this->field_map[] = array(
422 + 'from_tablename' => 'usermeta',
423 + 'from_fieldname' => 'meta_value',
424 + 'from_expression' => 'WHERE usermeta.meta_key = "bb_favorites"',
425 + 'to_type' => 'favorites',
426 + 'to_fieldname' => '_bbp_favorites'
427 + );
428 +
429 + // Favorited user ID (Stored in usermeta)
430 + $this->field_map[] = array(
431 + 'from_tablename' => 'usermeta',
432 + 'from_fieldname' => 'user_id',
433 + 'from_expression' => 'WHERE usermeta.meta_key = "bb_favorites"',
434 + 'to_type' => 'favorites',
435 + 'to_fieldname' => 'user_id',
436 + 'callback_method' => 'callback_userid'
437 + );
438 +
296 439 /** Reply Section *****************************************************/
297 440
298 - // Post id. Stores in postmeta.
441 + // Old reply id (Stored in postmeta)
299 442 $this->field_map[] = array(
300 443 'from_tablename' => 'posts',
301 444 'from_fieldname' => 'post_id',
302 445 'to_type' => 'reply',
303 - 'to_fieldname' => '_bbp_post_id'
446 + 'to_fieldname' => '_bbp_old_reply_id'
304 447 );
305 448
306 - // Topic id (Stores in postmeta)
449 + // Reply parent topic id (If no parent, then 0. Stored in postmeta)
450 + // Note: We join the 'topics' table to limit the replies section to only import replies
307 451 $this->field_map[] = array(
308 - 'from_tablename' => 'posts',
452 + 'from_tablename' => 'topics',
309 453 'from_fieldname' => 'topic_id',
454 + 'join_tablename' => 'posts',
455 + 'join_type' => 'INNER',
456 + 'join_expression' => 'USING (topic_id) WHERE posts.post_position NOT IN (0,1)',
310 457 'to_type' => 'reply',
311 458 'to_fieldname' => '_bbp_topic_id',
312 459 'callback_method' => 'callback_topicid'
313 460 );
314 461
315 - // Forum id (Stored in postmeta)
462 + // Reply parent forum id (If no parent, then 0. Stored in postmeta)
316 463 $this->field_map[] = array(
317 464 'from_tablename' => 'posts',
318 465 'from_fieldname' => 'forum_id',
319 466 'to_type' => 'reply',
@@ -320,22 +467,10 @@
320 467 'to_fieldname' => '_bbp_forum_id',
321 468 'callback_method' => 'callback_forumid'
322 469 );
323 470
324 - // Topic title (for reply title).
471 + // Reply author ip (Stored in postmeta)
325 472 $this->field_map[] = array(
326 - 'from_tablename' => 'topics',
327 - 'from_fieldname' => 'topic_title',
328 - 'join_tablename' => 'posts',
329 - 'join_type' => 'INNER',
330 - 'join_expression' => 'USING (topic_id) WHERE posts.post_position NOT IN (0,1)',
331 - 'to_type' => 'reply',
332 - 'to_fieldname' => 'post_title',
333 - 'callback_method' => 'callback_reply_title'
334 - );
335 -
336 - // Author ip.
337 - $this->field_map[] = array(
338 473 'from_tablename' => 'posts',
339 474 'from_fieldname' => 'poster_ip',
340 475 'to_type' => 'reply',
341 476 'to_fieldname' => '_bbp_author_ip'
@@ -349,9 +484,9 @@
349 484 'to_fieldname' => 'post_author',
350 485 'callback_method' => 'callback_userid'
351 486 );
352 487
353 - // Reply status
488 + // Reply status (Spam, Trash or Publish, bbPress v1.x publish = 0, trash = 1 & spam = 2)
354 489 $this->field_map[] = array(
355 490 'from_tablename' => 'posts',
356 491 'from_fieldname' => 'post_status',
357 492 'to_type' => 'reply',
@@ -375,9 +510,9 @@
375 510 'to_type' => 'reply',
376 511 'to_fieldname' => 'menu_order'
377 512 );
378 513
379 - // Topic id. If no parent, than 0.
514 + // Reply parent topic id (If no parent, then 0)
380 515 $this->field_map[] = array(
381 516 'from_tablename' => 'posts',
382 517 'from_fieldname' => 'topic_id',
383 518 'to_type' => 'reply',
@@ -412,17 +547,17 @@
412 547 );
413 548
414 549 /** User Section ******************************************************/
415 550
416 - // Store old User id. Stores in usermeta.
551 + // Store old user id (Stored in usermeta)
417 552 $this->field_map[] = array(
418 553 'from_tablename' => 'users',
419 554 'from_fieldname' => 'ID',
420 555 'to_type' => 'user',
421 - 'to_fieldname' => '_bbp_user_id'
556 + 'to_fieldname' => '_bbp_old_user_id'
422 557 );
423 558
424 - // Store old User password. Stores in usermeta.
559 + // Store old user password (Stored in usermeta)
425 560 $this->field_map[] = array(
426 561 'from_tablename' => 'users',
427 562 'from_fieldname' => 'user_pass',
428 563 'to_type' => 'user',
@@ -476,9 +611,9 @@
476 611 'to_type' => 'user',
477 612 'to_fieldname' => 'user_status'
478 613 );
479 614
480 - // User status.
615 + // User display name.
481 616 $this->field_map[] = array(
482 617 'from_tablename' => 'users',
483 618 'from_fieldname' => 'display_name',
484 619 'to_type' => 'user',
@@ -494,12 +629,12 @@
494 629 return '';
495 630 }
496 631
497 632 /**
498 - * Translate the post status from bbPress 1's numeric's to WordPress's
633 + * Translate the post status from bbPress 1's numerics to WordPress's
499 634 * strings.
500 635 *
501 - * @param int $status bbPress 1.x numeric status
636 + * @param int $status bbPress 1.x numeric post status
502 637 * @return string WordPress safe
503 638 */
504 639 public function callback_status( $status = 0 ) {
505 640 switch ( $status ) {
@@ -519,33 +654,82 @@
519 654 return $status;
520 655 }
521 656
522 657 /**
523 - * Verify the topic reply count.
658 + * Translate the forum type from bbPress 1.x numerics to WordPress's strings.
524 659 *
525 - * @param int $count bbPress 1.x reply count
660 + * @param int $status bbPress 1.x numeric forum type
526 661 * @return string WordPress safe
527 662 */
528 - public function callback_topic_reply_count( $count = 1 ) {
529 - $count = absint( (int) $count - 1 );
530 - return $count;
663 + public function callback_forum_type( $status = 0 ) {
664 + if ( 1 === (int) $status ) {
665 + $status = 'category';
666 + } else {
667 + $status = 'forum';
668 + }
669 + return $status;
531 670 }
532 671
533 672 /**
534 - * Set the reply title
673 + * Translate the topic status from bbPress 1's numerics to WordPress's
674 + * strings.
535 675 *
536 - * @param string $title bbPress 1.x topic title of this reply
537 - * @return string Prefixed topic title, or empty string
676 + * @param int $topic_status bbPress 1.x numeric status
677 + * @return string WordPress safe
538 678 */
539 - public function callback_reply_title( $title = '' ) {
540 - $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : '';
541 - return $title;
679 + public function callback_topic_status( $topic_status = 1 ) {
680 + switch ( $topic_status ) {
681 + case 0 :
682 + $topic_status = 'closed'; // bbp_get_closed_status_id()
683 + break;
684 +
685 + case 1 :
686 + default :
687 + $topic_status = 'publish'; // bbp_get_public_status_id()
688 + break;
689 + }
690 + return $topic_status;
542 691 }
543 692
544 693 /**
694 + * Translate the topic sticky status type from bbPress 1.x numerics to WordPress's strings.
695 + *
696 + * @param int $status bbPress 1.x numeric forum type
697 + * @return string WordPress safe
698 + */
699 + public function callback_sticky_status( $status = 0 ) {
700 + switch ( $status ) {
701 + case 2 :
702 + $status = 'super-sticky'; // bbPress Super Sticky 'topic_sticky = 2'
703 + break;
704 +
705 + case 1 :
706 + $status = 'sticky'; // bbPress Sticky 'topic_sticky = 1'
707 + break;
708 +
709 + case 0 :
710 + default :
711 + $status = 'normal'; // bbPress Normal Topic 'topic_sticky = 0'
712 + break;
713 + }
714 + return $status;
715 + }
716 +
717 + /**
718 + * Verify the topic reply count.
719 + *
720 + * @param int $count bbPress 1.x topic and reply counts
721 + * @return string WordPress safe
722 + */
723 + public function callback_topic_reply_count( $count = 1 ) {
724 + $count = absint( (int) $count - 1 );
725 + return $count;
726 + }
727 +
728 + /**
545 729 * This method is to save the salt and password together. That
546 730 * way when we authenticate it we can get it out of the database
547 - * as one value. Array values are auto sanitized by wordpress.
731 + * as one value. Array values are auto sanitized by WordPress.
548 732 */
549 733 public function callback_savepass( $field, $row ) {
550 734 return false;
551 735 }
@@ -555,6 +739,21 @@
555 739 * to a pass the user has typed in.
556 740 */
557 741 public function authenticate_pass( $password, $serialized_pass ) {
558 742 return false;
743 + }
744 +
745 + /**
746 + * This callback strips `topic-` from topic subscriptions taxonomy
747 + *
748 + * @since 2.6.0 bbPress (r5572)
749 + *
750 + * @param string $field Topic ID
751 + * @return integer WordPress safe
752 + */
753 + protected function callback_topic_subscriptions( $field ) {
754 +
755 + // Replace 'topic-' with '' so that only the original topic ID remains
756 + $field = absint( (int) preg_replace( '/(topic-)(\d+)/', '$2', $field ) );
757 + return $field;
559 758 }
560 759 }