| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* bbPress Options |
| 5 |
* |
| 6 |
* @package bbPress |
| 7 |
* @subpackage Options |
| 8 |
*/ |
| 9 |
|
| 10 |
// Exit if accessed directly |
| 11 |
if ( !defined( 'ABSPATH' ) ) exit; |
| 12 |
|
| 13 |
/** |
| 14 |
* Add default options |
| 15 |
* |
| 16 |
* Hooked to bbp_activate, it is only called once when bbPress is activated. |
| 17 |
* This is non-destructive, so existing settings will not be overridden. |
| 18 |
* |
| 19 |
* @uses add_option() Adds default options |
| 20 |
* @uses do_action() Calls 'bbp_add_options' |
| 21 |
*/ |
| 22 |
function bbp_add_options() { |
| 23 |
|
| 24 |
// Default options |
| 25 |
$options = array ( |
| 26 |
|
| 27 |
/** Database **********************************************************/ |
| 28 |
|
| 29 |
// DB version |
| 30 |
'_bbp_db_version' => '110', |
| 31 |
|
| 32 |
/** Settings **********************************************************/ |
| 33 |
|
| 34 |
// Lock post editing after 5 minutes |
| 35 |
'_bbp_edit_lock' => '5', |
| 36 |
|
| 37 |
// Throttle post time to 10 seconds |
| 38 |
'_bbp_throttle_time' => '10', |
| 39 |
|
| 40 |
// Favorites |
| 41 |
'_bbp_enable_favorites' => true, |
| 42 |
|
| 43 |
// Subscriptions |
| 44 |
'_bbp_enable_subscriptions' => true, |
| 45 |
|
| 46 |
// Allow anonymous posting |
| 47 |
'_bbp_allow_anonymous' => false, |
| 48 |
|
| 49 |
/** Per Page **********************************************************/ |
| 50 |
|
| 51 |
// Topics per page |
| 52 |
'_bbp_topics_per_page' => '15', |
| 53 |
|
| 54 |
// Replies per page |
| 55 |
'_bbp_replies_per_page' => '15', |
| 56 |
|
| 57 |
// Forums per page |
| 58 |
'_bbp_forums_per_page' => '50', |
| 59 |
|
| 60 |
// Topics per RSS page |
| 61 |
'_bbp_topics_per_rss_page' => '25', |
| 62 |
|
| 63 |
// Replies per RSS page |
| 64 |
'_bbp_replies_per_rss_page' => '25', |
| 65 |
|
| 66 |
/** Page For **********************************************************/ |
| 67 |
|
| 68 |
// Page for forums |
| 69 |
'_bbp_page_for_forums' => '0', |
| 70 |
|
| 71 |
// Page for forums |
| 72 |
'_bbp_page_for_topics' => '0', |
| 73 |
|
| 74 |
// Page for login |
| 75 |
'_bbp_page_for_login' => '0', |
| 76 |
|
| 77 |
// Page for register |
| 78 |
'_bbp_page_for_register' => '0', |
| 79 |
|
| 80 |
// Page for lost-pass |
| 81 |
'_bbp_page_for_lost_pass' => '0', |
| 82 |
|
| 83 |
/** Archive Slugs *****************************************************/ |
| 84 |
|
| 85 |
// Forum archive slug |
| 86 |
'_bbp_root_slug' => 'forums', |
| 87 |
|
| 88 |
// Topic archive slug |
| 89 |
'_bbp_topic_archive_slug' => 'topics', |
| 90 |
|
| 91 |
/** Single Slugs ******************************************************/ |
| 92 |
|
| 93 |
// Include Forum archive before single slugs |
| 94 |
'_bbp_include_root' => true, |
| 95 |
|
| 96 |
// Forum slug |
| 97 |
'_bbp_forum_slug' => 'forum', |
| 98 |
|
| 99 |
// Topic slug |
| 100 |
'_bbp_topic_slug' => 'topic', |
| 101 |
|
| 102 |
// Reply slug |
| 103 |
'_bbp_reply_slug' => 'reply', |
| 104 |
|
| 105 |
// Topic tag slug |
| 106 |
'_bbp_topic_tag_slug' => 'topic-tag', |
| 107 |
|
| 108 |
/** Other Slugs *******************************************************/ |
| 109 |
|
| 110 |
// User profile slug |
| 111 |
'_bbp_user_slug' => 'users', |
| 112 |
|
| 113 |
// View slug |
| 114 |
'_bbp_view_slug' => 'view', |
| 115 |
|
| 116 |
/** Topics ************************************************************/ |
| 117 |
|
| 118 |
// Title Max Length |
| 119 |
'_bbp_title_max_length' => '80', |
| 120 |
|
| 121 |
// Super stickies |
| 122 |
'_bbp_super_sticky_topics' => '', |
| 123 |
|
| 124 |
/** Forums ************************************************************/ |
| 125 |
|
| 126 |
// Private forums |
| 127 |
'_bbp_private_forums' => '', |
| 128 |
|
| 129 |
// Hidden forums |
| 130 |
'_bbp_hidden_forums' => '', |
| 131 |
); |
| 132 |
|
| 133 |
// Add default options |
| 134 |
foreach ( $options as $key => $value ) |
| 135 |
add_option( $key, $value ); |
| 136 |
|
| 137 |
// Allow previously activated plugins to append their own options. |
| 138 |
// This is an extremely rare use-case. |
| 139 |
do_action( 'bbp_add_options' ); |
| 140 |
} |
| 141 |
|
| 142 |
/** Active? *******************************************************************/ |
| 143 |
|
| 144 |
/** |
| 145 |
* Checks if favorites feature is enabled. |
| 146 |
* |
| 147 |
* @since bbPress (r2658) |
| 148 |
* |
| 149 |
* @param $default bool Optional.Default value |
| 150 |
* |
| 151 |
* @uses get_option() To get the favorites option |
| 152 |
* @return bool Is favorites enabled or not |
| 153 |
*/ |
| 154 |
function bbp_is_favorites_active( $default = true ) { |
| 155 |
return apply_filters( 'bbp_is_favorites_active', (bool) get_option( '_bbp_enable_favorites', $default ) ); |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* Checks if subscription feature is enabled. |
| 160 |
* |
| 161 |
* @since bbPress (r2658) |
| 162 |
* |
| 163 |
* @param $default bool Optional.Default value |
| 164 |
* |
| 165 |
* @uses get_option() To get the subscriptions option |
| 166 |
* @return bool Is subscription enabled or not |
| 167 |
*/ |
| 168 |
function bbp_is_subscriptions_active( $default = true ) { |
| 169 |
return apply_filters( 'bbp_is_subscriptions_active', (bool) get_option( '_bbp_enable_subscriptions', $default ) ); |
| 170 |
} |
| 171 |
|
| 172 |
/** |
| 173 |
* Is the anonymous posting allowed? |
| 174 |
* |
| 175 |
* @since bbPress (r2659) |
| 176 |
* |
| 177 |
* @param $default bool Optional. Default value |
| 178 |
* |
| 179 |
* @uses get_option() To get the allow anonymous option |
| 180 |
* @return bool Is anonymous posting allowed? |
| 181 |
*/ |
| 182 |
function bbp_allow_anonymous( $default = false ) { |
| 183 |
return apply_filters( 'bbp_allow_anonymous', (bool) get_option( '_bbp_allow_anonymous', $default ) ); |
| 184 |
} |
| 185 |
|
| 186 |
/** |
| 187 |
* Output the maximum length of a title |
| 188 |
* |
| 189 |
* @since bbPress (r3246) |
| 190 |
* |
| 191 |
* @param $default bool Optional. Default value |
| 192 |
*/ |
| 193 |
function bbp_title_max_length( $default = '80' ) { |
| 194 |
echo bbp_get_title_max_length( $default ); |
| 195 |
} |
| 196 |
/** |
| 197 |
* Return the maximum length of a title |
| 198 |
* |
| 199 |
* @since bbPress (r3246) |
| 200 |
* |
| 201 |
* @param $default bool Optional. Default value |
| 202 |
* |
| 203 |
* @uses get_option() To get the maximum title length |
| 204 |
* @return int Is anonymous posting allowed? |
| 205 |
*/ |
| 206 |
function bbp_get_title_max_length( $default = '80' ) { |
| 207 |
return apply_filters( 'bbp_get_title_max_length', (int) get_option( '_bbp_title_max_length', $default ) ); |
| 208 |
} |
| 209 |
|
| 210 |
?> |
| 211 |
|