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


Generated: Mon Jul 22 01:01:32 2019 Cross-referenced by PHPXref 0.7.1