Skip to:
Content

BuddyPress.org

Changeset 5813


Ignore:
Timestamp:
02/21/2012 12:12:13 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Move bp_screens and bp_actions onto bp_template_redirect action, which is hooked to template redirect.

  • Moves template redirecting where it belongs, the template_redirect action
  • Leaves bp_ready hooked to 'wp' for now, pending testing
  • Anything hooked to bp_ready works the way it always did
  • Anything properly hooked to bp_actions and bp_screens works normally
  • Fully backwards compatible
  • Fixes #4029
Location:
trunk/bp-core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-catchuri.php

    r5811 r5813  
    430430    }
    431431}
    432 add_action( 'wp', 'bp_core_catch_no_access' );
     432add_action( 'bp_template_redirect', 'bp_core_catch_no_access', 1 );
    433433
    434434/**
  • trunk/bp-core/bp-core-hooks.php

    r5797 r5813  
    2525 * updates to WordPress occur.
    2626 */
    27 add_action( 'plugins_loaded',         'bp_loaded',                 10 );
    28 add_action( 'init',                   'bp_init',                   10 );
    29 add_action( 'wp',                     'bp_ready',                  10 );
     27add_action( 'plugins_loaded',     'bp_loaded',            10    );
     28add_action( 'init',               'bp_init',              10    );
     29add_action( 'wp',                 'bp_ready',             10    );
     30add_action( 'template_redirect',  'bp_template_redirect', 10    );
     31add_action( 'wp_enqueue_scripts', 'bp_enqueue_scripts',   10    );
     32add_action( 'admin_bar_menu',     'bp_setup_admin_bar',   10    );
     33add_action( 'template_redirect',  'bp_template_redirect', 10    );
     34add_filter( 'template_include',   'bp_template_include',  10    );
     35add_filter( 'after_theme_setup',  'bp_after_theme_setup', 10    );
     36add_filter( 'map_meta_cap',       'bp_map_meta_caps',     10, 4 );
     37
     38// Piggy back WordPress theme actions
     39add_action( 'wp_head',   'bp_head',   10 );
     40add_action( 'wp_footer', 'bp_footer', 10 );
     41
    3042//add_action( 'generate_rewrite_rules', 'bp_generate_rewrite_rules', 10 );
    31 //add_action( 'wp_enqueue_scripts',     'bp_enqueue_scripts',        10 );
    32 //add_filter( 'template_include',       'bp_template_include',       10 );
    3343
    3444/**
     
    5767
    5868/**
    59  * bp_ready - Attached to 'wp' above
    60  *
    61  * Attach various initialization actions to the bp_init action.
     69 * bp_template_redirect - Attached to 'template_redirect' above
     70 *
     71 * Attach various template actions to the bp_template_redirect action.
    6272 * The load order helps to execute code at the correct time.
    63  *                                    v---Load order
    64  */
    65 add_action( 'bp_ready', 'bp_actions', 2 );
    66 add_action( 'bp_ready', 'bp_screens', 4 );
    67 
    68 /** Theme *********************************************************************/
    69 
    70 // Piggy back WordPress theme actions
    71 add_action( 'wp_head',   'bp_head'   );
    72 add_action( 'wp_footer', 'bp_footer' );
    73 
    74 /** Admin Bar *****************************************************************/
    75 
    76 // Setup the navigation menu
    77 add_action( 'admin_bar_menu', 'bp_setup_admin_bar', 11 );
    78 
    79 /** Roles and Capabilities ****************************************************/
    80 
    81 // Map our custom capabilities onto WP's
    82 add_filter( 'map_meta_cap', 'bp_map_meta_caps', 10, 4 );
     73 *
     74 * Note that we currently use template_redirect versus template include because
     75 * BuddyPress is a bully and overrides the existing themes output in many
     76 * places. This won't always be this way, we promise.
     77 *                                                v---Load order
     78 */
     79add_action( 'bp_template_redirect', 'bp_actions', 2 );
     80add_action( 'bp_template_redirect', 'bp_screens', 4 );
    8381
    8482/** The hooks *****************************************************************/
     
    215213}
    216214
     215/**
     216 * Enqueue BuddyPress specific CSS and JS
     217 *
     218 * @since bbPress (r5812)
     219 *
     220 * @uses do_action() Calls 'bp_enqueue_scripts'
     221 */
     222function bp_enqueue_scripts() {
     223    do_action ( 'bp_enqueue_scripts' );
     224}
     225
     226/**
     227 * Piggy back action for BuddyPress sepecific theme actions once the theme has
     228 * been setup and the theme's functions.php has loaded.
     229 *
     230 * @since bbPress (r5812)
     231 *
     232 * @uses do_action() Calls 'bp_after_theme_setup'
     233 */
     234function bp_after_theme_setup() {
     235    do_action ( 'bp_after_theme_setup' );
     236}
     237
     238/** Theme Compatibility Filter ************************************************/
     239
     240/**
     241 * The main filter used for theme compatibility and displaying custom BuddyPress
     242 * theme files.
     243 *
     244 * @since BuddyPress (r5812)
     245 *
     246 * @uses apply_filters()
     247 *
     248 * @param string $template
     249 * @return string Template file to use
     250 */
     251function bp_template_include( $template = '' ) {
     252    return apply_filters( 'bp_template_include', $template );
     253}
     254
     255/** Theme Permissions *********************************************************/
     256
     257/**
     258 * The main action used for redirecting BuddyPress theme actions that are not
     259 * permitted by the current_user
     260 *
     261 * @since BuddyPress (r5812)
     262 *
     263 * @uses do_action()
     264 */
     265function bp_template_redirect() {
     266    do_action( 'bp_template_redirect' );
     267}
     268
    217269?>
Note: See TracChangeset for help on using the changeset viewer.