[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/core/ -> options.php (source)

   1  <?php
   2  
   3  /**
   4   * bbPress Options
   5   *
   6   * @package bbPress
   7   * @subpackage Core
   8   */
   9  
  10  // Exit if accessed directly
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Get the default site options and their values.
  15   *
  16   * These option
  17   *
  18   * @since 2.0.0 bbPress (r3421)
  19   *
  20   * @return array Filtered option names and values
  21   */
  22  function bbp_get_default_options() {
  23      static $options = null;
  24  
  25      // Store these to avoid recreating them
  26      if ( is_null( $options ) ) {
  27  
  28          // Use the participant role for the default-default role
  29          $role    = bbp_get_participant_role();
  30          $options = array(
  31  
  32              /** DB Version ********************************************************/
  33  
  34              '_bbp_db_version'             => 0,         // Database version
  35              '_bbp_db_pending_upgrades'    => array(),   // Database upgrades pending
  36  
  37              /** Flags *************************************************************/
  38  
  39              '_bbp_flag_initial_content'   => 1,         // Flag to indicate initial content was created
  40  
  41              /** Features **********************************************************/
  42  
  43              '_bbp_enable_favorites'       => 1,         // Enable favorites
  44              '_bbp_enable_subscriptions'   => 1,         // Enable subscriptions
  45              '_bbp_enable_engagements'     => 1,         // Enable engagements
  46              '_bbp_allow_content_edit'     => 1,         // Allow content edit
  47              '_bbp_allow_content_throttle' => 1,         // Allow content throttle
  48              '_bbp_allow_revisions'        => 1,         // Allow revisions
  49              '_bbp_allow_topic_tags'       => 1,         // Allow topic tagging
  50              '_bbp_allow_search'           => 1,         // Allow forum-wide search
  51              '_bbp_allow_forum_mods'       => 1,         // Allow per-forum moderation
  52              '_bbp_allow_global_access'    => 1,         // Allow users from all sites to post
  53              '_bbp_allow_anonymous'        => 0,         // Allow anonymous posting
  54              '_bbp_allow_super_mods'       => 0,         // Allow mods to edit users
  55              '_bbp_allow_threaded_replies' => 0,         // Allow threaded replies
  56              '_bbp_use_wp_editor'          => 1,         // Use the WordPress editor if available
  57              '_bbp_use_autoembed'          => 0,         // Use oEmbed in topics and replies
  58  
  59              /** Settings **********************************************************/
  60  
  61              '_bbp_default_role'           => $role,     // Default forums role
  62              '_bbp_edit_lock'              => 5,         // Lock post editing after 5 minutes
  63              '_bbp_throttle_time'          => 10,        // Throttle post time to 10 seconds
  64              '_bbp_thread_replies_depth'   => 2,         // Thread replies depth
  65              '_bbp_theme_package_id'       => 'default', // The ID for the current theme package
  66              '_bbp_settings_integration'   => 'basic',   // How to integrate into wp-admin
  67              '_bbp_engagements_strategy'   => 'meta',    // How to interact with engagements
  68  
  69              /** Per Page **********************************************************/
  70  
  71              '_bbp_topics_per_page'      => 15,          // Topics per page
  72              '_bbp_replies_per_page'     => 15,          // Replies per page
  73              '_bbp_forums_per_page'      => 50,          // Forums per page
  74              '_bbp_topics_per_rss_page'  => 25,          // Topics per RSS page
  75              '_bbp_replies_per_rss_page' => 25,          // Replies per RSS page
  76  
  77              /** Page For **********************************************************/
  78  
  79              '_bbp_page_for_forums'      => 0,           // Page for forums
  80              '_bbp_page_for_topics'      => 0,           // Page for forums
  81              '_bbp_page_for_login'       => 0,           // Page for login
  82              '_bbp_page_for_register'    => 0,           // Page for register
  83              '_bbp_page_for_lost_pass'   => 0,           // Page for lost-pass
  84  
  85              /** Forum Root ********************************************************/
  86  
  87              '_bbp_root_slug'            => 'forums',    // Forum archive slug
  88              '_bbp_show_on_root'         => 'forums',    // What to show on root (forums|topics)
  89              '_bbp_include_root'         => 1,           // Include forum-archive before single slugs
  90  
  91              /** Single Slugs ******************************************************/
  92  
  93              '_bbp_forum_slug'           => 'forum',     // Forum slug
  94              '_bbp_topic_slug'           => 'topic',     // Topic slug
  95              '_bbp_reply_slug'           => 'reply',     // Reply slug
  96              '_bbp_topic_tag_slug'       => 'topic-tag', // Topic tag slug
  97  
  98              /** User Slugs ********************************************************/
  99  
 100              '_bbp_user_slug'            => 'users',         // User profile slug
 101              '_bbp_user_engs_slug'       => 'engagements',   // User engagements slug
 102              '_bbp_user_favs_slug'       => 'favorites',     // User favorites slug
 103              '_bbp_user_subs_slug'       => 'subscriptions', // User subscriptions slug
 104              '_bbp_topic_archive_slug'   => 'topics',        // Topic archive slug
 105              '_bbp_reply_archive_slug'   => 'replies',       // Reply archive slug
 106  
 107              /** Other Slugs *******************************************************/
 108  
 109              '_bbp_view_slug'            => 'view',      // View slug
 110              '_bbp_search_slug'          => 'search',    // Search slug
 111  
 112              /** Topics ************************************************************/
 113  
 114              '_bbp_title_max_length'     => 80,          // Title Max Length
 115              '_bbp_super_sticky_topics'  => '',          // Super stickies
 116  
 117              /** Forums ************************************************************/
 118  
 119              '_bbp_private_forums'       => '',          // Private forums
 120              '_bbp_hidden_forums'        => '',          // Hidden forums
 121  
 122              /** BuddyPress ********************************************************/
 123  
 124              '_bbp_enable_group_forums'  => 1,           // Enable BuddyPress Group Extension
 125              '_bbp_group_forums_root_id' => 0,           // Group Forums parent forum id
 126  
 127              /** Akismet ***********************************************************/
 128  
 129              '_bbp_enable_akismet'       => 1,           // Users from all sites can post
 130  
 131              /** Converter *********************************************************/
 132  
 133              // Connection
 134              '_bbp_converter_db_user'    => '',          // Database User
 135              '_bbp_converter_db_pass'    => '',          // Database Password
 136              '_bbp_converter_db_name'    => '',          // Database Name
 137              '_bbp_converter_db_port'    => 3306,        // Database Port
 138              '_bbp_converter_db_server'  => 'localhost', // Database Server/IP
 139              '_bbp_converter_db_prefix'  => '',          // Database table prefix
 140  
 141              // Options
 142              '_bbp_converter_rows'          => 100,      // Number of rows to query
 143              '_bbp_converter_delay_time'    => 2,        // Seconds to wait between queries
 144              '_bbp_converter_step'          => false,    // Current converter step
 145              '_bbp_converter_start'         => false,    // Step to start at
 146              '_bbp_converter_convert_users' => false,    // Whether to convert users
 147              '_bbp_converter_halt'          => false,    // Halt on errors
 148              '_bbp_converter_platform'      => false,    // Which platform to use
 149              '_bbp_converter_query'         => false     // Last query
 150          );
 151      }
 152  
 153      // Filter & return
 154      return (array) apply_filters( 'bbp_get_default_options', $options );
 155  }
 156  
 157  /**
 158   * Add default options
 159   *
 160   * Hooked to bbp_activate, it is only called once when bbPress is activated.
 161   * This is non-destructive, so existing settings will not be overridden.
 162   *
 163   * @since 2.0.0 bbPress (r3421)
 164   */
 165  function bbp_add_options() {
 166  
 167      // Add default options
 168      foreach ( bbp_get_default_options() as $key => $value ) {
 169          add_option( $key, $value );
 170      }
 171  
 172      // Allow previously activated plugins to append their own options.
 173      do_action( 'bbp_add_options' );
 174  }
 175  
 176  /**
 177   * Delete default options
 178   *
 179   * Hooked to bbp_uninstall, it is only called once when bbPress is uninstalled.
 180   * This is destructive, so existing settings will be destroyed.
 181   *
 182   * @since 2.0.0 bbPress (r3421)
 183   */
 184  function bbp_delete_options() {
 185  
 186      // Add default options
 187      foreach ( array_keys( bbp_get_default_options() ) as $key ) {
 188          delete_option( $key );
 189      }
 190  
 191      // Allow previously activated plugins to append their own options.
 192      do_action( 'bbp_delete_options' );
 193  }
 194  
 195  /**
 196   * Add filters to each bbPress option and allow them to be overloaded from
 197   * inside the $bbp->options array.
 198   *
 199   * @since 2.0.0 bbPress (r3451)
 200   */
 201  function bbp_setup_option_filters() {
 202  
 203      // Add filters to each bbPress option
 204      foreach ( array_keys( bbp_get_default_options() ) as $key ) {
 205          add_filter( 'pre_option_'     . $key, 'bbp_filter_pre_get_option', 10, 2 );
 206          add_filter( 'default_option_' . $key, 'bbp_filter_default_option', 10, 3 );
 207      }
 208  
 209      // Allow previously activated plugins to append their own options.
 210      do_action( 'bbp_setup_option_filters' );
 211  }
 212  
 213  /**
 214   * Filter pre options and maybe overloaded from the $bbp->options array.
 215   *
 216   * This function should not be called directly.
 217   *
 218   * @since 2.0.0 bbPress (r3451)
 219   * @access private
 220   *
 221   * @param bool   $value  Default value false
 222   * @param string $option Name of the option
 223   *
 224   * @return mixed false if not overloaded, mixed if set
 225   */
 226  function bbp_filter_pre_get_option( $value = false, $option = '' ) {
 227  
 228      // Check the options global for preset value
 229      if ( isset( bbpress()->options[ $option ] ) ) {
 230          $value = bbpress()->options[ $option ];
 231      }
 232  
 233      // Always return a value, even if false
 234      return $value;
 235  }
 236  
 237  /**
 238   * Filter default_options set them from inside the $bbp->options array.
 239   *
 240   * This function should not be called directly.
 241   *
 242   * @since 2.6.0 bbPress (r3451)
 243   * @access private
 244   *
 245   * @param bool $value Optional. Default value false
 246   * @return mixed false if not overloaded, mixed if set
 247   */
 248  function bbp_filter_default_option( $default = false, $option = '', $passed_default = false ) {
 249      $options = bbp_get_default_options();
 250  
 251      // Maybe use the default value
 252      if ( isset( $options[ $option ] ) ) {
 253  
 254          // Try to use the passed default and fallback to assumed default
 255          $default = ( true === $passed_default )
 256              ? $default
 257              : $options[ $option ];
 258      }
 259  
 260      // Always return a value, even if false
 261      return $default;
 262  }
 263  
 264  /**
 265   * Loads & caches bbPress options if a persistent cache is not being used.
 266   *
 267   * @since 2.6.0
 268   */
 269  function bbp_pre_load_options() {
 270  
 271      // Bail if using object cache or installing
 272      if ( wp_using_ext_object_cache() || wp_installing() ) {
 273          return;
 274      }
 275  
 276      // Maybe intercept
 277      $strategy  = apply_filters( 'bbp_pre_load_options_strategy', 'notoptions' );
 278      $intercept = bbp_maybe_intercept( __FUNCTION__, $strategy );
 279      if ( bbp_is_intercepted( $intercept ) ) {
 280          return $intercept;
 281      }
 282  
 283      // Get variables
 284      $bbp         = bbpress();
 285      $bbp_options = bbp_get_default_options();
 286      $all_options = wp_load_alloptions();
 287      $not_options = (array) wp_cache_get( 'notoptions', 'options' );
 288  
 289      // Loop through all bbPress options to maybe cache their non-existence
 290      foreach ( $bbp_options as $option => $value ) {
 291  
 292          // Skip if already saved to database
 293          if ( isset( $all_options[ $option ] ) ) {
 294              continue;
 295  
 296          // Skip if overloaded
 297          } elseif ( isset( $bbp->options[ $option ] ) ) {
 298              continue;
 299  
 300          // Skip if already in cache
 301          } elseif ( wp_cache_get( $option, 'options' ) !== false ) {
 302              continue;
 303  
 304          // Needs caching to avoid database hit
 305          } else {
 306  
 307              // Store internally, for easier identification later
 308              $bbp->not_options[ $option ] = $value;
 309  
 310              // Cache to notoptions
 311              if ( 'notoptions' === $strategy ) {
 312                  $not_options[ $option ] = true;
 313                  wp_cache_set( 'notoptions', $not_options, 'options' );
 314  
 315              // Cache to option
 316              } elseif ( 'option' === $strategy ) {
 317                  wp_cache_set( $option, $value, 'options' );
 318              }
 319          }
 320      }
 321  }
 322  
 323  /** Active? *******************************************************************/
 324  
 325  /**
 326   * Checks if favorites feature is enabled.
 327   *
 328   * @since 2.0.0 bbPress (r2658)
 329   *
 330   * @param bool $default Optional.Default value true
 331   * @return bool Is favorites enabled or not
 332   */
 333  function bbp_is_favorites_active( $default = 1 ) {
 334  
 335      // Filter & return
 336      return (bool) apply_filters( 'bbp_is_favorites_active', (bool) get_option( '_bbp_enable_favorites', $default ) );
 337  }
 338  
 339  /**
 340   * Checks if subscription feature is enabled.
 341   *
 342   * @since 2.0.0 bbPress (r2658)
 343   *
 344   * @param bool $default Optional.Default value true
 345   * @return bool Is subscription enabled or not
 346   */
 347  function bbp_is_subscriptions_active( $default = 1 ) {
 348  
 349      // Filter & return
 350      return (bool) apply_filters( 'bbp_is_subscriptions_active', (bool) get_option( '_bbp_enable_subscriptions', $default ) );
 351  }
 352  
 353  /**
 354   * Checks if engagements feature is enabled.
 355   *
 356   * @since 2.6.0 bbPress (r6320)
 357   *
 358   * @param bool $default Optional.Default value true
 359   * @return bool Is engagements enabled or not
 360   */
 361  function bbp_is_engagements_active( $default = 1 ) {
 362  
 363      // Filter & return
 364      return (bool) apply_filters( 'bbp_is_engagements_active', (bool) get_option( '_bbp_enable_engagements', $default ) );
 365  }
 366  
 367  /**
 368   * Is content editing available when posting new topics & replies?
 369   *
 370   * @since 2.6.0 bbPress (r6441)
 371   *
 372   * @param bool $default Optional. Default value false
 373   * @return bool Is content editing allowed?
 374   */
 375  function bbp_allow_content_edit( $default = 1 ) {
 376  
 377      // Filter & return
 378      return (bool) apply_filters( 'bbp_allow_content_edit', (bool) get_option( '_bbp_allow_content_edit', $default ) );
 379  }
 380  
 381  /**
 382   * Is content throttling engaged when posting new topics & replies?
 383   *
 384   * @since 2.6.0 bbPress (r6441)
 385   *
 386   * @param bool $default Optional. Default value false
 387   * @return bool Is content throttling allowed?
 388   */
 389  function bbp_allow_content_throttle( $default = 1 ) {
 390  
 391      // Filter & return
 392      return (bool) apply_filters( 'bbp_allow_content_throttle', (bool) get_option( '_bbp_allow_content_throttle', $default ) );
 393  }
 394  
 395  /**
 396   * Are topic tags allowed
 397   *
 398   * @since 2.2.0 bbPress (r4097)
 399   *
 400   * @param bool $default Optional. Default value true
 401   * @return bool Are tags allowed?
 402   */
 403  function bbp_allow_topic_tags( $default = 1 ) {
 404  
 405      // Filter & return
 406      return (bool) apply_filters( 'bbp_allow_topic_tags', (bool) get_option( '_bbp_allow_topic_tags', $default ) );
 407  }
 408  
 409  /**
 410   * Are per-forum moderators allowed
 411   *
 412   * @since 2.6.0 bbPress (r5834)
 413   *
 414   * @param bool $default Optional. Default value true.
 415   *
 416   * @return bool Are per-forum moderators allowed?
 417   */
 418  function bbp_allow_forum_mods( $default = 1 ) {
 419  
 420      // Filter & return
 421      return (bool) apply_filters( 'bbp_allow_forum_mods', (bool) get_option( '_bbp_allow_forum_mods', $default ) );
 422  }
 423  
 424  /**
 425   * Are moderators allowed to edit users
 426   *
 427   * @since 2.6.0 bbPress (r6562)
 428   *
 429   * @param bool $default Optional. Default value true.
 430   *
 431   * @return bool Are moderators allowed to edit users?
 432   */
 433  function bbp_allow_super_mods( $default = 0 ) {
 434  
 435      // Filter & return
 436      return (bool) apply_filters( 'bbp_allow_super_mods', (bool) get_option( '_bbp_allow_super_mods', $default ) );
 437  }
 438  
 439  /**
 440   * Is forum-wide searching allowed
 441   *
 442   * @since 2.4.0 bbPress (r4970)
 443   *
 444   * @param bool $default Optional. Default value true
 445   * @return bool Is forum-wide searching allowed?
 446   */
 447  function bbp_allow_search( $default = 1 ) {
 448  
 449      // Filter & return
 450      return (bool) apply_filters( 'bbp_allow_search', (bool) get_option( '_bbp_allow_search', $default ) );
 451  }
 452  
 453  /**
 454   * Are threaded replies allowed
 455   *
 456   * @since 2.4.0 bbPress (r4964)
 457   *
 458   * @param bool $default Optional. Default value false
 459   * @return bool Are threaded replies allowed?
 460   */
 461  function bbp_allow_threaded_replies( $default = 0 ) {
 462  
 463      // Filter & return
 464      return (bool) apply_filters( '_bbp_allow_threaded_replies', (bool) get_option( '_bbp_allow_threaded_replies', $default ) );
 465  }
 466  
 467  /**
 468   * Maximum reply thread depth
 469   *
 470   * @since 2.4.0 bbPress (r4944)
 471   *
 472   * @param int $default Thread replies depth
 473   * @return int Thread replies depth
 474   */
 475  function bbp_thread_replies_depth( $default = 2 ) {
 476  
 477      // Filter & return
 478      return (int) apply_filters( 'bbp_thread_replies_depth', (int) get_option( '_bbp_thread_replies_depth', $default ) );
 479  }
 480  
 481  /**
 482   * Are topic and reply revisions allowed
 483   *
 484   * @since 2.0.0 bbPress (r3412)
 485   *
 486   * @param bool $default Optional. Default value true
 487   * @return bool Are revisions allowed?
 488   */
 489  function bbp_allow_revisions( $default = 1 ) {
 490  
 491      // Filter & return
 492      return (bool) apply_filters( 'bbp_allow_revisions', (bool) get_option( '_bbp_allow_revisions', $default ) );
 493  }
 494  
 495  /**
 496   * Is the anonymous posting allowed?
 497   *
 498   * @since 2.0.0 bbPress (r2659)
 499   *
 500   * @param bool $default Optional. Default value
 501   * @return bool Is anonymous posting allowed?
 502   */
 503  function bbp_allow_anonymous( $default = 0 ) {
 504  
 505      // Filter & return
 506      return apply_filters( 'bbp_allow_anonymous', (bool) get_option( '_bbp_allow_anonymous', $default ) );
 507  }
 508  
 509  /**
 510   * Is this forum available to all users on all sites in this installation?
 511   *
 512   * @since 2.0.0 bbPress (r3378)
 513   *
 514   * @param bool $default Optional. Default value false
 515   * @return bool Is global access allowed?
 516   */
 517  function bbp_allow_global_access( $default = 1 ) {
 518  
 519      // Filter & return
 520      return (bool) apply_filters( 'bbp_allow_global_access', (bool) get_option( '_bbp_allow_global_access', $default ) );
 521  }
 522  
 523  /**
 524   * Get the default forums role (issued to users on their first visit to the
 525   * forums) by bbp_set_current_user_default_role() and repair tools
 526   *
 527   * @since 2.2.0 bbPress (r4294)
 528   *
 529   * @param string $default Optional. Default value empty
 530   * @return string The default forums user role
 531   */
 532  function bbp_get_default_role( $default = 'bbp_participant' ) {
 533  
 534      // Filter & return
 535      return apply_filters( 'bbp_get_default_role', get_option( '_bbp_default_role', $default ) );
 536  }
 537  
 538  /**
 539   * Use the WordPress editor if available
 540   *
 541   * @since 2.0.0 bbPress (r3386)
 542   *
 543   * @param bool $default Optional. Default value true
 544   * @return bool Use WP editor?
 545   */
 546  function bbp_use_wp_editor( $default = 1 ) {
 547  
 548      // Filter & return
 549      return (bool) apply_filters( 'bbp_use_wp_editor', (bool) get_option( '_bbp_use_wp_editor', $default ) );
 550  }
 551  
 552  /**
 553   * Use WordPress's oEmbed API
 554   *
 555   * @since 2.1.0 bbPress (r3752)
 556   *
 557   * @param bool $default Optional. Default value true
 558   * @return bool Use oEmbed?
 559   */
 560  function bbp_use_autoembed( $default = 1 ) {
 561  
 562      // Filter & return
 563      return (bool) apply_filters( 'bbp_use_autoembed', (bool) get_option( '_bbp_use_autoembed', $default ) );
 564  }
 565  
 566  /**
 567   * Get the current theme package ID
 568   *
 569   * @since 2.1.0 bbPress (r3829)
 570   *
 571   * @param string $default Optional. Default value 'default'
 572   * @return string ID of the theme-package
 573   */
 574  function bbp_get_theme_package_id( $default = 'default' ) {
 575  
 576      // Filter & return
 577      return apply_filters( 'bbp_get_theme_package_id', get_option( '_bbp_theme_package_id', $default ) );
 578  }
 579  
 580  /**
 581   * Output the maximum length of a title
 582   *
 583   * @since 2.0.0 bbPress (r3246)
 584   *
 585   * @param bool $default Optional. Default value 80
 586   */
 587  function bbp_title_max_length( $default = 80 ) {
 588      echo bbp_get_title_max_length( $default );
 589  }
 590      /**
 591       * Return the maximum length of a title
 592       *
 593       * @since 2.0.0 bbPress (r3246)
 594       *
 595       * @param bool $default Optional. Default value 80
 596       * @return int Is anonymous posting allowed?
 597       */
 598  	function bbp_get_title_max_length( $default = 80 ) {
 599  
 600          // Filter & return
 601          return (int) apply_filters( 'bbp_get_title_max_length', (int) get_option( '_bbp_title_max_length', $default ) );
 602      }
 603  
 604  /**
 605   * Output the number of minutes a topic or reply can be edited after it's
 606   * published. Used by `bbp_past_edit_lock()`.
 607   *
 608   * @since 2.6.0 bbPress (r6868)
 609   *
 610   * @param bool $default Optional. Default value 5
 611   */
 612  function bbp_edit_lock( $default = 5 ) {
 613      echo bbp_get_edit_lock( $default );
 614  }
 615      /**
 616       * Return the number of minutes a topic or reply can be edited after it's
 617       * published. Used by `bbp_past_edit_lock()`.
 618       *
 619       * @since 2.6.0 bbPress (r6868)
 620       *
 621       * @param bool $default Optional. Default value 5
 622       * @return int Is anonymous posting allowed?
 623       */
 624  	function bbp_get_edit_lock( $default = 5 ) {
 625  
 626          // Filter & return
 627          return (int) apply_filters( 'bbp_get_edit_lock', (int) get_option( '_bbp_edit_lock', $default ) );
 628      }
 629  
 630  /**
 631   * Output the group forums root parent forum id
 632   *
 633   * @since 2.1.0 bbPress (r3575)
 634   *
 635   * @param int $default Optional. Default value
 636   */
 637  function bbp_group_forums_root_id( $default = 0 ) {
 638      echo bbp_get_group_forums_root_id( $default );
 639  }
 640      /**
 641       * Return the group forums root parent forum id
 642       *
 643       * @since 2.1.0 bbPress (r3575)
 644       *
 645       * @param bool $default Optional. Default value 0
 646       * @return int The post ID for the root forum
 647       */
 648  	function bbp_get_group_forums_root_id( $default = 0 ) {
 649  
 650          // Filter & return
 651          return (int) apply_filters( 'bbp_get_group_forums_root_id', (int) get_option( '_bbp_group_forums_root_id', $default ) );
 652      }
 653  
 654  /**
 655   * Checks if BuddyPress Group Forums are enabled
 656   *
 657   * @since 2.1.0 bbPress (r3575)
 658   *
 659   * @param bool $default Optional. Default value true
 660   * @return bool Is group forums enabled or not
 661   */
 662  function bbp_is_group_forums_active( $default = 1 ) {
 663  
 664      // Filter & return
 665      return (bool) apply_filters( 'bbp_is_group_forums_active', (bool) get_option( '_bbp_enable_group_forums', $default ) );
 666  }
 667  
 668  /**
 669   * Checks if Akismet is enabled
 670   *
 671   * @since 2.1.0 bbPress (r3575)
 672   *
 673   * @param bool $default Optional. Default value true
 674   * @return bool Is Akismet enabled or not
 675   */
 676  function bbp_is_akismet_active( $default = 1 ) {
 677  
 678      // Filter & return
 679      return (bool) apply_filters( 'bbp_is_akismet_active', (bool) get_option( '_bbp_enable_akismet', $default ) );
 680  }
 681  
 682  /**
 683   * Integrate settings into existing WordPress pages
 684   *
 685   * There are 3 possible modes:
 686   * - 'basic'   Traditional admin integration
 687   * - 'compact' One "bbPress" top-level admin menu
 688   * - 'deep'    Deeply integrate with the WordPress admin interface
 689   *
 690   * @since 2.4.0 bbPress (r4932)
 691   *
 692   * @param bool $default Optional. Default value false
 693   * @return string How to integrate settings
 694   */
 695  function bbp_settings_integration( $default = 'basic' ) {
 696  
 697      // Get the option value
 698      $integration = get_option( '_bbp_settings_integration', $default );
 699  
 700      // Back-compat for deep/basic (pre-2.6)
 701      if ( is_numeric( $integration ) ) {
 702          $integration = ( 1 === (int) $integration )
 703              ? 'deep'
 704              : 'basic';
 705      }
 706  
 707      // Fallback to 'basic' if invalid
 708      if ( ! in_array( $integration, array( 'basic', 'deep', 'compact' ), true ) ) {
 709          $integration = 'basic';
 710      }
 711  
 712      // Filter & return
 713      return apply_filters( 'bbp_settings_integration', $integration, $default );
 714  }
 715  
 716  /**
 717   * How to interact with engagements
 718   *
 719   * There are 3 possible strategies:
 720   * - 'meta' 2.6 and higher. Uses multiple postmeta keys.
 721   * - 'user' Pre-2.6. Uses comma-separated string of IDs in usermeta.
 722   * - 'term' Alternate. Uses taxonomy term relationships.
 723   *
 724   * @since 2.6.0 bbPress (r6875)
 725   *
 726   * @param bool $default Optional. Default value false
 727   * @return string How to interact with engagements
 728   */
 729  function bbp_engagements_strategy( $default = 'meta' ) {
 730  
 731      // Get the option value
 732      $integration = get_option( '_bbp_engagements_strategy', $default );
 733  
 734      // Check that class exists, or fallback
 735      $class_name  = 'BBP_User_Engagements_' . ucwords( $integration );
 736  
 737      // Fallback to 'meta' if invalid
 738      if ( ! class_exists( $class_name ) ) {
 739          $integration = 'meta';
 740      }
 741  
 742      // Filter & return
 743      return apply_filters( 'bbp_engagements_strategy', $integration, $default );
 744  }
 745  
 746  /** Slugs *********************************************************************/
 747  
 748  /**
 749   * Return the root slug
 750   *
 751   * @since 2.1.0 bbPress (r3759)
 752   *
 753   * @param string $default Optional. Default value 'forums'
 754   * @return string
 755   */
 756  function bbp_get_root_slug( $default = 'forums' ) {
 757  
 758      // Filter & return
 759      return apply_filters( 'bbp_get_root_slug', get_option( '_bbp_root_slug', $default ) );
 760  }
 761  
 762  /**
 763   * Are we including the root slug in front of forum pages?
 764   *
 765   * @since 2.1.0 bbPress (r3759)
 766   *
 767   * @param bool $default Optional. Default value true
 768   * @return bool
 769   */
 770  function bbp_include_root_slug( $default = 1 ) {
 771  
 772      // Filter & return
 773      return (bool) apply_filters( 'bbp_include_root_slug', (bool) get_option( '_bbp_include_root', $default ) );
 774  }
 775  
 776  /**
 777   * What to show on root, forums or topics?
 778   *
 779   * @since 2.4.0 bbPress (r4932)
 780   *
 781   * @param string $default Optional. Default value 'forums'
 782   * @return string
 783   */
 784  function bbp_show_on_root( $default = 'forums' ) {
 785  
 786      // Filter & return
 787      return apply_filters( 'bbp_show_on_root', get_option( '_bbp_show_on_root', $default ) );
 788  }
 789  
 790  /**
 791   * Maybe return the root slug, based on whether or not it's included in the url
 792   *
 793   * @since 2.1.0 bbPress (r3759)
 794   *
 795   * @param string $default Optional. Default value 'forums'
 796   * @return string
 797   */
 798  function bbp_maybe_get_root_slug() {
 799      $slug   = bbp_get_root_slug();
 800      $retval = ( ! empty( $slug ) && bbp_include_root_slug() )
 801          ? trailingslashit( $slug )
 802          : '';
 803  
 804      // Filter & return
 805      return apply_filters( 'bbp_maybe_get_root_slug', $retval );
 806  }
 807  
 808  /**
 809   * Return the single forum slug
 810   *
 811   * @since 2.1.0 bbPress (r3759)
 812   *
 813   * @param string $default Optional. Default value 'forum'
 814   * @return string
 815   */
 816  function bbp_get_forum_slug( $default = 'forum' ) {
 817  
 818      // Filter & return
 819      return apply_filters( 'bbp_get_forum_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_forum_slug', $default ) );
 820  }
 821  
 822  /**
 823   * Return the topic archive slug
 824   *
 825   * @since 2.1.0 bbPress (r3759)
 826   *
 827   * @param string $default Optional. Default value 'topics'
 828   * @return string
 829   */
 830  function bbp_get_topic_archive_slug( $default = 'topics' ) {
 831  
 832      // Filter & return
 833      return apply_filters( 'bbp_get_topic_archive_slug', get_option( '_bbp_topic_archive_slug', $default ) );
 834  }
 835  
 836  /**
 837   * Return the reply archive slug
 838   *
 839   * @since 2.4.0 bbPress (r4925)
 840   *
 841   * @param string $default Optional. Default value 'replies'
 842   * @return string
 843   */
 844  function bbp_get_reply_archive_slug( $default = 'replies' ) {
 845  
 846      // Filter & return
 847      return apply_filters( 'bbp_get_reply_archive_slug', get_option( '_bbp_reply_archive_slug', $default ) );
 848  }
 849  
 850  /**
 851   * Return the single topic slug
 852   *
 853   * @since 2.1.0 bbPress (r3759)
 854   *
 855   * @param string $default Optional. Default value 'topic'
 856   * @return string
 857   */
 858  function bbp_get_topic_slug( $default = 'topic' ) {
 859  
 860      // Filter & return
 861      return apply_filters( 'bbp_get_topic_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_topic_slug', $default ) );
 862  }
 863  
 864  /**
 865   * Return the topic-tag taxonomy slug
 866   *
 867   * @since 2.1.0 bbPress (r3759)
 868   *
 869   * @param string $default Optional. Default value 'topic-tag'
 870   * @return string
 871   */
 872  function bbp_get_topic_tag_tax_slug( $default = 'topic-tag' ) {
 873  
 874      // Filter & return
 875      return apply_filters( 'bbp_get_topic_tag_tax_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_topic_tag_slug', $default ) );
 876  }
 877  
 878  /**
 879   * Return the single reply slug (used mostly for editing)
 880   *
 881   * @since 2.1.0 bbPress (r3759)
 882   *
 883   * @param string $default Optional. Default value 'reply'
 884   * @return string
 885   */
 886  function bbp_get_reply_slug( $default = 'reply' ) {
 887  
 888      // Filter & return
 889      return apply_filters( 'bbp_get_reply_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_reply_slug', $default ) );
 890  }
 891  
 892  /**
 893   * Return the single user slug
 894   *
 895   * @since 2.1.0 bbPress (r3759)
 896   *
 897   * @param string $default Optional. Default value 'users'
 898   * @return string
 899   */
 900  function bbp_get_user_slug( $default = 'users' ) {
 901  
 902      // Filter & return
 903      return apply_filters( 'bbp_get_user_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_user_slug', $default ) );
 904  }
 905  
 906  /**
 907   * Return the single user favorites slug
 908   *
 909   * @since 2.2.0 bbPress (r4187)
 910   *
 911   * @param string $default Optional. Default value 'favorites'
 912   * @return string
 913   */
 914  function bbp_get_user_favorites_slug( $default = 'favorites' ) {
 915  
 916      // Filter & return
 917      return apply_filters( 'bbp_get_user_favorites_slug', get_option( '_bbp_user_favs_slug', $default ) );
 918  }
 919  
 920  /**
 921   * Return the single user subscriptions slug
 922   *
 923   * @since 2.2.0 bbPress (r4187)
 924   *
 925   * @param string $default Optional. Default value 'subscriptions'
 926   * @return string
 927   */
 928  function bbp_get_user_subscriptions_slug( $default = 'subscriptions' ) {
 929  
 930      // Filter & return
 931      return apply_filters( 'bbp_get_user_subscriptions_slug', get_option( '_bbp_user_subs_slug', $default ) );
 932  }
 933  
 934  /**
 935   * Return the single user engagements slug
 936   *
 937   * @since 2.6.0 bbPress (r6320)
 938   *
 939   * @param string $default Optional. Default value 'engagements'
 940   * @return string
 941   */
 942  function bbp_get_user_engagements_slug( $default = 'engagements' ) {
 943  
 944      // Filter & return
 945      return apply_filters( 'bbp_get_user_engagements_slug', get_option( '_bbp_user_engs_slug', $default ) );
 946  }
 947  
 948  /**
 949   * Return the topic view slug
 950   *
 951   * @since 2.1.0 bbPress (r3759)
 952   *
 953   * @param string $default Optional. Default value 'view'
 954   * @return string
 955   */
 956  function bbp_get_view_slug( $default = 'view' ) {
 957  
 958      // Filter & return
 959      return apply_filters( 'bbp_get_view_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_view_slug', $default ) );
 960  }
 961  
 962  /**
 963   * Return the search slug
 964   *
 965   * @since 2.3.0 bbPress (r4579)
 966   *
 967   * @param string $default Optional. Default value 'search'
 968   * @return string
 969   */
 970  function bbp_get_search_slug( $default = 'search' ) {
 971  
 972      // Filter & return
 973      return apply_filters( 'bbp_get_search_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_search_slug', $default ) );
 974  }
 975  
 976  /**
 977   * Return the edit slug
 978   *
 979   * @since 2.6.2 bbPress (r6965)
 980   *
 981   * @param string $default Optional. Default value 'edit'
 982   * @return string
 983   */
 984  function bbp_get_edit_slug( $default = 'edit' ) {
 985  
 986      // Filter & return
 987      return apply_filters( 'bbp_get_edit_slug', get_option( '_bbp_edit_slug', $default ) );
 988  }
 989  
 990  /** Legacy ********************************************************************/
 991  
 992  /**
 993   * Checks if there is a previous BuddyPress Forum configuration
 994   *
 995   * @since 2.1.0 bbPress (r3790)
 996   *
 997   * @param string $default Optional. Default empty string
 998   * @return string The location of the bb-config.php file, if any
 999   */
1000  function bbp_get_config_location( $default = '' ) {
1001  
1002      // Filter & return
1003      return apply_filters( 'bbp_get_config_location', get_option( 'bb-config-location', $default ) );
1004  }


Generated: Fri Oct 4 01:00:52 2024 Cross-referenced by PHPXref 0.7.1