Changeset 6751
- Timestamp:
- 12/08/2017 02:09:08 PM (7 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/abstraction.php
r6739 r6751 74 74 } 75 75 76 /** Globals *******************************************************************/ 77 76 78 /** 77 79 * Lookup and return a global variable … … 144 146 return bbp_get_global_object( 'wpdb', 'WPDB' ); 145 147 } 148 149 /** Pagination ****************************************************************/ 146 150 147 151 /** … … 302 306 } 303 307 308 /** Multisite *****************************************************************/ 309 304 310 /** 305 311 * Is this a large bbPress installation? … … 359 365 * @since 2.6.0 bbPress (r6733) 360 366 */ 361 function bbp_restore_current_site( 367 function bbp_restore_current_site() { 362 368 363 369 // Switch back to the original site … … 365 371 restore_current_blog(); 366 372 } 373 } 374 375 /** Interception **************************************************************/ 376 377 /** 378 * Generate a default intercept value. 379 * 380 * @since 2.6.0 381 * 382 * @staticvar mixed $rand Null by default, random string on first call 383 * 384 * @return string 385 */ 386 function bbp_default_intercept() { 387 static $rand = null; 388 389 // Generate a new random and unique string 390 if ( null === $rand ) { 391 392 // If ext/hash is not present, compat.php's hash_hmac() does not support sha256. 393 $algo = function_exists( 'hash' ) 394 ? 'sha256' 395 : 'sha1'; 396 397 // Old WP installs may not have AUTH_SALT defined. 398 $salt = defined( 'AUTH_SALT' ) && AUTH_SALT 399 ? AUTH_SALT 400 : (string) wp_rand(); 401 402 // Create unique ID 403 $rand = hash_hmac( $algo, uniqid( $salt, true ), $salt ); 404 } 405 406 // Return random string (from locally static variable) 407 return $rand; 408 } 409 410 /** 411 * Whether a value has been intercepted 412 * 413 * @since 2.6.0 414 * 415 * @param bool $value 416 */ 417 function bbp_is_intercepted( $value = '' ) { 418 return ( bbp_default_intercept() === $value ); 419 } 420 421 /** 422 * Allow interception of a method or function call. 423 * 424 * @since 2.6.0 425 * 426 * @param string $action Typically the name of the caller function 427 * @param array $args Typically the results of caller function func_get_args() 428 * 429 * @return mixed Intercept results. Default bbp_default_intercept(). 430 */ 431 function bbp_maybe_intercept( $action = '', $args = array() ) { 432 433 // Backwards compatibility juggle 434 $hook = ( false === strpos( $action, 'pre_' ) ) 435 ? "pre_{$action}" 436 : $action; 437 438 // Sanitize the hook same 439 $key = sanitize_key( $hook ); 440 441 // Default return value 442 $default = bbp_default_intercept(); 443 444 // Filter and return 445 return apply_filters( $key, $default, extract( (array) $args ) ); 367 446 } 368 447 -
trunk/src/includes/core/options.php
r6705 r6751 263 263 } 264 264 265 // Bail if strategy is overloaded to false|null266 $ strategy = apply_filters( 'bbp_pre_load_options', 'notoptions' );267 if ( empty( $strategy) ) {268 return ;265 // Maybe intercept 266 $intercept = bbp_maybe_intercept( __FUNCTION__, 'notoptions' ); 267 if ( bbp_is_intercepted( $intercept ) ) { 268 return $intercept; 269 269 } 270 270 -
trunk/src/includes/extend/buddypress/functions.php
r6674 r6751 794 794 } 795 795 796 /** 797 * Overrides the formatted activity action new activity string. 798 * 799 * @since 2.6.0 bbPress (r6370) 800 * 801 * @param string $activity_action Activity action string value 802 * @param string $type The type of post. Expects `topic` or `reply`. 803 * @param string $action The current action string. 804 * @param BP_Activity_Activity $activity The BuddyPress activity object. 805 */ 806 if ( $pre = apply_filters( 'bbp_pre_format_activity_action_new_post', false, $type, $action, $activity ) ) { 807 return $pre; 796 // Bail if intercepted 797 $intercept = bbp_maybe_intercept( __FUNCTION__, func_get_args() ); 798 if ( bbp_is_intercepted( $intercept ) ) { 799 return $intercept; 808 800 } 809 801 -
trunk/src/includes/topics/template.php
r6737 r6751 321 321 function bbp_add_sticky_topics( &$query, $args = array() ) { 322 322 323 // Bail if overloaded 324 if ( null !== apply_filters( 'bbp_pre_add_stick_topics', null, $query, $args ) ) { 325 return; 323 // Bail if intercepted 324 $intercept = bbp_maybe_intercept( __FUNCTION__, func_get_args() ); 325 if ( bbp_is_intercepted( $intercept ) ) { 326 return $intercept; 326 327 } 327 328 -
trunk/src/includes/users/template.php
r6745 r6751 535 535 } 536 536 537 // Allow early overriding of the profile URL to cut down on processing538 $ early_profile_url = apply_filters( 'bbp_pre_get_user_profile_url', $user_id);539 if ( is_string( $early_profile_url) ) {540 return $ early_profile_url;537 // Bail if intercepted 538 $intercept = bbp_maybe_intercept( 'bbp_pre_get_user_profile_url', func_get_args() ); 539 if ( bbp_is_intercepted( $intercept ) ) { 540 return $intercept; 541 541 } 542 542 … … 625 625 } 626 626 627 // Allow early overriding of the profile edit URL to cut down on processing628 $ early_profile_url = apply_filters( 'bbp_pre_get_user_profile_edit_url', $user_id);629 if ( is_string( $early_profile_url) ) {630 return $ early_profile_url;627 // Bail if intercepted 628 $intercept = bbp_maybe_intercept( 'bbp_pre_get_user_profile_edit_url', func_get_args() ); 629 if ( bbp_is_intercepted( $intercept ) ) { 630 return $intercept; 631 631 } 632 632 … … 984 984 } 985 985 986 // Allow early overriding of the profile URL to cut down on processing987 $ early_profile_url = apply_filters( 'bbp_pre_get_favorites_permalink', $user_id);988 if ( is_string( $early_profile_url) ) {989 return $ early_profile_url;986 // Bail if intercepted 987 $intercept = bbp_maybe_intercept( 'bbp_pre_get_favorites_permalink', func_get_args() ); 988 if ( bbp_is_intercepted( $intercept ) ) { 989 return $intercept; 990 990 } 991 991 … … 1175 1175 } 1176 1176 1177 // Allow early overriding of the profile URL to cut down on processing1178 $ early_profile_url = apply_filters( 'bbp_pre_get_subscriptions_permalink', $user_id);1179 if ( is_string( $early_profile_url) ) {1180 return $ early_profile_url;1177 // Bail if intercepted 1178 $intercept = bbp_maybe_intercept( 'bbp_pre_get_subscriptions_permalink', func_get_args() ); 1179 if ( bbp_is_intercepted( $intercept ) ) { 1180 return $intercept; 1181 1181 } 1182 1182 … … 1614 1614 } 1615 1615 1616 // Allow early overriding of the profile URL to cut down on processing1617 $ early_url = apply_filters( 'bbp_pre_get_user_topics_created_url', $user_id);1618 if ( is_string( $early_url) ) {1619 return $ early_url;1616 // Bail if intercepted 1617 $intercept = bbp_maybe_intercept( 'bbp_pre_get_user_topics_created_url', func_get_args() ); 1618 if ( bbp_is_intercepted( $intercept ) ) { 1619 return $intercept; 1620 1620 } 1621 1621 … … 1667 1667 } 1668 1668 1669 // Allow early overriding of the profile URL to cut down on processing1670 $ early_url = apply_filters( 'bbp_pre_get_user_replies_created_url', $user_id);1671 if ( is_string( $early_url) ) {1672 return $ early_url;1669 // Bail if intercepted 1670 $intercept = bbp_maybe_intercept( 'bbp_pre_get_user_replies_created_url', func_get_args() ); 1671 if ( bbp_is_intercepted( $intercept ) ) { 1672 return $intercept; 1673 1673 } 1674 1674 … … 1720 1720 } 1721 1721 1722 // Allow early overriding of the profile URL to cut down on processing1723 $ early_url = apply_filters( 'bbp_pre_get_user_engagements_url', $user_id);1724 if ( is_string( $early_url) ) {1725 return $ early_url;1722 // Bail if intercepted 1723 $intercept = bbp_maybe_intercept( 'bbp_pre_get_user_engagements_url', func_get_args() ); 1724 if ( bbp_is_intercepted( $intercept ) ) { 1725 return $intercept; 1726 1726 } 1727 1727
Note: See TracChangeset
for help on using the changeset viewer.