Changeset 1636 for trunk/bp-core.php
- Timestamp:
- 08/08/2009 05:25:01 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/bp-core.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r1621 r1636 1 1 <?php 2 2 3 /* Define the current version number for checking if DB tables are up to date. */ 3 define( 'BP_CORE_DB_VERSION', '1 300' );4 define( 'BP_CORE_DB_VERSION', '1400' ); 4 5 5 6 /* Define the path and url of the BuddyPress plugins directory */ … … 30 31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php' ); 31 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' ); 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-ajax.php' );33 33 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' ); 34 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' ); 34 35 35 36 /* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar */ 36 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )37 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) ) 37 38 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' ); 39 40 /* If BP_IGNORE_DEPRECATED is defined, do not load any deprecated functions for backwards support */ 41 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 42 require ( BP_PLUGIN_DIR . '/bp-core/deprecated/bp-core-deprecated.php' ); 38 43 39 44 /* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */ … … 118 123 /* Sets up the array container for the component navigation rendered by bp_get_nav() */ 119 124 $bp->bp_nav = array(); 120 121 /* Sets up the array container for the user navigation rendered by bp_get_user_nav() */122 $bp->bp_users_nav = array();123 125 124 126 /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */ … … 146 148 /* Used to determine if the logged in user is a moderator for the current content. */ 147 149 $bp->is_item_mod = false; 148 149 $bp->core->image_base = BP_PLUGIN_URL . '/bp-core/images'; 150 150 151 $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications'; 151 152 … … 219 220 bp_core_add_illegal_names(); 220 221 221 // dbDelta won't change character sets, so we need to do this seperately.222 // This will only be in here pre v1.0223 $wpdb->query( $wpdb->prepare( "ALTER TABLE {$bp->core->table_name_notifications} DEFAULT CHARACTER SET %s", $wpdb->charset ) );224 225 222 update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION ); 226 223 } … … 253 250 add_action( 'admin_menu', 'bp_core_check_installed' ); 254 251 255 256 /**257 * bp_core_setup_cookies()258 *259 * Checks if there is a feedback message in the WP cookie, if so, adds a "template_notices" action260 * so that the message can be parsed into the template and displayed to the user.261 *262 * After the message is displayed, it removes the message vars from the cookie so that the message263 * is not shown to the user multiple times.264 *265 * @package BuddyPress Core266 * @global $bp_message The message text267 * @global $bp_message_type The type of message (error/success)268 * @uses setcookie() Sets a cookie value for the user.269 */270 function bp_core_setup_cookies() {271 global $bp_message, $bp_message_type;272 273 // Render any error/success feedback on the template274 if ( $_COOKIE['bp-message'] == '' || !isset( $_COOKIE['bp-message'] ) )275 return false;276 277 $bp_message = $_COOKIE['bp-message'];278 $bp_message_type = $_COOKIE['bp-message-type'];279 add_action( 'template_notices', 'bp_core_render_notice' );280 281 setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );282 setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );283 }284 add_action( 'init', 'bp_core_setup_cookies' );285 286 287 252 /** 288 253 * bp_core_add_admin_menu() … … 335 300 * @uses bp_core_add_subnav_item() Adds a sub navigation item to a nav item 336 301 * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user 337 * @uses bp_core_ get_avatar() Returns the either the thumb (1) or full (2)avatar URL for the user_id passed302 * @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed 338 303 */ 339 304 function bp_core_setup_nav() { … … 354 319 $bp->bp_options_title = __('My Profile', 'buddypress'); 355 320 } else { 356 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);321 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 357 322 $bp->bp_options_title = $bp->displayed_user->fullname; 358 323 } … … 381 346 $bp->current_component = false; 382 347 383 wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ));348 do_action( 'bp_core_action_directory_members' ); 384 349 bp_core_load_template( apply_filters( 'bp_core_template_directory_members', 'directories/members/index' ) ); 385 350 } … … 498 463 } 499 464 } 500 /* DEPRECATED - use bp_core_new_nav_item() as it's more friendly and allows ordering */ 501 function bp_core_add_nav_item( $name, $slug, $css_id = false, $show_for_displayed_user = true ) { 502 bp_core_new_nav_item( array( 'name' => $name, 'slug' => $slug, 'item_css_id' => $css_id, 'show_for_displayed_user' => $show_for_displayed_user ) ); 503 } 465 504 466 505 467 /** … … 591 553 return false; 592 554 593 if ( !$user_has_access )594 return false;595 596 555 /* If this is for site admins only and the user is not one, don't create the subnav item */ 597 556 if ( $site_admin_only && !is_site_admin() ) … … 609 568 ); 610 569 611 if ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) {570 if ( $bp->current_action == $slug && $bp->current_component == $parent_slug && $user_has_access ) { 612 571 if ( !is_object($screen_function[0]) ) 613 572 add_action( 'wp', $screen_function, 3 ); … … 616 575 } 617 576 } 618 /* DEPRECATED - use bp_core_new_subnav_item() as it's more friendly and allows ordering. */619 function bp_core_add_subnav_item( $parent_id, $slug, $name, $link, $function, $css_id = false, $user_has_access = true, $admin_only = false ) {620 bp_core_new_subnav_item( array( 'name' => $name, 'slug' => $slug, 'parent_slug' => $parent_id, 'parent_url' => $link, 'item_css_id' => $css_id, 'user_has_access' => $user_has_access, 'site_admin_only' => $admin_only, 'screen_function' => $function ) );621 }622 577 623 578 function bp_core_sort_subnav_items() { … … 799 754 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 800 755 } 801 function bp_core_get_userid_from_user_login( $deprecated ) {802 return bp_core_get_userid( $deprecated );803 }804 756 805 757 /** … … 965 917 return apply_filters( 'bp_core_get_user_displayname', stripslashes( strip_tags( trim( $fullname ) ) ) ); 966 918 } 967 /* DEPRECATED Use: bp_core_get_user_displayname */968 function bp_core_global_user_fullname( $user_id ) { return bp_core_get_user_displayname( $user_id ); }969 970 919 971 920 /** … … 985 934 } 986 935 987 988 936 /** 989 937 * bp_core_get_userlink_by_username() … … 1034 982 */ 1035 983 function bp_core_add_message( $message, $type = false ) { 984 global $bp; 985 1036 986 if ( !$type ) 1037 987 $type = 'success'; 1038 988 989 /* Send the values to the cookie for page reload display */ 1039 990 setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH ); 1040 991 setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH ); 1041 } 1042 1043 1044 /** 1045 * bp_core_render_notice() 1046 * 1047 * Renders a feedback notice (either error or success message) to the theme template. 992 993 /*** 994 * Send the values to the $bp global so we can still output messages 995 * without a page reload 996 */ 997 $bp->template_message = $message; 998 $bp->template_message_type = $type; 999 } 1000 1001 /** 1002 * bp_core_setup_message() 1003 * 1004 * Checks if there is a feedback message in the WP cookie, if so, adds a "template_notices" action 1005 * so that the message can be parsed into the template and displayed to the user. 1006 * 1007 * After the message is displayed, it removes the message vars from the cookie so that the message 1008 * is not shown to the user multiple times. 1009 * 1010 * @package BuddyPress Core 1011 * @global $bp_message The message text 1012 * @global $bp_message_type The type of message (error/success) 1013 * @uses setcookie() Sets a cookie value for the user. 1014 */ 1015 function bp_core_setup_message() { 1016 global $bp; 1017 1018 if ( empty( $bp->template_message ) ) 1019 $bp->template_message = $_COOKIE['bp-message']; 1020 1021 if ( empty( $bp->template_message_type ) ) 1022 $bp->template_message_type = $_COOKIE['bp-message-type']; 1023 1024 add_action( 'template_notices', 'bp_core_render_message' ); 1025 1026 setcookie( 'bp-message', false, time() - 1000, COOKIEPATH ); 1027 setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); 1028 } 1029 add_action( 'wp', 'bp_core_setup_message' ); 1030 1031 /** 1032 * bp_core_render_message() 1033 * 1034 * Renders a feedback message (either error or success message) to the theme template. 1048 1035 * The hook action 'template_notices' is used to call this function, it is not called directly. 1049 1036 * … … 1051 1038 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 1052 1039 */ 1053 function bp_core_render_notice() { 1054 if ( $_COOKIE['bp-message'] ) { 1055 $type = ( 'success' == $_COOKIE['bp-message-type'] ) ? 'updated' : 'error'; 1040 function bp_core_render_message() { 1041 global $bp; 1042 1043 if ( $bp->template_message ) { 1044 $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error'; 1056 1045 ?> 1057 1046 <div id="message" class="<?php echo $type; ?>"> 1058 <p><?php echo stripslashes( $_COOKIE['bp-message']); ?></p>1047 <p><?php echo stripslashes( attribute_escape( $bp->template_message ) ); ?></p> 1059 1048 </div> 1060 1049 <?php 1061 do_action( 'bp_core_render_notice' ); 1062 } 1063 } 1064 1050 do_action( 'bp_core_render_message' ); 1051 } 1052 } 1065 1053 1066 1054 /** … … 1266 1254 1267 1255 /** 1268 * bp_core_get_buddypress_themes()1269 *1270 * Gets an array of all the BuddyPress themes in the /bp-themes/ directory.1271 *1272 * @package BuddyPress Core1273 * @uses get_themes()1274 * @return An array containing all of the themes.1275 */1276 function bp_core_get_buddypress_themes() {1277 global $wp_themes;1278 1279 /* Remove the cached WP themes first */1280 $wp_existing_themes = &$wp_themes;1281 $wp_themes = null;1282 1283 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );1284 $themes = get_themes();1285 1286 if ( $themes ) {1287 foreach ( $themes as $name => $values ) {1288 if ( $name == 'BuddyPress Default Home Theme' )1289 continue;1290 1291 $member_themes[] = array(1292 'name' => $name,1293 'template' => $values['Template'],1294 'version' => $values['Version']1295 );1296 }1297 }1298 1299 /* Restore the cached WP themes */1300 $wp_themes = $wp_existing_themes;1301 1302 return $member_themes;1303 }1304 function bp_core_get_member_themes() { return bp_core_get_buddypress_themes(); } // DEPRECATED1305 1306 1307 /**1308 * bp_get_buddypress_theme_uri()1309 *1310 * Get the url of the selected BuddyPress theme.1311 *1312 * @package BuddyPress Core1313 */1314 function bp_get_buddypress_theme_uri() {1315 return apply_filters( 'bp_get_buddypress_theme_uri', WP_CONTENT_URL . '/bp-themes/' . get_site_option( 'active-member-theme' ) );1316 }1317 1318 1319 /**1320 * bp_get_buddypress_theme_path()1321 *1322 * Get the path of the selected BuddyPress theme.1323 *1324 * @package BuddyPress Core1325 */1326 function bp_get_buddypress_theme_path() {1327 return apply_filters( 'bp_get_buddypress_theme_path', WP_CONTENT_DIR . '/bp-themes/' . get_site_option( 'active-member-theme' ) );1328 }1329 1330 1331 /**1332 * bp_core_filter_buddypress_theme_root()1333 *1334 * Adds a filter that changes the root path of the theme directory to the bp-themes directory.1335 *1336 * @package BuddyPress Core1337 */1338 function bp_core_filter_buddypress_theme_root() {1339 return apply_filters( 'bp_core_filter_buddypress_theme_root', WP_CONTENT_DIR . "/bp-themes" );1340 }1341 1342 1343 /**1344 * bp_core_filter_buddypress_theme_root_uri()1345 *1346 * Adds a filter that changes the root URI of the theme directory to the bp-themes directory.1347 *1348 * @package BuddyPress Core1349 */1350 function bp_core_filter_buddypress_theme_root_uri() {1351 return apply_filters( 'bp_core_filter_buddypress_theme_root_uri', WP_CONTENT_URL . '/bp-themes' );1352 }1353 1354 1355 /**1356 1256 * bp_core_add_illegal_names() 1357 1257 * … … 1383 1283 update_site_option( 'illegal_names', $new ); 1384 1284 } 1385 1386 1285 1387 1286 /** … … 1629 1528 add_action ( 'plugins_loaded', 'bp_core_load_buddypress_textdomain', 9 ); 1630 1529 1530 function bp_core_add_ajax_hook() { 1531 do_action( 'wp_ajax_' . $_REQUEST['action'] ); 1532 } 1533 add_action( 'init', 'bp_core_add_ajax_hook' ); 1631 1534 1632 1535 /**
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)