Changeset 3742
- Timestamp:
- 01/19/2011 08:31:10 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r3728 r3742 1267 1267 do_action( 'bp_register_activity_actions' ); 1268 1268 } 1269 add_action( 'bp_ loaded', 'bp_register_activity_actions', 8 );1269 add_action( 'bp_init', 'bp_register_activity_actions', 8 ); 1270 1270 1271 1271 -
trunk/bp-core.php
r3736 r3742 253 253 } 254 254 255 256 255 function bp_core_get_page_names() { 257 global $wpdb; 258 259 $page_ids = bp_core_get_page_meta(); 260 256 global $wpdb, $bp; 257 258 // Set pages as standard class 261 259 $pages = new stdClass; 262 260 263 // When upgrading to BP 1.3+ from a version of BP that does not use WP pages, $bp->pages 264 // must be populated with dummy info to avoid crashing the site while the db is upgraded 265 if ( empty( $page_ids ) ) { 266 $dummy_components = array( 267 'members', 268 'groups', 269 'activity', 270 'forums', 271 'activate', 272 'register', 273 'blogs' 274 ); 275 276 foreach ( $dummy_components as $dc ) { 277 $pages->{$dc}->name = $dc; 278 $pages->{$dc}->slug = $dc; 279 $pages->{$dc}->id = $dc; 261 // When upgrading to BP 1.3+ from a version of BP that does not use WP 262 // pages, $bp->pages must be populated with dummy info to avoid crashing the 263 // site while the db is upgraded. 264 if ( !$page_ids = bp_core_get_page_meta() ) { 265 foreach ( $bp->active_components as $component ) { 266 $pages->{$component->id}->name = $component->id; 267 $pages->{$component->id}->slug = $component->id; 268 $pages->{$component->id}->id = $component->id; 280 269 } 281 270 … … 284 273 285 274 $posts_table_name = is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'posts' : $wpdb->posts; 286 287 $page_ids_sql = implode( ',', (array)$page_ids ); 288 289 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) " ) ); 275 $page_ids_sql = implode( ',', (array)$page_ids ); 276 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) " ) ); 290 277 291 278 foreach ( (array)$page_ids as $key => $page_id ) { … … 293 280 if ( $page_name->ID == $page_id ) { 294 281 $pages->{$key}->name = $page_name->post_name; 295 $pages->{$key}->id = $page_name->ID; 296 297 $slug[] = $page_name->post_name; 298 299 /* Get the slug */ 282 $pages->{$key}->id = $page_name->ID; 283 $slug[] = $page_name->post_name; 284 285 // Get the slug 300 286 while ( $page_name->post_parent != 0 ) { 301 $parent = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d", $page_name->post_parent ) );302 $slug[] = $parent[0]->post_name;287 $parent = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d", $page_name->post_parent ) ); 288 $slug[] = $parent[0]->post_name; 303 289 $page_name->post_parent = $parent[0]->post_parent; 304 290 } … … 377 363 // Add the administration tab under the "Site Admin" tab for site administrators 378 364 $hook = bp_core_add_admin_menu_page( array( 379 'menu_title' 380 'page_title' 381 'capability' 382 'file' 383 'function' 384 'position' 365 'menu_title' => __( 'BuddyPress', 'buddypress' ), 366 'page_title' => __( 'BuddyPress', 'buddypress' ), 367 'capability' => 'manage_options', 368 'file' => 'bp-general-settings', 369 'function' => 'bp_core_admin_dashboard', 370 'position' => 2 385 371 ) ); 386 372 … … 411 397 */ 412 398 if ( !bp_is_active( 'xprofile' ) ) { 413 / * Fallback values if xprofile is disabled */399 // Fallback values if xprofile is disabled 414 400 $bp->core->profile->slug = 'profile'; 415 401 $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug; 416 402 417 / * Add 'Profile' to the main navigation */403 // Add 'Profile' to the main navigation 418 404 bp_core_new_nav_item( array( 419 405 'name' => __('Profile', 'buddypress'), … … 426 412 $profile_link = $bp->loggedin_user->domain . '/profile/'; 427 413 428 / * Add the subnav items to the profile */414 // Add the subnav items to the profile 429 415 bp_core_new_subnav_item( array( 430 416 'name' => __( 'Public', 'buddypress' ), … … 1444 1430 1445 1431 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { 1446 / * Add to output var */1432 // Add to output var 1447 1433 $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2]; 1448 1434 } … … 1697 1683 bp_core_redirect( apply_filters( 'bp_core_search_site', site_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) ); 1698 1684 } 1699 add_action( ' init', 'bp_core_action_search_site', 5);1685 add_action( 'bp_init', 'bp_core_action_search_site', 7 ); 1700 1686 1701 1687 /** … … 1865 1851 return false; 1866 1852 } 1867 add_action ( 'bp_ loaded', 'bp_core_load_buddypress_textdomain', 2 );1853 add_action ( 'bp_init', 'bp_core_load_buddypress_textdomain', 2 ); 1868 1854 1869 1855 function bp_core_add_ajax_hook() { … … 1872 1858 do_action( 'wp_ajax_' . $_REQUEST['action'] ); 1873 1859 } 1874 add_action( ' init', 'bp_core_add_ajax_hook' );1860 add_action( 'bp_init', 'bp_core_add_ajax_hook' ); 1875 1861 1876 1862 /** … … 1957 1943 } 1958 1944 1959 /******************************************************************************** 1960 * Custom Actions 1961 * 1962 * Functions to set up custom BuddyPress actions that all other components can 1963 * hook in to. 1964 */ 1965 1966 /** 1967 * Allow plugins to include their files ahead of core filters 1968 */ 1969 function bp_include() { 1970 do_action( 'bp_include' ); 1971 } 1972 add_action( 'bp_loaded', 'bp_include', 2 ); 1973 1974 /** 1975 * Allow core components and dependent plugins to set root components 1976 */ 1977 function bp_setup_root_components() { 1978 do_action( 'bp_setup_root_components' ); 1979 } 1980 add_action( 'bp_loaded', 'bp_setup_root_components', 2 ); 1981 1982 /** 1983 * Allow core components and dependent plugins to set globals 1984 */ 1985 function bp_setup_globals() { 1986 do_action( 'bp_setup_globals' ); 1987 } 1988 add_action( 'bp_loaded', 'bp_setup_globals', 6 ); 1989 1990 /** 1991 * Allow core components and dependent plugins to set their nav 1992 */ 1993 function bp_setup_nav() { 1994 do_action( 'bp_setup_nav' ); 1995 } 1996 add_action( 'bp_loaded', 'bp_setup_nav', 8 ); 1997 1998 /** 1999 * Allow core components and dependent plugins to register widgets 2000 */ 2001 function bp_setup_widgets() { 2002 do_action( 'bp_register_widgets' ); 2003 } 2004 add_action( 'bp_loaded', 'bp_setup_widgets', 8 ); 2005 2006 /** 2007 * Allow components to initialize themselves cleanly 2008 */ 2009 function bp_init() { 2010 do_action( 'bp_init' ); 2011 } 2012 add_action( 'bp_loaded', 'bp_init' ); 2013 1945 /** 1946 * BuddyPress uses site options to store configuration settings. Many of these settings are needed 1947 * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch 1948 * them all in one go. 1949 * 1950 * @package BuddyPress Core 1951 */ 1952 function bp_core_get_site_options() { 1953 global $bp, $wpdb; 1954 1955 // These options come from the options table in WP single, and sitemeta in MS 1956 $site_options = apply_filters( 'bp_core_site_options', array( 1957 'bp-deactivated-components', 1958 'bp-blogs-first-install', 1959 'bp-disable-blog-forum-comments', 1960 'bp-xprofile-base-group-name', 1961 'bp-xprofile-fullname-field-name', 1962 'bp-disable-profile-sync', 1963 'bp-disable-avatar-uploads', 1964 'bp-disable-account-deletion', 1965 'bp-disable-forum-directory', 1966 'bp-disable-blogforum-comments', 1967 'bb-config-location', 1968 'hide-loggedout-adminbar', 1969 1970 // Useful WordPress settings used often 1971 'tags_blog_id', 1972 'registration', 1973 'fileupload_maxk' 1974 ) ); 1975 1976 // These options always come from the options table of BP_ROOT_BLOG 1977 $root_blog_options = apply_filters( 'bp_core_root_blog_options', array( 1978 'avatar_default' 1979 ) ); 1980 1981 $meta_keys = "'" . implode( "','", (array)$site_options ) ."'"; 1982 1983 if ( is_multisite() ) 1984 $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}" ); 1985 else 1986 $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" ); 1987 1988 $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'"; 1989 $root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options'; 1990 $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})" ) ); 1991 1992 $site_options = array(); 1993 foreach( array( $site_meta, $root_blog_meta ) as $meta ) { 1994 if ( !empty( $meta ) ) { 1995 foreach( (array)$meta as $meta_item ) 1996 $site_options[$meta_item->name] = $meta_item->value; 1997 } 1998 } 1999 return apply_filters( 'bp_core_get_site_options', $site_options ); 2000 } 2014 2001 2015 2002 /******************************************************************************** … … 2031 2018 wp_cache_add_global_groups( array( 'bp' ) ); 2032 2019 } 2033 add_action( ' init', 'bp_core_add_global_group' );2020 add_action( 'bp_loaded', 'bp_core_add_global_group' ); 2034 2021 2035 2022 /** -
trunk/bp-core/bp-core-adminbar.php
r3722 r3742 309 309 } 310 310 } 311 add_action( 'bp_ loaded', 'bp_core_load_admin_bar' );311 add_action( 'bp_init', 'bp_core_load_admin_bar' ); 312 312 313 313 ?> -
trunk/bp-core/bp-core-avatars.php
r3703 r3742 45 45 define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-core/images/mystery-man-50.jpg' ); 46 46 } 47 add_action( 'bp_ loaded', 'bp_core_set_avatar_constants', 8 );47 add_action( 'bp_init', 'bp_core_set_avatar_constants', 8 ); 48 48 49 49 /** -
trunk/bp-core/bp-core-catchuri.php
r3592 r3742 213 213 $action_variables = array_merge( array(), $action_variables ); 214 214 } 215 add_action( 'bp_ loaded', 'bp_core_set_uri_globals', 4 );215 add_action( 'bp_init', 'bp_core_set_uri_globals', 4 ); 216 216 217 217 /** -
trunk/bp-core/bp-core-cssjs.php
r3706 r3742 24 24 } 25 25 } 26 add_action( ' init', 'bp_core_add_admin_bar_css' );26 add_action( 'bp_init', 'bp_core_add_admin_bar_css' ); 27 27 28 28 /** -
trunk/bp-core/bp-core-deprecated.php
r3728 r3742 39 39 if ( empty( $match ) ) { 40 40 $bp->add_root[] = $slug; 41 add_action( ' init', 'bp_core_create_root_component_page' );41 add_action( 'bp_init', 'bp_core_create_root_component_page' ); 42 42 } 43 43 } -
trunk/bp-core/bp-core-signup.php
r3734 r3742 623 623 add_action( 'wp', 'bp_core_wpsignup_redirect' ); 624 624 else 625 add_action( ' init', 'bp_core_wpsignup_redirect' );625 add_action( 'bp_init', 'bp_core_wpsignup_redirect' ); 626 626 627 627 ?> -
trunk/bp-friends.php
r3728 r3742 201 201 return false; 202 202 } 203 add_action( ' init', 'friends_action_add_friend' );203 add_action( 'bp_init', 'friends_action_add_friend' ); 204 204 205 205 function friends_action_remove_friend() { … … 240 240 return false; 241 241 } 242 add_action( ' init', 'friends_action_remove_friend' );242 add_action( 'bp_init', 'friends_action_remove_friend' ); 243 243 244 244 -
trunk/bp-loader.php
r3736 r3742 72 72 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 73 73 } 74 75 add_action( 'plugins_loaded', 'bp_loaded', 20 );76 74 } 77 75 76 /******************************************************************************** 77 * Custom Actions 78 * 79 * Functions to set up custom BuddyPress actions that all other components can 80 * hook in to. 81 */ 82 78 83 /** 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 */ 86 function bp_include() { 87 do_action( 'bp_include' ); 88 } 89 add_action( 'bp_loaded', 'bp_include', 2 ); 90 91 /** 92 * Allow core components and dependent plugins to set root components 93 */ 94 function bp_setup_root_components() { 95 do_action( 'bp_setup_root_components' ); 96 } 97 add_action( 'bp_init', 'bp_setup_root_components', 2 ); 98 99 /** 100 * Allow core components and dependent plugins to set globals 101 */ 102 function bp_setup_globals() { 103 do_action( 'bp_setup_globals' ); 104 } 105 add_action( 'bp_init', 'bp_setup_globals', 6 ); 106 107 /** 108 * Allow core components and dependent plugins to set their nav 109 */ 110 function bp_setup_nav() { 111 do_action( 'bp_setup_nav' ); 112 } 113 add_action( 'bp_init', 'bp_setup_nav', 8 ); 114 115 /** 116 * Allow core components and dependent plugins to register widgets 117 */ 118 function bp_setup_widgets() { 119 do_action( 'bp_register_widgets' ); 120 } 121 add_action( 'bp_init', 'bp_setup_widgets', 8 ); 122 123 /** 124 * Allow components to initialize themselves cleanly 125 */ 126 function bp_init() { 127 do_action( 'bp_init' ); 128 } 129 add_action( 'init', 'bp_init' ); 130 131 /** 132 * Attached to plugins_loaded 83 133 */ 84 134 function bp_loaded() { 85 135 do_action( 'bp_loaded' ); 86 136 } 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 } 137 add_action( 'plugins_loaded', 'bp_loaded', 10 ); 144 138 145 139 /** -
trunk/bp-themes/bp-default/functions.php
r3736 r3742 117 117 endif; 118 118 119 /** 120 * Enqueue theme javascript safely after the 'init' action, per WordPress Codex. 119 if ( !function_exists( 'bp_dtheme_enqueue_scripts' ) ) : 120 /** 121 * Enqueue theme javascript safely 121 122 * 122 123 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 146 147 } 147 148 add_action( 'wp_enqueue_scripts', 'bp_dtheme_enqueue_scripts' ); 149 endif; 148 150 149 151 if ( !function_exists( 'bp_dtheme_admin_header_style' ) ) : … … 289 291 endif; 290 292 293 if ( !function_exists( 'bp_dtheme_widgets_init' ) ) : 291 294 /** 292 295 * Register widgetised areas, including one sidebar and four widget-ready columns in the footer. … … 355 358 } 356 359 add_action( 'widgets_init', 'bp_dtheme_widgets_init' ); 360 endif; 357 361 358 362 if ( !function_exists( 'bp_dtheme_blog_comments' ) ) : … … 425 429 endif; 426 430 431 if ( !function_exists( 'bp_dtheme_page_on_front' ) ) : 427 432 /** 428 433 * Return the ID of a page set as the home page. … … 437 442 return apply_filters( 'bp_dtheme_page_on_front', get_option( 'page_on_front' ) ); 438 443 } 439 444 endif; 445 446 if ( !function_exists( 'bp_dtheme_activity_secondary_avatars' ) ) : 440 447 /** 441 448 * Add secondary avatar image to this activity stream's record, if supported. … … 463 470 } 464 471 add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 ); 465 472 endif; 473 474 if ( !function_exists( 'bp_dtheme_show_notice' ) ) : 466 475 /** 467 476 * Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) … … 479 488 if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) 480 489 add_action( 'admin_notices', 'bp_dtheme_show_notice' ); 490 endif; 481 491 482 492 if ( !function_exists( 'bp_dtheme_main_nav' ) ) : … … 516 526 endif; 517 527 528 if ( !function_exists( 'bp_dtheme_page_menu_args' ) ) : 518 529 /** 519 530 * Get our wp_nav_menu() fallback, bp_dtheme_main_nav(), to show a home link. … … 528 539 } 529 540 add_filter( 'wp_page_menu_args', 'bp_dtheme_page_menu_args' ); 530 541 endif; 542 543 if ( !function_exists( 'bp_dtheme_comment_form' ) ) : 531 544 /** 532 545 * Applies BuddyPress customisations to the post comment form. … … 564 577 } 565 578 add_filter( 'comment_form_defaults', 'bp_dtheme_comment_form', 10 ); 566 579 endif; 580 581 if ( !function_exists( 'bp_dtheme_before_comment_form' ) ) : 567 582 /** 568 583 * Adds the user's avatar before the comment form box. … … 592 607 } 593 608 add_action( 'comment_form_top', 'bp_dtheme_before_comment_form' ); 594 609 endif; 610 611 if ( !function_exists( 'bp_dtheme_after_comment_form' ) ) : 595 612 /** 596 613 * Closes tags opened in bp_dtheme_before_comment_form(). … … 602 619 function bp_dtheme_after_comment_form() { 603 620 ?> 621 604 622 </div><!-- .comment-content standard-form --> 623 605 624 <?php 606 625 } 607 626 add_action( 'comment_form', 'bp_dtheme_after_comment_form' ); 608 627 endif; 609 628 610 629 // Everything beyond this point is deprecated as of BuddyPress 1.3. This will be removed in a future version. 630 631 if ( BP_VERSION < 1.3 ) : 611 632 612 633 /** … … 701 722 wp_enqueue_script( 'comment-reply' ); 702 723 } 724 endif; 725 703 726 ?>
Note: See TracChangeset
for help on using the changeset viewer.