/bp-core/bp-core-options.php

  1. <?php 
  2. /** 
  3. * BuddyPress Options. 
  4. * 
  5. * @package BuddyPress 
  6. * @subpackage Options 
  7. * @since 1.6.0 
  8. */ 
  9.  
  10. // Exit if accessed directly. 
  11. defined( 'ABSPATH' ) || exit; 
  12.  
  13. /** 
  14. * Get the default site options and their values. 
  15. * 
  16. * Default values should not be set by calls to `get_option()` or `get_site_option()` due to 
  17. * these causing load order problems with `bp_core_clear_root_options_cache()`; see #BP7227. 
  18. * 
  19. * @since 1.6.0 
  20. * 
  21. * @return array Filtered option names and values. 
  22. */ 
  23. function bp_get_default_options() { 
  24.  
  25. // Default options. 
  26. $options = array ( 
  27.  
  28. /** Components ********************************************************/ 
  29.  
  30. 'bp-deactivated-components' => array(),  
  31.  
  32. /** bbPress ***********************************************************/ 
  33.  
  34. // Legacy bbPress config location. 
  35. 'bb-config-location' => ABSPATH . 'bb-config.php',  
  36.  
  37. /** XProfile **********************************************************/ 
  38.  
  39. // Base profile groups name. 
  40. 'bp-xprofile-base-group-name' => 'Base',  
  41.  
  42. // Base fullname field name. 
  43. 'bp-xprofile-fullname-field-name' => 'Name',  
  44.  
  45. /** Blogs *************************************************************/ 
  46.  
  47. // Used to decide if blogs need indexing. 
  48. 'bp-blogs-first-install' => false,  
  49.  
  50. /** Settings **********************************************************/ 
  51.  
  52. // Disable the WP to BP profile sync. 
  53. 'bp-disable-profile-sync' => false,  
  54.  
  55. // Hide the Toolbar for logged out users. 
  56. 'hide-loggedout-adminbar' => false,  
  57.  
  58. // Avatar uploads. 
  59. 'bp-disable-avatar-uploads' => false,  
  60.  
  61. // Cover image uploads. 
  62. 'bp-disable-cover-image-uploads' => false,  
  63.  
  64. // Group Profile Photos. 
  65. 'bp-disable-group-avatar-uploads' => false,  
  66.  
  67. // Group Cover image uploads. 
  68. 'bp-disable-group-cover-image-uploads' => false,  
  69.  
  70. // Allow users to delete their own accounts. 
  71. 'bp-disable-account-deletion' => false,  
  72.  
  73. // Allow comments on blog and forum activity items. 
  74. 'bp-disable-blogforum-comments' => true,  
  75.  
  76. // The ID for the current theme package. 
  77. '_bp_theme_package_id' => 'legacy',  
  78.  
  79. // Email unsubscribe salt. 
  80. 'bp-emails-unsubscribe-salt' => '',  
  81.  
  82. /** Groups ************************************************************/ 
  83.  
  84. // @todo Move this into the groups component 
  85. // Restrict group creation to super admins. 
  86. 'bp_restrict_group_creation' => false,  
  87.  
  88. /** Akismet ***********************************************************/ 
  89.  
  90. // Users from all sites can post. 
  91. '_bp_enable_akismet' => true,  
  92.  
  93. /** Activity HeartBeat ************************************************/ 
  94.  
  95. // HeartBeat is on to refresh activities. 
  96. '_bp_enable_heartbeat_refresh' => true,  
  97.  
  98. /** BuddyBar **********************************************************/ 
  99.  
  100. // Force the BuddyBar. 
  101. '_bp_force_buddybar' => false,  
  102.  
  103. /** Legacy *********************************************/ 
  104.  
  105. // Do not register the bp-default themes directory. 
  106. '_bp_retain_bp_default' => false,  
  107.  
  108. // Ignore deprecated code. 
  109. '_bp_ignore_deprecated_code' => true,  
  110.  
  111. /** Widgets **************************************************/ 
  112. 'widget_bp_core_login_widget' => false,  
  113. 'widget_bp_core_members_widget' => false,  
  114. 'widget_bp_core_whos_online_widget' => false,  
  115. 'widget_bp_core_recently_active_widget' => false,  
  116. 'widget_bp_groups_widget' => false,  
  117. 'widget_bp_messages_sitewide_notices_widget' => false,  
  118. ); 
  119.  
  120. /** 
  121. * Filters the default options to be set upon activation. 
  122. * 
  123. * @since 1.6.0 
  124. * 
  125. * @param array $options Array of default options to set. 
  126. */ 
  127. return apply_filters( 'bp_get_default_options', $options ); 
  128.  
  129. /** 
  130. * Add default options when BuddyPress is first activated. 
  131. * 
  132. * Only called once when BuddyPress is activated. 
  133. * Non-destructive, so existing settings will not be overridden. 
  134. * 
  135. * @since 1.6.0 
  136. */ 
  137. function bp_add_options() { 
  138.  
  139. // Get the default options and values. 
  140. $options = bp_get_default_options(); 
  141.  
  142. // Add default options. 
  143. foreach ( $options as $key => $value ) { 
  144. bp_add_option( $key, $value ); 
  145.  
  146. /** 
  147. * Fires after the addition of default options when BuddyPress is first activated. 
  148. * 
  149. * Allows previously activated plugins to append their own options. 
  150. * 
  151. * @since 1.6.0 
  152. */ 
  153. do_action( 'bp_add_options' ); 
  154.  
  155. /** 
  156. * Delete default options. 
  157. * 
  158. * Hooked to bp_uninstall, it is only called once when BuddyPress is uninstalled. 
  159. * This is destructive, so existing settings will be destroyed. 
  160. * 
  161. * Currently unused. 
  162. * 
  163. * @since 1.6.0 
  164. */ 
  165. function bp_delete_options() { 
  166.  
  167. // Get the default options and values. 
  168. $options = bp_get_default_options(); 
  169.  
  170. // Add default options. 
  171. foreach ( array_keys( $options ) as $key ) { 
  172. delete_option( $key ); 
  173.  
  174. /** 
  175. * Fires after the deletion of default options when BuddyPress is first deactivated. 
  176. * 
  177. * Allows previously activated plugins to append their own options. 
  178. * 
  179. * @since 1.6.0 
  180. */ 
  181. do_action( 'bp_delete_options' ); 
  182.  
  183. /** 
  184. * Add filters to each BP option, allowing them to be overloaded from inside the $bp->options array. 
  185. * 
  186. * Currently unused. 
  187. * 
  188. * @since 1.6.0 
  189. */ 
  190. function bp_setup_option_filters() { 
  191.  
  192. // Get the default options and values. 
  193. $options = bp_get_default_options(); 
  194.  
  195. // Add filters to each BuddyPress option. 
  196. foreach ( array_keys( $options ) as $key ) { 
  197. add_filter( 'pre_option_' . $key, 'bp_pre_get_option' ); 
  198.  
  199. /** 
  200. * Fires after the addition of filters to each BuddyPress option. 
  201. * 
  202. * Allows previously activated plugins to append their own options. 
  203. * 
  204. * @since 1.6.0 
  205. */ 
  206. do_action( 'bp_setup_option_filters' ); 
  207.  
  208. /** 
  209. * Filter default options and allow them to be overloaded from inside the $bp->options array. 
  210. * 
  211. * Currently unused. 
  212. * 
  213. * @since 1.6.0 
  214. * 
  215. * @param bool $value Optional. Default value false. 
  216. * @return mixed False if not overloaded, mixed if set. 
  217. */ 
  218. function bp_pre_get_option( $value = false ) { 
  219. $bp = buddypress(); 
  220.  
  221. // Get the name of the current filter so we can manipulate it. 
  222. $filter = current_filter(); 
  223.  
  224. // Remove the filter prefix. 
  225. $option = str_replace( 'pre_option_', '', $filter ); 
  226.  
  227. // Check the options global for preset value. 
  228. if ( ! empty( $bp->options[ $option ] ) ) { 
  229. $value = $bp->options[ $option ]; 
  230.  
  231. // Always return a value, even if false. 
  232. return $value; 
  233.  
  234. /** 
  235. * Retrieve an option. 
  236. * 
  237. * This is a wrapper for {@link get_blog_option()}, which in turn stores settings data 
  238. * (such as bp-pages) on the appropriate blog, given your current setup. 
  239. * 
  240. * The 'bp_get_option' filter is primarily for backward-compatibility. 
  241. * 
  242. * @since 1.5.0 
  243. * 
  244. * @param string $option_name The option to be retrieved. 
  245. * @param string $default Optional. Default value to be returned if the option 
  246. * isn't set. See {@link get_blog_option()}. 
  247. * @return mixed The value for the option. 
  248. */ 
  249. function bp_get_option( $option_name, $default = '' ) { 
  250. $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default ); 
  251.  
  252. /** 
  253. * Filters the option value for the requested option. 
  254. * 
  255. * @since 1.5.0 
  256. * 
  257. * @param mixed $value The value for the option. 
  258. */ 
  259. return apply_filters( 'bp_get_option', $value ); 
  260.  
  261. /** 
  262. * Add an option. 
  263. * 
  264. * This is a wrapper for {@link add_blog_option()}, which in turn stores 
  265. * settings data on the appropriate blog, given your current setup. 
  266. * 
  267. * @since 2.0.0 
  268. * 
  269. * @param string $option_name The option key to be set. 
  270. * @param mixed $value The value to be set. 
  271. * @return bool True on success, false on failure. 
  272. */ 
  273. function bp_add_option( $option_name, $value ) { 
  274. return add_blog_option( bp_get_root_blog_id(), $option_name, $value ); 
  275.  
  276. /** 
  277. * Save an option. 
  278. * 
  279. * This is a wrapper for {@link update_blog_option()}, which in turn stores 
  280. * settings data (such as bp-pages) on the appropriate blog, given your current 
  281. * setup. 
  282. * 
  283. * @since 1.5.0 
  284. * 
  285. * @param string $option_name The option key to be set. 
  286. * @param string $value The value to be set. 
  287. * @return bool True on success, false on failure. 
  288. */ 
  289. function bp_update_option( $option_name, $value ) { 
  290. return update_blog_option( bp_get_root_blog_id(), $option_name, $value ); 
  291.  
  292. /** 
  293. * Delete an option. 
  294. * 
  295. * This is a wrapper for {@link delete_blog_option()}, which in turn deletes 
  296. * settings data (such as bp-pages) on the appropriate blog, given your current 
  297. * setup. 
  298. * 
  299. * @since 1.5.0 
  300. * 
  301. * @param string $option_name The option key to be deleted. 
  302. * @return bool True on success, false on failure. 
  303. */ 
  304. function bp_delete_option( $option_name ) { 
  305. return delete_blog_option( bp_get_root_blog_id(), $option_name ); 
  306.  
  307. /** 
  308. * Copy BP options from a single site to multisite config. 
  309. * 
  310. * Run when switching from single to multisite and we need to copy blog options 
  311. * to site options. 
  312. * 
  313. * This function is no longer used. 
  314. * 
  315. * @since 1.2.4 
  316. * @deprecated 1.6.0 
  317. * 
  318. * @param array $keys Array of site options. 
  319. * @return bool 
  320. */ 
  321. function bp_core_activate_site_options( $keys = array() ) { 
  322.  
  323. if ( !empty( $keys ) && is_array( $keys ) ) { 
  324. $bp = buddypress(); 
  325.  
  326. $errors = false; 
  327.  
  328. foreach ( $keys as $key => $default ) { 
  329. if ( empty( $bp->site_options[ $key ] ) ) { 
  330. $bp->site_options[ $key ] = bp_get_option( $key, $default ); 
  331.  
  332. if ( !bp_update_option( $key, $bp->site_options[ $key ] ) ) { 
  333. $errors = true; 
  334.  
  335. if ( empty( $errors ) ) { 
  336. return true; 
  337.  
  338. return false; 
  339.  
  340. /** 
  341. * Fetch global BP options. 
  342. * 
  343. * BuddyPress uses common options to store configuration settings. Many of these 
  344. * settings are needed at run time. Instead of fetching them all and adding many 
  345. * initial queries to each page load, let's fetch them all in one go. 
  346. * 
  347. * @since 1.5.0 
  348. * 
  349. * @todo Use settings API and audit these methods. 
  350. * 
  351. * @return array $root_blog_options_meta List of options. 
  352. */ 
  353. function bp_core_get_root_options() { 
  354. global $wpdb; 
  355.  
  356. // Get all the BuddyPress settings, and a few useful WP ones too. 
  357. $root_blog_options = bp_get_default_options(); 
  358. $root_blog_options['registration'] = '0'; 
  359. $root_blog_options['avatar_default'] = 'mysteryman'; 
  360. $root_blog_option_keys = array_keys( $root_blog_options ); 
  361.  
  362. // Do some magic to get all the root blog options in 1 swoop 
  363. // Check cache first - We cache here instead of using the standard WP 
  364. // settings cache because the current blog may not be the root blog,  
  365. // and it's not practical to access the cache across blogs. 
  366. $root_blog_options_meta = wp_cache_get( 'root_blog_options', 'bp' ); 
  367.  
  368. if ( false === $root_blog_options_meta ) { 
  369. $blog_options_keys = "'" . join( "', '", (array) $root_blog_option_keys ) . "'"; 
  370. $blog_options_table = bp_is_multiblog_mode() ? $wpdb->options : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'options'; 
  371. $blog_options_query = "SELECT option_name AS name, option_value AS value FROM {$blog_options_table} WHERE option_name IN ( {$blog_options_keys} )"; 
  372. $root_blog_options_meta = $wpdb->get_results( $blog_options_query ); 
  373.  
  374. // On Multisite installations, some options must always be fetched from sitemeta. 
  375. if ( is_multisite() ) { 
  376.  
  377. /** 
  378. * Filters multisite options retrieved from sitemeta. 
  379. * 
  380. * @since 1.5.0 
  381. * 
  382. * @param array $value Array of multisite options from sitemeta table. 
  383. */ 
  384. $network_options = apply_filters( 'bp_core_network_options', array( 
  385. 'tags_blog_id' => '0',  
  386. 'sitewide_tags_blog' => '',  
  387. 'registration' => '0',  
  388. 'fileupload_maxk' => '1500' 
  389. ) ); 
  390.  
  391. $current_site = get_current_site(); 
  392. $network_option_keys = array_keys( $network_options ); 
  393. $sitemeta_options_keys = "'" . join( "', '", (array) $network_option_keys ) . "'"; 
  394. $sitemeta_options_query = $wpdb->prepare( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ( {$sitemeta_options_keys} ) AND site_id = %d", $current_site->id ); 
  395. $network_options_meta = $wpdb->get_results( $sitemeta_options_query ); 
  396.  
  397. // Sitemeta comes second in the merge, so that network 'registration' value wins. 
  398. $root_blog_options_meta = array_merge( $root_blog_options_meta, $network_options_meta ); 
  399.  
  400. // Loop through our results and make them usable. 
  401. foreach ( $root_blog_options_meta as $root_blog_option ) { 
  402. $root_blog_options[$root_blog_option->name] = $root_blog_option->value; 
  403.  
  404. // Copy the options no the return val. 
  405. $root_blog_options_meta = $root_blog_options; 
  406.  
  407. // Clean up our temporary copy. 
  408. unset( $root_blog_options ); 
  409.  
  410. wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' ); 
  411.  
  412. /** 
  413. * Filters the global BP options. 
  414. * 
  415. * @since 1.5.0 
  416. * 
  417. * @param array $root_blog_options_meta Array of global BP options. 
  418. */ 
  419. return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta ); 
  420.  
  421. /** 
  422. * Get a root option. 
  423. * 
  424. * "Root options" are those that apply across an entire installation, and are fetched only a single 
  425. * time during a pageload and stored in `buddypress()->site_options` to prevent future lookups. 
  426. * See {@see bp_core_get_root_options()}. 
  427. * 
  428. * @since 2.3.0 
  429. * 
  430. * @param string $option Name of the option key. 
  431. * @return mixed Value, if found. 
  432. */ 
  433. function bp_core_get_root_option( $option ) { 
  434. $bp = buddypress(); 
  435.  
  436. if ( ! isset( $bp->site_options ) ) { 
  437. $bp->site_options = bp_core_get_root_options(); 
  438.  
  439. $value = ''; 
  440. if ( isset( $bp->site_options[ $option ] ) ) { 
  441. $value = $bp->site_options[ $option ]; 
  442.  
  443. return $value; 
  444.  
  445. /** Active? *******************************************************************/ 
  446.  
  447. /** 
  448. * Is profile syncing disabled? 
  449. * 
  450. * @since 1.6.0 
  451. * 
  452. * @param bool $default Optional. Fallback value if not found in the database. 
  453. * Default: true. 
  454. * @return bool True if profile sync is enabled, otherwise false. 
  455. */ 
  456. function bp_disable_profile_sync( $default = false ) { 
  457.  
  458. /** 
  459. * Filters whether or not profile syncing is disabled. 
  460. * 
  461. * @since 1.6.0 
  462. * 
  463. * @param bool $value Whether or not syncing is disabled. 
  464. */ 
  465. return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) ); 
  466.  
  467. /** 
  468. * Is the Toolbar hidden for logged out users? 
  469. * 
  470. * @since 1.6.0 
  471. * 
  472. * @param bool $default Optional. Fallback value if not found in the database. 
  473. * Default: true. 
  474. * @return bool True if the admin bar should be hidden for logged-out users,  
  475. * otherwise false. 
  476. */ 
  477. function bp_hide_loggedout_adminbar( $default = true ) { 
  478.  
  479. /** 
  480. * Filters whether or not the toolbar is hidden for logged out users. 
  481. * 
  482. * @since 1.6.0 
  483. * 
  484. * @param bool $value Whether or not the toolbar is hidden. 
  485. */ 
  486. return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) ); 
  487.  
  488. /** 
  489. * Are members able to upload their own avatars? 
  490. * 
  491. * @since 1.6.0 
  492. * 
  493. * @param bool $default Optional. Fallback value if not found in the database. 
  494. * Default: true. 
  495. * @return bool True if avatar uploads are disabled, otherwise false. 
  496. */ 
  497. function bp_disable_avatar_uploads( $default = true ) { 
  498.  
  499. /** 
  500. * Filters whether or not members are able to upload their own avatars. 
  501. * 
  502. * @since 1.6.0 
  503. * 
  504. * @param bool $value Whether or not members are able to upload their own avatars. 
  505. */ 
  506. return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) ); 
  507.  
  508. /** 
  509. * Are members able to upload their own cover images? 
  510. * 
  511. * @since 2.4.0 
  512. * 
  513. * @param bool $default Optional. Fallback value if not found in the database. 
  514. * Default: false. 
  515. * @return bool True if cover image uploads are disabled, otherwise false. 
  516. */ 
  517. function bp_disable_cover_image_uploads( $default = false ) { 
  518.  
  519. /** 
  520. * Filters whether or not members are able to upload their own cover images. 
  521. * 
  522. * @since 2.4.0 
  523. * 
  524. * @param bool $value Whether or not members are able to upload their own cover images. 
  525. */ 
  526. return (bool) apply_filters( 'bp_disable_cover_image_uploads', (bool) bp_get_option( 'bp-disable-cover-image-uploads', $default ) ); 
  527.  
  528. /** 
  529. * Are group avatars disabled? 
  530. * 
  531. * For backward compatibility, this option falls back on the value of 'bp-disable-avatar-uploads' when no value is 
  532. * found in the database. 
  533. * 
  534. * @since 2.3.0 
  535. * 
  536. * @param bool|null $default Optional. Fallback value if not found in the database. 
  537. * Defaults to the value of `bp_disable_avatar_uploads()`. 
  538. * @return bool True if group avatar uploads are disabled, otherwise false. 
  539. */ 
  540. function bp_disable_group_avatar_uploads( $default = null ) { 
  541. $disabled = bp_get_option( 'bp-disable-group-avatar-uploads', '' ); 
  542.  
  543. if ( '' === $disabled ) { 
  544. if ( is_null( $default ) ) { 
  545. $disabled = bp_disable_avatar_uploads(); 
  546. } else { 
  547. $disabled = $default; 
  548.  
  549. /** 
  550. * Filters whether or not members are able to upload group avatars. 
  551. * 
  552. * @since 2.3.0 
  553. * 
  554. * @param bool $disabled Whether or not members are able to upload their groups avatars. 
  555. * @param bool $default Default value passed to the function. 
  556. */ 
  557. return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default ); 
  558.  
  559. /** 
  560. * Are group cover images disabled? 
  561. * 
  562. * @since 2.4.0 
  563. * 
  564. * @param bool $default Optional. Fallback value if not found in the database. 
  565. * Default: false. 
  566. * @return bool True if group cover image uploads are disabled, otherwise false. 
  567. */ 
  568. function bp_disable_group_cover_image_uploads( $default = false ) { 
  569.  
  570. /** 
  571. * Filters whether or not members are able to upload group cover images. 
  572. * 
  573. * @since 2.4.0 
  574. * 
  575. * @param bool $value Whether or not members are able to upload thier groups cover images. 
  576. */ 
  577. return (bool) apply_filters( 'bp_disable_group_cover_image_uploads', (bool) bp_get_option( 'bp-disable-group-cover-image-uploads', $default ) ); 
  578.  
  579. /** 
  580. * Are members able to delete their own accounts? 
  581. * 
  582. * @since 1.6.0 
  583. * 
  584. * @param bool $default Optional. Fallback value if not found in the database. 
  585. * Default: true. 
  586. * @return bool True if users are able to delete their own accounts, otherwise 
  587. * false. 
  588. */ 
  589. function bp_disable_account_deletion( $default = false ) { 
  590.  
  591. /** 
  592. * Filters whether or not members are able to delete their own accounts. 
  593. * 
  594. * @since 1.6.0 
  595. * 
  596. * @param bool $value Whether or not members are able to delete their own accounts. 
  597. */ 
  598. return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) ); 
  599.  
  600. /** 
  601. * Are blog and forum activity stream comments disabled? 
  602. * 
  603. * @since 1.6.0 
  604. * 
  605. * @todo split and move into blog and forum components. 
  606. * 
  607. * @param bool $default Optional. Fallback value if not found in the database. 
  608. * Default: false. 
  609. * @return bool True if activity comments are disabled for blog and forum 
  610. * items, otherwise false. 
  611. */ 
  612. function bp_disable_blogforum_comments( $default = false ) { 
  613.  
  614. /** 
  615. * Filters whether or not blog and forum activity stream comments are disabled. 
  616. * 
  617. * @since 1.6.0 
  618. * 
  619. * @param bool $value Whether or not blog and forum activity stream comments are disabled. 
  620. */ 
  621. return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) ); 
  622.  
  623. /** 
  624. * Is group creation turned off? 
  625. * 
  626. * @since 1.6.0 
  627. * 
  628. * @todo Move into groups component. 
  629. * 
  630. * @param bool $default Optional. Fallback value if not found in the database. 
  631. * Default: true. 
  632. * @return bool True if group creation is restricted, otherwise false. 
  633. */ 
  634. function bp_restrict_group_creation( $default = true ) { 
  635.  
  636. /** 
  637. * Filters whether or not group creation is turned off. 
  638. * 
  639. * @since 1.6.0 
  640. * 
  641. * @param bool $value Whether or not group creation is turned off. 
  642. */ 
  643. return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) ); 
  644.  
  645. /** 
  646. * Should the old BuddyBar be forced in place of the WP admin bar? 
  647. * 
  648. * @since 1.6.0 
  649. * 
  650. * @param bool $default Optional. Fallback value if not found in the database. 
  651. * Default: true. 
  652. * @return bool True if the BuddyBar should be forced on, otherwise false. 
  653. */ 
  654. function bp_force_buddybar( $default = true ) { 
  655.  
  656. /** 
  657. * Filters whether or not BuddyBar should be forced in place of WP Admin Bar. 
  658. * 
  659. * @since 1.6.0 
  660. * 
  661. * @param bool $value Whether or not BuddyBar should be forced in place of WP Admin Bar. 
  662. */ 
  663. return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) ); 
  664.  
  665. /** 
  666. * Output the group forums root parent forum id. 
  667. * 
  668. * @since 1.6.0 
  669. * 
  670. * @param bool|string $default Optional. Default: '0'. 
  671. */ 
  672. function bp_group_forums_root_id( $default = '0' ) { 
  673. echo bp_get_group_forums_root_id( $default ); 
  674. /** 
  675. * Return the group forums root parent forum id. 
  676. * 
  677. * @since 1.6.0 
  678. * 
  679. * @param bool|string $default Optional. Default: '0'. 
  680. * @return int The ID of the group forums root forum. 
  681. */ 
  682. function bp_get_group_forums_root_id( $default = '0' ) { 
  683.  
  684. /** 
  685. * Filters the group forums root parent forum id. 
  686. * 
  687. * @since 1.6.0 
  688. * 
  689. * @param int $value The group forums root parent forum id. 
  690. */ 
  691. return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) ); 
  692.  
  693. /** 
  694. * Check whether BuddyPress Group Forums are enabled. 
  695. * 
  696. * @since 1.6.0 
  697. * 
  698. * @param bool $default Optional. Fallback value if not found in the database. 
  699. * Default: true. 
  700. * @return bool True if group forums are active, otherwise false. 
  701. */ 
  702. function bp_is_group_forums_active( $default = true ) { 
  703.  
  704. /** 
  705. * Filters whether or not BuddyPress Group Forums are enabled. 
  706. * 
  707. * @since 1.6.0 
  708. * 
  709. * @param bool $value Whether or not BuddyPress Group Forums are enabled. 
  710. */ 
  711. return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) ); 
  712.  
  713. /** 
  714. * Check whether Akismet is enabled. 
  715. * 
  716. * @since 1.6.0 
  717. * 
  718. * @param bool $default Optional. Fallback value if not found in the database. 
  719. * Default: true. 
  720. * @return bool True if Akismet is enabled, otherwise false. 
  721. */ 
  722. function bp_is_akismet_active( $default = true ) { 
  723.  
  724. /** 
  725. * Filters whether or not Akismet is enabled. 
  726. * 
  727. * @since 1.6.0 
  728. * 
  729. * @param bool $value Whether or not Akismet is enabled. 
  730. */ 
  731. return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) ); 
  732.  
  733. /** 
  734. * Check whether Activity Heartbeat refresh is enabled. 
  735. * 
  736. * @since 2.0.0 
  737. * 
  738. * @param bool $default Optional. Fallback value if not found in the database. 
  739. * Default: true. 
  740. * @return bool True if Heartbeat refresh is enabled, otherwise false. 
  741. */ 
  742. function bp_is_activity_heartbeat_active( $default = true ) { 
  743.  
  744. /** 
  745. * Filters whether or not Activity Heartbeat refresh is enabled. 
  746. * 
  747. * @since 2.0.0 
  748. * 
  749. * @param bool $value Whether or not Activity Heartbeat refresh is enabled. 
  750. */ 
  751. return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) ); 
  752.  
  753. /** 
  754. * Get the current theme package ID. 
  755. * 
  756. * @since 1.7.0 
  757. * 
  758. * @param string $default Optional. Fallback value if not found in the database. 
  759. * Default: 'legacy'. 
  760. * @return string ID of the theme package. 
  761. */ 
  762. function bp_get_theme_package_id( $default = 'legacy' ) { 
  763.  
  764. /** 
  765. * Filters the current theme package ID. 
  766. * 
  767. * @since 1.7.0 
  768. * 
  769. * @param string $value The current theme package ID. 
  770. */ 
  771. return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) ); 
.