[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/admin/converters/ -> bbPress1.php (source)

   1  <?php
   2  
   3  /**
   4   * bbPress 1.x Converter
   5   *
   6   * @package bbPress
   7   * @subpackage Converters
   8   */
   9  
  10  /**
  11   * bbPress 1.1 Converter
  12   *
  13   * @since 2.1.0 bbPress (r3816)
  14   *
  15   * @link Codex Docs https://codex.bbpress.org/import-forums/bbpress-1-x-buddypress-group-forums
  16   */
  17  class bbPress1 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' => 'forums',
  43              'from_fieldname' => 'forum_id',
  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' => 'forums',
  51              'from_fieldname' => 'forum_parent',
  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' => 'forums',
  59              'from_fieldname' => 'topics',
  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' => 'forums',
  67              'from_fieldname' => 'posts',
  68              'to_type'        => 'forum',
  69              'to_fieldname'   => '_bbp_reply_count'
  70          );
  71  
  72          // Forum total topic count (Stored in postmeta)
  73          $this->field_map[] = array(
  74              'from_tablename' => 'forums',
  75              'from_fieldname' => 'topics',
  76              'to_type'        => 'forum',
  77              'to_fieldname'   => '_bbp_total_topic_count'
  78          );
  79  
  80          // Forum total reply count (Stored in postmeta)
  81          $this->field_map[] = array(
  82              'from_tablename' => 'forums',
  83              'from_fieldname' => 'posts',
  84              'to_type'        => 'forum',
  85              'to_fieldname'   => '_bbp_total_reply_count'
  86          );
  87  
  88          // Forum title.
  89          $this->field_map[] = array(
  90              'from_tablename' => 'forums',
  91              'from_fieldname' => 'forum_name',
  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'   => 'forums',
  99              'from_fieldname'   => 'forum_slug',
 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'   => 'forums',
 108              'from_fieldname'   => 'forum_desc',
 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' => 'forums',
 117              'from_fieldname' => 'forum_order',
 118              'to_type'        => 'forum',
 119              'to_fieldname'   => 'menu_order'
 120          );
 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  
 141          // Forum dates.
 142          $this->field_map[] = array(
 143              'to_type'      => 'forum',
 144              'to_fieldname' => 'post_date',
 145              'default'      => date('Y-m-d H:i:s')
 146          );
 147          $this->field_map[] = array(
 148              'to_type'      => 'forum',
 149              'to_fieldname' => 'post_date_gmt',
 150              'default'      => date('Y-m-d H:i:s')
 151          );
 152          $this->field_map[] = array(
 153              'to_type'      => 'forum',
 154              'to_fieldname' => 'post_modified',
 155              'default'      => date('Y-m-d H:i:s')
 156          );
 157          $this->field_map[] = array(
 158              'to_type'      => 'forum',
 159              'to_fieldname' => 'post_modified_gmt',
 160              'default'      => date('Y-m-d H:i:s')
 161          );
 162  
 163          /** Forum Subscriptions Section ***************************************/
 164  
 165          /**
 166           * bbPress 1.x Forums do not support forum subscriptions
 167           */
 168  
 169          /** Topic Section *****************************************************/
 170  
 171          // Old topic id (Stored in postmeta)
 172          $this->field_map[] = array(
 173              'from_tablename' => 'topics',
 174              'from_fieldname' => 'topic_id',
 175              'to_type'        => 'topic',
 176              'to_fieldname'   => '_bbp_old_topic_id'
 177          );
 178  
 179          // Topic reply count (Stored in postmeta)
 180          $this->field_map[] = array(
 181              'from_tablename'  => 'topics',
 182              'from_fieldname'  => 'topic_posts',
 183              'to_type'         => 'topic',
 184              'to_fieldname'    => '_bbp_reply_count',
 185              'callback_method' => 'callback_topic_reply_count'
 186          );
 187  
 188          // Topic total reply count (Includes unpublished replies, Stored in postmeta)
 189          $this->field_map[] = array(
 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',
 200              'from_fieldname'  => 'forum_id',
 201              'to_type'         => 'topic',
 202              'to_fieldname'    => '_bbp_forum_id',
 203              'callback_method' => 'callback_forumid'
 204          );
 205  
 206          // Topic author.
 207          $this->field_map[] = array(
 208              'from_tablename'  => 'topics',
 209              'from_fieldname'  => 'topic_poster',
 210              'to_type'         => 'topic',
 211              'to_fieldname'    => 'post_author',
 212              'callback_method' => 'callback_userid'
 213          );
 214  
 215          // Topic title.
 216          $this->field_map[] = array(
 217              'from_tablename' => 'topics',
 218              'from_fieldname' => 'topic_title',
 219              'to_type'        => 'topic',
 220              'to_fieldname'   => 'post_title'
 221          );
 222  
 223          // Topic slug (Clean name to avoid conflicts)
 224          $this->field_map[] = array(
 225              'from_tablename'  => 'topics',
 226              'from_fieldname'  => 'topic_slug',
 227              'to_type'         => 'topic',
 228              'to_fieldname'    => 'post_name',
 229              'callback_method' => 'callback_slug'
 230          );
 231  
 232          // Topic content.
 233          // Note: We join the 'posts' table because 'topics' table does not include content.
 234          $this->field_map[] = array(
 235              'from_tablename'  => 'posts',
 236              'from_fieldname'  => 'post_text',
 237              'join_tablename'  => 'topics',
 238              'join_type'       => 'INNER',
 239              'join_expression' => 'USING (topic_id) WHERE posts.post_position IN (0,1)',
 240              'to_type'         => 'topic',
 241              'to_fieldname'    => 'post_content',
 242              'callback_method' => 'callback_html'
 243          );
 244  
 245          // Topic status (Spam, Trash or Publish, bbPress v1.x publish = 0, trash = 1 & spam = 2)
 246          $this->field_map[] = array(
 247              'from_tablename'  => 'posts',
 248              'from_fieldname'  => 'post_status',
 249              'join_tablename'  => 'topics',
 250              'join_type'       => 'INNER',
 251              'join_expression' => 'USING (topic_id) WHERE posts.post_position IN (0,1)',
 252              'to_type'         => 'topic',
 253              'to_fieldname'    => 'post_status',
 254              'callback_method' => 'callback_status'
 255          );
 256  
 257          // Topic status (Publish or Closed to new replies)
 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(
 269              'from_tablename'  => 'posts',
 270              'from_fieldname'  => 'poster_ip',
 271              'join_tablename'  => 'topics',
 272              'join_type'       => 'INNER',
 273              'join_expression' => 'USING (topic_id) WHERE posts.post_position IN (0,1)',
 274              'to_type'         => 'topic',
 275              'to_fieldname'    => '_bbp_author_ip'
 276          );
 277  
 278          // Topic parent forum id (If no parent, then 0)
 279          $this->field_map[] = array(
 280              'from_tablename'  => 'topics',
 281              'from_fieldname'  => 'forum_id',
 282              'to_type'         => 'topic',
 283              'to_fieldname'    => 'post_parent',
 284              'callback_method' => 'callback_forumid'
 285          );
 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  
 296          // Topic dates.
 297          $this->field_map[] = array(
 298              'from_tablename' => 'topics',
 299              'from_fieldname' => 'topic_start_time',
 300              'to_type'        => 'topic',
 301              'to_fieldname'   => 'post_date'
 302          );
 303          $this->field_map[] = array(
 304              'from_tablename' => 'topics',
 305              'from_fieldname' => 'topic_start_time',
 306              'to_type'        => 'topic',
 307              'to_fieldname'   => 'post_date_gmt'
 308          );
 309          $this->field_map[] = array(
 310              'from_tablename' => 'topics',
 311              'from_fieldname' => 'topic_time',
 312              'to_type'        => 'topic',
 313              'to_fieldname'   => 'post_modified'
 314          );
 315          $this->field_map[] = array(
 316              'from_tablename' => 'topics',
 317              'from_fieldname' => 'topic_time',
 318              'to_type'        => 'topic',
 319              'to_fieldname'   => 'post_modified_gmt'
 320          );
 321          $this->field_map[] = array(
 322              'from_tablename' => 'topics',
 323              'from_fieldname' => 'topic_time',
 324              'to_type'        => 'topic',
 325              'to_fieldname'   => '_bbp_last_active_time'
 326          );
 327  
 328          /** Tags Section ******************************************************/
 329  
 330          // Topic id.
 331          $this->field_map[] = array(
 332              'from_tablename'  => 'term_relationships',
 333              'from_fieldname'  => 'object_id',
 334              'to_type'         => 'tags',
 335              'to_fieldname'    => 'objectid',
 336              'callback_method' => 'callback_topicid'
 337          );
 338  
 339          // Taxonomy ID.
 340          $this->field_map[] = array(
 341              'from_tablename'  => 'term_taxonomy',
 342              'from_fieldname'  => 'term_taxonomy_id',
 343              'join_tablename'  => 'term_relationships',
 344              'join_type'       => 'INNER',
 345              'join_expression' => 'USING (term_taxonomy_id)',
 346              'to_type'         => 'tags',
 347              'to_fieldname'    => 'taxonomy'
 348          );
 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  
 362          // Term text.
 363          $this->field_map[] = array(
 364              'from_tablename'  => 'terms',
 365              'from_fieldname'  => 'name',
 366              'join_tablename'  => 'term_taxonomy',
 367              'join_type'       => 'INNER',
 368              'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_topic_tag"',
 369              'to_type'         => 'tags',
 370              'to_fieldname'    => 'name'
 371          );
 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  
 439          /** Reply Section *****************************************************/
 440  
 441          // Old reply id (Stored in postmeta)
 442          $this->field_map[] = array(
 443              'from_tablename'  => 'posts',
 444              'from_fieldname'  => 'post_id',
 445              'to_type'         => 'reply',
 446              'to_fieldname'    => '_bbp_old_reply_id'
 447          );
 448  
 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
 451          $this->field_map[] = array(
 452              'from_tablename'  => 'topics',
 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)',
 457              'to_type'         => 'reply',
 458              'to_fieldname'    => '_bbp_topic_id',
 459              'callback_method' => 'callback_topicid'
 460          );
 461  
 462          // Reply parent forum id (If no parent, then 0. Stored in postmeta)
 463          $this->field_map[] = array(
 464              'from_tablename'  => 'posts',
 465              'from_fieldname'  => 'forum_id',
 466              'to_type'         => 'reply',
 467              'to_fieldname'    => '_bbp_forum_id',
 468              'callback_method' => 'callback_forumid'
 469          );
 470  
 471          // Reply author ip (Stored in postmeta)
 472          $this->field_map[] = array(
 473              'from_tablename' => 'posts',
 474              'from_fieldname' => 'poster_ip',
 475              'to_type'        => 'reply',
 476              'to_fieldname'   => '_bbp_author_ip'
 477          );
 478  
 479          // Reply author.
 480          $this->field_map[] = array(
 481              'from_tablename'  => 'posts',
 482              'from_fieldname'  => 'poster_id',
 483              'to_type'         => 'reply',
 484              'to_fieldname'    => 'post_author',
 485              'callback_method' => 'callback_userid'
 486          );
 487  
 488          // Reply status (Spam, Trash or Publish, bbPress v1.x publish = 0, trash = 1 & spam = 2)
 489          $this->field_map[] = array(
 490              'from_tablename'  => 'posts',
 491              'from_fieldname'  => 'post_status',
 492              'to_type'         => 'reply',
 493              'to_fieldname'    => 'post_status',
 494              'callback_method' => 'callback_status'
 495          );
 496  
 497          // Reply content.
 498          $this->field_map[] = array(
 499              'from_tablename'  => 'posts',
 500              'from_fieldname'  => 'post_text',
 501              'to_type'         => 'reply',
 502              'to_fieldname'    => 'post_content',
 503              'callback_method' => 'callback_html'
 504          );
 505  
 506          // Reply order.
 507          $this->field_map[] = array(
 508              'from_tablename'  => 'posts',
 509              'from_fieldname'  => 'post_position',
 510              'to_type'         => 'reply',
 511              'to_fieldname'    => 'menu_order'
 512          );
 513  
 514          // Reply parent topic id (If no parent, then 0)
 515          $this->field_map[] = array(
 516              'from_tablename'  => 'posts',
 517              'from_fieldname'  => 'topic_id',
 518              'to_type'         => 'reply',
 519              'to_fieldname'    => 'post_parent',
 520              'callback_method' => 'callback_topicid'
 521          );
 522  
 523          // Reply dates.
 524          $this->field_map[] = array(
 525              'from_tablename' => 'posts',
 526              'from_fieldname' => 'post_time',
 527              'to_type'        => 'reply',
 528              'to_fieldname'   => 'post_date'
 529          );
 530          $this->field_map[] = array(
 531              'from_tablename' => 'posts',
 532              'from_fieldname' => 'post_time',
 533              'to_type'        => 'reply',
 534              'to_fieldname'   => 'post_date_gmt'
 535          );
 536          $this->field_map[] = array(
 537              'from_tablename' => 'posts',
 538              'from_fieldname' => 'post_time',
 539              'to_type'        => 'reply',
 540              'to_fieldname'   => 'post_modified'
 541          );
 542          $this->field_map[] = array(
 543              'from_tablename' => 'posts',
 544              'from_fieldname' => 'post_time',
 545              'to_type'        => 'reply',
 546              'to_fieldname'   => 'post_modified_gmt'
 547          );
 548  
 549          /** User Section ******************************************************/
 550  
 551          // Store old user id (Stored in usermeta)
 552          $this->field_map[] = array(
 553              'from_tablename' => 'users',
 554              'from_fieldname' => 'ID',
 555              'to_type'        => 'user',
 556              'to_fieldname'   => '_bbp_old_user_id'
 557          );
 558  
 559          // Store old user password (Stored in usermeta)
 560          $this->field_map[] = array(
 561              'from_tablename' => 'users',
 562              'from_fieldname' => 'user_pass',
 563              'to_type'        => 'user',
 564              'to_fieldname'   => '_bbp_password'
 565          );
 566  
 567          // User name.
 568          $this->field_map[] = array(
 569              'from_tablename' => 'users',
 570              'from_fieldname' => 'user_login',
 571              'to_type'        => 'user',
 572              'to_fieldname'   => 'user_login'
 573          );
 574  
 575          // User nice name.
 576          $this->field_map[] = array(
 577              'from_tablename' => 'users',
 578              'from_fieldname' => 'user_nicename',
 579              'to_type'        => 'user',
 580              'to_fieldname'   => 'user_nicename'
 581          );
 582  
 583          // User email.
 584          $this->field_map[] = array(
 585              'from_tablename' => 'users',
 586              'from_fieldname' => 'user_email',
 587              'to_type'        => 'user',
 588              'to_fieldname'   => 'user_email'
 589          );
 590  
 591          // User homepage.
 592          $this->field_map[] = array(
 593              'from_tablename' => 'users',
 594              'from_fieldname' => 'user_url',
 595              'to_type'        => 'user',
 596              'to_fieldname'   => 'user_url'
 597          );
 598  
 599          // User registered.
 600          $this->field_map[] = array(
 601              'from_tablename' => 'users',
 602              'from_fieldname' => 'user_registered',
 603              'to_type'        => 'user',
 604              'to_fieldname'   => 'user_registered'
 605          );
 606  
 607          // User status.
 608          $this->field_map[] = array(
 609              'from_tablename' => 'users',
 610              'from_fieldname' => 'user_status',
 611              'to_type'        => 'user',
 612              'to_fieldname'   => 'user_status'
 613          );
 614  
 615          // User display name.
 616          $this->field_map[] = array(
 617              'from_tablename' => 'users',
 618              'from_fieldname' => 'display_name',
 619              'to_type'        => 'user',
 620              'to_fieldname'   => 'display_name'
 621          );
 622      }
 623  
 624      /**
 625       * This method allows us to indicates what is or is not converted for each
 626       * converter.
 627       */
 628  	public function info() {
 629          return '';
 630      }
 631  
 632      /**
 633       * Translate the post status from bbPress 1's numerics to WordPress's
 634       * strings.
 635       *
 636       * @param int $status bbPress 1.x numeric post status
 637       * @return string WordPress safe
 638       */
 639  	public function callback_status( $status = 0 ) {
 640          switch ( $status ) {
 641              case 2 :
 642                  $status = 'spam';    // bbp_get_spam_status_id()
 643                  break;
 644  
 645              case 1 :
 646                  $status = 'trash';   // bbp_get_trash_status_id()
 647                  break;
 648  
 649              case 0  :
 650              default :
 651                  $status = 'publish'; // bbp_get_public_status_id()
 652                  break;
 653          }
 654          return $status;
 655      }
 656  
 657      /**
 658       * Translate the forum type from bbPress 1.x numerics to WordPress's strings.
 659       *
 660       * @param int $status bbPress 1.x numeric forum type
 661       * @return string WordPress safe
 662       */
 663  	public function callback_forum_type( $status = 0 ) {
 664          if ( $status == 1 ) {
 665              $status = 'category';
 666          } else {
 667              $status = 'forum';
 668          }
 669          return $status;
 670      }
 671  
 672      /**
 673       * Translate the topic status from bbPress 1's numerics to WordPress's
 674       * strings.
 675       *
 676       * @param int $topic_status bbPress 1.x numeric status
 677       * @return string WordPress safe
 678       */
 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;
 691      }
 692  
 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      /**
 729       * This method is to save the salt and password together. That
 730       * way when we authenticate it we can get it out of the database
 731       * as one value. Array values are auto sanitized by WordPress.
 732       */
 733  	public function callback_savepass( $field, $row ) {
 734          return false;
 735      }
 736  
 737      /**
 738       * This method is to take the pass out of the database and compare
 739       * to a pass the user has typed in.
 740       */
 741  	public function authenticate_pass( $password, $serialized_pass ) {
 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;
 758      }
 759  }


Generated: Sun Sep 22 01:01:33 2019 Cross-referenced by PHPXref 0.7.1