PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
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 2.2.1 All 72 releases
bbpress / includes / admin / converters / vBulletin.php

vBulletin.php in bbPress 2.6.17, at includes/admin/converters/vBulletin.php

779 lines 22.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress vBulletin 4.x Converter
5 *
6 * @package bbPress
7 * @subpackage Converters
8 */
9
10 /**
11 * Implementation of vBulletin v4.x Converter.
12 *
13 * @since 2.3.0 bbPress (r4724)
14 *
15 * @link Codex Docs https://codex.bbpress.org/import-forums/vbulletin
16 */
17 class vBulletin extends BBP_Converter_Base {
18
19 /**
20 * Main constructor
21 *
22 */
23 public function __construct() {
24 parent::__construct();
25 }
26
27 /**
28 * Sets up the field mappings
29 */
30 public function setup_globals() {
31
32 // Setup smiley URL & path
33 $this->bbcode_parser_properties = array(
34 'smiley_url' => false,
35 'smiley_dir' => false
36 );
37
38 /** Forum Section *****************************************************/
39
40 // Old forum id (Stored in postmeta)
41 $this->field_map[] = array(
42 'from_tablename' => 'forum',
43 'from_fieldname' => 'forumid',
44 'to_type' => 'forum',
45 'to_fieldname' => '_bbp_old_forum_id'
46 );
47
48 // Forum parent id (If no parent, then 0. Stored in postmeta)
49 $this->field_map[] = array(
50 'from_tablename' => 'forum',
51 'from_fieldname' => 'parentid',
52 'to_type' => 'forum',
53 'to_fieldname' => '_bbp_old_forum_parent_id'
54 );
55
56 // Forum topic count (Stored in postmeta)
57 $this->field_map[] = array(
58 'from_tablename' => 'forum',
59 'from_fieldname' => 'threadcount',
60 'to_type' => 'forum',
61 'to_fieldname' => '_bbp_topic_count'
62 );
63
64 // Forum reply count (Stored in postmeta)
65 $this->field_map[] = array(
66 'from_tablename' => 'forum',
67 'from_fieldname' => 'replycount',
68 'to_type' => 'forum',
69 'to_fieldname' => '_bbp_reply_count'
70 );
71
72 // Forum total topic count (Includes unpublished topics, Stored in postmeta)
73 $this->field_map[] = array(
74 'from_tablename' => 'forum',
75 'from_fieldname' => 'threadcount',
76 'to_type' => 'forum',
77 'to_fieldname' => '_bbp_total_topic_count'
78 );
79
80 // Forum total reply count (Includes unpublished replies, Stored in postmeta)
81 $this->field_map[] = array(
82 'from_tablename' => 'forum',
83 'from_fieldname' => 'replycount',
84 'to_type' => 'forum',
85 'to_fieldname' => '_bbp_total_reply_count'
86 );
87
88 // Forum title.
89 $this->field_map[] = array(
90 'from_tablename' => 'forum',
91 'from_fieldname' => 'title',
92 'to_type' => 'forum',
93 'to_fieldname' => 'post_title'
94 );
95
96 // Forum slug (Clean name to avoid confilcts)
97 $this->field_map[] = array(
98 'from_tablename' => 'forum',
99 'from_fieldname' => 'title_clean',
100 'to_type' => 'forum',
101 'to_fieldname' => 'post_name',
102 'callback_method' => 'callback_slug'
103 );
104
105 // Forum description.
106 $this->field_map[] = array(
107 'from_tablename' => 'forum',
108 'from_fieldname' => 'description',
109 'to_type' => 'forum',
110 'to_fieldname' => 'post_content',
111 'callback_method' => 'callback_null'
112 );
113
114 // Forum display order (Starts from 1)
115 $this->field_map[] = array(
116 'from_tablename' => 'forum',
117 'from_fieldname' => 'displayorder',
118 'to_type' => 'forum',
119 'to_fieldname' => 'menu_order'
120 );
121
122 // Forum type (Category = -1 or Forum > 0, Stored in postmeta)
123 $this->field_map[] = array(
124 'from_tablename' => 'forum',
125 'from_fieldname' => 'parentid',
126 'to_type' => 'forum',
127 'to_fieldname' => '_bbp_forum_type',
128 'callback_method' => 'callback_forum_type'
129 );
130
131 // Forum status (Set a default value 'open', Stored in postmeta)
132 $this->field_map[] = array(
133 'to_type' => 'forum',
134 'to_fieldname' => '_bbp_status',
135 'default' => 'open'
136 );
137
138 // Forum dates.
139 $this->field_map[] = array(
140 'to_type' => 'forum',
141 'to_fieldname' => 'post_date',
142 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
143 );
144 $this->field_map[] = array(
145 'to_type' => 'forum',
146 'to_fieldname' => 'post_date_gmt',
147 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
148 );
149 $this->field_map[] = array(
150 'to_type' => 'forum',
151 'to_fieldname' => 'post_modified',
152 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
153 );
154 $this->field_map[] = array(
155 'to_type' => 'forum',
156 'to_fieldname' => 'post_modified_gmt',
157 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
158 );
159
160 /** Forum Subscriptions Section ***************************************/
161
162 // Subscribed forum ID (Stored in usermeta)
163 $this->field_map[] = array(
164 'from_tablename' => 'subscribeforum',
165 'from_fieldname' => 'forumid',
166 'to_type' => 'forum_subscriptions',
167 'to_fieldname' => '_bbp_forum_subscriptions'
168 );
169
170 // Subscribed user ID (Stored in usermeta)
171 $this->field_map[] = array(
172 'from_tablename' => 'subscribeforum',
173 'from_fieldname' => 'userid',
174 'to_type' => 'forum_subscriptions',
175 'to_fieldname' => 'user_id',
176 'callback_method' => 'callback_userid'
177 );
178
179 /** Topic Section *****************************************************/
180
181 // Old topic id (Stored in postmeta)
182 $this->field_map[] = array(
183 'from_tablename' => 'thread',
184 'from_fieldname' => 'threadid',
185 'to_type' => 'topic',
186 'to_fieldname' => '_bbp_old_topic_id'
187 );
188
189 // Topic parent forum id (If no parent, then 0. Stored in postmeta)
190 $this->field_map[] = array(
191 'from_tablename' => 'thread',
192 'from_fieldname' => 'forumid',
193 'to_type' => 'topic',
194 'to_fieldname' => '_bbp_forum_id',
195 'callback_method' => 'callback_forumid'
196 );
197
198 // Topic reply count (Stored in postmeta)
199 $this->field_map[] = array(
200 'from_tablename' => 'thread',
201 'from_fieldname' => 'replycount',
202 'to_type' => 'topic',
203 'to_fieldname' => '_bbp_reply_count',
204 'callback_method' => 'callback_topic_reply_count'
205 );
206
207 // Topic total reply count (Includes unpublished replies, Stored in postmeta)
208 $this->field_map[] = array(
209 'from_tablename' => 'thread',
210 'from_fieldname' => 'replycount',
211 'to_type' => 'topic',
212 'to_fieldname' => '_bbp_total_reply_count',
213 'callback_method' => 'callback_topic_reply_count'
214 );
215
216 // Topic author.
217 $this->field_map[] = array(
218 'from_tablename' => 'thread',
219 'from_fieldname' => 'postuserid',
220 'to_type' => 'topic',
221 'to_fieldname' => 'post_author',
222 'callback_method' => 'callback_userid'
223 );
224
225 // Topic author name (Stored in postmeta as _bbp_anonymous_name)
226 $this->field_map[] = array(
227 'from_tablename' => 'thread',
228 'from_fieldname' => 'postusername',
229 'to_type' => 'topic',
230 'to_fieldname' => '_bbp_old_topic_author_name_id'
231 );
232
233 // Is the topic anonymous (Stored in postmeta)
234 $this->field_map[] = array(
235 'from_tablename' => 'thread',
236 'from_fieldname' => 'postuserid',
237 'to_type' => 'topic',
238 'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
239 'callback_method' => 'callback_check_anonymous'
240 );
241
242 // Topic Author ip (Stored in postmeta)
243 // Note: We join the 'post' table because 'thread' table does not include topic content.
244 $this->field_map[] = array(
245 'from_tablename' => 'post',
246 'from_fieldname' => 'ipaddress',
247 'join_tablename' => 'thread',
248 'join_type' => 'INNER',
249 'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
250 'to_type' => 'topic',
251 'to_fieldname' => '_bbp_author_ip'
252 );
253
254 // Topic title.
255 $this->field_map[] = array(
256 'from_tablename' => 'thread',
257 'from_fieldname' => 'title',
258 'to_type' => 'topic',
259 'to_fieldname' => 'post_title'
260 );
261
262 // Topic slug (Clean name to avoid conflicts)
263 $this->field_map[] = array(
264 'from_tablename' => 'thread',
265 'from_fieldname' => 'title',
266 'to_type' => 'topic',
267 'to_fieldname' => 'post_name',
268 'callback_method' => 'callback_slug'
269 );
270
271 // Topic parent forum id (If no parent, then 0)
272 $this->field_map[] = array(
273 'from_tablename' => 'thread',
274 'from_fieldname' => 'forumid',
275 'to_type' => 'topic',
276 'to_fieldname' => 'post_parent',
277 'callback_method' => 'callback_forumid'
278 );
279
280 // Topic content.
281 // Note: We join the 'post' table because 'thread' table does not include topic content.
282 $this->field_map[] = array(
283 'from_tablename' => 'post',
284 'from_fieldname' => 'pagetext',
285 'join_tablename' => 'thread',
286 'join_type' => 'INNER',
287 'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
288 'to_type' => 'topic',
289 'to_fieldname' => 'post_content',
290 'callback_method' => 'callback_html'
291 );
292
293 // Topic status (Open or Closed)
294 $this->field_map[] = array(
295 'from_tablename' => 'thread',
296 'from_fieldname' => 'open',
297 'to_type' => 'topic',
298 'to_fieldname' => '_bbp_old_closed_status_id',
299 'callback_method' => 'callback_topic_status'
300 );
301
302 // Sticky status (Stored in postmeta)
303 $this->field_map[] = array(
304 'from_tablename' => 'thread',
305 'from_fieldname' => 'sticky',
306 'to_type' => 'topic',
307 'to_fieldname' => '_bbp_old_sticky_status_id',
308 'callback_method' => 'callback_sticky_status'
309 );
310
311 // Topic dates.
312 $this->field_map[] = array(
313 'from_tablename' => 'thread',
314 'from_fieldname' => 'dateline',
315 'to_type' => 'topic',
316 'to_fieldname' => 'post_date',
317 'callback_method' => 'callback_datetime'
318 );
319 $this->field_map[] = array(
320 'from_tablename' => 'thread',
321 'from_fieldname' => 'dateline',
322 'to_type' => 'topic',
323 'to_fieldname' => 'post_date_gmt',
324 'callback_method' => 'callback_datetime'
325 );
326 $this->field_map[] = array(
327 'from_tablename' => 'thread',
328 'from_fieldname' => 'dateline',
329 'to_type' => 'topic',
330 'to_fieldname' => 'post_modified',
331 'callback_method' => 'callback_datetime'
332 );
333 $this->field_map[] = array(
334 'from_tablename' => 'thread',
335 'from_fieldname' => 'dateline',
336 'to_type' => 'topic',
337 'to_fieldname' => 'post_modified_gmt',
338 'callback_method' => 'callback_datetime'
339 );
340 $this->field_map[] = array(
341 'from_tablename' => 'thread',
342 'from_fieldname' => 'lastpost',
343 'to_type' => 'topic',
344 'to_fieldname' => '_bbp_last_active_time',
345 'callback_method' => 'callback_datetime'
346 );
347
348 /** Tags Section ******************************************************/
349
350 // Topic id.
351 $this->field_map[] = array(
352 'from_tablename' => 'tagcontent',
353 'from_fieldname' => 'contentid',
354 'to_type' => 'tags',
355 'to_fieldname' => 'objectid',
356 'callback_method' => 'callback_topicid'
357 );
358
359 // Taxonomy ID.
360 $this->field_map[] = array(
361 'from_tablename' => 'tagcontent',
362 'from_fieldname' => 'tagid',
363 'to_type' => 'tags',
364 'to_fieldname' => 'taxonomy'
365 );
366
367 // Term text.
368 $this->field_map[] = array(
369 'from_tablename' => 'tag',
370 'from_fieldname' => 'tagtext',
371 'join_tablename' => 'tagcontent',
372 'join_type' => 'INNER',
373 'join_expression' => 'USING (tagid)',
374 'to_type' => 'tags',
375 'to_fieldname' => 'name'
376 );
377
378 // Term slug.
379 $this->field_map[] = array(
380 'from_tablename' => 'tag',
381 'from_fieldname' => 'tagtext',
382 'join_tablename' => 'tagcontent',
383 'join_type' => 'INNER',
384 'join_expression' => 'USING (tagid)',
385 'to_type' => 'tags',
386 'to_fieldname' => 'slug',
387 'callback_method' => 'callback_slug'
388 );
389
390 /** Topic Subscriptions Section ***************************************/
391
392 // Subscribed topic ID (Stored in usermeta)
393 $this->field_map[] = array(
394 'from_tablename' => 'subscribethread',
395 'from_fieldname' => 'threadid',
396 'to_type' => 'topic_subscriptions',
397 'to_fieldname' => '_bbp_subscriptions'
398 );
399
400 // Subscribed user ID (Stored in usermeta)
401 $this->field_map[] = array(
402 'from_tablename' => 'subscribethread',
403 'from_fieldname' => 'userid',
404 'to_type' => 'topic_subscriptions',
405 'to_fieldname' => 'user_id',
406 'callback_method' => 'callback_userid'
407 );
408
409 /** Reply Section *****************************************************/
410
411 // Old reply id (Stored in postmeta)
412 $this->field_map[] = array(
413 'from_tablename' => 'post',
414 'from_fieldname' => 'postid',
415 'to_type' => 'reply',
416 'to_fieldname' => '_bbp_old_reply_id'
417 );
418
419 // Reply parent forum id (If no parent, then 0. Stored in postmeta)
420 $this->field_map[] = array(
421 'from_tablename' => 'post',
422 'from_fieldname' => 'threadid',
423 'from_expression' => 'WHERE parentid != 0',
424 'to_type' => 'reply',
425 'to_fieldname' => '_bbp_forum_id',
426 'callback_method' => 'callback_topicid_to_forumid'
427 );
428
429 // Reply parent topic id (If no parent, then 0, Stored in postmeta)
430 $this->field_map[] = array(
431 'from_tablename' => 'post',
432 'from_fieldname' => 'threadid',
433 'to_type' => 'reply',
434 'to_fieldname' => '_bbp_topic_id',
435 'callback_method' => 'callback_topicid'
436 );
437
438 // Reply author ip (Stored in postmeta)
439 $this->field_map[] = array(
440 'from_tablename' => 'post',
441 'from_fieldname' => 'ipaddress',
442 'to_type' => 'reply',
443 'to_fieldname' => '_bbp_author_ip'
444 );
445
446 // Reply author.
447 $this->field_map[] = array(
448 'from_tablename' => 'post',
449 'from_fieldname' => 'userid',
450 'to_type' => 'reply',
451 'to_fieldname' => 'post_author',
452 'callback_method' => 'callback_userid'
453 );
454
455 // Reply author name (Stored in postmeta as _bbp_anonymous_name)
456 $this->field_map[] = array(
457 'from_tablename' => 'post',
458 'from_fieldname' => 'username',
459 'to_type' => 'reply',
460 'to_fieldname' => '_bbp_old_reply_author_name_id'
461 );
462
463 // Is the reply anonymous (Stored in postmeta)
464 $this->field_map[] = array(
465 'from_tablename' => 'post',
466 'from_fieldname' => 'userid',
467 'to_type' => 'reply',
468 'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
469 'callback_method' => 'callback_check_anonymous'
470 );
471
472 // Reply content.
473 $this->field_map[] = array(
474 'from_tablename' => 'post',
475 'from_fieldname' => 'pagetext',
476 'to_type' => 'reply',
477 'to_fieldname' => 'post_content',
478 'callback_method' => 'callback_html'
479 );
480
481 // Reply parent topic id (If no parent, then 0)
482 $this->field_map[] = array(
483 'from_tablename' => 'post',
484 'from_fieldname' => 'threadid',
485 'to_type' => 'reply',
486 'to_fieldname' => 'post_parent',
487 'callback_method' => 'callback_topicid'
488 );
489
490 // Reply dates.
491 $this->field_map[] = array(
492 'from_tablename' => 'post',
493 'from_fieldname' => 'dateline',
494 'to_type' => 'reply',
495 'to_fieldname' => 'post_date',
496 'callback_method' => 'callback_datetime'
497 );
498 $this->field_map[] = array(
499 'from_tablename' => 'post',
500 'from_fieldname' => 'dateline',
501 'to_type' => 'reply',
502 'to_fieldname' => 'post_date_gmt',
503 'callback_method' => 'callback_datetime'
504 );
505 $this->field_map[] = array(
506 'from_tablename' => 'post',
507 'from_fieldname' => 'dateline',
508 'to_type' => 'reply',
509 'to_fieldname' => 'post_modified',
510 'callback_method' => 'callback_datetime'
511 );
512 $this->field_map[] = array(
513 'from_tablename' => 'post',
514 'from_fieldname' => 'dateline',
515 'to_type' => 'reply',
516 'to_fieldname' => 'post_modified_gmt',
517 'callback_method' => 'callback_datetime'
518 );
519
520 /** User Section ******************************************************/
521
522 // Store old user id (Stored in usermeta)
523 $this->field_map[] = array(
524 'from_tablename' => 'user',
525 'from_fieldname' => 'userid',
526 'to_type' => 'user',
527 'to_fieldname' => '_bbp_old_user_id'
528 );
529
530 // Store old user password (Stored in usermeta serialized with salt)
531 $this->field_map[] = array(
532 'from_tablename' => 'user',
533 'from_fieldname' => 'password',
534 'to_type' => 'user',
535 'to_fieldname' => '_bbp_password',
536 'callback_method' => 'callback_savepass'
537 );
538
539 // Store old user salt (This is only used for the SELECT row info for the above password save)
540 $this->field_map[] = array(
541 'from_tablename' => 'user',
542 'from_fieldname' => 'salt',
543 'to_type' => 'user',
544 'to_fieldname' => '_bbp_salt'
545 );
546
547 // User password verify class (Stored in usermeta for verifying password)
548 $this->field_map[] = array(
549 'to_type' => 'user',
550 'to_fieldname' => '_bbp_class',
551 'default' => 'vBulletin'
552 );
553
554 // User name.
555 $this->field_map[] = array(
556 'from_tablename' => 'user',
557 'from_fieldname' => 'username',
558 'to_type' => 'user',
559 'to_fieldname' => 'user_login'
560 );
561
562 // User email.
563 $this->field_map[] = array(
564 'from_tablename' => 'user',
565 'from_fieldname' => 'email',
566 'to_type' => 'user',
567 'to_fieldname' => 'user_email'
568 );
569
570 // User homepage.
571 $this->field_map[] = array(
572 'from_tablename' => 'user',
573 'from_fieldname' => 'homepage',
574 'to_type' => 'user',
575 'to_fieldname' => 'user_url'
576 );
577
578 // User registered.
579 $this->field_map[] = array(
580 'from_tablename' => 'user',
581 'from_fieldname' => 'joindate',
582 'to_type' => 'user',
583 'to_fieldname' => 'user_registered',
584 'callback_method' => 'callback_datetime'
585 );
586
587 // User AIM (Stored in usermeta)
588 $this->field_map[] = array(
589 'from_tablename' => 'user',
590 'from_fieldname' => 'aim',
591 'to_type' => 'user',
592 'to_fieldname' => '_bbp_vbulletin_user_aim'
593 );
594
595 // User Yahoo (Stored in usermeta)
596 $this->field_map[] = array(
597 'from_tablename' => 'user',
598 'from_fieldname' => 'yahoo',
599 'to_type' => 'user',
600 'to_fieldname' => '_bbp_vbulletin_user_yim'
601 );
602
603 // User ICQ (Stored in usermeta)
604 $this->field_map[] = array(
605 'from_tablename' => 'user',
606 'from_fieldname' => 'icq',
607 'to_type' => 'user',
608 'to_fieldname' => '_bbp_vbulletin_user_icq'
609 );
610
611 // User MSN (Stored in usermeta)
612 $this->field_map[] = array(
613 'from_tablename' => 'user',
614 'from_fieldname' => 'msn',
615 'to_type' => 'user',
616 'to_fieldname' => '_bbp_vbulletin_user_msn'
617 );
618
619 // User Skype (Stored in usermeta)
620 $this->field_map[] = array(
621 'from_tablename' => 'user',
622 'from_fieldname' => 'skype',
623 'to_type' => 'user',
624 'to_fieldname' => '_bbp_vbulletin_user_skype'
625 );
626 }
627
628 /**
629 * This method allows us to indicates what is or is not converted for each
630 * converter.
631 */
632 public function info() {
633 return '';
634 }
635
636
637 /**
638 * This method is to save the salt and password together. That
639 * way when we authenticate it we can get it out of the database
640 * as one value. Array values are auto sanitized by WordPress.
641 */
642 public function callback_savepass( $field, $row ) {
643 $pass_array = array(
644 'hash' => $field,
645 'salt' => $row['salt']
646 );
647
648 return $pass_array;
649 }
650
651 /**
652 * This method is to take the pass out of the database and compare
653 * to a pass the user has typed in.
654 *
655 */
656 public function authenticate_pass( $password, $serialized_pass ) {
657
658 // Unserialize the password, with safeguards
659 $pass_array = unserialize(
660 $serialized_pass,
661 array(
662 'allowed_classes' => false,
663 'max_depth' => 1
664 )
665 );
666
667 // Bail if missing values
668 if ( ! is_array( $pass_array ) || ! isset( $pass_array['hash'], $pass_array['salt'] ) ) {
669 return false;
670 }
671
672 // Return comparison
673 return hash_equals(
674 $pass_array['hash'],
675 md5( md5( $password ) . $pass_array['salt'] )
676 );
677 }
678
679 /**
680 * Translate the forum type from vBulletin v4.x numerics to WordPress's strings.
681 *
682 * @param int $status vBulletin v4.x numeric forum type
683 * @return string WordPress safe
684 */
685 public function callback_forum_type( $status = 0 ) {
686 if ( -1 === (int) $status ) {
687 $status = 'category';
688 } else {
689 $status = 'forum';
690 }
691 return $status;
692 }
693
694 /**
695 * Translate the topic sticky status type from vBulletin v4.x numerics to WordPress's strings.
696 *
697 * @param int $status vBulletin v4.x numeric forum type
698 * @return string WordPress safe
699 */
700 public function callback_sticky_status( $status = 0 ) {
701 switch ( $status ) {
702 case 2 :
703 $status = 'super-sticky'; // vBulletin Super Sticky 'sticky = 2'
704 break;
705
706 case 1 :
707 $status = 'sticky'; // vBulletin Sticky 'sticky = 1'
708 break;
709
710 case 0 :
711 default :
712 $status = 'normal'; // vBulletin Normal Topic 'sticky = 0'
713 break;
714 }
715 return $status;
716 }
717
718 /**
719 * Verify the topic reply count.
720 *
721 * @param int $count vBulletin v4.x reply count
722 * @return string WordPress safe
723 */
724 public function callback_topic_reply_count( $count = 1 ) {
725 $count = absint( (int) $count - 1 );
726 return $count;
727 }
728
729 /**
730 * Translate the post status from vBulletin numerics to WordPress's strings.
731 *
732 * @param int $status vBulletin v4.x numeric topic status
733 * @return string WordPress safe
734 */
735 public function callback_topic_status( $status = 1 ) {
736 switch ( $status ) {
737 case 0 :
738 $status = 'closed';
739 break;
740
741 case 1 :
742 default :
743 $status = 'publish';
744 break;
745 }
746 return $status;
747 }
748
749 /**
750 * This callback processes any custom parser.php attributes and custom code with preg_replace
751 */
752 protected function callback_html( $field ) {
753
754 // Strips vBulletin custom HTML first from $field before parsing $field to parser.php
755 $vbulletin_markup = $field;
756 $vbulletin_markup = html_entity_decode( $vbulletin_markup );
757
758 // Replace '[QUOTE]' with '<blockquote>'
759 $vbulletin_markup = preg_replace( '/\[QUOTE\]/', '<blockquote>', $vbulletin_markup );
760 // Replace '[QUOTE=User Name($1);PostID($2)]' with '<em>@$1 $2 wrote:</em><blockquote>"
761 $vbulletin_markup = preg_replace( '/\[QUOTE=(.*?);(.*?)\]/', '<em>@$1 $2 wrote:</em><blockquote>', $vbulletin_markup );
762 // Replace '[/QUOTE]' with '</blockquote>'
763 $vbulletin_markup = preg_replace( '/\[\/QUOTE\]/', '</blockquote>', $vbulletin_markup );
764 // Replace '[MENTION=###($1)]User Name($2)[/MENTION]' with '@$2"
765 $vbulletin_markup = preg_replace( '/\[MENTION=(.*?)\](.*?)\[\/MENTION\]/', '@$2', $vbulletin_markup );
766
767 // Replace '[video=youtube;$1]$2[/video]' with '$2"
768 $vbulletin_markup = preg_replace( '/\[video\=youtube;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
769 // Replace '[video=youtube_share;$1]$2[/video]' with '$2"
770 $vbulletin_markup = preg_replace( '/\[video\=youtube_share;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
771
772 // Now that vBulletin custom HTML has been stripped put the cleaned HTML back in $field
773 $field = $vbulletin_markup;
774
775 // Parse out any bbCodes in $field with the BBCode 'parser.php'
776 return parent::callback_html( $field );
777 }
778 }
779