Skip to:
Content

BuddyPress.org

Changeset 3742 for trunk/bp-loader.php


Ignore:
Timestamp:
01/19/2011 08:31:10 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Adjust internal action load orders to stop 'doing it wrong' by moving appropriate actions off plugins_loaded and into init. Fixes #2609 but will need testing; it may have adverse effects on external plugins. Adds missing function_exists checks to bp-default functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-loader.php

    r3736 r3742  
    7272        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
    7373    }
    74 
    75     add_action( 'plugins_loaded', 'bp_loaded', 20 );
    7674}
    7775
     76/********************************************************************************
     77 * Custom Actions
     78 *
     79 * Functions to set up custom BuddyPress actions that all other components can
     80 * hook in to.
     81 */
     82
    7883/**
    79  * Allow dependent plugins and core actions to attach themselves in a safe way.
    80  *
    81  * See bp-core.php for the following core actions:
    82  *      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
     84 * Allow plugins to include their files ahead of core filters
     85 */
     86function bp_include() {
     87    do_action( 'bp_include' );
     88}
     89add_action( 'bp_loaded', 'bp_include', 2 );
     90
     91/**
     92 * Allow core components and dependent plugins to set root components
     93 */
     94function bp_setup_root_components() {
     95    do_action( 'bp_setup_root_components' );
     96}
     97add_action( 'bp_init', 'bp_setup_root_components', 2 );
     98
     99/**
     100 * Allow core components and dependent plugins to set globals
     101 */
     102function bp_setup_globals() {
     103    do_action( 'bp_setup_globals' );
     104}
     105add_action( 'bp_init', 'bp_setup_globals', 6 );
     106
     107/**
     108 * Allow core components and dependent plugins to set their nav
     109 */
     110function bp_setup_nav() {
     111    do_action( 'bp_setup_nav' );
     112}
     113add_action( 'bp_init', 'bp_setup_nav', 8 );
     114
     115/**
     116 * Allow core components and dependent plugins to register widgets
     117 */
     118function bp_setup_widgets() {
     119    do_action( 'bp_register_widgets' );
     120}
     121add_action( 'bp_init', 'bp_setup_widgets', 8 );
     122
     123/**
     124 * Allow components to initialize themselves cleanly
     125 */
     126function bp_init() {
     127    do_action( 'bp_init' );
     128}
     129add_action( 'init', 'bp_init' );
     130
     131/**
     132 * Attached to plugins_loaded
    83133 */
    84134function bp_loaded() {
    85135    do_action( 'bp_loaded' );
    86136}
    87 
    88 /**
    89  * BuddyPress uses site options to store configuration settings. Many of these settings are needed
    90  * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
    91  * them all in one go.
    92  *
    93  * @package BuddyPress Core
    94  */
    95 function bp_core_get_site_options() {
    96     global $bp, $wpdb;
    97 
    98     // These options come from the options table in WP single, and sitemeta in MS
    99     $site_options = apply_filters( 'bp_core_site_options', array(
    100         'bp-deactivated-components',
    101         'bp-blogs-first-install',
    102         'bp-disable-blog-forum-comments',
    103         'bp-xprofile-base-group-name',
    104         'bp-xprofile-fullname-field-name',
    105         'bp-disable-profile-sync',
    106         'bp-disable-avatar-uploads',
    107         'bp-disable-account-deletion',
    108         'bp-disable-forum-directory',
    109         'bp-disable-blogforum-comments',
    110         'bb-config-location',
    111         'hide-loggedout-adminbar',
    112 
    113         // Useful WordPress settings used often
    114         'tags_blog_id',
    115         'registration',
    116         'fileupload_maxk'
    117     ) );
    118 
    119     // These options always come from the options table of BP_ROOT_BLOG
    120     $root_blog_options = apply_filters( 'bp_core_root_blog_options', array(
    121         'avatar_default'
    122     ) );
    123 
    124     $meta_keys = "'" . implode( "','", (array)$site_options ) ."'";
    125 
    126     if ( is_multisite() )
    127         $site_meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
    128     else
    129         $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
    130 
    131     $root_blog_meta_keys  = "'" . implode( "','", (array)$root_blog_options ) ."'";
    132     $root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options';
    133     $root_blog_meta       = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) );
    134 
    135     $site_options = array();
    136     foreach( array( $site_meta, $root_blog_meta ) as $meta ) {
    137         if ( !empty( $meta ) ) {
    138             foreach( (array)$meta as $meta_item )
    139                 $site_options[$meta_item->name] = $meta_item->value;
    140         }
    141     }
    142     return apply_filters( 'bp_core_get_site_options', $site_options );
    143 }
     137add_action( 'plugins_loaded', 'bp_loaded', 10 );
    144138
    145139/**
Note: See TracChangeset for help on using the changeset viewer.