Changeset 3451
- Timestamp:
- 08/25/2011 09:38:52 PM (15 years ago)
- Location:
- branches/plugin
- Files:
-
- 3 edited
-
bbp-includes/bbp-core-hooks.php (modified) (1 diff)
-
bbp-includes/bbp-core-options.php (modified) (4 diffs)
-
bbpress.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-core-hooks.php
r3445 r3451 70 70 add_action( 'bbp_init', 'bbp_register_shortcodes', 20 ); 71 71 add_action( 'bbp_init', 'bbp_add_rewrite_tags', 22 ); 72 add_action( 'bbp_init', 'bbp_add_option_filters', 24 ); 72 73 add_action( 'bbp_init', 'bbp_ready', 999 ); 73 74 -
branches/plugin/bbp-includes/bbp-core-options.php
r3445 r3451 140 140 * This is non-destructive, so existing settings will not be overridden. 141 141 * 142 * @uses bbp_get_default_options() To get default options 142 143 * @uses add_option() Adds default options 143 144 * @uses do_action() Calls 'bbp_add_options' … … 153 154 154 155 // Allow previously activated plugins to append their own options. 155 // This is an extremely rare use-case.156 156 do_action( 'bbp_add_options' ); 157 157 } … … 162 162 * This is destructive, so existing settings will be destroyed. 163 163 * 164 * @uses bbp_get_default_options() To get default options 164 165 * @uses delete_option() Removes default options 165 166 * @uses do_action() Calls 'bbp_delete_options' … … 175 176 176 177 // Allow previously activated plugins to append their own options. 177 // This is an extremely rare use-case.178 178 do_action( 'bbp_delete_options' ); 179 } 180 181 /** 182 * Add filters to each bbPress option and allow them to be overloaded from 183 * inside the $bbp->options array. 184 * 185 * @since bbPress (r3451) 186 * 187 * @uses bbp_get_default_options() To get default options 188 * @uses add_filter() To add filters to 'pre_option_{$key}' 189 * @uses do_action() Calls 'bbp_add_option_filters' 190 */ 191 function bbp_add_option_filters() { 192 193 // Get the default options and values 194 $options = bbp_get_default_options(); 195 196 // Add filters to each bbPress option 197 foreach ( $options as $key => $value ) 198 add_filter( 'pre_option_' . $key, 'bbp_pre_get_option' ); 199 200 // Allow previously activated plugins to append their own options. 201 do_action( 'bbp_add_option_filters' ); 202 } 203 204 /** 205 * Filter default options and allow them to be overloaded from inside the 206 * $bbp->options array. 207 * 208 * @since bbPress (r3451) 209 * 210 * @global bbPress $bbp 211 * @param bool $value 212 * @return mixed false if not overloaded, mixed if set 213 */ 214 function bbp_pre_get_option( $value = false ) { 215 global $bbp; 216 217 // Get the name of the current filter so we can manipulate it 218 $filter = current_filter(); 219 220 // Remove the filter prefix 221 $option = str_replace( 'pre_option_', '', $filter ); 222 223 // Check the options global for preset value 224 if ( !empty( $bbp->options[$option] ) ) 225 $value = $bbp->options[$option]; 226 227 // Always return a value, even if false 228 return $value; 179 229 } 180 230 -
branches/plugin/bbpress.php
r3432 r3451 275 275 */ 276 276 public $extend = false; 277 278 /** Option Overload *******************************************************/ 279 280 /** 281 * @var array Optional Overloads default options retrieved from get_option() 282 */ 283 public $options = array(); 277 284 278 285 /** Functions *************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.