Changeset 5524
- Timestamp:
- 12/12/2011 02:33:04 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-update.php
r5441 r5524 395 395 return false; 396 396 397 if ( !function_exists( 'bp_core_admin_component _options' ) )398 require ( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core- admin.php' ); ?>397 if ( !function_exists( 'bp_core_admin_components_options' ) ) 398 require ( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-components.php' ); ?> 399 399 400 400 <p><?php _e( "BuddyPress bundles several individual social components together, each one adding a distinct feature. This first step decides which features are enabled on your site; all features are enabled by default. Don't worry, you can change your mind at any point in the future.", 'buddypress' ); ?></p> 401 401 402 <?php bp_core_admin_component _options(); ?>402 <?php bp_core_admin_components_options(); ?> 403 403 404 404 <div class="submit clear"> -
trunk/bp-core/bp-core-cssjs.php
r5406 r5524 2 2 // Exit if accessed directly 3 3 if ( !defined( 'ABSPATH' ) ) exit; 4 5 /**6 * bp_core_admin_menu_icon_css()7 *8 * Add a hover-able icon to the "BuddyPress" wp-admin area menu.9 *10 * @package BuddyPress Core11 */12 function bp_core_admin_menu_icon_css() {13 global $bp; ?>14 15 <style type="text/css">16 /* Wizard Icon */17 ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a img { display: none; }18 ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }19 ul#adminmenu li.toplevel_page_bp-wizard:hover .wp-menu-image a,20 ul#adminmenu li.toplevel_page_bp-wizard.wp-has-current-submenu .wp-menu-image a {21 background-position: -1px 0;22 }23 24 /* Settings Icon */25 ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a img,26 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img {27 display: none;28 }29 30 ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a,31 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a {32 background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px;33 }34 35 ul#adminmenu li.toplevel_page_bp-general-config:hover .wp-menu-image a,36 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a,37 ul#adminmenu li.toplevel_page_bp-general-config.wp-has-current-submenu .wp-menu-image a,38 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a {39 background-position: -1px 0;40 }41 42 /* Activity Icon */43 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image a img { display: none; }44 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }45 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image a,46 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image a {47 background-position: -1px 0;48 }49 </style>50 51 <?php52 }53 add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );54 4 55 5 function bp_core_confirmation_js() { -
trunk/bp-core/bp-core-functions.php
r5510 r5524 253 253 } 254 254 255 function bp_core_do_network_admin() {256 $do_network_admin = false;257 258 if ( is_multisite() && !bp_is_multiblog_mode() )259 $do_network_admin = true;260 261 return apply_filters( 'bp_core_do_network_admin', $do_network_admin );262 }263 264 function bp_core_admin_hook() {265 $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';266 267 return apply_filters( 'bp_core_admin_hook', $hook );268 }269 270 /**271 * Initializes the wp-admin area "BuddyPress" menus and sub menus.272 *273 * @package BuddyPress Core274 * @uses bp_current_user_can() returns true if the current user is a site admin, false if not275 */276 function bp_core_admin_menu_init() {277 278 // Bail if not in admin279 if ( !is_admin() )280 return false;281 282 // Bail if user cannot moderate283 if ( !bp_current_user_can( 'bp_moderate' ) )284 return false;285 286 add_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 );287 288 require ( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin.php' );289 }290 add_action( 'bp_init', 'bp_core_admin_menu_init' );291 292 /**293 * In BP 1.6, the top-level admin menu was removed. For backpat, this function294 * keeps the top-level menu if a plugin has registered a menu into the old295 * 'bp-general-settings' menu.296 *297 * The old "bp-general-settings" page was renamed "bp-general-config".298 *299 * @global array $_parent_pages300 * @global array $_registered_pages301 * @global array $submenu302 * @since 1.6303 */304 function bp_core_admin_backpat_menu() {305 global $_parent_pages, $_registered_pages, $submenu;306 307 if ( ! is_super_admin() )308 return;309 310 // Don't do anything if a BP upgrade is in progress, or if the bp-wizard is in progress.311 if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE || empty( $submenu['bp-general-settings'] ) )312 return;313 314 /**315 * By default, only the core "Help" submenu is added under the top-level BuddyPress menu.316 * This means that if no third-party plugins have registered their admin pages into the317 * 'bp-general-settings' menu, it will only contain one item. Kill it.318 */319 if ( 1 == count( $submenu['bp-general-settings'] ) ) {320 // This removes the top-level menu321 remove_submenu_page( 'bp-general-settings', 'bp-general-settings' );322 remove_menu_page( 'bp-general-settings' );323 324 // These stop people accessing the URL directly325 unset( $_parent_pages['bp-general-settings'] );326 unset( $_registered_pages['toplevel_page_bp-general-settings'] );327 }328 }329 add_action( bp_core_admin_hook(), 'bp_core_admin_backpat_menu', 999 );330 331 /**332 * Registers BuddyPress' admin menus.333 *334 * @since 1.0335 */336 function bp_core_add_admin_menu() {337 if ( ! bp_current_user_can( 'bp_moderate' ) )338 return;339 340 /**341 * Don't add this version of the admin menu if a BP upgrade is in progress.342 * See bp_core_update_add_admin_menu().343 */344 if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE )345 return;346 347 $hooks = array();348 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';349 350 // Changed in BP 1.6 . See bp_core_admin_backpat_menu()351 $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_backpat_menu', '' );352 $hooks[] = add_submenu_page( 'bp-general-settings', __( 'BuddyPress Help', 'buddypress' ), __( 'Help', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_backpat_page' );353 354 // Add the option pages355 $hooks[] = add_submenu_page( $page, __( 'BuddyPress Components', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-config', 'bp_core_admin_component_setup' );356 $hooks[] = add_submenu_page( $page, __( 'BuddyPress Pages', 'buddypress' ), __( 'BuddyPress Pages', 'buddypress' ), 'manage_options', 'bp-page-settings', 'bp_core_admin_page_setup' );357 $hooks[] = add_submenu_page( $page, __( 'BuddyPress Settings', 'buddypress' ), __( 'BuddyPress Settings', 'buddypress' ), 'manage_options', 'bp-settings', 'bp_core_admin_settings' );358 359 foreach( $hooks as $hook ) {360 // Add a hook for common BP admin CSS/JS scripts361 add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );362 363 // Fudge the highlighted subnav item when on a BuddyPress admin page364 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );365 }366 }367 368 /**369 * Tweak the Settings subnav menu to show only one BuddyPress menu item (Settings > BuddyPress).370 *371 * @since 1.6372 */373 function bp_core_modify_admin_menu() {374 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';375 376 remove_submenu_page( $page, 'bb-forums-setup' );377 remove_submenu_page( $page, 'bp-page-settings' );378 remove_submenu_page( $page, 'bp-settings' );379 }380 add_action( "admin_head", 'bp_core_modify_admin_menu', 999 );381 382 /**383 * This tells WP to highlight the Settings > BuddyPress menu item,384 * regardless of which actual BuddyPress admin screen we are on.385 *386 * The conditional prevents the behaviour when the user is viewing the387 * backpat "Help" page, the Activity page, or any third-party plugins.388 *389 * @global string $plugin_page390 * @global array $submenu391 * @since 1.6392 */393 function bp_core_modify_admin_menu_highlight() {394 global $plugin_page, $submenu_file;395 396 // This tweaks the Settings subnav menu to show only one BuddyPress menu item397 if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings', ) ) )398 $submenu_file = 'bp-general-config';399 }400 401 /**402 * Print admin messages to admin_notices or network_admin_notices403 *404 * BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow405 * boxes.406 *407 * @package BuddyPress Core408 * @since 1.5409 *410 * @global object $bp Global BuddyPress settings object411 * @uses bp_current_user_can() to check current user permissions before showing the notices412 * @uses bp_is_root_blog()413 */414 function bp_core_print_admin_notices() {415 global $bp;416 417 // Only the super admin should see messages418 if ( !bp_current_user_can( 'bp_moderate' ) )419 return;420 421 // On multisite installs, don't show on the Site Admin of a non-root blog, unless422 // do_network_admin is overridden423 if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )424 return;425 426 // Show the messages427 if ( !empty( $bp->admin->notices ) ) {428 ?>429 <div id="message" class="updated fade">430 <?php foreach( $bp->admin->notices as $notice ) : ?>431 <p><?php echo $notice ?></p>432 <?php endforeach ?>433 </div>434 <?php435 }436 }437 add_action( 'admin_notices', 'bp_core_print_admin_notices' );438 add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );439 440 /**441 * Add an admin notice to the BP queue442 *443 * Messages added with this function are displayed in BuddyPress's general purpose admin notices444 * box. It is recommended that you hook this function to admin_init, so that your messages are445 * loaded in time.446 *447 * @package BuddyPress Core448 * @since 1.5449 *450 * @global object $bp Global BuddyPress settings object451 * @param string $notice The notice you are adding to the queue452 */453 function bp_core_add_admin_notice( $notice ) {454 global $bp;455 456 if ( empty( $bp->admin->notices ) ) {457 $bp->admin->notices = array();458 }459 460 $bp->admin->notices[] = $notice;461 }462 463 /**464 * Verify that some BP prerequisites are set up properly, and notify the admin if not465 *466 * On every Dashboard page, this function checks the following:467 * - that pretty permalinks are enabled468 * - that a BP-compatible theme is activated469 * - that every BP component that needs a WP page for a directory has one470 * - that no WP page has multiple BP components associated with it471 * The administrator will be shown a notice for each check that fails.472 *473 * @package BuddyPress Core474 */475 function bp_core_activation_notice() {476 global $wp_rewrite, $wpdb, $bp;477 478 // Only the super admin gets warnings479 if ( !bp_current_user_can( 'bp_moderate' ) )480 return;481 482 // On multisite installs, don't load on a non-root blog, unless do_network_admin is483 // overridden484 if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )485 return;486 487 // Don't show these messages during setup or upgrade488 if ( !empty( $bp->maintenance_mode ) )489 return;490 491 /**492 * Check to make sure that the blog setup routine has run. This can't happen during the493 * wizard because of the order which the components are loaded. We check for multisite here494 * on the off chance that someone has activated the blogs component and then disabled MS495 */496 if ( bp_is_active( 'blogs' ) ) {497 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$bp->blogs->table_name}" ) );498 499 if ( !$count )500 bp_blogs_record_existing_blogs();501 }502 503 /**504 * Are pretty permalinks enabled?505 */506 if ( isset( $_POST['permalink_structure'] ) )507 return false;508 509 if ( empty( $wp_rewrite->permalink_structure ) ) {510 bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );511 }512 513 /**514 * Are you using a BP-compatible theme?515 */516 517 // Get current theme info518 $ct = current_theme_info();519 520 // The best way to remove this notice is to add a "buddypress" tag to521 // your active theme's CSS header.522 if ( !defined( 'BP_SILENCE_THEME_NOTICE' ) && !in_array( 'buddypress', (array)$ct->tags ) ) {523 bp_core_add_admin_notice( sprintf( __( "You'll need to <a href='%s'>activate a <strong>BuddyPress-compatible theme</strong></a> to take advantage of all of BuddyPress's features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a> or <a href='%s'>update your existing WordPress theme</a>.", 'buddypress' ), admin_url( 'themes.php' ), network_admin_url( 'theme-install.php?type=tag&s=buddypress&tab=search' ), network_admin_url( 'plugin-install.php?type=term&tab=search&s=%22bp-template-pack%22' ) ) );524 }525 526 /**527 * Check for orphaned BP components (BP component is enabled, no WP page exists)528 */529 530 $orphaned_components = array();531 $wp_page_components = array();532 533 // Only components with 'has_directory' require a WP page to function534 foreach( $bp->loaded_components as $component_id => $is_active ) {535 if ( !empty( $bp->{$component_id}->has_directory ) ) {536 $wp_page_components[] = array(537 'id' => $component_id,538 'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id )539 );540 }541 }542 543 // Activate and Register are special cases. They are not components but they need WP pages.544 // If user registration is disabled, we can skip this step.545 if ( bp_get_signup_allowed() ) {546 $wp_page_components[] = array(547 'id' => 'activate',548 'name' => __( 'Activate', 'buddypress' )549 );550 551 $wp_page_components[] = array(552 'id' => 'register',553 'name' => __( 'Register', 'buddypress' )554 );555 }556 557 foreach( $wp_page_components as $component ) {558 if ( !isset( $bp->pages->{$component['id']} ) ) {559 $orphaned_components[] = $component['name'];560 }561 }562 563 if ( !empty( $orphaned_components ) ) {564 $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );565 $notice = sprintf( __( 'The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress' ), $admin_url, '<strong>' . implode( '</strong>, <strong>', $orphaned_components ) . '</strong>' );566 567 bp_core_add_admin_notice( $notice );568 }569 570 /**571 * BP components cannot share a single WP page. Check for duplicate assignments, and post572 * a message if found.573 */574 $dupe_names = array();575 $page_ids = (array)bp_core_get_directory_page_ids();576 $dupes = array_diff_assoc( $page_ids, array_unique( $page_ids ) );577 578 if ( !empty( $dupes ) ) {579 foreach( $dupes as $dupe_component => $dupe_id ) {580 $dupe_names[] = $bp->pages->{$dupe_component}->title;581 }582 583 // Make sure that there are no duplicate duplicates :)584 $dupe_names = array_unique( $dupe_names );585 }586 587 // If there are duplicates, post a message about them588 if ( !empty( $dupe_names ) ) {589 $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );590 $notice = sprintf( __( 'Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress' ), $admin_url, '<strong>' . implode( '</strong>, <strong>', $dupe_names ) . '</strong>' );591 592 bp_core_add_admin_notice( $notice );593 }594 }595 add_action( 'admin_init', 'bp_core_activation_notice' );596 597 255 /** 598 256 * Returns the domain for the root blog. … … 1084 742 1085 743 /** 1086 * When switching from single to multisite we need to copy blog options to1087 * site options.1088 *1089 * @package BuddyPress Core1090 * @todo Does this need to be here anymore after the introduction of bp_get_option etc?1091 */1092 function bp_core_activate_site_options( $keys = array() ) {1093 global $bp;1094 1095 if ( !empty( $keys ) && is_array( $keys ) ) {1096 $errors = false;1097 1098 foreach ( $keys as $key => $default ) {1099 if ( empty( $bp->site_options[ $key ] ) ) {1100 $bp->site_options[ $key ] = bp_get_option( $key, $default );1101 1102 if ( !bp_update_option( $key, $bp->site_options[ $key ] ) )1103 $errors = true;1104 }1105 }1106 1107 if ( empty( $errors ) )1108 return true;1109 }1110 1111 return false;1112 }1113 1114 /**1115 * BuddyPress uses common options to store configuration settings. Many of these1116 * settings are needed at run time. Instead of fetching them all and adding many1117 * initial queries to each page load, let's fetch them all in one go.1118 *1119 * @package BuddyPress Core1120 * @todo Use settings API and audit these methods1121 */1122 function bp_core_get_root_options() {1123 global $wpdb;1124 1125 // These options come from the root blog options table1126 $root_blog_options = apply_filters( 'bp_core_site_options', array(1127 1128 // BuddyPress core settings1129 'bp-deactivated-components' => serialize( array( ) ),1130 'bp-blogs-first-install' => '0',1131 'bp-disable-blogforum-comments' => '0',1132 'bp-xprofile-base-group-name' => 'Base',1133 'bp-xprofile-fullname-field-name' => 'Name',1134 'bp-disable-profile-sync' => '0',1135 'bp-disable-avatar-uploads' => '0',1136 'bp-disable-account-deletion' => '0',1137 'bp-disable-blogforum-comments' => '0',1138 'bb-config-location' => ABSPATH . 'bb-config.php',1139 'hide-loggedout-adminbar' => '0',1140 1141 // Useful WordPress settings1142 'registration' => '0',1143 'avatar_default' => 'mysteryman'1144 ) );1145 1146 $root_blog_option_keys = array_keys( $root_blog_options );1147 $blog_options_keys = "'" . join( "', '", (array) $root_blog_option_keys ) . "'";1148 $blog_options_table = bp_is_multiblog_mode() ? $wpdb->options : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'options';1149 1150 $blog_options_query = $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$blog_options_table} WHERE option_name IN ( {$blog_options_keys} )" );1151 $root_blog_options_meta = $wpdb->get_results( $blog_options_query );1152 1153 // On Multisite installations, some options must always be fetched from sitemeta1154 if ( is_multisite() ) {1155 $network_options = apply_filters( 'bp_core_network_options', array(1156 'tags_blog_id' => '0',1157 'sitewide_tags_blog' => '',1158 'registration' => '0',1159 'fileupload_maxk' => '1500'1160 ) );1161 1162 $current_site = get_current_site();1163 $network_option_keys = array_keys( $network_options );1164 $sitemeta_options_keys = "'" . join( "', '", (array) $network_option_keys ) . "'";1165 $sitemeta_options_query = $wpdb->prepare( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ( {$sitemeta_options_keys} ) AND site_id = %d", $current_site->id );1166 $network_options_meta = $wpdb->get_results( $sitemeta_options_query );1167 1168 // Sitemeta comes second in the merge, so that network 'registration' value wins1169 $root_blog_options_meta = array_merge( $root_blog_options_meta, $network_options_meta );1170 }1171 1172 // Missing some options, so do some one-time fixing1173 if ( empty( $root_blog_options_meta ) || ( count( $root_blog_options_meta ) < count( $root_blog_option_keys ) ) ) {1174 1175 // Unset the query - We'll be resetting it soon1176 unset( $root_blog_options_meta );1177 1178 // Loop through options1179 foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) {1180 // Clear out the value from the last time around1181 unset( $old_meta_value );1182 1183 // Get old site option1184 if ( is_multisite() )1185 $old_meta_value = get_site_option( $old_meta_key );1186 1187 // No site option so look in root blog1188 if ( empty( $old_meta_value ) )1189 $old_meta_value = bp_get_option( $old_meta_key, $old_meta_default );1190 1191 // Update the root blog option1192 bp_update_option( $old_meta_key, $old_meta_value );1193 1194 // Update the global array1195 $root_blog_options_meta[$old_meta_key] = $old_meta_value;1196 }1197 1198 // We're all matched up1199 } else {1200 // Loop through our results and make them usable1201 foreach ( $root_blog_options_meta as $root_blog_option )1202 $root_blog_options[$root_blog_option->name] = $root_blog_option->value;1203 1204 // Copy the options no the return val1205 $root_blog_options_meta = $root_blog_options;1206 1207 // Clean up our temporary copy1208 unset( $root_blog_options );1209 }1210 1211 return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta );1212 }1213 1214 /**1215 744 * This function originally let plugins add support for pages in the root of the install. 1216 745 * These root level pages are now handled by actual WordPress pages and this function is now … … 1466 995 } 1467 996 997 /** Embeds ********************************************************************/ 998 1468 999 /** 1469 1000 * Are oembeds allowed in activity items? … … 1505 1036 return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES ); 1506 1037 } 1038 1039 /** Admin *********************************************************************/ 1507 1040 1508 1041 /** … … 1546 1079 } 1547 1080 1081 function bp_core_do_network_admin() { 1082 $do_network_admin = false; 1083 1084 if ( is_multisite() && !bp_is_multiblog_mode() ) 1085 $do_network_admin = true; 1086 1087 return apply_filters( 'bp_core_do_network_admin', $do_network_admin ); 1088 } 1089 1090 function bp_core_admin_hook() { 1091 $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu'; 1092 1093 return apply_filters( 'bp_core_admin_hook', $hook ); 1094 } 1095 1548 1096 /** Global Manipulators *******************************************************/ 1549 1097 -
trunk/bp-core/bp-core-hooks.php
r5309 r5524 195 195 } 196 196 197 /** Admin *********************************************************************/ 198 199 if ( is_admin() ) { 200 201 /** Actions ***************************************************************/ 202 203 add_action( 'bp_loaded', 'bp_admin' ); 204 //add_action( 'bp_admin_init', 'bp_admin_settings_help' ); 205 //add_action( 'admin_menu', 'bp_admin_separator' ); 206 //add_action( 'custom_menu_order', 'bp_admin_custom_menu_order' ); 207 //add_action( 'menu_order', 'bp_admin_menu_order' ); 208 209 /** 210 * Run the updater late on 'bp_admin_init' to ensure that all alterations 211 * to the permalink structure have taken place. This fixes the issue of 212 * permalinks not being flushed properly when a bbPress update occurs. 213 */ 214 //add_action( 'bp_admin_init', 'bp_setup_updater', 999 ); 215 216 /** Filters ***************************************************************/ 217 } 218 197 219 ?> -
trunk/bp-core/bp-core-loader.php
r5316 r5524 24 24 function __construct() { 25 25 parent::start( 26 ' _core',26 'core', 27 27 __( 'BuddyPress Core', 'buddypress' ) 28 28 , BP_PLUGIN_DIR … … 119 119 // Add Core to required components 120 120 $bp->required_components[] = 'core'; 121 } 122 123 function includes() { 124 125 if ( !is_admin() ) 126 return; 127 128 $includes = array( 129 'admin' 130 ); 131 132 parent::includes( $includes ); 121 133 } 122 134 -
trunk/bp-core/bp-core-options.php
r5508 r5524 25 25 /** DB Version ********************************************************/ 26 26 27 '_bp_db_version' => '155', 27 '_bp_db_version' => '155', 28 29 /** Components ********************************************************/ 30 31 'bp-deactivated-components' => serialize( array() ), 32 33 /** bbPress ***********************************************************/ 34 35 // Legacy bbPress config location 36 'bb-config-location' => ABSPATH . 'bb-config.php', 37 38 /** XProfile **********************************************************/ 39 40 // Base profile groups name 41 'bp-xprofile-base-group-name' => 'Base', 42 43 // Base fullname field name 44 'bp-xprofile-fullname-field-name' => 'Name', 45 46 /** Blogs *************************************************************/ 47 48 // Used to decide if blogs need indexing 49 'bp-blogs-first-install' => false, 28 50 29 51 /** Settings **********************************************************/ 30 52 31 53 // Disable the WP to BP profile sync 32 'bp-disable-profile-sync' => false,54 'bp-disable-profile-sync' => false, 33 55 34 56 // Hide the admin bar for logged out users 35 'hide-loggedout-adminbar' => false,57 'hide-loggedout-adminbar' => false, 36 58 37 59 // Avatar uploads 38 'bp-disable-avatar-uploads' => false,60 'bp-disable-avatar-uploads' => false, 39 61 40 62 // Allow users to delete their own accounts 41 'bp-disable-account-deletion' => true,63 'bp-disable-account-deletion' => true, 42 64 43 65 // Allow anonymous posting 44 'bp-disable-blogforum-comments' => true,66 'bp-disable-blogforum-comments' => true, 45 67 46 68 // Use the WordPress editor when possible 47 '_bp_use_wp_editor' => false,69 '_bp_use_wp_editor' => false, 48 70 49 71 /** Groups ************************************************************/ … … 52 74 53 75 // Restrict group creation to super admins 54 'bp_restrict_group_creation' => false,76 'bp_restrict_group_creation' => false, 55 77 56 78 // Root forum ID for groups 57 '_bbp_group_forums_root_id' => 0,79 '_bbp_group_forums_root_id' => 0, 58 80 59 81 /** Akismet ***********************************************************/ 60 82 61 83 // Users from all sites can post 62 '_bp_enable_akismet' => true,84 '_bp_enable_akismet' => true, 63 85 ); 64 86 … … 164 186 // Always return a value, even if false 165 187 return $value; 188 } 189 190 /** 191 * When switching from single to multisite we need to copy blog options to 192 * site options. 193 * 194 * @package BuddyPress Core 195 * @todo Does this need to be here anymore after the introduction of bp_get_option etc? 196 */ 197 function bp_core_activate_site_options( $keys = array() ) { 198 global $bp; 199 200 if ( !empty( $keys ) && is_array( $keys ) ) { 201 $errors = false; 202 203 foreach ( $keys as $key => $default ) { 204 if ( empty( $bp->site_options[ $key ] ) ) { 205 $bp->site_options[ $key ] = bp_get_option( $key, $default ); 206 207 if ( !bp_update_option( $key, $bp->site_options[ $key ] ) ) 208 $errors = true; 209 } 210 } 211 212 if ( empty( $errors ) ) 213 return true; 214 } 215 216 return false; 217 } 218 219 /** 220 * BuddyPress uses common options to store configuration settings. Many of these 221 * settings are needed at run time. Instead of fetching them all and adding many 222 * initial queries to each page load, let's fetch them all in one go. 223 * 224 * @package BuddyPress Core 225 * @todo Use settings API and audit these methods 226 */ 227 function bp_core_get_root_options() { 228 global $wpdb; 229 230 // Get all the BuddyPress settings, and a few useful WP ones too 231 $root_blog_options = bp_get_default_options(); 232 $root_blog_options['registration'] = '0'; 233 $root_blog_options['avatar_default'] = 'mysteryman'; 234 $root_blog_option_keys = array_keys( $root_blog_options ); 235 236 // Do some magic to get all the root blog options in 1 swoop 237 $blog_options_keys = "'" . join( "', '", (array) $root_blog_option_keys ) . "'"; 238 $blog_options_table = bp_is_multiblog_mode() ? $wpdb->options : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'options'; 239 $blog_options_query = $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$blog_options_table} WHERE option_name IN ( {$blog_options_keys} )" ); 240 $root_blog_options_meta = $wpdb->get_results( $blog_options_query ); 241 242 // On Multisite installations, some options must always be fetched from sitemeta 243 if ( is_multisite() ) { 244 $network_options = apply_filters( 'bp_core_network_options', array( 245 'tags_blog_id' => '0', 246 'sitewide_tags_blog' => '', 247 'registration' => '0', 248 'fileupload_maxk' => '1500' 249 ) ); 250 251 $current_site = get_current_site(); 252 $network_option_keys = array_keys( $network_options ); 253 $sitemeta_options_keys = "'" . join( "', '", (array) $network_option_keys ) . "'"; 254 $sitemeta_options_query = $wpdb->prepare( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ( {$sitemeta_options_keys} ) AND site_id = %d", $current_site->id ); 255 $network_options_meta = $wpdb->get_results( $sitemeta_options_query ); 256 257 // Sitemeta comes second in the merge, so that network 'registration' value wins 258 $root_blog_options_meta = array_merge( $root_blog_options_meta, $network_options_meta ); 259 } 260 261 // Missing some options, so do some one-time fixing 262 if ( empty( $root_blog_options_meta ) || ( count( $root_blog_options_meta ) < count( $root_blog_option_keys ) ) ) { 263 264 // Unset the query - We'll be resetting it soon 265 unset( $root_blog_options_meta ); 266 267 // Loop through options 268 foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) { 269 // Clear out the value from the last time around 270 unset( $old_meta_value ); 271 272 // Get old site option 273 if ( is_multisite() ) 274 $old_meta_value = get_site_option( $old_meta_key ); 275 276 // No site option so look in root blog 277 if ( empty( $old_meta_value ) ) 278 $old_meta_value = bp_get_option( $old_meta_key, $old_meta_default ); 279 280 // Update the root blog option 281 bp_update_option( $old_meta_key, $old_meta_value ); 282 283 // Update the global array 284 $root_blog_options_meta[$old_meta_key] = $old_meta_value; 285 } 286 287 // We're all matched up 288 } else { 289 // Loop through our results and make them usable 290 foreach ( $root_blog_options_meta as $root_blog_option ) 291 $root_blog_options[$root_blog_option->name] = $root_blog_option->value; 292 293 // Copy the options no the return val 294 $root_blog_options_meta = $root_blog_options; 295 296 // Clean up our temporary copy 297 unset( $root_blog_options ); 298 } 299 300 return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta ); 166 301 } 167 302 -
trunk/bp-loader.php
r5439 r5524 453 453 require( $this->plugin_dir . 'bp-core/bp-core-cssjs.php' ); 454 454 require( $this->plugin_dir . 'bp-core/bp-core-update.php' ); 455 require( $this->plugin_dir . 'bp-core/bp-core-options.php' ); 455 456 require( $this->plugin_dir . 'bp-core/bp-core-classes.php' ); 456 457 require( $this->plugin_dir . 'bp-core/bp-core-filters.php' );
Note: See TracChangeset
for help on using the changeset viewer.