Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/03/2012 12:33:13 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Theme Compatibility:

  • First pass at including theme compatibility into BuddyPress.
  • Introduce dependency, theme-compatibility, template-loader files into Core component.
  • Add theme compatibility classes for components with direct template access.
  • Move actions and filters around for improved plugin dependency.
  • Remove old $bbp references.
  • Turn $bp global into byref singleton, and include methods for setting up theme compatibility. (Fixes #4470.)
  • Add is_buddypress() function to bp-core-template.php.
  • Rename incorrectly named bp_after_theme_setup sub-action.
  • See: #3741.
File:
1 edited

Legend:

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

    r6177 r6285  
    3636add_action( 'wp',                      'bp_ready',                  10    );
    3737add_action( 'setup_theme',             'bp_setup_theme',            10    );
    38 add_action( 'after_theme_setup',       'bp_after_theme_setup',      10    );
     38add_action( 'after_setup_theme',       'bp_after_setup_theme',      10    );
    3939add_action( 'wp_enqueue_scripts',      'bp_enqueue_scripts',        10    );
    4040add_action( 'admin_bar_menu',          'bp_setup_admin_bar',        20    ); // After WP core
     
    4949 * Attach various loader actions to the bp_loaded action.
    5050 * The load order helps to execute code at the correct time.
    51  *                                                 v---Load order
     51 *                                                     v---Load order
    5252 */
    53 add_action( 'bp_loaded', 'bp_setup_components',    2  );
    54 add_action( 'bp_loaded', 'bp_include',             4  );
    55 add_action( 'bp_loaded', 'bp_setup_widgets',       6  );
    56 add_action( 'bp_loaded', 'bp_core_load_admin_bar', 10 );
     53add_action( 'bp_loaded', 'bp_setup_components',        2  );
     54add_action( 'bp_loaded', 'bp_include',                 4  );
     55add_action( 'bp_loaded', 'bp_setup_widgets',           6  );
     56add_action( 'bp_loaded', 'bp_core_load_admin_bar',     10 );
     57add_action( 'bp_loaded', 'bp_register_theme_packages', 16 );
    5758
    5859/**
     
    7778 * BuddyPress is a bully and overrides the existing themes output in many
    7879 * places. This won't always be this way, we promise.
    79  *                                                       v---Load order
     80 *                                                v---Load order
    8081 */
    81 add_action( 'bp_template_redirect', 'bp_redirect_canonical', 2 );
    82 add_action( 'bp_template_redirect', 'bp_actions',        4 );
    83 add_action( 'bp_template_redirect', 'bp_screens',        6 );
     82add_action( 'bp_template_redirect', 'bp_actions', 4 );
     83add_action( 'bp_template_redirect', 'bp_screens', 6 );
     84
     85/**
     86 * Add the BuddyPress functions file
     87 */
     88add_action( 'after_setup_theme', 'bp_load_theme_functions', 1 );
    8489
    8590// Load the admin
     
    8792    add_action( 'bp_loaded', 'bp_admin' );
    8893}
    89 
    90 /**
    91  * Plugin Dependency
    92  *
    93  * The purpose of the following actions is to mimic the behavior of something
    94  * called 'plugin dependency' which enables a plugin to have plugins of their
    95  * own in a safe and reliable way.
    96  *
    97  * We do this in BuddyPress by mirroring existing WordPress actions in many places
    98  * allowing dependant plugins to hook into the BuddyPress specific ones, thus
    99  * guaranteeing proper code execution only whenBuddyPresss is active.
    100  *
    101  * The following functions are wrappers for their actions, allowing them to be
    102  * manually called and/or piggy-backed on top of other actions if needed.
    103  */
    104 
    105 /** Sub-actions ***************************************************************/
    106 
    107 /**
    108  * Include files on this action
    109  */
    110 function bp_include() {
    111     do_action( 'bp_include' );
    112 }
    113 
    114 /**
    115  * Include files on this action
    116  */
    117 function bp_setup_components() {
    118     do_action( 'bp_setup_components' );
    119 }
    120 
    121 /**
    122  * Setup global variables and objects
    123  */
    124 function bp_setup_globals() {
    125     do_action( 'bp_setup_globals' );
    126 }
    127 
    128 /**
    129  * Set navigation elements
    130  */
    131 function bp_setup_nav() {
    132     do_action( 'bp_setup_nav' );
    133 }
    134 
    135 /**
    136  * Set up BuddyPress implementation of the WP Toolbar
    137  */
    138 function bp_setup_admin_bar() {
    139     if ( bp_use_wp_admin_bar() )
    140         do_action( 'bp_setup_admin_bar' );
    141 }
    142 
    143 /**
    144  * Set the page title
    145  */
    146 function bp_setup_title() {
    147     do_action( 'bp_setup_title' );
    148 }
    149 
    150 /**
    151  * Register widgets
    152  */
    153 function bp_setup_widgets() {
    154     do_action( 'bp_register_widgets' );
    155 }
    156 
    157 /**
    158  * Initlialize code
    159  */
    160 function bp_init() {
    161     do_action( 'bp_init' );
    162 }
    163 
    164 /**
    165  * Attached to plugins_loaded
    166  */
    167 function bp_loaded() {
    168     do_action( 'bp_loaded' );
    169 }
    170 
    171 /**
    172  * Attached to wp
    173  */
    174 function bp_ready() {
    175     do_action( 'bp_ready' );
    176 }
    177 
    178 /**
    179  * Attach potential template actions
    180  */
    181 function bp_actions() {
    182     do_action( 'bp_actions' );
    183 }
    184 
    185 /**
    186  * Attach potential template screens
    187  */
    188 function bp_screens() {
    189     do_action( 'bp_screens' );
    190 }
    191 
    192 /**
    193  * Initialize widgets
    194  */
    195 function bp_widgets_init() {
    196     do_action ( 'bp_widgets_init' );
    197 }
    198 
    199 /** Theme *********************************************************************/
    200 
    201 /**
    202  * Enqueue BuddyPress specific CSS and JS
    203  *
    204  * @since BuddyPress (1.6)
    205  *
    206  * @uses do_action() Calls 'bp_enqueue_scripts'
    207  */
    208 function bp_enqueue_scripts() {
    209     do_action ( 'bp_enqueue_scripts' );
    210 }
    211 
    212 /**
    213  * Piggy back action for BuddyPress sepecific theme actions before the theme has
    214  * been setup and the theme's functions.php has loaded.
    215  *
    216  * @since BuddyPress (1.6)
    217  *
    218  * @uses do_action() Calls 'bp_setup_theme'
    219  */
    220 function bp_setup_theme() {
    221     do_action ( 'bp_setup_theme' );
    222 }
    223 
    224 /**
    225  * Piggy back action for BuddyPress sepecific theme actions once the theme has
    226  * been setup and the theme's functions.php has loaded.
    227  *
    228  * @since BuddyPress (1.6)
    229  *
    230  * @uses do_action() Calls 'bp_after_theme_setup'
    231  */
    232 function bp_after_theme_setup() {
    233     do_action ( 'bp_after_theme_setup' );
    234 }
    235 
    236 /** Theme Compatibility Filter ************************************************/
    237 
    238 /**
    239  * The main filter used for theme compatibility and displaying custom BuddyPress
    240  * theme files.
    241  *
    242  * @since BuddyPress (1.6)
    243  *
    244  * @uses apply_filters()
    245  *
    246  * @param string $template
    247  * @return string Template file to use
    248  */
    249 function bp_template_include( $template = '' ) {
    250     return apply_filters( 'bp_template_include', $template );
    251 }
    252 
    253 /** Theme Permissions *********************************************************/
    254 
    255 /**
    256  * The main action used for redirecting BuddyPress theme actions that are not
    257  * permitted by the current_user
    258  *
    259  * @since BuddyPress (1.6)
    260  *
    261  * @uses do_action()
    262  */
    263 function bp_template_redirect() {
    264     do_action( 'bp_template_redirect' );
    265 }
    266 
    267 ?>
Note: See TracChangeset for help on using the changeset viewer.