Changeset 5749
- Timestamp:
- 02/13/2012 04:03:55 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 deleted
- 10 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-admin.php
r5739 r5749 35 35 36 36 // Hook into early actions to load custom CSS and our init handler. 37 add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );38 37 add_action( "load-$hook", 'bp_activity_admin_load' ); 39 38 } -
trunk/bp-core/admin/bp-core-components.php
r5683 r5749 52 52 */ 53 53 function bp_core_admin_components_options() { 54 global $bp_wizard;55 54 56 55 // Load core functions, if needed … … 131 130 132 131 // On new install, set all components to be active by default 133 if ( !empty( $bp_wizard ) && 'install' == $bp_wizard->setup_type && empty( $active_components) )132 if ( empty( $active_components ) && ( bp_get_maintenance_mode() == 'install' ) ) 134 133 $active_components = $optional_components; 135 134 136 ?> 137 138 <?php /* The setup wizard uses different, more descriptive text here */ ?> 139 <?php if ( empty( $bp_wizard ) ) : ?> 135 // The setup wizard uses different, more descriptive text 136 if ( bp_get_maintenance_mode() ) : ?> 140 137 141 138 <h3><?php _e( 'Available Components', 'buddypress' ); ?></h3> … … 169 166 </table> 170 167 171 <?php if ( empty( $bp_wizard) ) : ?>168 <?php if ( bp_get_maintenance_mode() ) : ?> 172 169 173 170 <h3><?php _e( 'Required Components', 'buddypress' ); ?></h3> -
trunk/bp-core/admin/bp-core-functions.php
r5739 r5749 332 332 333 333 /** 334 * Loads admin panel styles and scripts.335 *336 * @package BuddyPress Core337 * @since {@internal Unknown}}338 */339 function bp_core_add_admin_menu_styles() {340 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )341 wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', BP_PLUGIN_URL . 'bp-core/css/admin.dev.css' ), array(), '20110723' );342 else343 wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', BP_PLUGIN_URL . 'bp-core/css/admin.css' ), array(), '20110723' );344 345 wp_enqueue_script( 'thickbox' );346 wp_enqueue_style( 'thickbox' );347 }348 349 /**350 334 * Output the tabs in the admin area 351 335 * … … 363 347 $tabs = array( 364 348 '0' => array( 365 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),349 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ), 366 350 'name' => __( 'Components', 'buddypress' ) 367 351 ), 368 352 '1' => array( 369 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' 353 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ), 370 354 'name' => __( 'Permalinks', 'buddypress' ) 371 355 ), 372 356 '2' => array( 373 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),357 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ), 374 358 'name' => __( 'Settings', 'buddypress' ) 375 359 ) … … 379 363 if ( bp_is_active( 'forums' ) ) { 380 364 $tabs['3'] = array( 381 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bb-forums-setup' ), 'admin.php' ) ),365 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bb-forums-setup' ), 'admin.php' ) ), 382 366 'name' => __( 'Forums', 'buddypress' ) 383 367 ); -
trunk/bp-core/admin/bp-core-schema.php
r5683 r5749 1 1 <?php 2 2 3 // Exit if accessed directly 3 4 if ( !defined( 'ABSPATH' ) ) exit; … … 13 14 14 15 return ''; 16 } 17 18 function bp_core_install( $active_components = false ) { 19 20 if ( empty( $active_components ) ) 21 $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) ); 22 23 // Core DB Tables 24 bp_core_install_notifications(); 25 26 // Activity Streams 27 if ( !empty( $active_components['activity'] ) ) 28 bp_core_install_activity_streams(); 29 30 // Friend Connections 31 if ( !empty( $active_components['friends'] ) ) 32 bp_core_install_friends(); 33 34 // Extensible Groups 35 if ( !empty( $active_components['groups'] ) ) 36 bp_core_install_groups(); 37 38 // Private Messaging 39 if ( !empty( $active_components['messages'] ) ) 40 bp_core_install_private_messaging(); 41 42 // Extended Profiles 43 if ( !empty( $active_components['xprofile'] ) ) 44 bp_core_install_extended_profiles(); 45 46 // Blog tracking 47 if ( !empty( $active_components['blogs'] ) ) 48 bp_core_install_blog_tracking(); 15 49 } 16 50 … … 301 335 } 302 336 337 /** 338 * I don't appear to be used anymore, but I'm here anyways. I was originally 339 * used in olden days to update pre-1.1 schemas, but that was before we had 340 * a legitimate update process. Keep me around just incase. 341 * 342 * @global WPDB $wpdb 343 * @global BuddyPress $bp 344 */ 345 function bp_update_db_stuff() { 346 global $wpdb, $bp; 347 348 $bp_prefix = bp_core_get_table_prefix(); 349 350 // Rename the old user activity cached table if needed. 351 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'" ) ) 352 $wpdb->query( "RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" ); 353 354 // Rename fields from pre BP 1.2 355 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) { 356 if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) ) { 357 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" ); 358 } 359 360 if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) ) { 361 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" ); 362 } 363 } 364 365 // On first installation - record all existing blogs in the system. 366 if ( !(int) $bp->site_options['bp-blogs-first-install'] ) { 367 bp_blogs_record_existing_blogs(); 368 bp_update_option( 'bp-blogs-first-install', 1 ); 369 } 370 371 if ( is_multisite() ) { 372 bp_core_add_illegal_names(); 373 } 374 375 // Update and remove the message threads table if it exists 376 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'" ) ) { 377 if ( BP_Messages_Thread::update_tables() ) { 378 $wpdb->query( "DROP TABLE {$bp_prefix}bp_messages_threads" ); 379 } 380 } 381 382 } 383 303 384 ?> -
trunk/bp-core/admin/bp-core-update.php
r5739 r5749 16 16 var $steps; 17 17 18 /** 19 * @var int Database version of current BuddyPress files 20 */ 21 var $db_version; 22 23 /** 24 * @var int Database version raw from the database connection 25 */ 26 var $db_version_raw; 27 28 /** 29 * @var string What kind of setup/update are we performing 30 */ 31 var $setup_type; 32 33 /** Functions *************************************************************/ 34 35 function bp_core_setup_wizard() { 36 $this->__construct(); 37 } 18 /** Methods ***************************************************************/ 38 19 39 20 function __construct() { 40 global $bp;41 21 42 22 // Ensure that we have access to some utility functions. Must use require_once() … … 44 24 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 45 25 46 // Get current DB version 47 $this->db_version_raw = !empty( $bp->db_version_raw ) ? (int) $bp->db_version_raw : 0; 48 26 // Set/reset the wizard cookie 49 27 setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH ); 50 28 $_COOKIE['bp-wizard-step'] = 0; 51 52 $this->db_version = bp_get_db_version();53 $this->setup_type = $bp->maintenance_mode;54 $this->current_step = $this->current_step();55 56 // Remove the admin menu while we update/install57 remove_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 );58 29 59 30 // Call the save method that will save data and modify $current_step … … 64 35 $this->steps = $this->add_steps(); 65 36 } 66 37 67 38 function current_step() { 68 39 if ( isset( $_POST['step'] ) ) { … … 84 55 $steps = array(); 85 56 86 if ( 'install' == $this->setup_type) {57 if ( bp_get_maintenance_mode() == 'install' ) { 87 58 $steps = array( 88 59 __( 'Components', 'buddypress' ), … … 96 67 } else { 97 68 98 if ( $this->db_version_raw < (int) $this->db_version)69 if ( bp_get_db_version_raw() < (int) bp_get_db_version() ) 99 70 $steps[] = __( 'Database Update', 'buddypress' ); 100 71 101 72 // New for BP 1.5 102 if ( $this->db_version_raw< 1801 || !bp_core_get_directory_page_ids() ) {73 if ( bp_get_db_version_raw() < 1801 || !bp_core_get_directory_page_ids() ) { 103 74 $steps[] = __( 'Components', 'buddypress' ); 104 75 $steps[] = __( 'Pages', 'buddypress' ); … … 106 77 107 78 // New for BP 1.6 108 if ( $this->db_version_raw< 5222 && !defined( 'BP_USE_WP_ADMIN_BAR' ) )79 if ( bp_get_db_version_raw() < 5222 && !defined( 'BP_USE_WP_ADMIN_BAR' ) ) 109 80 $steps[] = __( 'Admin Bar', 'buddypress' ); 110 81 … … 116 87 117 88 function save( $step_name ) { 89 90 // Bail if user is not capable of being here 91 if ( ! bp_current_user_can( 'activate_plugins' ) ) 92 wp_die( 'Uh... No.' ); 118 93 119 94 // Save any posted values … … 149 124 } 150 125 151 if ( !$result && $this->current_step )152 $this->current_step--;153 154 126 if ( 'finish' != $step_name ) 155 setcookie( 'bp-wizard-step', (int) $this->current_step , time() + 60 * 60 * 24, COOKIEPATH );127 setcookie( 'bp-wizard-step', (int) $this->current_step(), time() + 60 * 60 * 24, COOKIEPATH ); 156 128 } 157 129 158 130 function html() { 159 131 132 // Bail if user is not capable of being here 133 if ( ! bp_current_user_can( 'activate_plugins' ) ) 134 wp_die( 'You do not have sufficient permissions to access this page.' ); 135 160 136 // Update or Setup 161 $type = ( 'update' == $this->setup_type ) ? __( 'Update', 'buddypress' ) : __( 'Setup', 'buddypress' );162 137 $type = ( 'update' == bp_get_maintenance_mode() ) ? __( 'Update', 'buddypress' ) : __( 'Setup', 'buddypress' ); 138 163 139 ?> 164 140 165 <div class="wrap" id="bp- admin">141 <div class="wrap" id="bp-wizard"> 166 142 167 143 <?php screen_icon( 'buddypress' ); ?> … … 173 149 174 150 $step_count = count( $this->steps ) - 1; 175 $wiz_or_set = $this->current_step >= $step_count ? 'bp-components' : 'bp-wizard';176 $form_action = bp_core_ update_do_network_admin() ? network_admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) );151 $wiz_or_set = $this->current_step() >= $step_count ? 'bp-components' : 'bp-wizard'; 152 $form_action = bp_core_do_network_admin() ? network_admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'index.php' ) ); 177 153 ?> 178 154 179 <form action="<?php echo $form_action; ?>" method="post" id="bp- admin-form">180 <div id="bp- admin-nav">155 <form action="<?php echo $form_action; ?>" method="post" id="bp-wizard-form"> 156 <div id="bp-wizard-nav"> 181 157 <ol> 182 158 183 159 <?php foreach( (array) $this->steps as $i => $name ) : ?> 184 160 185 <li<?php if ( $this->current_step == $i ) : ?> class="current"<?php endif; ?>>186 <?php if ( $this->current_step > $i ) : ?>161 <li<?php if ( $this->current_step() == $i ) : ?> class="current"<?php endif; ?>> 162 <?php if ( $this->current_step() > $i ) : ?> 187 163 188 164 <span class="complete"> </span> … … 202 178 </ol> 203 179 204 <?php if ( __( 'Finish', 'buddypress' ) == $this->steps[$this->current_step ] ) : ?>180 <?php if ( __( 'Finish', 'buddypress' ) == $this->steps[$this->current_step()] ) : ?> 205 181 206 182 <div class="prev-next submit clear"> … … 218 194 </div> 219 195 220 <div id="bp- admin-content">221 222 <?php switch ( $this->steps[$this->current_step ] ) {196 <div id="bp-wizard-content"> 197 198 <?php switch ( $this->steps[$this->current_step()] ) { 223 199 case __( 'Database Update', 'buddypress') : 224 200 $this->step_db_update(); … … 260 236 261 237 function step_db_update() { 262 if ( !current_user_can( 'activate_plugins' ) ) 263 return false; ?> 238 ?> 264 239 265 240 <p><?php _e( 'Before you can continue using BuddyPress, a few minor adjustments need to be made. These changes are not destructive and will not remove or change any existing settings.', 'buddypress' ); ?></p> … … 267 242 <div class="submit clear"> 268 243 <input type="hidden" name="save" value="db_update" /> 269 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />244 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ); ?>" /> 270 245 271 246 <?php wp_nonce_field( 'bpwizard_db_update' ) ?> … … 277 252 278 253 function step_components() { 279 if ( !current_user_can( 'activate_plugins' ) )280 return false;281 254 282 255 if ( !function_exists( 'bp_core_admin_components_options' ) ) … … 289 262 <div class="submit clear"> 290 263 <input type="hidden" name="save" value="components" /> 291 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />264 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ); ?>" /> 292 265 293 266 <?php wp_nonce_field( 'bpwizard_components' ); ?> … … 306 279 switch_to_blog( bp_get_root_blog_id() ); 307 280 308 if ( !current_user_can( 'activate_plugins' ) ) 309 return false; 310 311 $existing_pages = bp_core_update_get_page_meta(); 281 $existing_pages = bp_core_get_directory_page_ids(); 312 282 313 283 // Provide empty indexes to avoid PHP errors with wp_dropdown_pages() … … 484 454 <div class="submit clear"> 485 455 <input type="hidden" name="save" value="pages" /> 486 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />456 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ); ?>" /> 487 457 488 458 <?php wp_nonce_field( 'bpwizard_pages' ); ?> … … 496 466 497 467 function step_permalinks() { 498 if ( !current_user_can( 'activate_plugins' ) )499 return false;500 468 501 469 $prefix = ''; … … 532 500 <div class="submit clear"> 533 501 <input type="hidden" name="save" value="permalinks" /> 534 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />502 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ); ?>" /> 535 503 536 504 <?php if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && empty( $_POST['skip-htaccess'] ) ) : ?> … … 548 516 549 517 function step_theme() { 550 if ( !current_user_can( 'activate_plugins' ) )551 return false;552 518 553 519 $installed_plugins = get_plugins(); … … 603 569 </tr> 604 570 605 <?php if ( $bp_theme_installed ) : ?> 571 <?php if ( !empty( $bp_theme_installed ) ) : ?> 572 606 573 <tr> 607 574 <th> 608 575 <h5><?php _e( 'Other themes', 'buddypress' ); ?></h5> 609 <img src="<?php echo plugins_url( '/buddypress/bp-core/ images/find.png' ); ?>" alt="<?php _e( 'A BuddyPress theme', 'buddypress' ); ?>" />576 <img src="<?php echo plugins_url( '/buddypress/bp-core/admin/images/find.png' ); ?>" alt="<?php _e( 'A BuddyPress theme', 'buddypress' ); ?>" /> 610 577 </th> 611 578 <td> … … 627 594 </td> 628 595 </tr> 596 629 597 <?php endif; ?> 630 598 631 <tr> 632 <th> 633 <h5><?php _e( 'Manually update current theme', 'buddypress' ); ?></h5> 634 635 <?php if ( !empty( $screenshot ) ) : ?> 636 637 <img src="<?php echo esc_url( $screenshot ); ?>" alt="<?php _e( 'Your existing theme', 'buddypress' ); ?>" /> 638 639 <?php endif; ?> 640 641 </th> 642 <td> 643 <p><?php _e( 'The BuddyPress Template Pack will guide you through the process of manually editing your existing theme. It comes with a step-by-step guide and involves copying the BuddyPress template files into your theme. <strong>This option requires knowledge of CSS and HTML.</strong> You will need to tweak the new templates to match your existing theme.', 'buddypress' ); ?></p> 644 645 <?php if ( empty( $template_pack_installed ) ) : ?> 646 647 <p><a id="bp-template-pack" class="thickbox onclick button" href="<?php echo network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=bp-template-pack&TB_iframe=true&width=640&height=500' ); ?>"><?php _e( 'Install BuddyPress Template Pack', 'buddypress' ); ?></a></p> 648 649 <?php else : ?> 650 651 <p><label><input type="radio" name="theme" value="manual_wp" /> <?php _e( 'Choose this option (go to Appearance → BP Compatibility after setup is complete)', 'buddypress' ); ?></label></p> 652 <p><a id="bp-template-pack" class="button installed disabled" href="javascript:void();"><span></span><?php _e( 'Plugin Installed', 'buddypress' ); ?></a></p> 653 654 <?php endif; ?> 655 656 </td> 657 </tr> 599 <?php if ( ! current_theme_supports( 'buddypress' ) ) : ?> 600 601 <tr> 602 <th> 603 <h5><?php _e( 'Manually update current theme', 'buddypress' ); ?></h5> 604 605 <?php if ( !empty( $screenshot ) ) : ?> 606 607 <img src="<?php echo esc_url( $screenshot ); ?>" alt="<?php _e( 'Your existing theme', 'buddypress' ); ?>" /> 608 609 <?php endif; ?> 610 611 </th> 612 <td> 613 <p><?php _e( 'The BuddyPress Template Pack will guide you through the process of manually editing your existing theme. It comes with a step-by-step guide and involves copying the BuddyPress template files into your theme. <strong>This option requires knowledge of CSS and HTML.</strong> You will need to tweak the new templates to match your existing theme.', 'buddypress' ); ?></p> 614 615 <?php if ( empty( $template_pack_installed ) ) : ?> 616 617 <p><a id="bp-template-pack" class="thickbox onclick button" href="<?php echo network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=bp-template-pack&TB_iframe=true&width=640&height=500' ); ?>"><?php _e( 'Install BuddyPress Template Pack', 'buddypress' ); ?></a></p> 618 619 <?php else : ?> 620 621 <p><label><input type="radio" name="theme" value="manual_wp" /> <?php _e( 'Choose this option (go to Appearance → BP Compatibility after setup is complete)', 'buddypress' ); ?></label></p> 622 <p><a id="bp-template-pack" class="button installed disabled" href="javascript:void();"><span></span><?php _e( 'Plugin Installed', 'buddypress' ); ?></a></p> 623 624 <?php endif; ?> 625 626 </td> 627 </tr> 628 629 <?php endif; ?> 658 630 659 631 <tr> … … 673 645 <div class="submit clear"> 674 646 <input type="hidden" name="save" value="theme" /> 675 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />647 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ) ?>" /> 676 648 677 649 <?php wp_nonce_field( 'bpwizard_theme' ) ?> … … 688 660 */ 689 661 function step_admin_bar() { 690 if ( !current_user_can( 'activate_plugins' ) ) 691 return false; 692 ?> 662 ?> 693 663 694 664 <p><?php _e( "BuddyPress now uses WordPress' Admin Bar; this sits at the top of your site and contains various links to useful admin screens. We've turbo-charged the Admin Bar by adding social items to help your users explore your site, and manage their content.", 'buddypress' ); ?></p> … … 705 675 <div class="submit clear"> 706 676 <input type="hidden" name="save" value="admin_bar" /> 707 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />677 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ); ?>" /> 708 678 709 679 <?php wp_nonce_field( 'bpwizard_admin_bar' ) ?> 680 710 681 </div> 711 682 … … 714 685 715 686 function step_finish() { 716 if ( !current_user_can( 'activate_plugins' ) )717 return false;718 687 719 688 // What type of action is happening here? 720 $type = ( 'install' == $this->setup_type) ? __( 'setup', 'buddypress' ) : __( 'update', 'buddypress' ); ?>721 722 <p><?php printf( __( "The BuddyPress %1\$s is complete, and your site is ready to go!", 'buddypress' ), $type , $type); ?></p>689 $type = ( bp_get_maintenance_mode() == 'install' ) ? __( 'setup', 'buddypress' ) : __( 'update', 'buddypress' ); ?> 690 691 <p><?php printf( __( "The BuddyPress %1\$s is complete, and your site is ready to go!", 'buddypress' ), $type ); ?></p> 723 692 724 693 <div class="submit clear"> 725 694 <input type="hidden" name="save" value="finish" /> 726 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ); ?>" />695 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ); ?>" /> 727 696 728 697 <?php wp_nonce_field( 'bpwizard_finish' ); ?> … … 736 705 737 706 function step_db_update_save() { 738 global $bp;739 707 740 708 if ( isset( $_POST['submit'] ) ) { … … 744 712 bp_core_install(); 745 713 746 if ( $this->db_version_raw < 1801 ) 714 // Update to 1.5 715 if ( bp_get_db_version_raw() < 1801 ) 747 716 $this->update_1_5(); 748 717 749 // Update t he active components option early if we're updating750 if ( 'update' == $this->setup_type)751 bp_update_option( 'bp-active-components', $bp->active_components);718 // Update to 1.6 719 if ( bp_get_db_version_raw() < bp_get_db_version() ) 720 $this->update_1_6(); 752 721 753 722 return true; … … 792 761 793 762 // Delete any existing pages 794 $existing_pages = bp_core_ update_get_page_meta( 'bp-pages');763 $existing_pages = bp_core_get_directory_page_ids(); 795 764 796 765 foreach ( (array) $existing_pages as $page_id ) { … … 992 961 check_admin_referer( 'bpwizard_finish' ); 993 962 994 // Delete possible site options995 delete_site_option( 'bp-db-version' );996 delete_site_option( '_bp_db_version' );997 delete_site_option( 'bp-core-db-version' );998 delete_site_option( '_bp-core-db-version' );999 1000 // Delete possible blog options1001 delete_blog_option( bp_get_root_blog_id(), 'bp-db-version' );1002 delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version' );1003 delete_site_option( bp_get_root_blog_id(), '_bp-core-db-version' );1004 delete_site_option( bp_get_root_blog_id(), '_bp_db_version' );1005 1006 963 // Update the DB version in the database 1007 964 // Stored in sitemeta. Do not use bp_update_option() 1008 update_blog_option( bp_get_root_blog_id(), '_bp_db_version', $this->db_version);965 update_blog_option( bp_get_root_blog_id(), '_bp_db_version', bp_get_db_version() ); 1009 966 1010 967 // Delete the setup cookie 1011 968 @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); 1012 969 1013 // Load BP and hook the admin menu, so that the redirect is successful1014 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-admin.php' );1015 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-template.php' );1016 bp_admin();1017 1018 970 // Redirect to the BuddyPress dashboard 1019 $redirect = bp_core_update_do_network_admin() ? add_query_arg( array( 'page' => 'bp-components' ), network_admin_url( 'settings.php' ) ) : add_query_arg( array( 'page' => 'bp-components' ), admin_url( 'options-general.php' ) ); 971 $redirect = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' ); 972 $redirect = add_query_arg( array( 'page' => 'bp-components' ), $redirect ); 1020 973 1021 974 wp_safe_redirect( $redirect ); 1022 975 1023 return true; 976 // That's all! 977 exit(); 1024 978 } 1025 979 … … 1049 1003 // Database update methods based on version numbers 1050 1004 function update_1_5() { 1005 1051 1006 // Delete old database version options 1052 1007 delete_site_option( 'bp-activity-db-version' ); … … 1058 1013 } 1059 1014 1015 // Database update methods based on version numbers 1016 function update_1_6() { 1017 1018 // Delete possible site options 1019 delete_site_option( 'bp-db-version' ); 1020 delete_site_option( '_bp_db_version' ); 1021 delete_site_option( 'bp-core-db-version' ); 1022 delete_site_option( '_bp-core-db-version' ); 1023 1024 // Delete possible blog options 1025 delete_blog_option( bp_get_root_blog_id(), 'bp-db-version' ); 1026 delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version' ); 1027 delete_site_option( bp_get_root_blog_id(), '_bp-core-db-version' ); 1028 delete_site_option( bp_get_root_blog_id(), '_bp_db_version' ); 1029 } 1030 1060 1031 /** 1061 1032 * Reset the cookie so the install script starts over … … 1063 1034 function reset_cookie() { 1064 1035 @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); 1065 } 1036 } 1066 1037 } 1067 1038 1068 function bp_core_setup_wizard_init() { 1069 global $bp_wizard; 1070 1071 $bp_wizard = new BP_Core_Setup_Wizard; 1039 /** 1040 * Get the wizard 1041 * 1042 * @global type $bp 1043 * @return boolean 1044 */ 1045 function bp_get_wizard() { 1046 global $bp; 1047 1048 if ( !empty( $bp->admin->wizard ) ) 1049 return $bp->admin->wizard; 1050 1051 return false; 1072 1052 } 1073 add_action( bp_core_update_admin_hook(), 'bp_core_setup_wizard_init', 7 );1074 1075 function bp_core_install( $active_components = false ) {1076 1077 if ( empty( $active_components ) )1078 $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );1079 1080 require( dirname( __FILE__ ) . '/bp-core-schema.php' );1081 1082 // Core DB Tables1083 bp_core_install_notifications();1084 1085 // Activity Streams1086 if ( !empty( $active_components['activity'] ) )1087 bp_core_install_activity_streams();1088 1089 // Friend Connections1090 if ( !empty( $active_components['friends'] ) )1091 bp_core_install_friends();1092 1093 // Extensible Groups1094 if ( !empty( $active_components['groups'] ) )1095 bp_core_install_groups();1096 1097 // Private Messaging1098 if ( !empty( $active_components['messages'] ) )1099 bp_core_install_private_messaging();1100 1101 // Extended Profiles1102 if ( !empty( $active_components['xprofile'] ) )1103 bp_core_install_extended_profiles();1104 1105 // Blog tracking1106 if ( !empty( $active_components['blogs'] ) )1107 bp_core_install_blog_tracking();1108 }1109 1110 function bp_core_update( $disabled ) {1111 require( dirname( __FILE__ ) . '/bp-core-schema.php' );1112 }1113 1114 function bp_update_db_stuff() {1115 $bp_prefix = bp_core_get_table_prefix();1116 // Rename the old user activity cached table if needed.1117 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'" ) )1118 $wpdb->query( "RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );1119 1120 // Rename fields from pre BP 1.21121 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {1122 if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) )1123 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );1124 1125 if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) )1126 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );1127 }1128 1129 // On first installation - record all existing blogs in the system.1130 if ( !(int) $bp->site_options['bp-blogs-first-install'] ) {1131 bp_blogs_record_existing_blogs();1132 bp_update_option( 'bp-blogs-first-install', 1 );1133 }1134 1135 if ( is_multisite() )1136 bp_core_add_illegal_names();1137 1138 // Update and remove the message threads table if it exists1139 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'" ) ) {1140 $update = BP_Messages_Thread::update_tables();1141 1142 if ( $update )1143 $wpdb->query( "DROP TABLE {$bp_prefix}bp_messages_threads" );1144 }1145 1146 }1147 1148 function bp_core_wizard_message() {1149 if ( isset( $_GET['updated'] ) )1150 $message = __( 'Installation was successful. The available options have now been updated, please continue with your selection.', 'buddypress' );1151 else1152 return false; ?>1153 1154 <div id="message" class="updated">1155 <p><?php echo esc_attr( $message ) ?></p>1156 </div>1157 1158 <?php1159 }1160 add_action( 'bp_admin_notices', 'bp_core_wizard_message' );1161 1162 // Alter thickbox screens so the entire plugin download and install1163 // interface is contained within.1164 function bp_core_wizard_thickbox() {1165 $form_action = bp_core_update_do_network_admin() ? network_admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ); ?>1166 1167 <script type="text/javascript">1168 jQuery('p.action-button a').attr( 'target', '' );1169 1170 if ( window.location != window.parent.location ) {1171 jQuery('#adminmenu, #wphead, #footer, #update-nag, #screen-meta').hide();1172 jQuery('#wpbody').css( 'margin', '15px' );1173 jQuery('body').css( 'min-width', '30px' );1174 jQuery('#wpwrap').css( 'min-height', '30px' );1175 jQuery('a').removeClass( 'thickbox thickbox-preview onclick' );1176 jQuery('body.update-php div.wrap p:last').hide();1177 jQuery('body.update-php div.wrap p:last').after( '<p><a class="button" target="_parent" href="<?php echo $form_action; ?>"><?php _e( 'Finish', 'buddypress' ) ?></a></p>' );1178 }1179 </script>1180 1181 <?php1182 }1183 add_action( 'admin_footer', 'bp_core_wizard_thickbox' );1184 1185 function bp_core_update_add_admin_menu_styles() {1186 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {1187 wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.dev.css' ), array(), '20110723' );1188 wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.dev.js' ), array( 'jquery' ), '20110723' );1189 } else {1190 wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.css' ), array(), '20110723' );1191 wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.js' ), array( 'jquery' ), '20110723' );1192 }1193 1194 wp_enqueue_script( 'thickbox' );1195 wp_enqueue_style( 'thickbox' );1196 }1197 add_action( 'admin_head', 'bp_core_update_add_admin_menu_styles' );1198 1199 /**1200 * Fetches BP pages from the meta table1201 *1202 * @package BuddyPress Core1203 * @since 1.51204 *1205 * @return array $page_ids1206 */1207 function bp_core_update_get_page_meta() {1208 $page_ids = bp_get_option( 'bp-pages' );1209 if ( empty( $page_ids ) )1210 $page_ids = array();1211 1212 return apply_filters( 'bp_core_update_get_page_meta', $page_ids );1213 }1214 1215 function bp_core_update_do_network_admin() {1216 $do_network_admin = false;1217 1218 if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )1219 $do_network_admin = true;1220 1221 return apply_filters( 'bp_core_do_network_admin', $do_network_admin );1222 }1223 1224 function bp_core_update_admin_hook() {1225 $hook = bp_core_update_do_network_admin() ? 'network_admin_menu' : 'admin_menu';1226 1227 return apply_filters( 'bp_core_admin_hook', $hook );1228 }1229 1230 /**1231 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.1232 *1233 * @package BuddyPress Core1234 * @global object $bp Global BuddyPress settings object1235 * @global $wpdb WordPress DB access object.1236 * @uses add_submenu_page() WP function to add a submenu item1237 */1238 function bp_core_update_add_admin_menu() {1239 global $bp_wizard;1240 1241 // Only load this version of the menu if this is an upgrade or a new installation1242 if ( empty( $bp_wizard->setup_type ) )1243 return false;1244 1245 if ( !current_user_can( 'manage_options' ) )1246 return false;1247 1248 if ( 'install' == $bp_wizard->setup_type )1249 $status = __( 'BuddyPress Setup', 'buddypress' );1250 else1251 $status = __( 'Update BuddyPress', 'buddypress' );1252 1253 // Add the administration tab under the "Site Admin" tab for site administrators1254 if ( ! is_multisite() || bp_is_multiblog_mode() )1255 $hook = add_dashboard_page( $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );1256 else1257 $hook = add_submenu_page( 'update-core.php', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );1258 1259 // Add a hook for css/js1260 add_action( "admin_print_styles-$hook", 'bp_core_update_add_admin_menu_styles' );1261 }1262 add_action( bp_core_update_admin_hook(), 'bp_core_update_add_admin_menu', 9 );1263 1264 /**1265 * Adds an admin nag about running the BP upgrade/install wizard1266 *1267 * @package BuddyPress Core1268 * @since 1.51269 * @global $pagenow The current admin page1270 */1271 function bp_core_update_nag() {1272 global $bp_wizard, $pagenow;1273 1274 // Bail if no wizard1275 if ( empty( $bp_wizard->setup_type ) )1276 return;1277 1278 // Bail if user cannot manage options1279 if ( ! current_user_can( 'manage_options' ) )1280 return;1281 1282 // Are we looking at a network?1283 if ( bp_core_update_do_network_admin() ) {1284 1285 // Bail if looking at wizard page1286 if ( ( 'admin.php' == $pagenow ) && ( !empty( $_GET['page'] ) && ( 'bp-wizard' == $_GET['page'] ) ) ) {1287 return;1288 }1289 1290 // Set the url for the nag1291 $url = network_admin_url( 'admin.php?page=bp-wizard' );1292 1293 // Single site1294 } else {1295 1296 // Bail if looking at wizard page1297 if ( ( 'index.php' == $pagenow ) && ( !empty( $_GET['page'] ) && ( 'bp-wizard' == $_GET['page'] ) ) ) {1298 return;1299 }1300 1301 // Set the url for the nag1302 $url = admin_url( 'index.php?page=bp-wizard' );1303 }1304 1305 // What does the nag say?1306 switch( $bp_wizard->setup_type ) {1307 1308 // Update text1309 case 'update' :1310 $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url );1311 break;1312 1313 // First install text1314 case 'install' : default :1315 $msg = sprintf( __( 'BuddyPress was successfully activated! Please run the <a href="%s">installation wizard</a>.', 'buddypress' ), $url );1316 break;1317 } ?>1318 1319 <div class="update-nag"><?php echo $msg; ?></div>1320 1321 <?php1322 }1323 add_action( 'admin_notices', 'bp_core_update_nag', 5 );1324 add_action( 'network_admin_notices', 'bp_core_update_nag', 5 );1325 1053 1326 1054 ?> -
trunk/bp-core/admin/css/wizard.dev.css
r5739 r5749 1 2 /* Icon 323 ------------------------------------------------------------------------------*/4 5 div#icon-buddypress {6 background: url( ../images/icons32.png ) no-repeat -370px -6px;7 }8 9 div#icon-buddypress-activity {10 background: url( ../images/icons32.png ) no-repeat -10px -6px;11 }12 13 /* Menu Icons14 ------------------------------------------------------------------------------*/15 16 ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a img {17 display: none;18 }19 ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a {20 background-image: url( '../images/menu.png' ) !important;21 background-position: -178pxpx -34px;22 }23 ul#adminmenu li.toplevel_page_bp-wizard:hover .wp-menu-image a,24 ul#adminmenu li.toplevel_page_bp-wizard.wp-has-current-submenu .wp-menu-image a {25 background-position: -178px -2px;26 }27 28 /* Backpat Icon */29 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image a img,30 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img {31 display: none;32 }33 34 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image a,35 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a {36 background-image: url( '../images/menu.png' ) !important;37 background-position: -178px -34px;38 }39 40 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image a,41 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a,42 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image a,43 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a {44 background-position: -178px -2px;45 }46 47 /* Activity Icon */48 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image a img {49 display: none;50 }51 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image a {52 background-image: url( '../images/menu.png' ) !important;53 background-position: 0px -34px;54 }55 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image a,56 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image a,57 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image a {58 background-position: 0 -2px;59 }60 1 61 2 /* General Admin Styling 62 3 ------------------------------------------------------------------------------*/ 63 4 64 div#bp- admin{5 div#bp-wizard { 65 6 color: #555; 66 7 min-width: 680px; 67 8 } 68 div#bp- adminp {9 div#bp-wizard p { 69 10 line-height: 170%; 70 11 } 71 12 72 form#bp- admin-form {13 form#bp-wizard-form { 73 14 margin: 0 10px; 74 15 } 75 16 76 div#bp- admin-nav {17 div#bp-wizard-nav { 77 18 background: #e0e0e0; 78 19 margin: 15px -10px 10px; … … 83 24 border-radius: 2px; 84 25 } 85 div#bp- admin-nav div.submit {26 div#bp-wizard-nav div.submit { 86 27 position: relative; 87 28 float: right; 88 29 margin-top: -36px !important; 89 30 } 90 div#bp- admin-nav div.submit input {31 div#bp-wizard-nav div.submit input { 91 32 padding: 6px 10px; 92 33 } 93 div#bp- admin-nav ol {34 div#bp-wizard-nav ol { 94 35 list-style-type: decimal; 95 36 margin: 0; 96 37 padding: 0; 97 38 } 98 div#bp- admin-nav ol li {39 div#bp-wizard-nav ol li { 99 40 float: left; 100 41 margin: 0 10px 0 0; 101 42 color: #666; 102 43 } 103 div#bp- admin-nav ol li {44 div#bp-wizard-nav ol li { 104 45 padding: 8px 12px; 105 46 display: block; … … 109 50 text-decoration: none; 110 51 } 111 div#bp- admin-nav ol li.current {52 div#bp-wizard-nav ol li.current { 112 53 background: #fff; 113 54 color: #555; 114 55 } 115 56 116 div#bp- admin-nav ol li span.complete {57 div#bp-wizard-nav ol li span.complete { 117 58 background: url( ../images/completed.gif ) center left no-repeat; 118 59 padding: 6px; … … 155 96 } 156 97 157 div#bp- admin div.prev-next, div#bp-admindiv.prev-next p,158 div#bp- admin div.submit, div#bp-admindiv.submit p {98 div#bp-wizard div.prev-next, div#bp-wizard div.prev-next p, 99 div#bp-wizard div.submit, div#bp-wizard div.submit p { 159 100 margin: 0; 160 101 padding: 0; 161 102 } 162 div#bp-admin div.submit { margin-top: 30px; } 163 div#bp-admin div.prev-next { text-align: right; margin-top: 0; } 103 div#bp-wizard div.submit { 104 margin-top: 30px; 105 } 106 div#bp-wizard div.prev-next { 107 text-align: right; 108 margin-top: 0; 109 } 164 110 165 div#bp- admindiv.prev-next {111 div#bp-wizard div.prev-next { 166 112 margin: 0 -20px; 167 113 padding: 0 20px 10px; 168 114 } 169 115 170 div#bp- admintable td {116 div#bp-wizard table td { 171 117 font-family: helvetica, arial, tahoma, sans-serif; 172 118 vertical-align: top; 173 119 } 174 120 175 div#bp- admintable.form-table th {121 div#bp-wizard table.form-table th { 176 122 border-right: 1px solid #eee; 177 123 padding: 15px 25px 15px 0; … … 179 125 vertical-align: top; 180 126 } 181 div#bp- admintable.form-table tr {127 div#bp-wizard table.form-table tr { 182 128 border-bottom: 1px dotted #f0f0f0; 183 129 } 184 div#bp-admin table.form-table td { padding-left: 25px; font-size: 12px; } 130 div#bp-wizard table.form-table td { 131 padding-left: 25px; 132 font-size: 12px; 133 } 185 134 186 div#bp- admintable.form-table th h5 {135 div#bp-wizard table.form-table th h5 { 187 136 font-size: 14px; 188 137 margin: 0; … … 190 139 } 191 140 192 div#bp- admintable.form-table th img {141 div#bp-wizard table.form-table th img { 193 142 margin-top: 5px; 194 143 } 195 144 196 div#bp-admin table.form-table th p { margin: 3px 0 0 0; } 145 div#bp-wizard table.form-table th p { 146 margin: 3px 0 0 0; 147 } 197 148 198 div#bp- admin code, div#bp-adminkbd {149 div#bp-wizard code, div#bp-wizard kbd { 199 150 font-size: 12px; 200 151 background: #f0f0f0; 201 152 } 202 153 203 div#bp- admin div#message code, div#bp-admindiv#message kbd {154 div#bp-wizard div#message code, div#bp-wizard div#message kbd { 204 155 background: #ffe293; 205 156 } … … 209 160 } 210 161 211 a.installed, a.installed:hover, a.installed:active { 162 a.installed, 163 a.installed:hover, 164 a.installed:active { 212 165 padding-left: 15px; 213 166 color: #888; … … 217 170 218 171 a.installed span { 219 background: url( ../images/installed.gif ) left center no-repeat;172 background: url( ../images/installed.gif ) left center no-repeat; 220 173 padding: 6px 10px 7px 6px; 221 174 margin-left: -5px; -
trunk/bp-core/bp-core-admin.php
r5661 r5749 45 45 public $styles_url = ''; 46 46 47 /** 48 * @var string URL to the BuddyPress admin CSS directory 49 */ 50 public $css_url = ''; 51 52 /** 53 * @var string URL to the BuddyPress admin JS directory 54 */ 55 public $js_url = ''; 56 47 57 /** Recounts **************************************************************/ 48 58 … … 59 69 public $content_depth = 0; 60 70 61 /** Functions*************************************************************/71 /** Methods ***************************************************************/ 62 72 63 73 /** … … 77 87 78 88 /** 89 * Admin globals 90 * 91 * @since BuddyPress (1.6) 92 * @access private 93 */ 94 private function setup_globals() { 95 global $bp; 96 97 // Admin url 98 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-core/admin' ); 99 100 // Admin url 101 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-core/admin' ); 102 103 // Admin images URL 104 $this->images_url = trailingslashit( $this->admin_url . 'images' ); 105 106 // Admin css URL 107 $this->css_url = trailingslashit( $this->admin_url . 'css' ); 108 109 // Admin css URL 110 $this->js_url = trailingslashit( $this->admin_url . 'js' ); 111 112 // Admin images URL 113 $this->styles_url = trailingslashit( $this->admin_url . 'styles' ); 114 } 115 116 /** 117 * Include required files 118 * 119 * @since BuddyPress (1.6) 120 * @access private 121 */ 122 private function includes() { 123 124 // If in maintenance mode, only include updater and schema 125 if ( bp_get_maintenance_mode() ) { 126 require( $this->admin_dir . 'bp-core-schema.php' ); 127 require( $this->admin_dir . 'bp-core-update.php' ); 128 129 // No update needed so proceed with loading everything 130 } else { 131 require( $this->admin_dir . 'bp-core-settings.php' ); 132 require( $this->admin_dir . 'bp-core-functions.php' ); 133 require( $this->admin_dir . 'bp-core-components.php' ); 134 require( $this->admin_dir . 'bp-core-slugs.php' ); 135 } 136 } 137 138 /** 79 139 * Setup the admin hooks, actions and filters 80 140 * … … 87 147 private function setup_actions() { 88 148 149 // Start the wizard if in maintenance mode 150 if ( bp_get_maintenance_mode() ) { 151 add_action( bp_core_admin_hook(), array( $this, 'start_wizard' ), 2 ); 152 } 153 89 154 /** General Actions ***************************************************/ 90 155 91 156 // Attach the BuddyPress admin_init action to the WordPress admin_init action. 92 add_action( 'admin_init', array( $this, 'admin_init') );93 94 // Add some general styling to the admin area95 add_action( 'admin_head', array( $this, 'admin_head') );157 add_action( 'admin_init', array( $this, 'admin_init' ) ); 158 159 // Add some page specific output to the <head> 160 add_action( 'admin_head', array( $this, 'admin_head' ) ); 96 161 97 162 // Add menu item to settings menu 98 add_action( bp_core_admin_hook(), array( $this, 'admin_menus'), 5 );163 add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); 99 164 100 165 // Add notice if not using a BuddyPress theme 101 add_action( 'admin_notices', array( $this, 'activation_notice' ) ); 102 103 // Add importers 104 //add_action( 'bp_admin_init', array( $this, 'register_importers' ) ); 105 106 // Add green admin style 107 //add_action( 'bp_admin_init', array( $this, 'register_admin_style' ) ); 108 109 // Add settings 110 add_action( 'bp_admin_init', array( $this, 'register_admin_settings' ) ); 166 add_action( 'admin_notices', array( $this, 'admin_notices' ) ); 167 168 // Enqueue all admin JS and CSS 169 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 111 170 112 171 // Forums 'Right now' Dashboard widget 113 172 //add_action( 'wp_dashboard_setup', array( $this, 'dashboard_widget_right_now' ) ); 114 173 174 /** BuddyPress Actions ************************************************/ 175 176 // Add importers 177 //add_action( 'bp_admin_init', array( $this, 'register_importers' ) ); 178 179 // Add red admin style 180 //add_action( 'bp_admin_init', array( $this, 'register_admin_style' ) ); 181 182 // Add settings 183 add_action( 'bp_admin_init', array( $this, 'register_admin_settings' ) ); 184 115 185 /** Filters ***********************************************************/ 116 186 … … 122 192 } 123 193 124 /** 125 * Include required files 126 * 127 * @since BuddyPress (1.6) 128 * @access private 129 */ 130 private function includes() { 131 132 // Include the files 133 require_once( $this->admin_dir . 'bp-core-settings.php' ); 134 require_once( $this->admin_dir . 'bp-core-functions.php' ); 135 require_once( $this->admin_dir . 'bp-core-components.php' ); 136 require_once( $this->admin_dir . 'bp-core-slugs.php' ); 137 //require( $this->admin_dir . 'bp-metaboxes.php' ); 138 } 139 140 /** 141 * Admin globals 142 * 143 * @since BuddyPress (1.6) 144 * @access private 145 */ 146 private function setup_globals() { 147 global $bp; 148 149 // Admin url 150 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-core/admin' ); 151 152 // Admin url 153 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-core/bp-admin' ); 154 155 // Admin images URL 156 $this->images_url = trailingslashit( $this->admin_url . 'images' ); 157 158 // Admin images URL 159 $this->styles_url = trailingslashit( $this->admin_url . 'styles' ); 194 public function start_wizard() { 195 $this->wizard = new BP_Core_Setup_Wizard; 160 196 } 161 197 … … 171 207 public function admin_menus() { 172 208 173 if ( ! bp_current_user_can( 'bp_moderate' ) ) 174 return; 175 176 // Don't add this version of the admin menu if a BP upgrade is in progress. 177 // @see bp_core_update_add_admin_menu(). 178 if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE ) 179 return; 180 181 $hooks = array(); 182 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; 183 184 // Changed in BP 1.6 . See bp_core_admin_backpat_menu() 185 $hooks[] = add_menu_page( 186 __( 'BuddyPress', 'buddypress' ), 187 __( 'BuddyPress', 'buddypress' ), 188 'manage_options', 189 'bp-general-settings', 190 'bp_core_admin_backpat_menu', 191 '' 192 ); 193 194 $hooks[] = add_submenu_page( 195 'bp-general-settings', 196 __( 'BuddyPress Help', 'buddypress' ), 197 __( 'Help', 'buddypress' ), 198 'manage_options', 199 'bp-general-settings', 200 'bp_core_admin_backpat_page' 201 ); 202 203 // Add the option pages 204 $hooks[] = add_submenu_page( 205 $page, 206 __( 'BuddyPress Components', 'buddypress' ), 207 __( 'BuddyPress', 'buddypress' ), 208 'manage_options', 209 'bp-components', 210 'bp_core_admin_components_settings' 211 ); 212 213 $hooks[] = add_submenu_page( 214 $page, 215 __( 'BuddyPress Pages', 'buddypress' ), 216 __( 'BuddyPress Pages', 'buddypress' ), 217 'manage_options', 218 'bp-page-settings', 219 'bp_core_admin_slugs_settings' 220 ); 221 222 $hooks[] = add_submenu_page( 223 $page, 224 __( 'BuddyPress Settings', 'buddypress' ), 225 __( 'BuddyPress Settings', 'buddypress' ), 226 'manage_options', 227 'bp-settings', 228 'bp_core_admin_settings' 229 ); 230 231 foreach( $hooks as $hook ) { 232 233 // Add a hook for common BP admin CSS/JS scripts 234 add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' ); 209 // In maintenance mode 210 if ( bp_get_maintenance_mode() ) { 211 212 if ( !current_user_can( 'manage_options' ) ) 213 return; 214 215 if ( bp_get_maintenance_mode() == 'install' ) 216 $status = __( 'BuddyPress Setup', 'buddypress' ); 217 else 218 $status = __( 'Update BuddyPress', 'buddypress' ); 219 220 if ( bp_get_wizard() ) { 221 if ( ! is_multisite() || bp_is_multiblog_mode() ) { 222 $hook = add_dashboard_page( $status, $status, 'manage_options', 'bp-wizard', array( bp_get_wizard(), 'html' ) ); 223 } else { 224 $hook = add_submenu_page( 'update-core.php', $status, $status, 'manage_options', 'bp-wizard', array( bp_get_wizard(), 'html' ) ); 225 } 226 } 227 228 // Not in maintenance mode 229 } else { 230 231 // Bail if user cannot moderate 232 if ( ! bp_current_user_can( 'manage_options' ) ) 233 return; 234 235 $hooks = array(); 236 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; 237 238 // Changed in BP 1.6 . See bp_core_admin_backpat_menu() 239 $hooks[] = add_menu_page( 240 __( 'BuddyPress', 'buddypress' ), 241 __( 'BuddyPress', 'buddypress' ), 242 'manage_options', 243 'bp-general-settings', 244 'bp_core_admin_backpat_menu', 245 '' 246 ); 247 248 $hooks[] = add_submenu_page( 249 'bp-general-settings', 250 __( 'BuddyPress Help', 'buddypress' ), 251 __( 'Help', 'buddypress' ), 252 'manage_options', 253 'bp-general-settings', 254 'bp_core_admin_backpat_page' 255 ); 256 257 // Add the option pages 258 $hooks[] = add_submenu_page( 259 $page, 260 __( 'BuddyPress Components', 'buddypress' ), 261 __( 'BuddyPress', 'buddypress' ), 262 'manage_options', 263 'bp-components', 264 'bp_core_admin_components_settings' 265 ); 266 267 $hooks[] = add_submenu_page( 268 $page, 269 __( 'BuddyPress Pages', 'buddypress' ), 270 __( 'BuddyPress Pages', 'buddypress' ), 271 'manage_options', 272 'bp-page-settings', 273 'bp_core_admin_slugs_settings' 274 ); 275 276 $hooks[] = add_submenu_page( 277 $page, 278 __( 'BuddyPress Settings', 'buddypress' ), 279 __( 'BuddyPress Settings', 'buddypress' ), 280 'manage_options', 281 'bp-settings', 282 'bp_core_admin_settings' 283 ); 235 284 236 285 // Fudge the highlighted subnav item when on a BuddyPress admin page 237 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); 286 foreach( $hooks as $hook ) { 287 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); 288 } 238 289 } 239 290 } … … 398 449 399 450 /** 400 * Admin area activation notice401 *402 * Shows a nag message in admin area about the theme not supporting BuddyPress403 *404 * @since BuddyPress (1.6)405 *406 * @uses current_user_can() To check notice should be displayed.407 */408 public function activation_notice() {409 // @todo - something fun410 }411 412 /**413 451 * Add Settings link to plugins area 414 452 * … … 457 495 * 458 496 * @since BuddyPress (1.6) 459 * 460 * @uses bp_get_forum_post_type() To get the forum post type 461 * @uses bp_get_topic_post_type() To get the topic post type 462 * @uses bp_get_reply_post_type() To get the reply post type 463 * @uses sanitize_html_class() To sanitize the classes 464 * @uses do_action() Calls 'bp_admin_head' 465 */ 466 public function admin_head() { 467 468 // Icons for top level admin menus 469 $menu_icon_url = $this->images_url . 'menu.png'; 470 $icon32_url = $this->images_url . 'icons32.png'; ?> 471 472 <style type="text/css" media="screen"> 473 /*<![CDATA[*/ 474 475 #bp-dashboard-right-now p.sub, 476 #bp-dashboard-right-now .table, 477 #bp-dashboard-right-now .versions { 478 margin: -12px; 479 } 480 481 #bp-dashboard-right-now .inside { 482 font-size: 12px; 483 padding-top: 20px; 484 margin-bottom: 0; 485 } 486 487 #bp-dashboard-right-now p.sub { 488 padding: 5px 0 15px; 489 color: #8f8f8f; 490 font-size: 14px; 491 position: absolute; 492 top: -17px; 493 494 <?php if ( is_rtl() ) : ?> 495 496 right: 15px; 497 498 <?php else : ?> 499 500 left: 15px; 501 502 <?php endif; ?> 503 504 } 505 506 #bp-dashboard-right-now .table { 507 margin: 0; 508 padding: 0; 509 position: relative; 510 } 511 512 #bp-dashboard-right-now .table_content { 513 514 <?php if ( is_rtl() ) : ?> 515 516 float: right; 517 518 <?php else : ?> 519 520 float: left; 521 522 <?php endif; ?> 523 524 border-top: #ececec 1px solid; 525 width: 45%; 526 } 527 528 #bp-dashboard-right-now .table_discussion { 529 530 <?php if ( is_rtl() ) : ?> 531 532 float: left; 533 534 <?php else : ?> 535 536 float: right; 537 538 <?php endif; ?> 539 540 border-top: #ececec 1px solid; 541 width: 45%; 542 } 543 544 #bp-dashboard-right-now table td { 545 padding: 3px 0; 546 white-space: nowrap; 547 } 548 549 #bp-dashboard-right-now table tr.first td { 550 border-top: none; 551 } 552 553 #bp-dashboard-right-now td.b { 554 555 <?php if ( is_rtl() ) : ?> 556 557 padding-left: 6px; 558 559 <?php else : ?> 560 561 padding-right: 6px; 562 563 <?php endif; ?> 564 565 text-align: right; 566 font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; 567 font-size: 14px; 568 width: 1%; 569 } 570 571 #bp-dashboard-right-now td.b a { 572 font-size: 18px; 573 } 574 575 #bp-dashboard-right-now td.b a:hover { 576 color: #d54e21; 577 } 578 579 #bp-dashboard-right-now .t { 580 font-size: 12px; 581 582 <?php if ( is_rtl() ) : ?> 583 584 padding-left: 12px; 585 586 <?php else : ?> 587 588 padding-right: 12px; 589 590 <?php endif; ?> 591 592 padding-top: 6px; 593 color: #777; 594 } 595 596 #bp-dashboard-right-now .t a { 597 white-space: nowrap; 598 } 599 600 #bp-dashboard-right-now .spam { 601 color: red; 602 } 603 604 #bp-dashboard-right-now .waiting { 605 color: #e66f00; 606 } 607 608 #bp-dashboard-right-now .approved { 609 color: green; 610 } 611 612 #bp-dashboard-right-now .versions { 613 padding: 6px 10px 12px; 614 clear: both; 615 } 616 617 #bp-dashboard-right-now .versions .b { 618 font-weight: bold; 619 } 620 621 #bp-dashboard-right-now a.button { 622 623 <?php if ( is_rtl() ) : ?> 624 625 float: left; 626 clear: left; 627 628 <?php else : ?> 629 630 float: right; 631 clear: right; 632 633 <?php endif; ?> 634 635 position: relative; 636 top: -5px; 637 } 638 639 /*]]>*/ 640 </style> 641 642 <?php 643 644 // Add extra actions to BuddyPress admin header area 497 */ 498 public function admin_head() { } 499 500 /** 501 * Add some general styling to the admin area 502 * 503 * @since BuddyPress (1.6) 504 */ 505 public function enqueue_scripts() { 506 507 $maybe_dev = ''; 508 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) 509 $maybe_dev = '.dev'; 510 511 $file = $this->css_url . "common{$maybe_dev}.css"; 512 $file = apply_filters( 'bp_core_admin_common_css', $file ); 513 wp_enqueue_style( 'bp-admin-common-css', $file, array(), bp_get_version() ); 514 515 // Extra bits for the installation wizard 516 if ( bp_get_maintenance_mode() ) { 517 518 // Styling 519 $file = $this->css_url . "wizard{$maybe_dev}.css"; 520 $file = apply_filters( 'bp_core_admin_wizard_css', $file ); 521 wp_enqueue_style( 'bp-admin-wizard-css', $file, array(), bp_get_version() ); 522 523 // JS 524 $file = $this->js_url . "wizard{$maybe_dev}.js"; 525 $file = apply_filters( 'bp_core_admin_wizard_js', $file ); 526 wp_enqueue_script( 'bp-admin-wizard-js', $file, array(), bp_get_version() ); 527 528 // We'll need the thickbox too 529 wp_enqueue_script( 'thickbox' ); 530 wp_enqueue_style( 'thickbox' ); 531 } 532 645 533 do_action( 'bp_admin_head' ); 646 534 } … … 673 561 // Load the admin CSS styling 674 562 //wp_admin_css_color( 'buddypress', __( 'Green', 'buddypress' ), $css_file, array( '#222222', '#006600', '#deece1', '#6eb469' ) ); 563 } 564 565 /** 566 * Add any admin notices we might need, mostly for update or new installs 567 * 568 * @since BuddyPress (1.6) 569 * 570 * @global string $pagenow 571 * @return If no notice is needed 572 */ 573 public function admin_notices() { 574 global $pagenow; 575 576 // Bail if not in maintenance mode 577 if ( ! bp_get_maintenance_mode() ) 578 return; 579 580 // Bail if user cannot manage options 581 if ( ! current_user_can( 'manage_options' ) ) 582 return; 583 584 // Are we looking at a network? 585 if ( bp_core_do_network_admin() ) { 586 587 // Bail if looking at wizard page 588 if ( ( 'admin.php' == $pagenow ) && ( !empty( $_GET['page'] ) && ( 'bp-wizard' == $_GET['page'] ) ) ) { 589 return; 590 } 591 592 // Set the url for the nag 593 $url = network_admin_url( 'admin.php?page=bp-wizard' ); 594 595 // Single site 596 } else { 597 598 // Bail if looking at wizard page 599 if ( ( 'index.php' == $pagenow ) && ( !empty( $_GET['page'] ) && ( 'bp-wizard' == $_GET['page'] ) ) ) { 600 return; 601 } 602 603 // Set the url for the nag 604 $url = admin_url( 'index.php?page=bp-wizard' ); 605 } 606 607 // What does the nag say? 608 switch ( bp_get_maintenance_mode() ) { 609 610 // Update text 611 case 'update' : 612 $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url ); 613 break; 614 615 // First install text 616 case 'install' : default : 617 $msg = sprintf( __( 'BuddyPress was successfully activated! Please run the <a href="%s">installation wizard</a>.', 'buddypress' ), $url ); 618 break; 619 } ?> 620 621 <div class="update-nag"><?php echo $msg; ?></div> 622 623 <?php 675 624 } 676 625 } -
trunk/bp-forums/bp-forums-admin.php
r5729 r5749 4 4 5 5 function bp_forums_add_admin_menu() { 6 global $bp;7 6 8 7 if ( ! bp_current_user_can( 'bp_moderate' ) ) … … 13 12 $hook = add_submenu_page( $page, __( 'BuddyPress Forums', 'buddypress' ), __( 'BuddyPress Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', 'bp_forums_bbpress_admin' ); 14 13 15 // Add a hook for common BP admin CSS/JS scripts16 add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );17 18 14 // Fudge the highlighted subnav item when on a BuddyPress admin page 19 15 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); … … 22 18 23 19 function bp_forums_bbpress_admin() { 24 global $bp;25 20 26 21 $action = bp_get_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ); ?> … … 209 204 210 205 function bp_forums_configure_existing_install() { 211 global $wpdb, $bbdb;212 206 213 207 check_admin_referer( 'bp_forums_existing_install_init' ); … … 232 226 233 227 function bp_forums_bbpress_install() { 234 global $wpdb, $b bdb, $bp;228 global $wpdb, $bp; 235 229 236 230 check_admin_referer( 'bp_forums_new_install_init' ); -
trunk/bp-loader.php
r5727 r5749 315 315 * @uses plugin_dir_url() 316 316 */ 317 p ublicfunction constants() {317 private function constants() { 318 318 319 319 // Define the BuddyPress version … … 475 475 // The installation process requires a few BuddyPress core libraries 476 476 if ( !empty( $this->maintenance_mode ) ) { 477 require( $this->plugin_dir . 'bp-core/bp-core-functions.php' ); 478 require( $this->plugin_dir . 'bp-core/bp-core-update.php' ); 479 require( $this->plugin_dir . 'bp-core/bp-core-caps.php' ); 480 require( $this->plugin_dir . 'bp-core/bp-core-options.php' ); 481 require( $this->plugin_dir . 'bp-core/admin/bp-core-update.php' ); 477 require( $this->plugin_dir . 'bp-core/bp-core-admin.php' ); 478 require( $this->plugin_dir . 'bp-core/bp-core-functions.php' ); 479 require( $this->plugin_dir . 'bp-core/bp-core-template.php' ); 480 require( $this->plugin_dir . 'bp-core/bp-core-update.php' ); 481 require( $this->plugin_dir . 'bp-core/bp-core-caps.php' ); 482 require( $this->plugin_dir . 'bp-core/bp-core-options.php' ); 483 484 // Load up BuddyPress's admin 485 add_action( 'plugins_loaded', 'bp_admin' ); 482 486 } 483 487 } -
trunk/bp-xprofile/bp-xprofile-admin.php
r5699 r5749 28 28 return false; 29 29 30 $hook = add_users_page( __( 'Profile Fields', 'buddypress' ), __( 'Profile Fields', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' ); 31 32 add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' ); 30 add_users_page( __( 'Profile Fields', 'buddypress' ), __( 'Profile Fields', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' ); 33 31 } 34 32 add_action( bp_core_admin_hook(), 'xprofile_add_admin_menu' ); -
trunk/bp-xprofile/bp-xprofile-cssjs.php
r5699 r5749 27 27 } 28 28 } 29 add_action( bp_core_admin_hook(), 'xprofile_add_admin_css' );29 add_action( 'admin_enqueue_scripts', 'xprofile_add_admin_css' ); 30 30 31 31 /** … … 52 52 } 53 53 } 54 add_action( bp_core_admin_hook(), 'xprofile_add_admin_js', 1 );54 add_action( 'admin_enqueue_scripts', 'xprofile_add_admin_js', 1 ); 55 55 56 56 ?>
Note: See TracChangeset
for help on using the changeset viewer.