[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/admin/ -> settings.php (source)

   1  <?php
   2  
   3  /**
   4   * bbPress Admin Settings
   5   *
   6   * @package bbPress
   7   * @subpackage Administration
   8   */
   9  
  10  // Exit if accessed directly
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /** Sections ******************************************************************/
  14  
  15  /**
  16   * Get the Forums settings sections.
  17   *
  18   * @since 2.1.0 bbPress (r4001)
  19   *
  20   * @return array
  21   */
  22  function bbp_admin_get_settings_sections() {
  23  
  24      // Filter & return
  25      return (array) apply_filters( 'bbp_admin_get_settings_sections', array(
  26  
  27          // Settings
  28          'bbp_settings_users' => array(
  29              'title'    => esc_html__( 'Forum User Settings', 'bbpress' ),
  30              'callback' => 'bbp_admin_setting_callback_user_section',
  31              'page'     => 'discussion'
  32          ),
  33          'bbp_settings_features' => array(
  34              'title'    => esc_html__( 'Forum Features', 'bbpress' ),
  35              'callback' => 'bbp_admin_setting_callback_features_section',
  36              'page'     => 'discussion'
  37          ),
  38          'bbp_settings_theme_compat' => array(
  39              'title'    => esc_html__( 'Forum Theme Packages', 'bbpress' ),
  40              'callback' => 'bbp_admin_setting_callback_subtheme_section',
  41              'page'     => 'general'
  42          ),
  43          'bbp_settings_per_page' => array(
  44              'title'    => esc_html__( 'Topics and Replies Per Page', 'bbpress' ),
  45              'callback' => 'bbp_admin_setting_callback_per_page_section',
  46              'page'     => 'reading'
  47          ),
  48          'bbp_settings_per_rss_page' => array(
  49              'title'    => esc_html__( 'Topics and Replies Per RSS Page', 'bbpress' ),
  50              'callback' => 'bbp_admin_setting_callback_per_rss_page_section',
  51              'page'     => 'reading',
  52          ),
  53          'bbp_settings_root_slugs' => array(
  54              'title'    => esc_html__( 'Forum Root Slug', 'bbpress' ),
  55              'callback' => 'bbp_admin_setting_callback_root_slug_section',
  56              'page'     => 'permalink'
  57          ),
  58          'bbp_settings_single_slugs' => array(
  59              'title'    => esc_html__( 'Forum Single Slugs', 'bbpress' ),
  60              'callback' => 'bbp_admin_setting_callback_single_slug_section',
  61              'page'     => 'permalink',
  62          ),
  63          'bbp_settings_user_slugs' => array(
  64              'title'    => esc_html__( 'Forum User Slugs', 'bbpress' ),
  65              'callback' => 'bbp_admin_setting_callback_user_slug_section',
  66              'page'     => 'permalink',
  67          ),
  68  
  69          // Extend
  70          'bbp_settings_buddypress' => array(
  71              'title'    => esc_html__( 'Forum Integration for BuddyPress', 'bbpress' ),
  72              'callback' => 'bbp_admin_setting_callback_buddypress_section',
  73              'page'     => 'buddypress',
  74          ),
  75          'bbp_settings_akismet' => array(
  76              'title'    => esc_html__( 'Forum Integration for Akismet', 'bbpress' ),
  77              'callback' => 'bbp_admin_setting_callback_akismet_section',
  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'
  91          )
  92      ) );
  93  }
  94  
  95  /**
  96   * Get all of the settings fields.
  97   *
  98   * @since 2.1.0 bbPress (r4001)
  99   *
 100   * @return array
 101   */
 102  function bbp_admin_get_settings_fields() {
 103  
 104      // Filter & return
 105      return (array) apply_filters( 'bbp_admin_get_settings_fields', array(
 106  
 107          /** User Section ******************************************************/
 108  
 109          'bbp_settings_users' => array(
 110  
 111              // Default role setting
 112              '_bbp_default_role' => array(
 113                  'sanitize_callback' => 'sanitize_text_field',
 114                  'args'              => array()
 115              ),
 116  
 117              // Allow global access
 118              '_bbp_allow_global_access' => array(
 119                  'title'             => esc_html__( 'Roles', 'bbpress' ),
 120                  'callback'          => 'bbp_admin_setting_callback_global_access',
 121                  'sanitize_callback' => 'intval',
 122                  'args'              => array()
 123              ),
 124  
 125              // Allow content throttling
 126              '_bbp_allow_content_throttle' => array(
 127                  'sanitize_callback' => 'intval',
 128                  'args'              => array()
 129              ),
 130  
 131              // Throttle setting
 132              '_bbp_throttle_time' => array(
 133                  'title'             => esc_html__( 'Flooding', 'bbpress' ),
 134                  'callback'          => 'bbp_admin_setting_callback_throttle',
 135                  'sanitize_callback' => 'intval',
 136                  'args'              => array()
 137              ),
 138  
 139              // Allow content editing
 140              '_bbp_allow_content_edit' => array(
 141                  'sanitize_callback' => 'intval',
 142                  'args'              => array()
 143              ),
 144  
 145              // Edit lock setting
 146              '_bbp_edit_lock' => array(
 147                  'title'             => esc_html__( 'Editing', 'bbpress' ),
 148                  'callback'          => 'bbp_admin_setting_callback_editlock',
 149                  'sanitize_callback' => 'intval',
 150                  'args'              => array()
 151              ),
 152  
 153              // Allow anonymous posting setting
 154              '_bbp_allow_anonymous' => array(
 155                  'title'             => esc_html__( 'Anonymous', 'bbpress' ),
 156                  'callback'          => 'bbp_admin_setting_callback_anonymous',
 157                  'sanitize_callback' => 'intval',
 158                  'args'              => array()
 159              )
 160          ),
 161  
 162          /** Features Section **************************************************/
 163  
 164          'bbp_settings_features' => array(
 165  
 166              // Allow auto embedding setting
 167              '_bbp_use_autoembed' => array(
 168                  'title'             => esc_html__( 'Auto-embed links', 'bbpress' ),
 169                  'callback'          => 'bbp_admin_setting_callback_use_autoembed',
 170                  'sanitize_callback' => 'intval',
 171                  'args'              => array()
 172              ),
 173  
 174              // Set reply threading level
 175              '_bbp_thread_replies_depth' => array(
 176                  'title'             => esc_html__( 'Reply Threading', 'bbpress' ),
 177                  'callback'          => 'bbp_admin_setting_callback_thread_replies_depth',
 178                  'sanitize_callback' => 'intval',
 179                  'args'              => array()
 180              ),
 181  
 182              // Allow threaded replies
 183              '_bbp_allow_threaded_replies' => array(
 184                  'sanitize_callback' => 'intval',
 185                  'args'              => array()
 186              ),
 187  
 188              // Allow topic and reply revisions
 189              '_bbp_allow_revisions' => array(
 190                  'title'             => esc_html__( 'Revisions', 'bbpress' ),
 191                  'callback'          => 'bbp_admin_setting_callback_revisions',
 192                  'sanitize_callback' => 'intval',
 193                  'args'              => array()
 194              ),
 195  
 196              // Allow favorites setting
 197              '_bbp_enable_favorites' => array(
 198                  'title'             => esc_html__( 'Favorites', 'bbpress' ),
 199                  'callback'          => 'bbp_admin_setting_callback_favorites',
 200                  'sanitize_callback' => 'intval',
 201                  'args'              => array()
 202              ),
 203  
 204              // Allow subscriptions setting
 205              '_bbp_enable_subscriptions' => array(
 206                  'title'             => esc_html__( 'Subscriptions', 'bbpress' ),
 207                  'callback'          => 'bbp_admin_setting_callback_subscriptions',
 208                  'sanitize_callback' => 'intval',
 209                  'args'              => array()
 210              ),
 211  
 212              // Allow engagements setting
 213              '_bbp_enable_engagements' => array(
 214                  'title'             => esc_html__( 'Engagements', 'bbpress' ),
 215                  'callback'          => 'bbp_admin_setting_callback_engagements',
 216                  'sanitize_callback' => 'intval',
 217                  'args'              => array()
 218              ),
 219  
 220              // Allow topic tags
 221              '_bbp_allow_topic_tags' => array(
 222                  'title'             => esc_html__( 'Topic tags', 'bbpress' ),
 223                  'callback'          => 'bbp_admin_setting_callback_topic_tags',
 224                  'sanitize_callback' => 'intval',
 225                  'args'              => array()
 226              ),
 227  
 228              // Allow topic tags
 229              '_bbp_allow_search' => array(
 230                  'title'             => esc_html__( 'Search', 'bbpress' ),
 231                  'callback'          => 'bbp_admin_setting_callback_search',
 232                  'sanitize_callback' => 'intval',
 233                  'args'              => array()
 234              ),
 235  
 236              // Allow fancy editor setting
 237              '_bbp_use_wp_editor' => array(
 238                  'title'             => esc_html__( 'Post Formatting', 'bbpress' ),
 239                  'callback'          => 'bbp_admin_setting_callback_use_wp_editor',
 240                  'args'              => array(),
 241                  'sanitize_callback' => 'intval'
 242              ),
 243  
 244              // Allow per-forum moderators
 245              '_bbp_allow_forum_mods' => array(
 246                  'title'             => esc_html__( 'Forum Moderators', 'bbpress' ),
 247                  'callback'          => 'bbp_admin_setting_callback_forum_mods',
 248                  'sanitize_callback' => 'intval',
 249                  'args'              => array()
 250              ),
 251  
 252              // Allow moderators to edit users
 253              '_bbp_allow_super_mods' => array(
 254                  'title'             => esc_html__( 'Super Moderators', 'bbpress' ),
 255                  'callback'          => 'bbp_admin_setting_callback_super_mods',
 256                  'sanitize_callback' => 'intval',
 257                  'capability'        => 'edit_users',
 258                  'args'              => array()
 259              )
 260          ),
 261  
 262          /** Theme Packages ****************************************************/
 263  
 264          'bbp_settings_theme_compat' => array(
 265  
 266              // Theme package setting
 267              '_bbp_theme_package_id' => array(
 268                  'title'             => esc_html__( 'Current Package', 'bbpress' ),
 269                  'callback'          => 'bbp_admin_setting_callback_subtheme_id',
 270                  'sanitize_callback' => 'esc_sql',
 271                  'args'              => array()
 272              )
 273          ),
 274  
 275          /** Per Page Section **************************************************/
 276  
 277          'bbp_settings_per_page' => array(
 278  
 279              // Topics per page setting
 280              '_bbp_topics_per_page' => array(
 281                  'title'             => esc_html__( 'Topics', 'bbpress' ),
 282                  'callback'          => 'bbp_admin_setting_callback_topics_per_page',
 283                  'sanitize_callback' => 'intval',
 284                  'args'              => array( 'label_for' => '_bbp_topics_per_page' )
 285              ),
 286  
 287              // Replies per page setting
 288              '_bbp_replies_per_page' => array(
 289                  'title'             => esc_html__( 'Replies', 'bbpress' ),
 290                  'callback'          => 'bbp_admin_setting_callback_replies_per_page',
 291                  'sanitize_callback' => 'intval',
 292                  'args'              => array( 'label_for' => '_bbp_replies_per_page' )
 293              )
 294          ),
 295  
 296          /** Per RSS Page Section **********************************************/
 297  
 298          'bbp_settings_per_rss_page' => array(
 299  
 300              // Topics per page setting
 301              '_bbp_topics_per_rss_page' => array(
 302                  'title'             => esc_html__( 'Topics', 'bbpress' ),
 303                  'callback'          => 'bbp_admin_setting_callback_topics_per_rss_page',
 304                  'sanitize_callback' => 'intval',
 305                  'args'              => array( 'label_for' => '_bbp_topics_per_rss_page' )
 306              ),
 307  
 308              // Replies per page setting
 309              '_bbp_replies_per_rss_page' => array(
 310                  'title'             => esc_html__( 'Replies', 'bbpress' ),
 311                  'callback'          => 'bbp_admin_setting_callback_replies_per_rss_page',
 312                  'sanitize_callback' => 'intval',
 313                  'args'              => array( 'label_for' => '_bbp_replies_per_rss_page' )
 314              )
 315          ),
 316  
 317          /** Front Slugs *******************************************************/
 318  
 319          'bbp_settings_root_slugs' => array(
 320  
 321              // Root slug setting
 322              '_bbp_root_slug' => array(
 323                  'title'             => esc_html__( 'Forum Root', 'bbpress' ),
 324                  'callback'          => 'bbp_admin_setting_callback_root_slug',
 325                  'sanitize_callback' => 'bbp_sanitize_slug',
 326                  'args'              => array( 'label_for' => '_bbp_root_slug' )
 327              ),
 328  
 329              // Include root setting
 330              '_bbp_include_root' => array(
 331                  'title'             => esc_html__( 'Forum Prefix', 'bbpress' ),
 332                  'callback'          => 'bbp_admin_setting_callback_include_root',
 333                  'sanitize_callback' => 'intval',
 334                  'args'              => array()
 335              ),
 336  
 337              // What to show on Forum Root
 338              '_bbp_show_on_root' => array(
 339                  'title'             => esc_html__( 'Forum root should show', 'bbpress' ),
 340                  'callback'          => 'bbp_admin_setting_callback_show_on_root',
 341                  'sanitize_callback' => 'sanitize_text_field',
 342                  'args'              => array( 'label_for'=>'_bbp_show_on_root' )
 343              ),
 344          ),
 345  
 346          /** Single Slugs ******************************************************/
 347  
 348          'bbp_settings_single_slugs' => array(
 349  
 350              // Forum slug setting
 351              '_bbp_forum_slug' => array(
 352                  'title'             => esc_html__( 'Forum', 'bbpress' ),
 353                  'callback'          => 'bbp_admin_setting_callback_forum_slug',
 354                  'sanitize_callback' => 'bbp_sanitize_slug',
 355                  'args'              => array( 'label_for'=>'_bbp_forum_slug' )
 356              ),
 357  
 358              // Topic slug setting
 359              '_bbp_topic_slug' => array(
 360                  'title'             => esc_html__( 'Topic', 'bbpress' ),
 361                  'callback'          => 'bbp_admin_setting_callback_topic_slug',
 362                  'sanitize_callback' => 'bbp_sanitize_slug',
 363                  'args'              => array( 'label_for'=>'_bbp_topic_slug' )
 364              ),
 365  
 366              // Topic tag slug setting
 367              '_bbp_topic_tag_slug' => array(
 368                  'title'             => esc_html__( 'Topic Tag', 'bbpress' ),
 369                  'callback'          => 'bbp_admin_setting_callback_topic_tag_slug',
 370                  'sanitize_callback' => 'bbp_sanitize_slug',
 371                  'args'              => array( 'label_for'=>'_bbp_topic_tag_slug' )
 372              ),
 373  
 374              // View slug setting
 375              '_bbp_view_slug' => array(
 376                  'title'             => esc_html__( 'Topic View', 'bbpress' ),
 377                  'callback'          => 'bbp_admin_setting_callback_view_slug',
 378                  'sanitize_callback' => 'bbp_sanitize_slug',
 379                  'args'              => array( 'label_for'=>'_bbp_view_slug' )
 380              ),
 381  
 382              // Reply slug setting
 383              '_bbp_reply_slug' => array(
 384                  'title'             => _x( 'Reply', 'noun', 'bbpress' ),
 385                  'callback'          => 'bbp_admin_setting_callback_reply_slug',
 386                  'sanitize_callback' => 'bbp_sanitize_slug',
 387                  'args'              => array( 'label_for'=>'_bbp_reply_slug' )
 388              ),
 389  
 390              // Edit slug setting
 391              '_bbp_edit_slug' => array(
 392                  'title'             => esc_html__( 'Edit', 'bbpress' ),
 393                  'callback'          => 'bbp_admin_setting_callback_edit_slug',
 394                  'sanitize_callback' => 'bbp_sanitize_slug',
 395                  'args'              => array( 'label_for'=>'_bbp_edit_slug' )
 396              ),
 397  
 398              // Search slug setting
 399              '_bbp_search_slug' => array(
 400                  'title'             => esc_html__( 'Search', 'bbpress' ),
 401                  'callback'          => 'bbp_admin_setting_callback_search_slug',
 402                  'sanitize_callback' => 'bbp_sanitize_slug',
 403                  'args'              => array( 'label_for'=>'_bbp_search_slug' )
 404              )
 405          ),
 406  
 407          /** User Slugs ********************************************************/
 408  
 409          'bbp_settings_user_slugs' => array(
 410  
 411              // User slug setting
 412              '_bbp_user_slug' => array(
 413                  'title'             => esc_html__( 'User Base', 'bbpress' ),
 414                  'callback'          => 'bbp_admin_setting_callback_user_slug',
 415                  'sanitize_callback' => 'bbp_sanitize_slug',
 416                  'args'              => array( 'label_for'=>'_bbp_user_slug' )
 417              ),
 418  
 419              // Topics slug setting
 420              '_bbp_topic_archive_slug' => array(
 421                  'title'             => esc_html__( 'Topics Started', 'bbpress' ),
 422                  'callback'          => 'bbp_admin_setting_callback_topic_archive_slug',
 423                  'sanitize_callback' => 'bbp_sanitize_slug',
 424                  'args'              => array( 'label_for'=>'_bbp_topic_archive_slug' )
 425              ),
 426  
 427              // Replies slug setting
 428              '_bbp_reply_archive_slug' => array(
 429                  'title'             => esc_html__( 'Replies Created', 'bbpress' ),
 430                  'callback'          => 'bbp_admin_setting_callback_reply_archive_slug',
 431                  'sanitize_callback' => 'bbp_sanitize_slug',
 432                  'args'              => array( 'label_for'=>'_bbp_reply_archive_slug' )
 433              ),
 434  
 435              // Favorites slug setting
 436              '_bbp_user_favs_slug' => array(
 437                  'title'             => esc_html__( 'Favorite Topics', 'bbpress' ),
 438                  'callback'          => 'bbp_admin_setting_callback_user_favs_slug',
 439                  'sanitize_callback' => 'bbp_sanitize_slug',
 440                  'args'              => array( 'label_for'=>'_bbp_user_favs_slug' )
 441              ),
 442  
 443              // Subscriptions slug setting
 444              '_bbp_user_subs_slug' => array(
 445                  'title'             => esc_html__( 'Subscriptions', 'bbpress' ),
 446                  'callback'          => 'bbp_admin_setting_callback_user_subs_slug',
 447                  'sanitize_callback' => 'bbp_sanitize_slug',
 448                  'args'              => array( 'label_for'=>'_bbp_user_subs_slug' )
 449              ),
 450  
 451              // Engagements slug setting
 452              '_bbp_user_engs_slug' => array(
 453                  'title'             => esc_html__( 'Engagements', 'bbpress' ),
 454                  'callback'          => 'bbp_admin_setting_callback_user_engagements_slug',
 455                  'sanitize_callback' => 'bbp_sanitize_slug',
 456                  'args'              => array( 'label_for'=>'_bbp_user_engs_slug' )
 457              )
 458          ),
 459  
 460          /** BuddyPress ********************************************************/
 461  
 462          'bbp_settings_buddypress' => array(
 463  
 464              // Are group forums enabled?
 465              '_bbp_enable_group_forums' => array(
 466                  'title'             => esc_html__( 'Group Forums', 'bbpress' ),
 467                  'callback'          => 'bbp_admin_setting_callback_group_forums',
 468                  'sanitize_callback' => 'intval',
 469                  'args'              => array()
 470              ),
 471  
 472              // Group forums parent forum ID
 473              '_bbp_group_forums_root_id' => array(
 474                  'title'             => esc_html__( 'Primary Forum', 'bbpress' ),
 475                  'callback'          => 'bbp_admin_setting_callback_group_forums_root_id',
 476                  'sanitize_callback' => 'intval',
 477                  'args'              => array( 'label_for'=>'_bbp_group_forums_root_id' )
 478              )
 479          ),
 480  
 481          /** Akismet ***********************************************************/
 482  
 483          'bbp_settings_akismet' => array(
 484  
 485              // Should we use Akismet
 486              '_bbp_enable_akismet' => array(
 487                  'title'             => esc_html__( 'Use Akismet', 'bbpress' ),
 488                  'callback'          => 'bbp_admin_setting_callback_akismet',
 489                  'sanitize_callback' => 'intval',
 490                  'args'              => array()
 491              )
 492          ),
 493  
 494          /** Converter Page ****************************************************/
 495  
 496          // Connection
 497          'bbp_converter_connection' => array(
 498  
 499              // System Select
 500              '_bbp_converter_platform' => array(
 501                  'title'             => esc_html__( 'Select Platform', 'bbpress' ),
 502                  'callback'          => 'bbp_converter_setting_callback_platform',
 503                  'sanitize_callback' => 'sanitize_text_field',
 504                  'args'              => array( 'label_for'=> '_bbp_converter_platform' )
 505              ),
 506  
 507              // Database Server
 508              '_bbp_converter_db_server' => array(
 509                  'title'             => esc_html__( 'Database Server', 'bbpress' ),
 510                  'callback'          => 'bbp_converter_setting_callback_dbserver',
 511                  'sanitize_callback' => 'sanitize_text_field',
 512                  'args'              => array( 'label_for'=> '_bbp_converter_db_server' )
 513              ),
 514  
 515              // Database Server Port
 516              '_bbp_converter_db_port' => array(
 517                  'title'             => esc_html__( 'Database Port', 'bbpress' ),
 518                  'callback'          => 'bbp_converter_setting_callback_dbport',
 519                  'sanitize_callback' => 'intval',
 520                  'args'              => array( 'label_for'=> '_bbp_converter_db_port' )
 521              ),
 522  
 523              // Database Name
 524              '_bbp_converter_db_name' => array(
 525                  'title'             => esc_html__( 'Database Name', 'bbpress' ),
 526                  'callback'          => 'bbp_converter_setting_callback_dbname',
 527                  'sanitize_callback' => 'sanitize_text_field',
 528                  'args'              => array( 'label_for'=> '_bbp_converter_db_name' )
 529              ),
 530  
 531              // Database User
 532              '_bbp_converter_db_user' => array(
 533                  'title'             => esc_html__( 'Database User', 'bbpress' ),
 534                  'callback'          => 'bbp_converter_setting_callback_dbuser',
 535                  'sanitize_callback' => 'sanitize_text_field',
 536                  'args'              => array( 'label_for'=> '_bbp_converter_db_user' )
 537              ),
 538  
 539              // Database Password
 540              '_bbp_converter_db_pass' => array(
 541                  'title'             => esc_html__( 'Database Password', 'bbpress' ),
 542                  'callback'          => 'bbp_converter_setting_callback_dbpass',
 543                  'sanitize_callback' => 'sanitize_text_field',
 544                  'args'              => array( 'label_for'=> '_bbp_converter_db_pass' )
 545              ),
 546  
 547              // Database Prefix
 548              '_bbp_converter_db_prefix' => array(
 549                  'title'             => esc_html__( 'Table Prefix', 'bbpress' ),
 550                  'callback'          => 'bbp_converter_setting_callback_dbprefix',
 551                  'sanitize_callback' => 'sanitize_text_field',
 552                  'args'              => array( 'label_for'=> '_bbp_converter_db_prefix' )
 553              )
 554          ),
 555  
 556          // Options
 557          'bbp_converter_options' => array(
 558  
 559              // Rows Limit
 560              '_bbp_converter_rows' => array(
 561                  'title'             => esc_html__( 'Rows Limit', 'bbpress' ),
 562                  'callback'          => 'bbp_converter_setting_callback_rows',
 563                  'sanitize_callback' => 'intval',
 564                  'args'              => array( 'label_for'=> '_bbp_converter_rows' )
 565              ),
 566  
 567              // Delay Time
 568              '_bbp_converter_delay_time' => array(
 569                  'title'             => esc_html__( 'Delay Time', 'bbpress' ),
 570                  'callback'          => 'bbp_converter_setting_callback_delay_time',
 571                  'sanitize_callback' => 'intval',
 572                  'args'              => array( 'label_for'=> '_bbp_converter_delay_time' )
 573              ),
 574  
 575              // Convert Users
 576              '_bbp_converter_convert_users' => array(
 577                  'title'             => esc_html__( 'Convert Users', 'bbpress' ),
 578                  'callback'          => 'bbp_converter_setting_callback_convert_users',
 579                  'sanitize_callback' => 'intval',
 580                  'args'              => array( 'label_for'=> '_bbp_converter_convert_users' )
 581              ),
 582  
 583              // Halt
 584              '_bbp_converter_halt' => array(
 585                  'title'             => esc_html__( 'Stop on Error', 'bbpress' ),
 586                  'callback'          => 'bbp_converter_setting_callback_halt',
 587                  'sanitize_callback' => 'intval',
 588                  'args'              => array( 'label_for'=> '_bbp_converter_halt' )
 589              ),
 590  
 591              // Restart
 592              '_bbp_converter_restart' => array(
 593                  'title'             => esc_html__( 'Start Over', 'bbpress' ),
 594                  'callback'          => 'bbp_converter_setting_callback_restart',
 595                  'sanitize_callback' => 'intval',
 596                  'args'              => array( 'label_for'=> '_bbp_converter_restart' )
 597              ),
 598  
 599              // Clean
 600              '_bbp_converter_clean' => array(
 601                  'title'             => esc_html__( 'Helper Data', 'bbpress' ),
 602                  'callback'          => 'bbp_converter_setting_callback_clean',
 603                  'sanitize_callback' => 'intval',
 604                  'args'              => array( 'label_for'=> '_bbp_converter_clean' )
 605              )
 606          )
 607      ) );
 608  }
 609  
 610  /**
 611   * Get settings fields by section.
 612   *
 613   * @since 2.1.0 bbPress (r4001)
 614   *
 615   * @param string $section_id ID of the section to get fields for
 616   * @staticvar array $fields All of the available fields
 617   * @return mixed False if section is invalid, array of fields otherwise.
 618   */
 619  function bbp_admin_get_settings_fields_for_section( $section_id = '' ) {
 620      static $fields = array();
 621  
 622      // Default return value
 623      $retval = array();
 624  
 625      // Bail if section is empty
 626      if ( empty( $section_id ) ) {
 627          return false;
 628      }
 629  
 630      // Get all of the fields (so we can snag one section of them)
 631      if ( empty( $fields ) ) {
 632          $fields = bbp_admin_get_settings_fields();
 633      }
 634  
 635      // Get the field by section
 636      if ( isset( $fields[ $section_id ] ) ) {
 637          $retval = $fields[ $section_id ];
 638      }
 639  
 640      // Filter & return
 641      return (array) apply_filters( 'bbp_admin_get_settings_fields_for_section', $retval, $section_id );
 642  }
 643  
 644  /** User Section **************************************************************/
 645  
 646  /**
 647   * User settings section description for the settings page
 648   *
 649   * @since 2.0.0 bbPress (r2786)
 650   */
 651  function bbp_admin_setting_callback_user_section() {
 652  ?>
 653  
 654      <p><?php esc_html_e( 'Setting time limits and other user posting capabilities', 'bbpress' ); ?></p>
 655  
 656  <?php
 657  }
 658  
 659  
 660  /**
 661   * Edit lock setting field
 662   *
 663   * @since 2.0.0 bbPress (r2737)
 664   */
 665  function bbp_admin_setting_callback_editlock() {
 666  
 667      // Start the output buffer for the second option
 668      ob_start(); ?>
 669  
 670      </label>
 671      <label for="_bbp_edit_lock">
 672          <input name="_bbp_edit_lock" id="_bbp_edit_lock" type="number" min="0" step="1" value="<?php bbp_form_option( '_bbp_edit_lock', '5' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_edit_lock' ); ?> />
 673  
 674      <?php $select = ob_get_clean(); ?>
 675  
 676      <label for="_bbp_allow_content_edit">
 677          <input name="_bbp_allow_content_edit" id="_bbp_allow_content_edit" type="checkbox" value="1" <?php checked( bbp_allow_content_edit( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_content_edit' ); ?> />
 678          <?php printf( esc_html__( 'Allow users to edit their content for %s minutes after posting', 'bbpress' ), $select ); ?>
 679      </label>
 680      <p class="description"><?php esc_html_e( 'If checked, setting to "0 minutes" allows editing forever.', 'bbpress' ); ?></p>
 681  
 682  <?php
 683  }
 684  
 685  /**
 686   * Throttle setting field
 687   *
 688   * @since 2.0.0 bbPress (r2737)
 689   */
 690  function bbp_admin_setting_callback_throttle() {
 691  
 692      // Start the output buffer for the second option
 693      ob_start(); ?>
 694  
 695      </label>
 696      <label for="_bbp_throttle_time">
 697          <input name="_bbp_throttle_time" id="_bbp_throttle_time" type="number" min="0" step="1" value="<?php bbp_form_option( '_bbp_throttle_time', '10' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_throttle_time' ); ?> />
 698  
 699      <?php $select = ob_get_clean(); ?>
 700  
 701      <label for="_bbp_allow_content_throttle">
 702          <input name="_bbp_allow_content_throttle" id="_bbp_allow_content_throttle" type="checkbox" value="1" <?php checked( bbp_allow_content_throttle( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_content_throttle' ); ?> />
 703          <?php printf( esc_html__( 'Allow flood protection by throttling users for %s seconds after posting', 'bbpress' ), $select ); ?>
 704      </label>
 705      <p class="description"><?php esc_html_e( 'Use this to discourage users from spamming your forums.', 'bbpress' ); ?></p>
 706  
 707  <?php
 708  }
 709  
 710  /**
 711   * Allow anonymous posting setting field
 712   *
 713   * @since 2.0.0 bbPress (r2737)
 714   */
 715  function bbp_admin_setting_callback_anonymous() {
 716  ?>
 717  
 718      <input name="_bbp_allow_anonymous" id="_bbp_allow_anonymous" type="checkbox" value="1" <?php checked( bbp_allow_anonymous( false ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_anonymous' ); ?> />
 719      <label for="_bbp_allow_anonymous"><?php esc_html_e( 'Allow guest users without accounts to create topics and replies', 'bbpress' ); ?></label>
 720      <p class="description"><?php esc_html_e( 'Works best on intranets or paired with antispam measures like Akismet.', 'bbpress' ); ?></p>
 721  
 722  <?php
 723  }
 724  
 725  /**
 726   * Allow global access setting field
 727   *
 728   * @since 2.0.0 bbPress (r3378)
 729   */
 730  function bbp_admin_setting_callback_global_access() {
 731  
 732      // Get the default role once rather than loop repeatedly below
 733      $default_role = bbp_get_default_role();
 734      $roles        = bbp_get_dynamic_roles();
 735  
 736      // Start the output buffer for the select dropdown
 737      ob_start(); ?>
 738  
 739      </label>
 740      <label for="_bbp_default_role">
 741          <select name="_bbp_default_role" id="_bbp_default_role" <?php bbp_maybe_admin_setting_disabled( '_bbp_default_role' ); ?>>
 742          <?php foreach ( $roles as $role => $details ) : ?>
 743  
 744              <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
 745  
 746          <?php endforeach; ?>
 747          </select>
 748  
 749      <?php $select = ob_get_clean(); ?>
 750  
 751      <label for="_bbp_allow_global_access">
 752          <input name="_bbp_allow_global_access" id="_bbp_allow_global_access" type="checkbox" value="1" <?php checked( bbp_allow_global_access( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_global_access' ); ?> />
 753          <?php printf( esc_html__( 'Automatically give registered visitors the %s forum role', 'bbpress' ), $select ); ?>
 754      </label>
 755      <p class="description"><?php esc_html_e( 'Uncheck this to manually assign all user access to your forums.', 'bbpress' ); ?></p>
 756  
 757  <?php
 758  }
 759  
 760  /** Features Section **********************************************************/
 761  
 762  /**
 763   * Features settings section description for the settings page
 764   *
 765   * @since 2.0.0 bbPress (r2786)
 766   */
 767  function bbp_admin_setting_callback_features_section() {
 768  ?>
 769  
 770      <p><?php esc_html_e( 'Forum features that can be toggled on and off', 'bbpress' ); ?></p>
 771  
 772  <?php
 773  }
 774  
 775  /**
 776   * Allow favorites setting field
 777   *
 778   * @since 2.0.0 bbPress (r2786)
 779   */
 780  function bbp_admin_setting_callback_favorites() {
 781  ?>
 782  
 783      <input name="_bbp_enable_favorites" id="_bbp_enable_favorites" type="checkbox" value="1" <?php checked( bbp_is_favorites_active( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_enable_favorites' ); ?> />
 784      <label for="_bbp_enable_favorites"><?php esc_html_e( 'Allow users to mark topics as favorites', 'bbpress' ); ?></label>
 785  
 786  <?php
 787  }
 788  
 789  /**
 790   * Allow subscriptions setting field
 791   *
 792   * @since 2.0.0 bbPress (r2737)
 793   */
 794  function bbp_admin_setting_callback_subscriptions() {
 795  ?>
 796  
 797      <input name="_bbp_enable_subscriptions" id="_bbp_enable_subscriptions" type="checkbox" value="1" <?php checked( bbp_is_subscriptions_active( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_enable_subscriptions' ); ?> />
 798      <label for="_bbp_enable_subscriptions"><?php esc_html_e( 'Allow users to subscribe to forums and topics', 'bbpress' ); ?></label>
 799  
 800  <?php
 801  }
 802  
 803  /**
 804   * Allow engagements setting field
 805   *
 806   * @since 2.0.0 bbPress (r2737)
 807   */
 808  function bbp_admin_setting_callback_engagements() {
 809  ?>
 810  
 811      <input name="_bbp_enable_engagements" id="_bbp_enable_engagements" type="checkbox" value="1" <?php checked( bbp_is_engagements_active( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_enable_engagements' ); ?> />
 812      <label for="_bbp_enable_engagements"><?php esc_html_e( 'Allow tracking of topics each user engages in', 'bbpress' ); ?></label>
 813  
 814  <?php
 815  }
 816  
 817  /**
 818   * Allow topic tags setting field
 819   *
 820   * @since 2.4.0 bbPress (r4944)
 821   */
 822  function bbp_admin_setting_callback_topic_tags() {
 823  ?>
 824  
 825      <input name="_bbp_allow_topic_tags" id="_bbp_allow_topic_tags" type="checkbox" value="1" <?php checked( bbp_allow_topic_tags( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_topic_tags' ); ?> />
 826      <label for="_bbp_allow_topic_tags"><?php esc_html_e( 'Allow topics to have tags', 'bbpress' ); ?></label>
 827  
 828  <?php
 829  }
 830  
 831  /**
 832   * Allow forum-mods setting field
 833   *
 834   * @since 2.6.0 bbPress (r5834)
 835   */
 836  function bbp_admin_setting_callback_forum_mods() {
 837  ?>
 838  
 839      <input name="_bbp_allow_forum_mods" id="_bbp_allow_forum_mods" type="checkbox" value="1" <?php checked( bbp_allow_forum_mods( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_forum_mods' ); ?> />
 840      <label for="_bbp_allow_forum_mods"><?php esc_html_e( 'Allow forums to have dedicated moderators', 'bbpress' ); ?></label>
 841      <p class="description"><?php esc_html_e( 'This does not include the ability to edit users.', 'bbpress' ); ?></p>
 842  
 843  <?php
 844  }
 845  
 846  /**
 847   * Allow super-mods setting field
 848   *
 849   * @since 2.6.0 bbPress (r6562)
 850   */
 851  function bbp_admin_setting_callback_super_mods() {
 852  ?>
 853  
 854      <input name="_bbp_allow_super_mods" id="_bbp_allow_super_mods" type="checkbox" value="1" <?php checked( bbp_allow_super_mods( false ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_super_mods' ); ?> />
 855      <label for="_bbp_allow_super_mods"><?php esc_html_e( 'Allow Moderators and Keymasters to edit users', 'bbpress' ); ?></label>
 856      <p class="description"><?php esc_html_e( 'This includes roles, passwords, and email addresses.', 'bbpress' ); ?></p>
 857  
 858  <?php
 859  }
 860  
 861  /**
 862   * Allow forum wide search
 863   *
 864   * @since 2.4.0 bbPress (r4970)
 865   */
 866  function bbp_admin_setting_callback_search() {
 867  ?>
 868  
 869      <input name="_bbp_allow_search" id="_bbp_allow_search" type="checkbox" value="1" <?php checked( bbp_allow_search( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_search' ); ?> />
 870      <label for="_bbp_allow_search"><?php esc_html_e( 'Allow forum wide search', 'bbpress' ); ?></label>
 871  
 872  <?php
 873  }
 874  
 875  /**
 876   * Hierarchical reply maximum depth level setting field
 877   *
 878   * Replies will be threaded if depth is 2 or greater
 879   *
 880   * @since 2.4.0 bbPress (r4944)
 881   */
 882  function bbp_admin_setting_callback_thread_replies_depth() {
 883  
 884      // Set maximum depth for dropdown
 885      $max_depth     = (int) apply_filters( 'bbp_thread_replies_depth_max', 10 );
 886      $current_depth = bbp_thread_replies_depth();
 887  
 888      // Start an output buffer for the select dropdown
 889      ob_start(); ?>
 890  
 891      </label>
 892      <label for="_bbp_thread_replies_depth">
 893          <select name="_bbp_thread_replies_depth" id="_bbp_thread_replies_depth" <?php bbp_maybe_admin_setting_disabled( '_bbp_thread_replies_depth' ); ?>>
 894          <?php for ( $i = 2; $i <= $max_depth; $i++ ) : ?>
 895  
 896              <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $current_depth ); ?>><?php echo esc_html( $i ); ?></option>
 897  
 898          <?php endfor; ?>
 899          </select>
 900  
 901      <?php $select = ob_get_clean(); ?>
 902  
 903      <label for="_bbp_allow_threaded_replies">
 904          <input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1" <?php checked( '1', bbp_allow_threaded_replies( false ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_threaded_replies' ); ?> />
 905          <?php printf( esc_html__( 'Enable threaded (nested) replies %s levels deep', 'bbpress' ), $select ); ?>
 906      </label>
 907  
 908  <?php
 909  }
 910  
 911  /**
 912   * Allow topic and reply revisions
 913   *
 914   * @since 2.0.0 bbPress (r3412)
 915   */
 916  function bbp_admin_setting_callback_revisions() {
 917  ?>
 918  
 919      <input name="_bbp_allow_revisions" id="_bbp_allow_revisions" type="checkbox" value="1" <?php checked( bbp_allow_revisions( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_revisions' ); ?> />
 920      <label for="_bbp_allow_revisions"><?php esc_html_e( 'Allow topic and reply revision logging', 'bbpress' ); ?></label>
 921  
 922  <?php
 923  }
 924  
 925  /**
 926   * Use the WordPress editor setting field
 927   *
 928   * @since 2.1.0 bbPress (r3586)
 929   */
 930  function bbp_admin_setting_callback_use_wp_editor() {
 931  ?>
 932  
 933      <input name="_bbp_use_wp_editor" id="_bbp_use_wp_editor" type="checkbox" value="1" <?php checked( bbp_use_wp_editor( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_use_wp_editor' ); ?> />
 934      <label for="_bbp_use_wp_editor"><?php esc_html_e( 'Add toolbar & buttons to textareas to help with HTML formatting', 'bbpress' ); ?></label>
 935  
 936  <?php
 937  }
 938  
 939  /**
 940   * Main subtheme section
 941   *
 942   * @since 2.0.0 bbPress (r2786)
 943   */
 944  function bbp_admin_setting_callback_subtheme_section() {
 945  ?>
 946  
 947      <p><?php esc_html_e( 'How your forum content is displayed within your existing theme.', 'bbpress' ); ?></p>
 948  
 949  <?php
 950  }
 951  
 952  /**
 953   * Use the WordPress editor setting field
 954   *
 955   * @since 2.1.0 bbPress (r3586)
 956   */
 957  function bbp_admin_setting_callback_subtheme_id() {
 958  
 959      // Declare locale variable
 960      $theme_options   = '';
 961      $current_package = bbp_get_theme_package_id( 'default' );
 962  
 963      // Note: This should never be empty. /templates/ is the
 964      // canonical backup if no other packages exist. If there's an error here,
 965      // something else is wrong.
 966      //
 967      // @see bbPress::register_theme_packages()
 968      foreach ( (array) bbpress()->theme_compat->packages as $id => $theme ) {
 969          $theme_options .= '<option value="' . esc_attr( $id ) . '"' . selected( $theme->id, $current_package, false ) . '>' . esc_html( $theme->name ) . '</option>';
 970      }
 971  
 972      if ( ! empty( $theme_options ) ) : ?>
 973  
 974          <select name="_bbp_theme_package_id" id="_bbp_theme_package_id" <?php bbp_maybe_admin_setting_disabled( '_bbp_theme_package_id' ); ?>><?php echo $theme_options; ?></select>
 975          <label for="_bbp_theme_package_id"><?php esc_html_e( 'will serve all bbPress templates', 'bbpress' ); ?></label>
 976  
 977      <?php else : ?>
 978  
 979          <p><?php esc_html_e( 'No template packages available.', 'bbpress' ); ?></p>
 980  
 981      <?php endif;
 982  }
 983  
 984  /**
 985   * Allow oEmbed in replies
 986   *
 987   * @since 2.1.0 bbPress (r3752)
 988   */
 989  function bbp_admin_setting_callback_use_autoembed() {
 990  ?>
 991  
 992      <input name="_bbp_use_autoembed" id="_bbp_use_autoembed" type="checkbox" value="1" <?php checked( bbp_use_autoembed( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_use_autoembed' ); ?> />
 993      <label for="_bbp_use_autoembed"><?php esc_html_e( 'Embed media (YouTube, Twitter, Flickr, etc...) directly into topics and replies', 'bbpress' ); ?></label>
 994  
 995  <?php
 996  }
 997  
 998  /** Per Page Section **********************************************************/
 999  
1000  /**
1001   * Per page settings section description for the settings page
1002   *
1003   * @since 2.0.0 bbPress (r2786)
1004   */
1005  function bbp_admin_setting_callback_per_page_section() {
1006  ?>
1007  
1008      <p><?php esc_html_e( 'How many topics and replies to show per page', 'bbpress' ); ?></p>
1009  
1010  <?php
1011  }
1012  
1013  /**
1014   * Topics per page setting field
1015   *
1016   * @since 2.0.0 bbPress (r2786)
1017   */
1018  function bbp_admin_setting_callback_topics_per_page() {
1019  ?>
1020  
1021      <input name="_bbp_topics_per_page" id="_bbp_topics_per_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_topics_per_page', '15' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_topics_per_page' ); ?> />
1022      <?php esc_html_e( 'per page', 'bbpress' ); ?>
1023  
1024  <?php
1025  }
1026  
1027  /**
1028   * Replies per page setting field
1029   *
1030   * @since 2.0.0 bbPress (r2786)
1031   */
1032  function bbp_admin_setting_callback_replies_per_page() {
1033  ?>
1034  
1035      <input name="_bbp_replies_per_page" id="_bbp_replies_per_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_replies_per_page', '15' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_replies_per_page' ); ?> />
1036      <?php esc_html_e( 'per page', 'bbpress' ); ?>
1037  
1038  <?php
1039  }
1040  
1041  /** Per RSS Page Section ******************************************************/
1042  
1043  /**
1044   * Per page settings section description for the settings page
1045   *
1046   * @since 2.0.0 bbPress (r2786)
1047   */
1048  function bbp_admin_setting_callback_per_rss_page_section() {
1049  ?>
1050  
1051      <p><?php esc_html_e( 'How many topics and replies to show per RSS page', 'bbpress' ); ?></p>
1052  
1053  <?php
1054  }
1055  
1056  /**
1057   * Topics per RSS page setting field
1058   *
1059   * @since 2.0.0 bbPress (r2786)
1060   */
1061  function bbp_admin_setting_callback_topics_per_rss_page() {
1062  ?>
1063  
1064      <input name="_bbp_topics_per_rss_page" id="_bbp_topics_per_rss_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_topics_per_rss_page', '25' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_topics_per_rss_page' ); ?> />
1065      <?php esc_html_e( 'per page', 'bbpress' ); ?>
1066  
1067  <?php
1068  }
1069  
1070  /**
1071   * Replies per RSS page setting field
1072   *
1073   * @since 2.0.0 bbPress (r2786)
1074   */
1075  function bbp_admin_setting_callback_replies_per_rss_page() {
1076  ?>
1077  
1078      <input name="_bbp_replies_per_rss_page" id="_bbp_replies_per_rss_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_replies_per_rss_page', '25' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_replies_per_rss_page' ); ?> />
1079      <?php esc_html_e( 'per page', 'bbpress' ); ?>
1080  
1081  <?php
1082  }
1083  
1084  /** Slug Section **************************************************************/
1085  
1086  /**
1087   * Slugs settings section description for the settings page
1088   *
1089   * @since 2.0.0 bbPress (r2786)
1090   */
1091  function bbp_admin_setting_callback_root_slug_section() {
1092  
1093      // Flush rewrite rules when this section is saved
1094      if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) ) {
1095          flush_rewrite_rules();
1096      } ?>
1097  
1098      <p><?php esc_html_e( 'Customize your Forums root. Partner with a WordPress Page and use Shortcodes for more flexibility.', 'bbpress' ); ?></p>
1099  
1100  <?php
1101  }
1102  
1103  /**
1104   * Root slug setting field
1105   *
1106   * @since 2.0.0 bbPress (r2786)
1107   */
1108  function bbp_admin_setting_callback_root_slug() {
1109  ?>
1110  
1111      <input name="_bbp_root_slug" id="_bbp_root_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_root_slug', 'forums', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_root_slug' ); ?> />
1112  
1113  <?php
1114      // Slug Check
1115      bbp_form_slug_conflict_check( '_bbp_root_slug', 'forums' );
1116  }
1117  
1118  /**
1119   * Include root slug setting field
1120   *
1121   * @since 2.0.0 bbPress (r2786)
1122   */
1123  function bbp_admin_setting_callback_include_root() {
1124  ?>
1125  
1126      <input name="_bbp_include_root" id="_bbp_include_root" type="checkbox" value="1" <?php checked( bbp_include_root_slug() ); bbp_maybe_admin_setting_disabled( '_bbp_include_root' ); ?> />
1127      <label for="_bbp_include_root"><?php esc_html_e( 'Prefix all forum content with the Forum Root slug (Recommended)', 'bbpress' ); ?></label>
1128  
1129  <?php
1130  }
1131  
1132  /**
1133   * Include root slug setting field
1134   *
1135   * @since 2.0.0 bbPress (r2786)
1136   */
1137  function bbp_admin_setting_callback_show_on_root() {
1138  
1139      // Current setting
1140      $show_on_root = bbp_show_on_root();
1141  
1142      // Options for forum root output
1143      $root_options = array(
1144          'forums' => array(
1145              'name' => esc_attr__( 'Forum Index', 'bbpress' )
1146          ),
1147          'topics' => array(
1148              'name' => esc_attr__( 'Topics by Last Post', 'bbpress' )
1149          )
1150      ); ?>
1151  
1152      <select name="_bbp_show_on_root" id="_bbp_show_on_root" <?php bbp_maybe_admin_setting_disabled( '_bbp_show_on_root' ); ?>>
1153  
1154          <?php foreach ( $root_options as $option_id => $details ) : ?>
1155  
1156              <option <?php selected( $show_on_root, $option_id ); ?> value="<?php echo esc_attr( $option_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
1157  
1158          <?php endforeach; ?>
1159  
1160      </select>
1161  
1162      <?php
1163  
1164      // Look for theme support
1165      $forum_archive = basename( bbp_get_forum_archive_template() );
1166  
1167      // This setting doesn't work if the theme has an archive-forum.php template.
1168      if ( ! empty( $forum_archive ) ) : ?>
1169  
1170          <p class="description"><?php printf( esc_html__( 'This setting will be ignored because %s was found in your theme.', 'bbpress' ), '<code>' . $forum_archive . '</code>' ); ?></p>
1171  
1172      <?php endif;
1173  }
1174  
1175  /** User Slug Section *********************************************************/
1176  
1177  /**
1178   * Slugs settings section description for the settings page
1179   *
1180   * @since 2.0.0 bbPress (r2786)
1181   */
1182  function bbp_admin_setting_callback_user_slug_section() {
1183  ?>
1184  
1185      <p><?php esc_html_e( 'Customize your user profile slugs.', 'bbpress' ); ?></p>
1186  
1187  <?php
1188  }
1189  
1190  /**
1191   * User slug setting field
1192   *
1193   * @since 2.0.0 bbPress (r2786)
1194   */
1195  function bbp_admin_setting_callback_user_slug() {
1196  ?>
1197  
1198      <input name="_bbp_user_slug" id="_bbp_user_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_slug', 'users', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_slug' ); ?> />
1199  
1200  <?php
1201      // Slug Check
1202      bbp_form_slug_conflict_check( '_bbp_user_slug', 'users' );
1203  }
1204  
1205  /**
1206   * Topic archive slug setting field
1207   *
1208   * @since 2.0.0 bbPress (r2786)
1209   */
1210  function bbp_admin_setting_callback_topic_archive_slug() {
1211  ?>
1212  
1213      <input name="_bbp_topic_archive_slug" id="_bbp_topic_archive_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_archive_slug', 'topics', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_topic_archive_slug' ); ?> />
1214  
1215  <?php
1216      // Slug Check
1217      bbp_form_slug_conflict_check( '_bbp_topic_archive_slug', 'topics' );
1218  }
1219  
1220  /**
1221   * Reply archive slug setting field
1222   *
1223   * @since 2.4.0 bbPress (r4932)
1224   */
1225  function bbp_admin_setting_callback_reply_archive_slug() {
1226  ?>
1227  
1228      <input name="_bbp_reply_archive_slug" id="_bbp_reply_archive_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_reply_archive_slug', 'replies', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_reply_archive_slug' ); ?> />
1229  
1230  <?php
1231      // Slug Check
1232      bbp_form_slug_conflict_check( '_bbp_reply_archive_slug', 'replies' );
1233  }
1234  
1235  /**
1236   * Favorites slug setting field
1237   *
1238   * @since 2.4.0 bbPress (r4932)
1239   */
1240  function bbp_admin_setting_callback_user_favs_slug() {
1241  ?>
1242  
1243      <input name="_bbp_user_favs_slug" id="_bbp_user_favs_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_favs_slug', 'favorites', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_favs_slug' ); ?> />
1244  
1245  <?php
1246      // Slug Check
1247      bbp_form_slug_conflict_check( '_bbp_user_favs_slug', 'favorites' );
1248  }
1249  
1250  /**
1251   * Subscriptions slug setting field
1252   *
1253   * @since 2.4.0 bbPress (r4932)
1254   */
1255  function bbp_admin_setting_callback_user_subs_slug() {
1256  ?>
1257  
1258      <input name="_bbp_user_subs_slug" id="_bbp_user_subs_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_subs_slug', 'subscriptions', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_subs_slug' ); ?> />
1259  
1260  <?php
1261      // Slug Check
1262      bbp_form_slug_conflict_check( '_bbp_user_subs_slug', 'subscriptions' );
1263  }
1264  
1265  /**
1266   * Engagements slug setting field
1267   *
1268   * @since 2.6.0 bbPress (r6320)
1269   */
1270  function bbp_admin_setting_callback_user_engagements_slug() {
1271  ?>
1272  
1273      <input name="_bbp_user_engs_slug" id="_bbp_user_engs_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_engs_slug', 'engagements', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_engs_slug' ); ?> />
1274  
1275  <?php
1276      // Slug Check
1277      bbp_form_slug_conflict_check( '_bbp_user_engs_slug', 'engagements' );
1278  }
1279  
1280  /** Single Slugs **************************************************************/
1281  
1282  /**
1283   * Slugs settings section description for the settings page
1284   *
1285   * @since 2.0.0 bbPress (r2786)
1286   */
1287  function bbp_admin_setting_callback_single_slug_section() {
1288  ?>
1289  
1290      <p><?php printf( esc_html__( 'Custom slugs for single forums, topics, replies, tags, views, edit, and search.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p>
1291  
1292  <?php
1293  }
1294  
1295  /**
1296   * Forum slug setting field
1297   *
1298   * @since 2.0.0 bbPress (r2786)
1299   */
1300  function bbp_admin_setting_callback_forum_slug() {
1301  ?>
1302  
1303      <input name="_bbp_forum_slug" id="_bbp_forum_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_forum_slug', 'forum', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_forum_slug' ); ?> />
1304  
1305  <?php
1306      // Slug Check
1307      bbp_form_slug_conflict_check( '_bbp_forum_slug', 'forum' );
1308  }
1309  
1310  /**
1311   * Topic slug setting field
1312   *
1313   * @since 2.0.0 bbPress (r2786)
1314   */
1315  function bbp_admin_setting_callback_topic_slug() {
1316  ?>
1317  
1318      <input name="_bbp_topic_slug" id="_bbp_topic_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_slug', 'topic', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_topic_slug' ); ?> />
1319  
1320  <?php
1321      // Slug Check
1322      bbp_form_slug_conflict_check( '_bbp_topic_slug', 'topic' );
1323  }
1324  
1325  /**
1326   * Reply slug setting field
1327   *
1328   * @since 2.0.0 bbPress (r2786)
1329   */
1330  function bbp_admin_setting_callback_reply_slug() {
1331  ?>
1332  
1333      <input name="_bbp_reply_slug" id="_bbp_reply_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_reply_slug', 'reply', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_reply_slug' ); ?> />
1334  
1335  <?php
1336      // Slug Check
1337      bbp_form_slug_conflict_check( '_bbp_reply_slug', 'reply' );
1338  }
1339  
1340  /**
1341   * Topic tag slug setting field
1342   *
1343   * @since 2.0.0 bbPress (r2786)
1344   */
1345  function bbp_admin_setting_callback_topic_tag_slug() {
1346  ?>
1347  
1348      <input name="_bbp_topic_tag_slug" id="_bbp_topic_tag_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_tag_slug', 'topic-tag', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_topic_tag_slug' ); ?> />
1349  
1350  <?php
1351  
1352      // Slug Check
1353      bbp_form_slug_conflict_check( '_bbp_topic_tag_slug', 'topic-tag' );
1354  }
1355  
1356  /**
1357   * View slug setting field
1358   *
1359   * @since 2.0.0 bbPress (r2789)
1360   */
1361  function bbp_admin_setting_callback_view_slug() {
1362  ?>
1363  
1364      <input name="_bbp_view_slug" id="_bbp_view_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_view_slug', 'view', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_view_slug' ); ?> />
1365  
1366  <?php
1367      // Slug Check
1368      bbp_form_slug_conflict_check( '_bbp_view_slug', 'view' );
1369  }
1370  
1371  /**
1372   * Search slug setting field
1373   *
1374   * @since 2.3.0 bbPress (r4579)
1375   */
1376  function bbp_admin_setting_callback_search_slug() {
1377  ?>
1378  
1379      <input name="_bbp_search_slug" id="_bbp_search_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_search_slug', 'search', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_search_slug' ); ?> />
1380  
1381  <?php
1382      // Slug Check
1383      bbp_form_slug_conflict_check( '_bbp_search_slug', 'search' );
1384  }
1385  
1386  /**
1387   * Edit slug setting field
1388   *
1389   * @since 2.6.2 bbPress (r6965)
1390   */
1391  function bbp_admin_setting_callback_edit_slug() {
1392  ?>
1393  
1394      <input name="_bbp_edit_slug" id="_bbp_edit_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_edit_slug', 'edit', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_edit_slug' ); ?> />
1395  
1396  <?php
1397      // Slug Check
1398      bbp_form_slug_conflict_check( '_bbp_edit_slug', 'edit' );
1399  }
1400  
1401  /** BuddyPress ****************************************************************/
1402  
1403  /**
1404   * Extension settings section description for the settings page
1405   *
1406   * @since 2.1.0 bbPress (r3575)
1407   */
1408  function bbp_admin_setting_callback_buddypress_section() {
1409  ?>
1410  
1411      <p><?php esc_html_e( 'Forum settings for BuddyPress', 'bbpress' ); ?></p>
1412  
1413  <?php
1414  }
1415  
1416  /**
1417   * Allow BuddyPress group forums setting field
1418   *
1419   * @since 2.1.0 bbPress (r3575)
1420   */
1421  function bbp_admin_setting_callback_group_forums() {
1422  ?>
1423  
1424      <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' ); ?> />
1425      <label for="_bbp_enable_group_forums"><?php esc_html_e( 'Allow BuddyPress Groups to have their own forums', 'bbpress' ); ?></label>
1426  
1427  <?php
1428  }
1429  
1430  /**
1431   * Replies per page setting field
1432   *
1433   * @since 2.1.0 bbPress (r3575)
1434   */
1435  function bbp_admin_setting_callback_group_forums_root_id() {
1436  
1437      // Group root ID
1438      $group_root = bbp_get_group_forums_root_id();
1439      if ( ! bbp_get_forum( $group_root ) ) {
1440          delete_option( '_bbp_group_forums_root_id' );
1441          $group_root = 0;
1442      }
1443  
1444      // Output the dropdown for all forums
1445      $select = bbp_get_dropdown( array(
1446          'selected'           => $group_root,
1447          'show_none'          => esc_html__( '&mdash; No parent &mdash;', 'bbpress' ),
1448          'orderby'            => 'title',
1449          'order'              => 'ASC',
1450          'select_id'          => '_bbp_group_forums_root_id',
1451          'disable_categories' => false,
1452          'disabled'           => '_bbp_group_forums_root_id'
1453      ) );
1454  
1455      // Check cap one time
1456      $can_add_new = current_user_can( 'publish_forums' );
1457      $button = '';
1458  
1459      // Text variations based on configuration
1460      if ( empty( $group_root ) && ( true === $can_add_new ) ) {
1461  
1462          // New URL
1463          $new_url = wp_nonce_url( add_query_arg( array(
1464              'page'   => 'bbpress',
1465              'create' => 'bbp-group-forum-root'
1466          ), admin_url( 'options-general.php' ) ), '_bbp_group_forums_root_id' );
1467  
1468          // Button & text
1469          $button = '<a href="' . esc_url( $new_url ) . '">' . esc_html__( 'create a new one', 'bbpress' ) . '</a>';
1470          $text   = esc_html__( 'Use %s to contain your group forums, or %s', 'bbpress' ); //phpcs:ignore
1471      } else {
1472          $text = esc_html__( 'Use %s to contain your group forums', 'bbpress' );
1473      }
1474  
1475      // Output
1476      printf( $text, $select, $button ); ?>
1477      <p class="description"><?php esc_html_e( 'Changing this will not move existing forums.', 'bbpress' ); ?></p>
1478  
1479  <?php
1480  }
1481  
1482  /** Akismet *******************************************************************/
1483  
1484  /**
1485   * Extension settings section description for the settings page
1486   *
1487   * @since 2.1.0 bbPress (r3575)
1488   */
1489  function bbp_admin_setting_callback_akismet_section() {
1490  ?>
1491  
1492      <p><?php esc_html_e( 'Forum settings for Akismet', 'bbpress' ); ?></p>
1493  
1494  <?php
1495  }
1496  
1497  
1498  /**
1499   * Allow Akismet setting field
1500   *
1501   * @since 2.1.0 bbPress (r3575)
1502   */
1503  function bbp_admin_setting_callback_akismet() {
1504  ?>
1505  
1506      <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' ); ?> />
1507      <label for="_bbp_enable_akismet"><?php esc_html_e( 'Allow Akismet to actively prevent forum spam.', 'bbpress' ); ?></label>
1508  
1509  <?php
1510  }
1511  
1512  /** Settings Page *************************************************************/
1513  
1514  /**
1515   * The main settings page
1516   *
1517   * @since 2.0.0 bbPress (r2643)
1518   */
1519  function bbp_admin_settings() {
1520  ?>
1521  
1522      <div class="wrap">
1523          <h1 class="wp-heading-inline"><?php esc_html_e( 'Forums Settings', 'bbpress' ); ?></h1>
1524          <hr class="wp-header-end">
1525  
1526          <form action="options.php" method="post">
1527  
1528              <?php settings_fields( 'bbpress' ); ?>
1529  
1530              <?php do_settings_sections( 'bbpress' ); ?>
1531  
1532              <p class="submit">
1533                  <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'bbpress' ); ?>" />
1534              </p>
1535          </form>
1536      </div>
1537  
1538  <?php
1539  }
1540  
1541  /** Converter Section *********************************************************/
1542  
1543  /**
1544   * Main settings section description for the settings page
1545   *
1546   * @since 2.1.0 bbPress (r3813)
1547   */
1548  function bbp_converter_setting_callback_main_section() {
1549  ?>
1550  
1551      <p><?php _e( 'Information about the database for your previous forums so they can be converted.', 'bbpress' ); ?></p>
1552  
1553  <?php
1554  }
1555  
1556  /**
1557   * Edit Platform setting field
1558   *
1559   * @since 2.1.0 bbPress (r3813)
1560   */
1561  function bbp_converter_setting_callback_platform() {
1562  
1563      // Converters
1564      $current    = get_option( '_bbp_converter_platform' );
1565      $converters = bbp_get_converters();
1566      $options    = '';
1567  
1568      // Put options together
1569      foreach ( $converters as $name => $file ) {
1570          $options .= '<option value="' . esc_attr( $name ) . '"' . selected( $name, $current, false ) . '>' . esc_html( $name ) . '</option>';
1571      } ?>
1572  
1573      <select name="_bbp_converter_platform" id="_bbp_converter_platform"><?php echo $options; ?></select>
1574      <p class="description"><?php esc_html_e( 'The previous forum software', 'bbpress' ); ?></p>
1575  
1576  <?php
1577  }
1578  
1579  /**
1580   * Edit Database Server setting field
1581   *
1582   * @since 2.1.0 bbPress (r3813)
1583   */
1584  function bbp_converter_setting_callback_dbserver() {
1585  ?>
1586  
1587      <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' ); ?> />
1588      <p class="description"><?php printf( esc_html__( 'Use default %s if same server, or IP or hostname', 'bbpress' ), '<code>localhost</code>' ); ?></p>
1589  
1590  <?php
1591  }
1592  
1593  /**
1594   * Edit Database Server Port setting field
1595   *
1596   * @since 2.1.0 bbPress (r3813)
1597   */
1598  function bbp_converter_setting_callback_dbport() {
1599  ?>
1600  
1601      <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' ); ?> />
1602      <p class="description"><?php printf( esc_html__( 'Use default %s if unsure', 'bbpress' ), '<code>3306</code>' ); ?></p>
1603  
1604  <?php
1605  }
1606  
1607  /**
1608   * Edit Database User setting field
1609   *
1610   * @since 2.1.0 bbPress (r3813)
1611   */
1612  function bbp_converter_setting_callback_dbuser() {
1613  ?>
1614  
1615      <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' ); ?> />
1616      <p class="description"><?php esc_html_e( 'User to access the database', 'bbpress' ); ?></p>
1617  
1618  <?php
1619  }
1620  
1621  /**
1622   * Edit Database Pass setting field
1623   *
1624   * @since 2.1.0 bbPress (r3813)
1625   */
1626  function bbp_converter_setting_callback_dbpass() {
1627  ?>
1628  
1629      <span class="bbp-converter-db-password-wrapper">
1630          <input name="_bbp_converter_db_pass" id="_bbp_converter_db_pass" class="bbp-converter-db-pass code" type="password" value="<?php bbp_form_option( '_bbp_converter_db_pass' ); ?>" autocomplete="off" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_pass' ); ?> />
1631          <button type="button" class="bbp-db-pass-toggle password">
1632              <span class="screen-reader-text"><?php esc_html_e( 'Toggle', 'bbpress' ); ?></span>
1633              <span class="toggle-indicator" aria-hidden="true"></span>
1634          </button>
1635      </span>
1636      <p class="description"><?php esc_html_e( 'Password for the above database user', 'bbpress' ); ?></p>
1637  
1638  <?php
1639  }
1640  
1641  /**
1642   * Edit Database Name setting field
1643   *
1644   * @since 2.1.0 bbPress (r3813)
1645   */
1646  function bbp_converter_setting_callback_dbname() {
1647  ?>
1648  
1649      <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' ); ?> />
1650      <p class="description"><?php esc_html_e( 'Name of the database with your old forum data', 'bbpress' ); ?></p>
1651  
1652  <?php
1653  }
1654  
1655  /**
1656   * Main settings section description for the settings page
1657   *
1658   * @since 2.1.0 bbPress (r3813)
1659   */
1660  function bbp_converter_setting_callback_options_section() {
1661  ?>
1662  
1663      <p><?php esc_html_e( 'Some optional parameters to help tune the conversion process.', 'bbpress' ); ?></p>
1664  
1665  <?php
1666  }
1667  
1668  /**
1669   * Edit Table Prefix setting field
1670   *
1671   * @since 2.1.0 bbPress (r3813)
1672   */
1673  function bbp_converter_setting_callback_dbprefix() {
1674  ?>
1675  
1676      <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' ); ?> />
1677      <p class="description"><?php printf( esc_html__( 'Use %s if converting from BuddyPress Legacy', 'bbpress' ), '<code>wp_bb_</code>' ); ?></p>
1678  
1679  <?php
1680  }
1681  
1682  /**
1683   * Edit Rows Limit setting field
1684   *
1685   * @since 2.1.0 bbPress (r3813)
1686   */
1687  function bbp_converter_setting_callback_rows() {
1688  ?>
1689  
1690      <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' ); ?> />
1691      <label for="_bbp_converter_rows"><?php esc_html_e( 'entry maximum when querying for data to convert', 'bbpress' ); ?></label>
1692      <p class="description"><?php esc_html_e( 'Keep this low if you experience out-of-memory issues.', 'bbpress' ); ?></p>
1693  
1694  <?php
1695  }
1696  
1697  /**
1698   * Edit Delay Time setting field
1699   *
1700   * @since 2.1.0 bbPress (r3813)
1701   */
1702  function bbp_converter_setting_callback_delay_time() {
1703  ?>
1704  
1705      <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' ); ?> />
1706      <label for="_bbp_converter_delay_time"><?php esc_html_e( 'second delay between each query of rows above', 'bbpress' ); ?></label>
1707      <p class="description"><?php esc_html_e( 'Keep this high to prevent too-many-connection issues.', 'bbpress' ); ?></p>
1708  
1709  <?php
1710  }
1711  
1712  /**
1713   * Edit Halt setting field
1714   *
1715   * @since 2.6.0 bbPress (r6599)
1716   */
1717  function bbp_converter_setting_callback_halt() {
1718  ?>
1719  
1720      <input name="_bbp_converter_halt" id="_bbp_converter_halt" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_halt', false ) ); ?> />
1721      <label for="_bbp_converter_halt"><?php esc_html_e( 'Halt the conversion if an error occurs', 'bbpress' ); ?></label>
1722      <p class="description"><?php esc_html_e( 'This is helpful if you want to debug problems.', 'bbpress' ); ?></p>
1723  
1724  <?php
1725  }
1726  
1727  
1728  /**
1729   * Edit Restart setting field
1730   *
1731   * @since 2.1.0 bbPress (r3813)
1732   */
1733  function bbp_converter_setting_callback_restart() {
1734  ?>
1735  
1736      <input name="_bbp_converter_restart" id="_bbp_converter_restart" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_restart', false ) ); ?> />
1737      <label for="_bbp_converter_restart"><?php esc_html_e( 'Restart the converter from the beginning', 'bbpress' ); ?></label>
1738      <p class="description"><?php esc_html_e( 'This forces all steps back to 0. Avoid duplicate data by purging or resetting first.', 'bbpress' ); ?></p>
1739  
1740  <?php
1741  }
1742  
1743  /**
1744   * Edit Clean setting field
1745   *
1746   * @since 2.1.0 bbPress (r3813)
1747   */
1748  function bbp_converter_setting_callback_clean() {
1749  ?>
1750  
1751      <input name="_bbp_converter_clean" id="_bbp_converter_clean" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_clean', false ) ); ?> />
1752      <label for="_bbp_converter_clean"><?php esc_html_e( 'Purge all meta-data from a previous import', 'bbpress' ); ?></label>
1753      <p class="description"><?php esc_html_e( 'Use this if an import failed, or you just want to remove the relationship data.', 'bbpress' ); ?></p>
1754  
1755  <?php
1756  }
1757  
1758  /**
1759   * Edit Convert Users setting field
1760   *
1761   * @since 2.1.0 bbPress (r3813)
1762   */
1763  function bbp_converter_setting_callback_convert_users() {
1764  ?>
1765  
1766      <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' ); ?> />
1767      <label for="_bbp_converter_convert_users"><?php esc_html_e( 'Import user accounts from previous forums', 'bbpress' ); ?></label>
1768      <p class="description"><?php esc_html_e( 'Passwords remain encrypted, and are converted as individual users log in.', 'bbpress' ); ?></p>
1769  
1770  <?php
1771  }
1772  
1773  /** Converter Page ************************************************************/
1774  
1775  /**
1776   * The main settings page
1777   *
1778   * @since 2.1.0 bbPress (r3186)
1779   */
1780  function bbp_converter_settings_page() {
1781  
1782      // Status
1783      $step = (int) get_option( '_bbp_converter_step', 0 );
1784      $max  = (int) bbp_admin()->converter->max_steps;
1785  
1786      // Starting or continuing?
1787      $status_text = ! empty( $step )
1788          ? sprintf( esc_html__( 'Up next: step %s', 'bbpress' ), $step )
1789          : esc_html__( 'Ready', 'bbpress' );
1790  
1791      // Starting or continuing?
1792      $start_text = ! empty( $step )
1793          ? esc_html__( 'Resume', 'bbpress' )
1794          : esc_html__( 'Start',  'bbpress' );
1795  
1796      // Starting or continuing?
1797      $progress_text = ! empty( $step )
1798          ? sprintf( esc_html__( 'Previously stopped at step %1$d of %2$d', 'bbpress' ), $step, $max )
1799          : esc_html__( 'Ready to go.', 'bbpress' ); ?>
1800  
1801      <div class="wrap">
1802          <h1 class="wp-heading-inline"><?php esc_html_e( 'Forum Tools', 'bbpress' ); ?></h1>
1803          <hr class="wp-header-end">
1804          <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( 'bbp-converter' ); ?></h2>
1805  
1806          <div class="bbp-converter-wrap">
1807              <div id="poststuff" class="bbp-converter-monitor-wrap">
1808                  <div id="post-body" class="metabox-holder columns-1">
1809                      <div id="postbox-container-1" class="postbox-container">
1810                          <div id="normal-sortables" class="meta-box-sortables ui-sortable">
1811                              <div id="bbp-converter-monitor" class="postbox">
1812                                  <button type="button" class="handlediv" aria-expanded="true">
1813                                      <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Import Status', 'bbpress' ); ?></span>
1814                                      <span class="toggle-indicator" aria-hidden="true"></span>
1815                                  </button>
1816                                  <h2 class="hndle ui-sortable-handle">
1817                                      <span><?php esc_html_e( 'Import Monitor', 'bbpress' ); ?></span>
1818                                      <span id="bbp-converter-status"><?php echo esc_html( $status_text ); ?></span>
1819                                      <span id="bbp-converter-step-percentage" class="bbp-progress-bar"></span>
1820                                      <span id="bbp-converter-total-percentage" class="bbp-progress-bar"></span>
1821                                  </h2>
1822                                  <div class="inside">
1823                                      <div id="bbp-converter-message" class="bbp-converter-log">
1824                                          <p><?php echo esc_html( $progress_text ); ?></p>
1825                                      </div>
1826                                  </div>
1827                                  <div class="actions">
1828                                      <input type="button" name="submit" class="button-primary" id="bbp-converter-start" value="<?php echo esc_attr( $start_text ); ?>" />
1829                                      <input type="button" name="submit" class="button-primary" id="bbp-converter-stop" value="<?php esc_attr_e( 'Pause', 'bbpress' ); ?>" />
1830                                      <span class="spinner" id="bbp-converter-spinner"></span>
1831                                  </div>
1832                              </div>
1833                          </div>
1834                      </div>
1835                  </div>
1836              </div>
1837  
1838              <form action="#" method="post" id="bbp-converter-settings" class="bbp-converter-settings-wrap"><?php
1839  
1840                  // Fields
1841                  settings_fields( 'converter' );
1842  
1843                  // Sections
1844                  do_settings_sections( 'converter' );
1845  
1846              ?></form>
1847          </div>
1848      </div>
1849  <?php
1850  }
1851  
1852  /** Helpers *******************************************************************/
1853  
1854  /**
1855   * Contextual help for Forums settings page
1856   *
1857   * @since 2.0.0 bbPress (r3119)
1858   */
1859  function bbp_admin_settings_help() {
1860  
1861      $current_screen = get_current_screen();
1862  
1863      // Bail if current screen could not be found
1864      if ( empty( $current_screen ) ) {
1865          return;
1866      }
1867  
1868      // Overview
1869      $current_screen->add_help_tab( array(
1870          'id'      => 'overview',
1871          'title'   => esc_html__( 'Overview', 'bbpress' ),
1872          'content' => '<p>' . esc_html__( 'This screen provides access to all of the Forums settings.',                          'bbpress' ) . '</p>' .
1873                       '<p>' . esc_html__( 'Please see the additional help tabs for more information on each individual section.', 'bbpress' ) . '</p>'
1874      ) );
1875  
1876      // Main Settings
1877      $current_screen->add_help_tab( array(
1878          'id'      => 'main_settings',
1879          'title'   => esc_html__( 'Main Settings', 'bbpress' ),
1880          'content' => '<p>' . esc_html__( 'The "Main Settings" section includes a number of options:', 'bbpress' ) . '</p>' .
1881                       '<p>' .
1882                          '<ul>' .
1883                              '<li>' . esc_html__( 'You can choose to lock a post after a certain number of minutes. "Locking post editing" will prevent the author from editing some amount of time after saving a post.',              'bbpress' ) . '</li>' .
1884                              '<li>' . esc_html__( '"Throttle time" is the amount of time required between posts from a single author. The higher the throttle time, the longer a user will need to wait between posting to the forum.', 'bbpress' ) . '</li>' .
1885                              '<li>' . esc_html__( 'Favorites are a way for users to save and later return to topics they favor. This is enabled by default.',                                                                           'bbpress' ) . '</li>' .
1886                              '<li>' . esc_html__( 'Subscriptions allow users to subscribe for notifications to topics that interest them. This is enabled by default.',                                                                 'bbpress' ) . '</li>' .
1887                              '<li>' . esc_html__( 'Topic-Tags allow users to filter topics between forums. This is enabled by default.',                                                                                                'bbpress' ) . '</li>' .
1888                              '<li>' . esc_html__( '"Anonymous Posting" allows guest users who do not have accounts on your site to both create topics as well as replies.',                                                             'bbpress' ) . '</li>' .
1889                              '<li>' . esc_html__( 'The Fancy Editor brings the luxury of the Visual editor and HTML editor from the traditional WordPress dashboard into your theme.',                                                  'bbpress' ) . '</li>' .
1890                              '<li>' . esc_html__( 'Auto-embed will embed the media content from a URL directly into the replies. For example: links to Flickr and YouTube.',                                                            'bbpress' ) . '</li>' .
1891                          '</ul>' .
1892                      '</p>' .
1893                      '<p>' . esc_html__( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'bbpress' ) . '</p>'
1894      ) );
1895  
1896      // Theme Package
1897      $current_screen->add_help_tab( array(
1898          'id'      => 'theme_packages',
1899          'title'   => esc_html__( 'Theme Packages', 'bbpress' ),
1900          'content' => '<p>' . esc_html__( 'The "Theme Packages" section allows you to choose which theme package should be used.', 'bbpress' ) . '</p>' .
1901                       '<p>' .
1902                          '<ul>' .
1903                              '<li>' . esc_html__( 'The "bbPress Default" package is installed by default.',      'bbpress' ) . '</li>' .
1904                              '<li>' . esc_html__( 'Some themes may choose to ignore this setting entirely.',     'bbpress' ) . '</li>' .
1905                              '<li>' . esc_html__( 'Packages can be stacked to allow for intelligent fallbacks.', 'bbpress' ) . '</li>' .
1906                          '</ul>' .
1907                      '</p>'
1908      ) );
1909  
1910      // Per Page
1911      $current_screen->add_help_tab( array(
1912          'id'      => 'per_page',
1913          'title'   => esc_html__( 'Per Page', 'bbpress' ),
1914          'content' => '<p>' . esc_html__( 'The "Per Page" section allows you to control the number of topics and replies appear on each page.',                                                    'bbpress' ) . '</p>' .
1915                          '<ul>' .
1916                              '<li>' . esc_html__( 'This is comparable to the WordPress "Reading Settings" page, where you can set the number of posts that should show on blog pages and in feeds.', 'bbpress' ) . '</li>' .
1917                              '<li>' . esc_html__( 'These are broken up into two separate groups: one for what appears in your theme, another for RSS feeds.',                                        'bbpress' ) . '</li>' .
1918                          '</ul>' .
1919                       '<p>'
1920      ) );
1921  
1922      // Slugs
1923      $current_screen->add_help_tab( array(
1924          'id'      => 'slugs',
1925          'title'   => esc_html__( 'Slugs', 'bbpress' ),
1926          'content' => '<p>' . esc_html__( 'The "Slugs" section allows you to control the permalink structure for your forums.',                                                                                                            'bbpress' ) . '</p>' .
1927                          '<ul>' .
1928                              '<li>' . esc_html__( '"Archive Slugs" are used as the "root" for your forums and topics. If you combine these values with existing page slugs, bbPress will attempt to output the most correct title and content.', 'bbpress' ) . '</li>' .
1929                              '<li>' . esc_html__( '"Single Slugs" are used as a prefix when viewing an individual forum, topic, reply, user, or view.',                                                                                          'bbpress' ) . '</li>' .
1930                              '<li>' . esc_html__( 'In the event of a slug collision with WordPress or BuddyPress, a warning will appear next to the problem slug(s).', 'bbpress' ) . '</li>' .
1931                          '</ul>' .
1932                       '<p>'
1933      ) );
1934  
1935      // Help Sidebar
1936      $current_screen->set_help_sidebar(
1937          '<p><strong>' . esc_html__( 'For more information:', 'bbpress' ) . '</strong></p>' .
1938          '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>',    'bbpress' ) . '</p>' .
1939          '<p>' . __( '<a href="https://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>'
1940      );
1941  }
1942  
1943  /**
1944   * Disable a settings field if it is forcibly set in the global options array.
1945   *
1946   * @since 2.2.0 bbPress (r4347)
1947   *
1948   * @param string $option_key
1949   */
1950  function bbp_maybe_admin_setting_disabled( $option_key = '' ) {
1951      disabled( isset( bbpress()->options[ $option_key ] ) );
1952  }
1953  
1954  /**
1955   * Output settings API option
1956   *
1957   * @since 2.0.0 bbPress (r3203)
1958   *
1959   * @param string $option
1960   * @param string $default
1961   * @param bool $slug
1962   */
1963  function bbp_form_option( $option, $default = '', $slug = false ) {
1964      echo bbp_get_form_option( $option, $default, $slug );
1965  }
1966      /**
1967       * Return settings API option
1968       *
1969       * @since 2.0.0 bbPress (r3203)
1970       *
1971       * @param string $option
1972       * @param string $default
1973       * @param bool   $is_slug
1974       *
1975       * @return mixed
1976       */
1977  	function bbp_get_form_option( $option, $default = '', $is_slug = false ) {
1978  
1979          // Get the option and sanitize it
1980          $value = get_option( $option, $default );
1981  
1982          // Slug?
1983          if ( true === $is_slug ) {
1984              $value = esc_attr( apply_filters( 'editable_slug', $value ) );
1985  
1986          // Not a slug
1987          } else {
1988              $value = esc_attr( $value );
1989          }
1990  
1991          // Fallback to default
1992          if ( empty( $value ) ) {
1993              $value = $default;
1994          }
1995  
1996          // Filter & return
1997          return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug );
1998      }
1999  
2000  /**
2001   * Used to check if a bbPress slug conflicts with an existing known slug.
2002   *
2003   * @since 2.0.0 bbPress (r3306)
2004   *
2005   * @param string $slug
2006   * @param string $default
2007   */
2008  function bbp_form_slug_conflict_check( $slug, $default ) {
2009  
2010      // Only set the slugs once ver page load
2011      static $the_core_slugs = array();
2012  
2013      // Get the form value
2014      $this_slug = bbp_get_form_option( $slug, $default, true );
2015  
2016      if ( empty( $the_core_slugs ) ) {
2017  
2018          // Slugs to check
2019          $core_slugs = apply_filters( 'bbp_slug_conflict_check', array(
2020  
2021              /** WordPress Core ****************************************************/
2022  
2023              // Core Post Types
2024              'post_base'       => array( 'name' => esc_html__( 'Posts',         'bbpress' ), 'default' => 'post',          'context' => 'WordPress' ),
2025              'page_base'       => array( 'name' => esc_html__( 'Pages',         'bbpress' ), 'default' => 'page',          'context' => 'WordPress' ),
2026              'revision_base'   => array( 'name' => esc_html__( 'Revisions',     'bbpress' ), 'default' => 'revision',      'context' => 'WordPress' ),
2027              'attachment_base' => array( 'name' => esc_html__( 'Attachments',   'bbpress' ), 'default' => 'attachment',    'context' => 'WordPress' ),
2028              'nav_menu_base'   => array( 'name' => esc_html__( 'Menus',         'bbpress' ), 'default' => 'nav_menu_item', 'context' => 'WordPress' ),
2029  
2030              // Post Tags
2031              'tag_base'        => array( 'name' => esc_html__( 'Tag base',      'bbpress' ), 'default' => 'tag',           'context' => 'WordPress' ),
2032  
2033              // Post Categories
2034              'category_base'   => array( 'name' => esc_html__( 'Category base', 'bbpress' ), 'default' => 'category',      'context' => 'WordPress' ),
2035  
2036              /** bbPress Core ******************************************************/
2037  
2038              // Forum archive slug
2039              '_bbp_root_slug'          => array( 'name' => esc_html__( 'Forums base', 'bbpress' ), 'default' => 'forums', 'context' => 'bbPress' ),
2040  
2041              // Topic archive slug
2042              '_bbp_topic_archive_slug' => array( 'name' => esc_html__( 'Topics base', 'bbpress' ), 'default' => 'topics', 'context' => 'bbPress' ),
2043  
2044              // Forum slug
2045              '_bbp_forum_slug'         => array( 'name' => esc_html__( 'Forum slug',  'bbpress' ), 'default' => 'forum',  'context' => 'bbPress' ),
2046  
2047              // Topic slug
2048              '_bbp_topic_slug'         => array( 'name' => esc_html__( 'Topic slug',  'bbpress' ), 'default' => 'topic',  'context' => 'bbPress' ),
2049  
2050              // Reply slug
2051              '_bbp_reply_slug'         => array( 'name' => esc_html__( 'Reply slug',  'bbpress' ), 'default' => 'reply',  'context' => 'bbPress' ),
2052  
2053              // Edit slug
2054              '_bbp_edit_slug'          => array( 'name' => esc_html__( 'Edit slug',   'bbpress' ), 'default' => 'edit',   'context' => 'bbPress' ),
2055  
2056              // User profile slug
2057              '_bbp_user_slug'          => array( 'name' => esc_html__( 'User base',   'bbpress' ), 'default' => 'users',  'context' => 'bbPress' ),
2058  
2059              // View slug
2060              '_bbp_view_slug'          => array( 'name' => esc_html__( 'View base',   'bbpress' ), 'default' => 'view',   'context' => 'bbPress' ),
2061  
2062              // Topic tag slug
2063              '_bbp_topic_tag_slug'     => array( 'name' => esc_html__( 'Topic tag slug', 'bbpress' ), 'default' => 'topic-tag', 'context' => 'bbPress' ),
2064          ) );
2065  
2066          /** BuddyPress Core *******************************************************/
2067  
2068          if ( defined( 'BP_VERSION' ) ) {
2069              $bp = buddypress();
2070  
2071              // Loop through root slugs and check for conflict
2072              if ( ! empty( $bp->pages ) ) {
2073                  foreach ( $bp->pages as $page => $page_data ) {
2074                      $page_base    = $page . '_base';
2075                      $page_title   = sprintf( esc_html__( '%s page', 'bbpress' ), $page_data->title );
2076                      $core_slugs[ $page_base ] = array(
2077                          'name'    => $page_title,
2078                          'default' => $page_data->slug,
2079                          'context' => 'BuddyPress'
2080                      );
2081                  }
2082              }
2083          }
2084  
2085          // Set the static
2086          $the_core_slugs = apply_filters( 'bbp_slug_conflict', $core_slugs );
2087      }
2088  
2089      // Loop through slugs to check
2090      foreach ( $the_core_slugs as $key => $value ) {
2091  
2092          // Get the slug
2093          $slug_check = bbp_get_form_option( $key, $value['default'], true );
2094  
2095          // Compare
2096          if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) : ?>
2097  
2098              <span class="attention"><?php printf( esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ), $value['context'], '<strong>' . $value['name'] . '</strong>' ); ?></span>
2099  
2100          <?php endif;
2101      }
2102  }


Generated: Thu Jul 9 01:01:21 2020 Cross-referenced by PHPXref 0.7.1