| @@ -3,104 +3,156 @@ | ||
| 3 | 3 | /** |
| 4 | 4 | * bbPress Options |
| 5 | 5 | * |
| 6 | 6 | * @package bbPress |
| 7 | - * @subpackage Options | |
| 7 | + * @subpackage Core | |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | // Exit if accessed directly |
| 11 | -if ( !defined( 'ABSPATH' ) ) exit; | |
| 11 | +defined( 'ABSPATH' ) || exit; | |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Get the default site options and their values. |
| 15 | - * | |
| 15 | + * | |
| 16 | 16 | * These option |
| 17 | 17 | * |
| 18 | - * @since bbPress (r3421) | |
| 18 | + * @since 2.0.0 bbPress (r3421) | |
| 19 | + * | |
| 19 | 20 | * @return array Filtered option names and values |
| 20 | 21 | */ |
| 21 | 22 | function bbp_get_default_options() { |
| 23 | + static $options = null; | |
| 22 | 24 | |
| 23 | - // Default options | |
| 24 | - return apply_filters( 'bbp_get_default_options', array( | |
| 25 | + // Store these to avoid recreating them | |
| 26 | + if ( is_null( $options ) ) { | |
| 25 | 27 | |
| 26 | - /** DB Version ********************************************************/ | |
| 28 | + // Use the participant role for the default-default role | |
| 29 | + $role = bbp_get_participant_role(); | |
| 30 | + $options = array( | |
| 27 | 31 | |
| 28 | - '_bbp_db_version' => bbpress()->db_version, | |
| 32 | + /** DB Version ********************************************************/ | |
| 29 | 33 | |
| 30 | - /** Settings **********************************************************/ | |
| 34 | + '_bbp_db_version' => 0, // Database version | |
| 35 | + '_bbp_db_pending_upgrades' => array(), // Database upgrades pending | |
| 31 | 36 | |
| 32 | - '_bbp_edit_lock' => 5, // Lock post editing after 5 minutes | |
| 33 | - '_bbp_throttle_time' => 10, // Throttle post time to 10 seconds | |
| 34 | - '_bbp_enable_favorites' => 1, // Favorites | |
| 35 | - '_bbp_enable_subscriptions' => 1, // Subscriptions | |
| 36 | - '_bbp_allow_topic_tags' => 1, // Topic Tags | |
| 37 | - '_bbp_allow_anonymous' => 0, // Allow anonymous posting | |
| 38 | - '_bbp_allow_global_access' => 1, // Users from all sites can post | |
| 39 | - '_bbp_use_wp_editor' => 1, // Use the WordPress editor if available | |
| 40 | - '_bbp_use_autoembed' => 0, // Allow oEmbed in topics and replies | |
| 41 | - '_bbp_theme_package_id' => 'default', // The ID for the current theme package. | |
| 42 | - '_bbp_default_role' => bbp_get_participant_role(), // Default forums role | |
| 37 | + /** Flags *************************************************************/ | |
| 43 | 38 | |
| 44 | - /** Per Page **********************************************************/ | |
| 39 | + '_bbp_flag_initial_content' => 1, // Flag to indicate initial content was created | |
| 45 | 40 | |
| 46 | - '_bbp_topics_per_page' => 15, // Topics per page | |
| 47 | - '_bbp_replies_per_page' => 15, // Replies per page | |
| 48 | - '_bbp_forums_per_page' => 50, // Forums per page | |
| 49 | - '_bbp_topics_per_rss_page' => 25, // Topics per RSS page | |
| 50 | - '_bbp_replies_per_rss_page' => 25, // Replies per RSS page | |
| 41 | + /** Features **********************************************************/ | |
| 51 | 42 | |
| 52 | - /** Page For **********************************************************/ | |
| 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 | |
| 53 | 58 | |
| 54 | - '_bbp_page_for_forums' => 0, // Page for forums | |
| 55 | - '_bbp_page_for_topics' => 0, // Page for forums | |
| 56 | - '_bbp_page_for_login' => 0, // Page for login | |
| 57 | - '_bbp_page_for_register' => 0, // Page for register | |
| 58 | - '_bbp_page_for_lost_pass' => 0, // Page for lost-pass | |
| 59 | + /** Settings **********************************************************/ | |
| 59 | 60 | |
| 60 | - /** Archive Slugs *****************************************************/ | |
| 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 | |
| 61 | 68 | |
| 62 | - '_bbp_root_slug' => 'forums', // Forum archive slug | |
| 63 | - '_bbp_topic_archive_slug' => 'topics', // Topic archive slug | |
| 69 | + /** Per Page **********************************************************/ | |
| 64 | 70 | |
| 65 | - /** Single Slugs ******************************************************/ | |
| 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 | |
| 66 | 76 | |
| 67 | - '_bbp_include_root' => 1, // Include forum-archive before single slugs | |
| 68 | - '_bbp_forum_slug' => 'forum', // Forum slug | |
| 69 | - '_bbp_topic_slug' => 'topic', // Topic slug | |
| 70 | - '_bbp_reply_slug' => 'reply', // Reply slug | |
| 71 | - '_bbp_topic_tag_slug' => 'topic-tag', // Topic tag slug | |
| 77 | + /** Page For **********************************************************/ | |
| 72 | 78 | |
| 73 | - /** User Slugs ********************************************************/ | |
| 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 | |
| 74 | 84 | |
| 75 | - '_bbp_user_slug' => 'users', // User profile slug | |
| 76 | - '_bbp_user_favs_slug' => 'favorites', // User favorites slug | |
| 77 | - '_bbp_user_subs_slug' => 'subscriptions', // User subscriptions slug | |
| 85 | + /** Forum Root ********************************************************/ | |
| 78 | 86 | |
| 79 | - /** Other Slugs *******************************************************/ | |
| 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 | |
| 80 | 90 | |
| 81 | - '_bbp_view_slug' => 'view', // View slug | |
| 91 | + /** Single Slugs ******************************************************/ | |
| 82 | 92 | |
| 83 | - /** Topics ************************************************************/ | |
| 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 | |
| 84 | 97 | |
| 85 | - '_bbp_title_max_length' => 80, // Title Max Length | |
| 86 | - '_bbp_super_sticky_topics' => '', // Super stickies | |
| 98 | + /** User Slugs ********************************************************/ | |
| 87 | 99 | |
| 88 | - /** Forums ************************************************************/ | |
| 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 | |
| 89 | 106 | |
| 90 | - '_bbp_private_forums' => '', // Private forums | |
| 91 | - '_bbp_hidden_forums' => '', // Hidden forums | |
| 107 | + /** Other Slugs *******************************************************/ | |
| 92 | 108 | |
| 93 | - /** BuddyPress ********************************************************/ | |
| 109 | + '_bbp_view_slug' => 'view', // View slug | |
| 110 | + '_bbp_search_slug' => 'search', // Search slug | |
| 94 | 111 | |
| 95 | - '_bbp_enable_group_forums' => 1, // Enable BuddyPress Group Extension | |
| 96 | - '_bbp_group_forums_root_id' => 0, // Group Forums parent forum id | |
| 112 | + /** Topics ************************************************************/ | |
| 97 | 113 | |
| 98 | - /** Akismet ***********************************************************/ | |
| 114 | + '_bbp_title_max_length' => 80, // Title Max Length | |
| 115 | + '_bbp_super_sticky_topics' => '', // Super stickies | |
| 99 | 116 | |
| 100 | - '_bbp_enable_akismet' => 1 // Users from all sites can post | |
| 117 | + /** Forums ************************************************************/ | |
| 101 | 118 | |
| 102 | - ) ); | |
| 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 ); | |
| 103 | 155 | } |
| 104 | 156 | |
| 105 | 157 | /** |
| 106 | 158 | * Add default options |
| @@ -107,18 +159,16 @@ | ||
| 107 | 159 | * |
| 108 | 160 | * Hooked to bbp_activate, it is only called once when bbPress is activated. |
| 109 | 161 | * This is non-destructive, so existing settings will not be overridden. |
| 110 | 162 | * |
| 111 | - * @since bbPress (r3421) | |
| 112 | - * @uses bbp_get_default_options() To get default options | |
| 113 | - * @uses add_option() Adds default options | |
| 114 | - * @uses do_action() Calls 'bbp_add_options' | |
| 163 | + * @since 2.0.0 bbPress (r3421) | |
| 115 | 164 | */ |
| 116 | 165 | function bbp_add_options() { |
| 117 | 166 | |
| 118 | 167 | // Add default options |
| 119 | - foreach ( bbp_get_default_options() as $key => $value ) | |
| 168 | + foreach ( bbp_get_default_options() as $key => $value ) { | |
| 120 | 169 | add_option( $key, $value ); |
| 170 | + } | |
| 121 | 171 | |
| 122 | 172 | // Allow previously activated plugins to append their own options. |
| 123 | 173 | do_action( 'bbp_add_options' ); |
| 124 | 174 | } |
| @@ -128,18 +178,16 @@ | ||
| 128 | 178 | * |
| 129 | 179 | * Hooked to bbp_uninstall, it is only called once when bbPress is uninstalled. |
| 130 | 180 | * This is destructive, so existing settings will be destroyed. |
| 131 | 181 | * |
| 132 | - * @since bbPress (r3421) | |
| 133 | - * @uses bbp_get_default_options() To get default options | |
| 134 | - * @uses delete_option() Removes default options | |
| 135 | - * @uses do_action() Calls 'bbp_delete_options' | |
| 182 | + * @since 2.0.0 bbPress (r3421) | |
| 136 | 183 | */ |
| 137 | 184 | function bbp_delete_options() { |
| 138 | 185 | |
| 139 | 186 | // Add default options |
| 140 | - foreach ( array_keys( bbp_get_default_options() ) as $key ) | |
| 187 | + foreach ( array_keys( bbp_get_default_options() ) as $key ) { | |
| 141 | 188 | delete_option( $key ); |
| 189 | + } | |
| 142 | 190 | |
| 143 | 191 | // Allow previously activated plugins to append their own options. |
| 144 | 192 | do_action( 'bbp_delete_options' ); |
| 145 | 193 | } |
| @@ -147,18 +195,17 @@ | ||
| 147 | 195 | /** |
| 148 | 196 | * Add filters to each bbPress option and allow them to be overloaded from |
| 149 | 197 | * inside the $bbp->options array. |
| 150 | 198 | * |
| 151 | - * @since bbPress (r3451) | |
| 152 | - * @uses bbp_get_default_options() To get default options | |
| 153 | - * @uses add_filter() To add filters to 'pre_option_{$key}' | |
| 154 | - * @uses do_action() Calls 'bbp_add_option_filters' | |
| 199 | + * @since 2.0.0 bbPress (r3451) | |
| 155 | 200 | */ |
| 156 | 201 | function bbp_setup_option_filters() { |
| 157 | 202 | |
| 158 | 203 | // Add filters to each bbPress option |
| 159 | - foreach ( array_keys( bbp_get_default_options() ) as $key ) | |
| 160 | - add_filter( 'pre_option_' . $key, 'bbp_pre_get_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 | + } | |
| 161 | 208 | |
| 162 | 209 | // Allow previously activated plugins to append their own options. |
| 163 | 210 | do_action( 'bbp_setup_option_filters' ); |
| 164 | 211 | } |
| @@ -163,39 +210,130 @@ | ||
| 163 | 210 | do_action( 'bbp_setup_option_filters' ); |
| 164 | 211 | } |
| 165 | 212 | |
| 166 | 213 | /** |
| 167 | - * Filter default options and allow them to be overloaded from inside the | |
| 168 | - * $bbp->options array. | |
| 214 | + * Filter pre options and maybe overloaded from the $bbp->options array. | |
| 169 | 215 | * |
| 170 | - * @since bbPress (r3451) | |
| 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 | + * | |
| 171 | 245 | * @param bool $value Optional. Default value false |
| 172 | 246 | * @return mixed false if not overloaded, mixed if set |
| 173 | 247 | */ |
| 174 | -function bbp_pre_get_option( $value = '' ) { | |
| 248 | +function bbp_filter_default_option( $default = false, $option = '', $passed_default = false ) { | |
| 249 | + $options = bbp_get_default_options(); | |
| 175 | 250 | |
| 176 | - // Remove the filter prefix | |
| 177 | - $option = str_replace( 'pre_option_', '', current_filter() ); | |
| 251 | + // Maybe use the default value | |
| 252 | + if ( isset( $options[ $option ] ) ) { | |
| 178 | 253 | |
| 179 | - // Check the options global for preset value | |
| 180 | - if ( isset( bbpress()->options[$option] ) ) | |
| 181 | - $value = bbpress()->options[$option]; | |
| 254 | + // Try to use the passed default and fallback to assumed default | |
| 255 | + $default = ( true === $passed_default ) | |
| 256 | + ? $default | |
| 257 | + : $options[ $option ]; | |
| 258 | + } | |
| 182 | 259 | |
| 183 | 260 | // Always return a value, even if false |
| 184 | - return $value; | |
| 261 | + return $default; | |
| 185 | 262 | } |
| 186 | 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 | + | |
| 187 | 323 | /** Active? *******************************************************************/ |
| 188 | 324 | |
| 189 | 325 | /** |
| 190 | 326 | * Checks if favorites feature is enabled. |
| 191 | 327 | * |
| 192 | - * @since bbPress (r2658) | |
| 193 | - * @param $default bool Optional.Default value true | |
| 194 | - * @uses get_option() To get the favorites option | |
| 328 | + * @since 2.0.0 bbPress (r2658) | |
| 329 | + * | |
| 330 | + * @param bool $default Optional.Default value true | |
| 195 | 331 | * @return bool Is favorites enabled or not |
| 196 | 332 | */ |
| 197 | 333 | function bbp_is_favorites_active( $default = 1 ) { |
| 334 | + | |
| 335 | + // Filter & return | |
| 198 | 336 | return (bool) apply_filters( 'bbp_is_favorites_active', (bool) get_option( '_bbp_enable_favorites', $default ) ); |
| 199 | 337 | } |
| 200 | 338 | |
| 201 | 339 | /** |
| @@ -200,38 +338,158 @@ | ||
| 200 | 338 | |
| 201 | 339 | /** |
| 202 | 340 | * Checks if subscription feature is enabled. |
| 203 | 341 | * |
| 204 | - * @since bbPress (r2658) | |
| 205 | - * @param $default bool Optional.Default value true | |
| 206 | - * @uses get_option() To get the subscriptions option | |
| 342 | + * @since 2.0.0 bbPress (r2658) | |
| 343 | + * | |
| 344 | + * @param bool $default Optional.Default value true | |
| 207 | 345 | * @return bool Is subscription enabled or not |
| 208 | 346 | */ |
| 209 | 347 | function bbp_is_subscriptions_active( $default = 1 ) { |
| 348 | + | |
| 349 | + // Filter & return | |
| 210 | 350 | return (bool) apply_filters( 'bbp_is_subscriptions_active', (bool) get_option( '_bbp_enable_subscriptions', $default ) ); |
| 211 | 351 | } |
| 212 | 352 | |
| 213 | 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 | +/** | |
| 214 | 396 | * Are topic tags allowed |
| 215 | 397 | * |
| 216 | - * @since bbPress (r4097) | |
| 217 | - * @param $default bool Optional. Default value true | |
| 218 | - * @uses get_option() To get the allow tags | |
| 398 | + * @since 2.2.0 bbPress (r4097) | |
| 399 | + * | |
| 400 | + * @param bool $default Optional. Default value true | |
| 219 | 401 | * @return bool Are tags allowed? |
| 220 | 402 | */ |
| 221 | 403 | function bbp_allow_topic_tags( $default = 1 ) { |
| 404 | + | |
| 405 | + // Filter & return | |
| 222 | 406 | return (bool) apply_filters( 'bbp_allow_topic_tags', (bool) get_option( '_bbp_allow_topic_tags', $default ) ); |
| 223 | 407 | } |
| 224 | 408 | |
| 225 | 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 | +/** | |
| 226 | 482 | * Are topic and reply revisions allowed |
| 227 | 483 | * |
| 228 | - * @since bbPress (r3412) | |
| 229 | - * @param $default bool Optional. Default value true | |
| 230 | - * @uses get_option() To get the allow revisions | |
| 484 | + * @since 2.0.0 bbPress (r3412) | |
| 485 | + * | |
| 486 | + * @param bool $default Optional. Default value true | |
| 231 | 487 | * @return bool Are revisions allowed? |
| 232 | 488 | */ |
| 233 | 489 | function bbp_allow_revisions( $default = 1 ) { |
| 490 | + | |
| 491 | + // Filter & return | |
| 234 | 492 | return (bool) apply_filters( 'bbp_allow_revisions', (bool) get_option( '_bbp_allow_revisions', $default ) ); |
| 235 | 493 | } |
| 236 | 494 | |
| 237 | 495 | /** |
| @@ -236,14 +494,16 @@ | ||
| 236 | 494 | |
| 237 | 495 | /** |
| 238 | 496 | * Is the anonymous posting allowed? |
| 239 | 497 | * |
| 240 | - * @since bbPress (r2659) | |
| 241 | - * @param $default bool Optional. Default value | |
| 242 | - * @uses get_option() To get the allow anonymous option | |
| 498 | + * @since 2.0.0 bbPress (r2659) | |
| 499 | + * | |
| 500 | + * @param bool $default Optional. Default value | |
| 243 | 501 | * @return bool Is anonymous posting allowed? |
| 244 | 502 | */ |
| 245 | 503 | function bbp_allow_anonymous( $default = 0 ) { |
| 504 | + | |
| 505 | + // Filter & return | |
| 246 | 506 | return apply_filters( 'bbp_allow_anonymous', (bool) get_option( '_bbp_allow_anonymous', $default ) ); |
| 247 | 507 | } |
| 248 | 508 | |
| 249 | 509 | /** |
| @@ -248,26 +508,31 @@ | ||
| 248 | 508 | |
| 249 | 509 | /** |
| 250 | 510 | * Is this forum available to all users on all sites in this installation? |
| 251 | 511 | * |
| 252 | - * @since bbPress (r3378) | |
| 253 | - * @param $default bool Optional. Default value false | |
| 254 | - * @uses get_option() To get the global access option | |
| 512 | + * @since 2.0.0 bbPress (r3378) | |
| 513 | + * | |
| 514 | + * @param bool $default Optional. Default value false | |
| 255 | 515 | * @return bool Is global access allowed? |
| 256 | 516 | */ |
| 257 | 517 | function bbp_allow_global_access( $default = 1 ) { |
| 518 | + | |
| 519 | + // Filter & return | |
| 258 | 520 | return (bool) apply_filters( 'bbp_allow_global_access', (bool) get_option( '_bbp_allow_global_access', $default ) ); |
| 259 | 521 | } |
| 260 | 522 | |
| 261 | 523 | /** |
| 262 | - * Is this forum available to all users on all sites in this installation? | |
| 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 | |
| 263 | 526 | * |
| 264 | - * @since bbPress (r4294) | |
| 265 | - * @param $default string Optional. Default value empty | |
| 266 | - * @uses get_option() To get the default forums role option | |
| 527 | + * @since 2.2.0 bbPress (r4294) | |
| 528 | + * | |
| 529 | + * @param string $default Optional. Default value empty | |
| 267 | 530 | * @return string The default forums user role |
| 268 | 531 | */ |
| 269 | 532 | function bbp_get_default_role( $default = 'bbp_participant' ) { |
| 533 | + | |
| 534 | + // Filter & return | |
| 270 | 535 | return apply_filters( 'bbp_get_default_role', get_option( '_bbp_default_role', $default ) ); |
| 271 | 536 | } |
| 272 | 537 | |
| 273 | 538 | /** |
| @@ -272,14 +537,16 @@ | ||
| 272 | 537 | |
| 273 | 538 | /** |
| 274 | 539 | * Use the WordPress editor if available |
| 275 | 540 | * |
| 276 | - * @since bbPress (r3386) | |
| 277 | - * @param $default bool Optional. Default value true | |
| 278 | - * @uses get_option() To get the WP editor option | |
| 541 | + * @since 2.0.0 bbPress (r3386) | |
| 542 | + * | |
| 543 | + * @param bool $default Optional. Default value true | |
| 279 | 544 | * @return bool Use WP editor? |
| 280 | 545 | */ |
| 281 | 546 | function bbp_use_wp_editor( $default = 1 ) { |
| 547 | + | |
| 548 | + // Filter & return | |
| 282 | 549 | return (bool) apply_filters( 'bbp_use_wp_editor', (bool) get_option( '_bbp_use_wp_editor', $default ) ); |
| 283 | 550 | } |
| 284 | 551 | |
| 285 | 552 | /** |
| @@ -284,14 +551,16 @@ | ||
| 284 | 551 | |
| 285 | 552 | /** |
| 286 | 553 | * Use WordPress's oEmbed API |
| 287 | 554 | * |
| 288 | - * @since bbPress (r3752) | |
| 289 | - * @param $default bool Optional. Default value true | |
| 290 | - * @uses get_option() To get the oEmbed option | |
| 555 | + * @since 2.1.0 bbPress (r3752) | |
| 556 | + * | |
| 557 | + * @param bool $default Optional. Default value true | |
| 291 | 558 | * @return bool Use oEmbed? |
| 292 | 559 | */ |
| 293 | 560 | function bbp_use_autoembed( $default = 1 ) { |
| 561 | + | |
| 562 | + // Filter & return | |
| 294 | 563 | return (bool) apply_filters( 'bbp_use_autoembed', (bool) get_option( '_bbp_use_autoembed', $default ) ); |
| 295 | 564 | } |
| 296 | 565 | |
| 297 | 566 | /** |
| @@ -296,14 +565,16 @@ | ||
| 296 | 565 | |
| 297 | 566 | /** |
| 298 | 567 | * Get the current theme package ID |
| 299 | 568 | * |
| 300 | - * @since bbPress (r3829) | |
| 301 | - * @param $default string Optional. Default value 'default' | |
| 302 | - * @uses get_option() To get the subtheme option | |
| 303 | - * @return string ID of the subtheme | |
| 569 | + * @since 2.1.0 bbPress (r3829) | |
| 570 | + * | |
| 571 | + * @param string $default Optional. Default value 'default' | |
| 572 | + * @return string ID of the theme-package | |
| 304 | 573 | */ |
| 305 | 574 | function bbp_get_theme_package_id( $default = 'default' ) { |
| 575 | + | |
| 576 | + // Filter & return | |
| 306 | 577 | return apply_filters( 'bbp_get_theme_package_id', get_option( '_bbp_theme_package_id', $default ) ); |
| 307 | 578 | } |
| 308 | 579 | |
| 309 | 580 | /** |
| @@ -308,10 +579,11 @@ | ||
| 308 | 579 | |
| 309 | 580 | /** |
| 310 | 581 | * Output the maximum length of a title |
| 311 | 582 | * |
| 312 | - * @since bbPress (r3246) | |
| 313 | - * @param $default bool Optional. Default value 80 | |
| 583 | + * @since 2.0.0 bbPress (r3246) | |
| 584 | + * | |
| 585 | + * @param bool $default Optional. Default value 80 | |
| 314 | 586 | */ |
| 315 | 587 | function bbp_title_max_length( $default = 80 ) { |
| 316 | 588 | echo bbp_get_title_max_length( $default ); |
| 317 | 589 | } |
| @@ -317,35 +589,66 @@ | ||
| 317 | 589 | } |
| 318 | 590 | /** |
| 319 | 591 | * Return the maximum length of a title |
| 320 | 592 | * |
| 321 | - * @since bbPress (r3246) | |
| 322 | - * @param $default bool Optional. Default value 80 | |
| 323 | - * @uses get_option() To get the maximum title length | |
| 593 | + * @since 2.0.0 bbPress (r3246) | |
| 594 | + * | |
| 595 | + * @param bool $default Optional. Default value 80 | |
| 324 | 596 | * @return int Is anonymous posting allowed? |
| 325 | 597 | */ |
| 326 | 598 | function bbp_get_title_max_length( $default = 80 ) { |
| 599 | + | |
| 600 | + // Filter & return | |
| 327 | 601 | return (int) apply_filters( 'bbp_get_title_max_length', (int) get_option( '_bbp_title_max_length', $default ) ); |
| 328 | 602 | } |
| 329 | 603 | |
| 330 | 604 | /** |
| 331 | - * Output the grop forums root parent forum id | |
| 605 | + * Output the number of minutes a topic or reply can be edited after it's | |
| 606 | + * published. Used by `bbp_past_edit_lock()`. | |
| 332 | 607 | * |
| 333 | - * @since bbPress (r3575) | |
| 334 | - * @param $default int Optional. Default value | |
| 608 | + * @since 2.6.0 bbPress (r6868) | |
| 609 | + * | |
| 610 | + * @param bool $default Optional. Default value 5 | |
| 335 | 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 | + */ | |
| 336 | 637 | function bbp_group_forums_root_id( $default = 0 ) { |
| 337 | 638 | echo bbp_get_group_forums_root_id( $default ); |
| 338 | 639 | } |
| 339 | 640 | /** |
| 340 | - * Return the grop forums root parent forum id | |
| 641 | + * Return the group forums root parent forum id | |
| 341 | 642 | * |
| 342 | - * @since bbPress (r3575) | |
| 343 | - * @param $default bool Optional. Default value 0 | |
| 344 | - * @uses get_option() To get the root group forum ID | |
| 643 | + * @since 2.1.0 bbPress (r3575) | |
| 644 | + * | |
| 645 | + * @param bool $default Optional. Default value 0 | |
| 345 | 646 | * @return int The post ID for the root forum |
| 346 | 647 | */ |
| 347 | 648 | function bbp_get_group_forums_root_id( $default = 0 ) { |
| 649 | + | |
| 650 | + // Filter & return | |
| 348 | 651 | return (int) apply_filters( 'bbp_get_group_forums_root_id', (int) get_option( '_bbp_group_forums_root_id', $default ) ); |
| 349 | 652 | } |
| 350 | 653 | |
| 351 | 654 | /** |
| @@ -350,14 +653,16 @@ | ||
| 350 | 653 | |
| 351 | 654 | /** |
| 352 | 655 | * Checks if BuddyPress Group Forums are enabled |
| 353 | 656 | * |
| 354 | - * @since bbPress (r3575) | |
| 355 | - * @param $default bool Optional. Default value true | |
| 356 | - * @uses get_option() To get the group forums option | |
| 657 | + * @since 2.1.0 bbPress (r3575) | |
| 658 | + * | |
| 659 | + * @param bool $default Optional. Default value true | |
| 357 | 660 | * @return bool Is group forums enabled or not |
| 358 | 661 | */ |
| 359 | 662 | function bbp_is_group_forums_active( $default = 1 ) { |
| 663 | + | |
| 664 | + // Filter & return | |
| 360 | 665 | return (bool) apply_filters( 'bbp_is_group_forums_active', (bool) get_option( '_bbp_enable_group_forums', $default ) ); |
| 361 | 666 | } |
| 362 | 667 | |
| 363 | 668 | /** |
| @@ -362,26 +667,96 @@ | ||
| 362 | 667 | |
| 363 | 668 | /** |
| 364 | 669 | * Checks if Akismet is enabled |
| 365 | 670 | * |
| 366 | - * @since bbPress (r3575) | |
| 367 | - * @param $default bool Optional. Default value true | |
| 368 | - * @uses get_option() To get the Akismet option | |
| 671 | + * @since 2.1.0 bbPress (r3575) | |
| 672 | + * | |
| 673 | + * @param bool $default Optional. Default value true | |
| 369 | 674 | * @return bool Is Akismet enabled or not |
| 370 | 675 | */ |
| 371 | 676 | function bbp_is_akismet_active( $default = 1 ) { |
| 677 | + | |
| 678 | + // Filter & return | |
| 372 | 679 | return (bool) apply_filters( 'bbp_is_akismet_active', (bool) get_option( '_bbp_enable_akismet', $default ) ); |
| 373 | 680 | } |
| 374 | 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 | + | |
| 375 | 746 | /** Slugs *********************************************************************/ |
| 376 | 747 | |
| 377 | 748 | /** |
| 378 | 749 | * Return the root slug |
| 379 | 750 | * |
| 380 | - * @since bbPress (r3759) | |
| 751 | + * @since 2.1.0 bbPress (r3759) | |
| 752 | + * | |
| 753 | + * @param string $default Optional. Default value 'forums' | |
| 381 | 754 | * @return string |
| 382 | 755 | */ |
| 383 | 756 | function bbp_get_root_slug( $default = 'forums' ) { |
| 757 | + | |
| 758 | + // Filter & return | |
| 384 | 759 | return apply_filters( 'bbp_get_root_slug', get_option( '_bbp_root_slug', $default ) ); |
| 385 | 760 | } |
| 386 | 761 | |
| 387 | 762 | /** |
| @@ -386,27 +761,48 @@ | ||
| 386 | 761 | |
| 387 | 762 | /** |
| 388 | 763 | * Are we including the root slug in front of forum pages? |
| 389 | 764 | * |
| 390 | - * @since bbPress (r3759) | |
| 765 | + * @since 2.1.0 bbPress (r3759) | |
| 766 | + * | |
| 767 | + * @param bool $default Optional. Default value true | |
| 391 | 768 | * @return bool |
| 392 | 769 | */ |
| 393 | 770 | function bbp_include_root_slug( $default = 1 ) { |
| 771 | + | |
| 772 | + // Filter & return | |
| 394 | 773 | return (bool) apply_filters( 'bbp_include_root_slug', (bool) get_option( '_bbp_include_root', $default ) ); |
| 395 | 774 | } |
| 396 | 775 | |
| 397 | 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 | +/** | |
| 398 | 791 | * Maybe return the root slug, based on whether or not it's included in the url |
| 399 | 792 | * |
| 400 | - * @since bbPress (r3759) | |
| 793 | + * @since 2.1.0 bbPress (r3759) | |
| 794 | + * | |
| 795 | + * @param string $default Optional. Default value 'forums' | |
| 401 | 796 | * @return string |
| 402 | 797 | */ |
| 403 | 798 | function bbp_maybe_get_root_slug() { |
| 404 | - $retval = ''; | |
| 799 | + $slug = bbp_get_root_slug(); | |
| 800 | + $retval = ( ! empty( $slug ) && bbp_include_root_slug() ) | |
| 801 | + ? trailingslashit( $slug ) | |
| 802 | + : ''; | |
| 405 | 803 | |
| 406 | - if ( bbp_get_root_slug() && bbp_include_root_slug() ) | |
| 407 | - $retval = trailingslashit( bbp_get_root_slug() ); | |
| 408 | - | |
| 804 | + // Filter & return | |
| 409 | 805 | return apply_filters( 'bbp_maybe_get_root_slug', $retval ); |
| 410 | 806 | } |
| 411 | 807 | |
| 412 | 808 | /** |
| @@ -411,32 +807,58 @@ | ||
| 411 | 807 | |
| 412 | 808 | /** |
| 413 | 809 | * Return the single forum slug |
| 414 | 810 | * |
| 415 | - * @since bbPress (r3759) | |
| 811 | + * @since 2.1.0 bbPress (r3759) | |
| 812 | + * | |
| 813 | + * @param string $default Optional. Default value 'forum' | |
| 416 | 814 | * @return string |
| 417 | 815 | */ |
| 418 | -function bbp_get_forum_slug( $default = 'forum' ) {; | |
| 419 | - return apply_filters( 'bbp_get_root_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_forum_slug', $default ) ); | |
| 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 ) ); | |
| 420 | 820 | } |
| 421 | 821 | |
| 422 | 822 | /** |
| 423 | 823 | * Return the topic archive slug |
| 424 | 824 | * |
| 425 | - * @since bbPress (r3759) | |
| 825 | + * @since 2.1.0 bbPress (r3759) | |
| 826 | + * | |
| 827 | + * @param string $default Optional. Default value 'topics' | |
| 426 | 828 | * @return string |
| 427 | 829 | */ |
| 428 | 830 | function bbp_get_topic_archive_slug( $default = 'topics' ) { |
| 831 | + | |
| 832 | + // Filter & return | |
| 429 | 833 | return apply_filters( 'bbp_get_topic_archive_slug', get_option( '_bbp_topic_archive_slug', $default ) ); |
| 430 | 834 | } |
| 431 | 835 | |
| 432 | 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 | +/** | |
| 433 | 851 | * Return the single topic slug |
| 434 | 852 | * |
| 435 | - * @since bbPress (r3759) | |
| 853 | + * @since 2.1.0 bbPress (r3759) | |
| 854 | + * | |
| 855 | + * @param string $default Optional. Default value 'topic' | |
| 436 | 856 | * @return string |
| 437 | 857 | */ |
| 438 | 858 | function bbp_get_topic_slug( $default = 'topic' ) { |
| 859 | + | |
| 860 | + // Filter & return | |
| 439 | 861 | return apply_filters( 'bbp_get_topic_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_topic_slug', $default ) ); |
| 440 | 862 | } |
| 441 | 863 | |
| 442 | 864 | /** |
| @@ -441,12 +863,16 @@ | ||
| 441 | 863 | |
| 442 | 864 | /** |
| 443 | 865 | * Return the topic-tag taxonomy slug |
| 444 | 866 | * |
| 445 | - * @since bbPress (r3759) | |
| 867 | + * @since 2.1.0 bbPress (r3759) | |
| 868 | + * | |
| 869 | + * @param string $default Optional. Default value 'topic-tag' | |
| 446 | 870 | * @return string |
| 447 | 871 | */ |
| 448 | 872 | function bbp_get_topic_tag_tax_slug( $default = 'topic-tag' ) { |
| 873 | + | |
| 874 | + // Filter & return | |
| 449 | 875 | return apply_filters( 'bbp_get_topic_tag_tax_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_topic_tag_slug', $default ) ); |
| 450 | 876 | } |
| 451 | 877 | |
| 452 | 878 | /** |
| @@ -451,12 +877,16 @@ | ||
| 451 | 877 | |
| 452 | 878 | /** |
| 453 | 879 | * Return the single reply slug (used mostly for editing) |
| 454 | 880 | * |
| 455 | - * @since bbPress (r3759) | |
| 881 | + * @since 2.1.0 bbPress (r3759) | |
| 882 | + * | |
| 883 | + * @param string $default Optional. Default value 'reply' | |
| 456 | 884 | * @return string |
| 457 | 885 | */ |
| 458 | 886 | function bbp_get_reply_slug( $default = 'reply' ) { |
| 887 | + | |
| 888 | + // Filter & return | |
| 459 | 889 | return apply_filters( 'bbp_get_reply_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_reply_slug', $default ) ); |
| 460 | 890 | } |
| 461 | 891 | |
| 462 | 892 | /** |
| @@ -461,12 +891,16 @@ | ||
| 461 | 891 | |
| 462 | 892 | /** |
| 463 | 893 | * Return the single user slug |
| 464 | 894 | * |
| 465 | - * @since bbPress (r3759) | |
| 895 | + * @since 2.1.0 bbPress (r3759) | |
| 896 | + * | |
| 897 | + * @param string $default Optional. Default value 'users' | |
| 466 | 898 | * @return string |
| 467 | 899 | */ |
| 468 | -function bbp_get_user_slug( $default = 'user' ) { | |
| 900 | +function bbp_get_user_slug( $default = 'users' ) { | |
| 901 | + | |
| 902 | + // Filter & return | |
| 469 | 903 | return apply_filters( 'bbp_get_user_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_user_slug', $default ) ); |
| 470 | 904 | } |
| 471 | 905 | |
| 472 | 906 | /** |
| @@ -471,12 +905,16 @@ | ||
| 471 | 905 | |
| 472 | 906 | /** |
| 473 | 907 | * Return the single user favorites slug |
| 474 | 908 | * |
| 475 | - * @since bbPress (r4187) | |
| 909 | + * @since 2.2.0 bbPress (r4187) | |
| 910 | + * | |
| 911 | + * @param string $default Optional. Default value 'favorites' | |
| 476 | 912 | * @return string |
| 477 | 913 | */ |
| 478 | 914 | function bbp_get_user_favorites_slug( $default = 'favorites' ) { |
| 915 | + | |
| 916 | + // Filter & return | |
| 479 | 917 | return apply_filters( 'bbp_get_user_favorites_slug', get_option( '_bbp_user_favs_slug', $default ) ); |
| 480 | 918 | } |
| 481 | 919 | |
| 482 | 920 | /** |
| @@ -481,34 +919,86 @@ | ||
| 481 | 919 | |
| 482 | 920 | /** |
| 483 | 921 | * Return the single user subscriptions slug |
| 484 | 922 | * |
| 485 | - * @since bbPress (r4187) | |
| 923 | + * @since 2.2.0 bbPress (r4187) | |
| 924 | + * | |
| 925 | + * @param string $default Optional. Default value 'subscriptions' | |
| 486 | 926 | * @return string |
| 487 | 927 | */ |
| 488 | 928 | function bbp_get_user_subscriptions_slug( $default = 'subscriptions' ) { |
| 929 | + | |
| 930 | + // Filter & return | |
| 489 | 931 | return apply_filters( 'bbp_get_user_subscriptions_slug', get_option( '_bbp_user_subs_slug', $default ) ); |
| 490 | 932 | } |
| 491 | 933 | |
| 492 | 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 | +/** | |
| 493 | 949 | * Return the topic view slug |
| 494 | 950 | * |
| 495 | - * @since bbPress (r3759) | |
| 951 | + * @since 2.1.0 bbPress (r3759) | |
| 952 | + * | |
| 953 | + * @param string $default Optional. Default value 'view' | |
| 496 | 954 | * @return string |
| 497 | 955 | */ |
| 498 | 956 | function bbp_get_view_slug( $default = 'view' ) { |
| 957 | + | |
| 958 | + // Filter & return | |
| 499 | 959 | return apply_filters( 'bbp_get_view_slug', bbp_maybe_get_root_slug() . get_option( '_bbp_view_slug', $default ) ); |
| 500 | 960 | } |
| 501 | 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 | + | |
| 502 | 990 | /** Legacy ********************************************************************/ |
| 503 | 991 | |
| 504 | 992 | /** |
| 505 | 993 | * Checks if there is a previous BuddyPress Forum configuration |
| 506 | 994 | * |
| 507 | - * @since bbPress (r3790) | |
| 508 | - * @param $default string Optional. Default empty string | |
| 509 | - * @uses get_option() To get the old bb-config.php location | |
| 995 | + * @since 2.1.0 bbPress (r3790) | |
| 996 | + * | |
| 997 | + * @param string $default Optional. Default empty string | |
| 510 | 998 | * @return string The location of the bb-config.php file, if any |
| 511 | 999 | */ |
| 512 | 1000 | function bbp_get_config_location( $default = '' ) { |
| 1001 | + | |
| 1002 | + // Filter & return | |
| 513 | 1003 | return apply_filters( 'bbp_get_config_location', get_option( 'bb-config-location', $default ) ); |
| 514 | 1004 | } |