Changeset 6343 for trunk/bp-core/admin/bp-core-update.php
- Timestamp:
- 09/19/2012 06:52:23 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-update.php
r6342 r6343 58 58 __( 'Pages', 'buddypress' ), 59 59 __( 'Permalinks', 'buddypress' ), 60 __( 'Theme', 'buddypress' ),61 60 __( 'Finish', 'buddypress' ) 62 61 ); … … 106 105 case 'permalinks': 107 106 $result = $this->step_permalinks_save(); 108 break;109 110 case 'theme':111 $result = $this->step_theme_save();112 107 break; 113 108 … … 214 209 break; 215 210 216 case __( 'Theme', 'buddypress') :217 $this->step_theme();218 break;219 220 211 case __( 'Toolbar', 'buddypress' ) : 221 212 $this->step_admin_bar(); … … 255 246 256 247 if ( !function_exists( 'bp_core_admin_components_options' ) ) 257 require ( BP_PLUGIN_DIR . 'bp-core/admin/bp-core-components.php' ); ?> 258 259 <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> 260 261 <?php bp_core_admin_components_options(); ?> 248 require ( BP_PLUGIN_DIR . 'bp-core/admin/bp-core-components.php' ); 249 250 bp_core_admin_components_options(); ?> 262 251 263 252 <div class="submit clear"> … … 324 313 jQuery( document ).ready( function() { 325 314 jQuery( 'select' ).change( function() { 326 jQuery( this ).siblings( 'input[ @type=radio]' ).click();315 jQuery( this ).siblings( 'input[type=radio]' ).click(); 327 316 }); 328 317 }); 329 318 </script> 330 319 331 <p><?php _e( 'BuddyPress uses WordPress pages to display directories. This allows you to easily change their titles and relocate them.', 'buddypress' ); ?></p> 332 333 <p><?php _e( 'Choose an existing page, have one auto-created, or create them manually and come back here once you are finished.', 'buddypress' ); ?></p> 320 <?php if ( bp_get_maintenance_mode() ) : ?> 321 322 <p><?php _e( 'BuddyPress uses WordPress pages to display directories. This allows you to easily change their titles and relocate them.', 'buddypress' ); ?></p> 323 <p><?php _e( 'Choose an existing page, have one auto-created, or create them manually and come back here once you are finished.', 'buddypress' ); ?></p> 324 325 <?php endif; ?> 334 326 335 327 <table class="form-table"> … … 345 337 <?php if ( $members_page_dropdown = wp_dropdown_pages( "name=bp-members-page&echo=0&selected={$existing_pages['members']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?> 346 338 347 <p><label><input type="radio" name="bp_pages[members]" <?php checked( !empty( $existing_pages['members'] ) ); ?> value=" page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $members_page_dropdown ?></label></p>339 <p><label><input type="radio" name="bp_pages[members]" <?php checked( !empty( $existing_pages['members'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['members'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $members_page_dropdown ?></label></p> 348 340 349 341 <?php endif ?> … … 362 354 363 355 <?php if ( $groups_page_dropdown = wp_dropdown_pages( "name=bp-groups-page&echo=0&selected={$existing_pages['groups']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?> 364 <p><label><input type="radio" name="bp_pages[groups]" <?php checked( !empty( $existing_pages['groups'] ) ); ?> value=" page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $groups_page_dropdown ?></label></p>356 <p><label><input type="radio" name="bp_pages[groups]" <?php checked( !empty( $existing_pages['groups'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['groups'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $groups_page_dropdown ?></label></p> 365 357 <?php endif ?> 366 358 </td> … … 381 373 382 374 <?php if ( $blogs_page_dropdown = wp_dropdown_pages( "name=bp-blogs-page&echo=0&selected={$existing_pages['blogs']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?> 383 <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( !empty( $existing_pages['blogs'] ) ); ?> value=" page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $blogs_page_dropdown ?></label></p>375 <p><label><input type="radio" name="bp_pages[blogs]" <?php checked( !empty( $existing_pages['blogs'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['blogs'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $blogs_page_dropdown ?></label></p> 384 376 <?php endif ?> 385 377 </td> … … 399 391 400 392 <?php if ( $activity_page_dropdown = wp_dropdown_pages( "name=bp-activity-page&echo=0&selected={$existing_pages['activity']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?> 401 <p><label><input type="radio" name="bp_pages[activity]" <?php checked( !empty( $existing_pages['activity'] ) ); ?> value=" page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activity_page_dropdown ?></label></p>393 <p><label><input type="radio" name="bp_pages[activity]" <?php checked( !empty( $existing_pages['activity'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['activity'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activity_page_dropdown ?></label></p> 402 394 <?php endif ?> 403 395 </td> … … 417 409 418 410 <?php if ( $forums_page_dropdown = wp_dropdown_pages( "name=bp-forums-page&echo=0&selected={$existing_pages['forums']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?> 419 <p><label><input type="radio" name="bp_pages[forums]" <?php checked( !empty( $existing_pages['forums'] ) ); ?> value=" page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $forums_page_dropdown ?></label></p>411 <p><label><input type="radio" name="bp_pages[forums]" <?php checked( !empty( $existing_pages['forums'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['forums'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $forums_page_dropdown ?></label></p> 420 412 <?php endif ?> 421 413 </td> … … 433 425 434 426 <?php if ( $register_page_dropdown = wp_dropdown_pages( "name=bp-register-page&echo=0&selected={$existing_pages['register']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?> 435 <p><label><input type="radio" name="bp_pages[register]" <?php checked( !empty( $existing_pages['register'] ) ); ?> value=" page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $register_page_dropdown ?></label></p>427 <p><label><input type="radio" name="bp_pages[register]" <?php checked( !empty( $existing_pages['register'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['register'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $register_page_dropdown ?></label></p> 436 428 <?php endif ?> 437 429 </td> … … 447 439 448 440 <?php if ( $activate_page_dropdown = wp_dropdown_pages( "name=bp-activate-page&echo=0&selected={$existing_pages['activate']}&show_option_none=" . __( '- Select -', 'buddypress' ) ) ) : ?> 449 <p><label><input type="radio" name="bp_pages[activate]" <?php checked( !empty( $existing_pages['activate'] ) ); ?> value=" page" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activate_page_dropdown ?></label></p>441 <p><label><input type="radio" name="bp_pages[activate]" <?php checked( !empty( $existing_pages['activate'] ) ); ?> value="<?php echo get_post_field( 'post_name', $existing_pages['activate'] ); ?>" /> <?php _e( 'Use an existing page:', 'buddypress' ); ?> <?php echo $activate_page_dropdown ?></label></p> 450 442 <?php endif ?> 451 443 </td> … … 472 464 $structures = array( '', $prefix . '/%year%/%monthnum%/%day%/%postname%/', $prefix . '/%year%/%monthnum%/%postname%/', $prefix . '/archives/%post_id%' ); 473 465 474 // If we're using permalinks already, adjust text accordingly475 if ( !empty( $permalink_structure ) )476 $permalink_setup_text = __( 'Your permalink settings are compatible with BuddyPress.', 'buddypress' );477 else478 $permalink_setup_text = __( 'Pretty permalinks must be active on your site.', 'buddypress' );479 480 466 if ( !got_mod_rewrite() && !iis7_supports_permalinks() ) 481 467 $prefix = '/index.php'; ?> 482 468 483 <p><?php echo $permalink_setup_text; ?></p> 469 <p><?php 470 471 // If we're using permalinks already, adjust text accordingly 472 if ( !empty( $permalink_structure ) ) { 473 _e( 'Your permalink settings are compatible with BuddyPress.', 'buddypress' ); 474 } else { 475 _e( 'Pretty permalinks must be active on your site.', 'buddypress' ); 476 } 477 478 ?></p> 484 479 <p><?php printf( __( 'For more advanced options please visit the <a href="%s">permalink settings page</a> now and come back here later.', 'buddypress' ), admin_url( 'options-permalink.php' ) ); ?> 485 480 486 481 <table class="form-table"> 482 483 <?php if ( !empty( $permalink_structure ) && ! in_array( $permalink_structure, $structures ) ) : ?> 484 <tr> 485 <th><label><input name="permalink_structure" type="radio" checked="checked" value="<?php echo esc_attr( $permalink_structure ); ?>" class="tog" <?php checked( true ); ?> /> <?php _e( 'Current' ); ?></label></th> 486 <td><code><?php echo get_home_url() . $prefix . $permalink_structure; ?></code></td> 487 </tr> 488 <?php endif; ?> 489 487 490 <tr> 488 491 <th><label><input name="permalink_structure" type="radio"<?php if ( empty( $permalink_structure ) || false != strpos( $permalink_structure, $structures[1] ) ) : ?> checked="checked" <?php endif; ?>value="<?php echo esc_attr( $structures[1] ); ?>" class="tog" <?php checked( $structures[1], $permalink_structure ); ?> /> <?php _e( 'Day and name' ); ?></label></th> … … 516 519 } 517 520 518 function step_theme() {519 global $bp;520 521 $installed_plugins = get_plugins();522 $installed_themes = wp_get_themes();523 $bp_themes = array();524 525 $template_pack_installed = false;526 $bp_theme_installed = false;527 528 foreach ( (array) $installed_plugins as $plugin ) {529 if ( 'BuddyPress Template Pack' == $plugin['Name'] ) {530 $template_pack_installed = true;531 }532 }533 534 foreach ( (array) $installed_themes as $theme ) {535 foreach ( (array) $theme['Tags'] as $tag ) {536 if ( ( 'BuddyPress Default' != $theme['Name'] ) && ( 'buddypress' == $tag ) ) {537 $bp_theme_installed = true;538 $bp_themes[] = $theme;539 }540 }541 }542 543 // Get theme screenshot544 $current_theme = wp_get_theme();545 $screenshot = '';546 547 if ( !empty( $installed_themes[$current_theme->stylesheet]['Screenshot'] ) ) {548 $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme->stylesheet]['Screenshot'];549 } ?>550 551 <script type="text/javascript">552 jQuery( document ).ready( function() {553 jQuery( 'select' ).change( function() {554 jQuery( this ).siblings( 'input[@type=radio]' ).click();555 });556 });557 </script>558 559 <table class="form-table">560 <tr>561 <th>562 <h5><?php _e( 'Use BuddyPress Default', 'buddypress' ); ?></h5>563 <img src="<?php echo plugins_url( 'bp-themes/bp-default/screenshot.png', $bp->file ); ?>" alt="<?php _e( 'BuddyPress Default', 'buddypress' ); ?>" />564 </th>565 <td>566 <p><?php _e( 'The default BuddyPress theme comes with the basics, to get up and running out of the box. It supports all features and is highly customizable.', 'buddypress' ); ?></p>567 <p><strong><?php _e( 'This is the best choice if you want to start using BuddyPress immediately.', 'buddypress' ); ?></strong></p>568 <p><label><input type="radio" name="theme" value="bp_default" checked="checked" /> <?php _e( 'Yes, please!', 'buddypress' ); ?></label></p>569 </td>570 </tr>571 572 <?php if ( !empty( $bp_theme_installed ) ) : ?>573 574 <tr>575 <th>576 <h5><?php _e( 'Other themes', 'buddypress' ); ?></h5>577 <img src="<?php echo plugins_url( 'bp-core/admin/images/find.png', $bp->file ); ?>" alt="<?php _e( 'A BuddyPress theme', 'buddypress' ); ?>" />578 </th>579 <td>580 <p><?php _e( "You have some other BuddyPress compatible themes available. Pick one of them from this list to use it.", 'buddypress' ); ?></p>581 <p>582 <label>583 <input type="radio" name="theme" value="3rd_party" /> <?php _e( 'Use this theme', 'buddypress' ); ?>584 </label>585 <select name="3rd_party_theme">586 587 <?php foreach( (array) $bp_themes as $theme ) : ?>588 589 <option value="<?php echo $theme['Template'] . ',' . $theme['Stylesheet']; ?>"><?php echo $theme['Name']; ?></option>590 591 <?php endforeach; ?>592 593 </select>594 </p>595 </td>596 </tr>597 598 <?php endif; ?>599 600 <?php if ( ! current_theme_supports( 'buddypress' ) ) : ?>601 602 <tr>603 <th>604 <h5><?php _e( 'Manually update current theme', 'buddypress' ); ?></h5>605 606 <?php if ( !empty( $screenshot ) ) : ?>607 608 <img src="<?php echo esc_url( $screenshot ); ?>" alt="<?php _e( 'Your existing theme', 'buddypress' ); ?>" />609 610 <?php endif; ?>611 612 </th>613 <td>614 <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>615 616 <?php if ( empty( $template_pack_installed ) ) : ?>617 618 <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>619 620 <?php else : ?>621 622 <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>623 <p><a id="bp-template-pack" class="button installed disabled" href="javascript:void();"><span></span><?php _e( 'Plugin Installed', 'buddypress' ); ?></a></p>624 625 <?php endif; ?>626 627 </td>628 </tr>629 630 <?php endif; ?>631 632 <tr>633 <th>634 <h5><?php _e( 'Do not change theme', 'buddypress' ) ?></h5>635 </th>636 <td>637 <p><?php _e( "You are happy with your current theme and plan on changing it later.", 'buddypress' ); ?></p>638 <p><strong><?php _e( 'This is the best choice if you have a custom theme already and want to manually integrate BuddyPress later.', 'buddypress' ); ?></strong></p>639 640 <p><label><input type="radio" name="theme" value="do_not_change" /> <?php _e( "Don't change my current theme", 'buddypress' ); ?></label></p>641 642 </td>643 </tr>644 </table>645 646 <div class="submit clear">647 <input type="hidden" name="save" value="theme" />648 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step() ) ?>" />649 650 <?php wp_nonce_field( 'bpwizard_theme' ) ?>651 652 </div>653 654 <?php655 }656 657 521 /** 658 522 * When upgrading to BP 1.6, prompt the admin to switch to WordPress' Toolbar. … … 711 575 function step_db_update_save() { 712 576 713 if ( isset( $_POST['submit'] ) ) { 714 check_admin_referer( 'bpwizard_db_update' ); 715 716 // Run the schema install to update tables 717 bp_core_install(); 718 719 // Update to 1.5 720 if ( bp_get_db_version_raw() < 1801 ) 721 $this->update_1_5(); 722 723 // Update to 1.6 724 if ( bp_get_db_version_raw() < bp_get_db_version() ) 725 $this->update_1_6(); 726 727 return true; 728 } 729 730 return false; 577 if ( ! isset( $_POST['submit'] ) ) 578 return false; 579 580 check_admin_referer( 'bpwizard_db_update' ); 581 582 // Run the schema install to update tables 583 bp_core_install(); 584 585 // Update to 1.5 586 if ( bp_get_db_version_raw() < 1801 ) 587 $this->update_1_5(); 588 589 // Update to 1.6 590 if ( bp_get_db_version_raw() < bp_get_db_version() ) 591 $this->update_1_6(); 592 593 return true; 731 594 } 732 595 733 596 function step_components_save() { 734 597 735 if ( isset( $_POST['submit'] ) && isset( $_POST['bp_components'] ) ) { 736 737 check_admin_referer( 'bpwizard_components' ); 738 739 $active_components = array(); 740 741 // Settings form submitted, now save the settings. 742 foreach ( (array) $_POST['bp_components'] as $key => $value ) { 743 $active_components[$key] = 1; 744 } 745 746 bp_update_option( 'bp-active-components', $active_components ); 747 748 wp_cache_flush(); 749 bp_core_install(); 750 751 return true; 752 } 753 754 return false; 598 if ( ! isset( $_POST['submit'] ) || ! isset( $_POST['bp_components'] ) ) 599 return false; 600 601 check_admin_referer( 'bpwizard_components' ); 602 603 $active_components = array(); 604 605 // Settings form submitted, now save the settings. 606 foreach ( (array) $_POST['bp_components'] as $key => $value ) { 607 $active_components[$key] = 1; 608 } 609 610 bp_update_option( 'bp-active-components', $active_components ); 611 612 wp_cache_flush(); 613 bp_core_install(); 614 615 return true; 755 616 } 756 617 757 618 function step_pages_save() { 758 global $wpdb; 759 760 if ( isset( $_POST['submit'] ) && isset( $_POST['bp_pages'] ) ) { 761 check_admin_referer( 'bpwizard_pages' ); 762 763 // Make sure that the pages are created on the bp_get_root_blog_id(), no matter which Dashboard the setup is being run on 764 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) 765 switch_to_blog( bp_get_root_blog_id() ); 766 767 // Delete any existing pages 768 $existing_pages = bp_core_get_directory_page_ids(); 769 770 foreach ( (array) $existing_pages as $page_id ) { 771 wp_delete_post( $page_id, true ); 772 } 773 774 $blog_pages = $this->setup_pages( (array) $_POST['bp_pages'] ); 775 bp_update_option( 'bp-pages', $blog_pages ); 776 777 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) 778 restore_current_blog(); 779 780 return true; 781 } 782 783 return false; 619 620 if ( ! isset( $_POST['submit'] ) || ! isset( $_POST['bp_pages'] ) ) 621 return false; 622 623 check_admin_referer( 'bpwizard_pages' ); 624 625 // Make sure that the pages are created on the bp_get_root_blog_id() 626 //no matter which Dashboard the setup is being run on. 627 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) 628 switch_to_blog( bp_get_root_blog_id() ); 629 630 $blog_pages = $this->setup_pages( (array) $_POST['bp_pages'] ); 631 bp_update_option( 'bp-pages', $blog_pages ); 632 633 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) 634 restore_current_blog(); 635 636 return true; 784 637 } 785 638 … … 790 643 $iis7_permalinks = $usingpi = $writable = false; 791 644 792 if ( isset( $_POST['submit'] ) ) { 793 check_admin_referer( 'bpwizard_permalinks' ); 794 795 $home_path = get_home_path(); 796 $iis7_permalinks = iis7_supports_permalinks(); 797 798 if ( isset( $_POST['permalink_structure'] ) ) { 799 $permalink_structure = $_POST['permalink_structure']; 800 801 if ( !empty( $permalink_structure ) ) 802 $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] ); 803 804 if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path ) 805 $permalink_structure = '/blog' . $permalink_structure; 806 807 $wp_rewrite->set_permalink_structure( $permalink_structure ); 645 if ( ! isset( $_POST['submit'] ) ) 646 return false; 647 648 check_admin_referer( 'bpwizard_permalinks' ); 649 650 $home_path = get_home_path(); 651 $iis7_permalinks = iis7_supports_permalinks(); 652 653 if ( isset( $_POST['permalink_structure'] ) ) { 654 $permalink_structure = $_POST['permalink_structure']; 655 656 if ( !empty( $permalink_structure ) ) 657 $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] ); 658 659 if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path ) 660 $permalink_structure = '/blog' . $permalink_structure; 661 662 $wp_rewrite->set_permalink_structure( $permalink_structure ); 663 } 664 665 if ( !empty( $iis7_permalinks ) ) { 666 if ( ( !file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) { 667 $writable = true; 808 668 } 809 810 if ( !empty( $iis7_permalinks ) ) { 811 if ( ( !file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) { 812 $writable = true; 813 } 669 } else { 670 if ( ( !file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) { 671 $writable = true; 672 } 673 } 674 675 if ( $wp_rewrite->using_index_permalinks() ) 676 $usingpi = true; 677 678 $wp_rewrite->flush_rules(); 679 680 if ( !empty( $iis7_permalinks ) || ( empty( $usingpi ) && empty( $writable ) ) ) { 681 682 function _bp_core_wizard_step_permalinks_message() { 683 global $wp_rewrite; ?> 684 685 <div id="message" class="updated fade"><p> 686 687 <?php 688 _e( 'Oops, there was a problem creating a configuration file. ', 'buddypress' ); 689 690 if ( !empty( $iis7_permalinks ) ) { 691 692 if ( !empty( $permalink_structure ) && empty( $usingpi ) && empty( $writable ) ) { 693 694 _e( 'If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.' ); ?> 695 696 <br /><br /> 697 698 <textarea rows="9" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea> 699 700 <?php 701 702 } else if ( !empty( $permalink_structure ) && empty( $usingpi ) && !empty( $writable ) ); { 703 _e( 'Permalink structure updated. Remove write access on web.config file now!' ); 704 } 705 706 } else { 707 708 _e( 'If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.' ); ?> 709 710 <br /><br /> 711 712 <textarea rows="6" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->mod_rewrite_rules() ); ?></textarea> 713 714 <?php } ?> 715 716 <br /><br /> 717 718 <?php 719 if ( empty( $iis7_permalinks ) ) 720 _e( 'Paste all these rules into a new <code>.htaccess</code> file in the root of your WordPress installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress' ); 721 ?> 722 723 </p></div> 724 725 <?php 726 } 727 728 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && !empty( $_POST['skip-htaccess'] ) ) { 729 return true; 814 730 } else { 815 if ( ( !file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) { 816 $writable = true; 817 } 731 add_action( 'bp_admin_notices', '_bp_core_wizard_step_permalinks_message' ); 732 return false; 818 733 } 819 820 if ( $wp_rewrite->using_index_permalinks() ) 821 $usingpi = true; 822 823 $wp_rewrite->flush_rules(); 824 825 if ( !empty( $iis7_permalinks ) || ( empty( $usingpi ) && empty( $writable ) ) ) { 826 827 function _bp_core_wizard_step_permalinks_message() { 828 global $wp_rewrite; ?> 829 830 <div id="message" class="updated fade"><p> 831 832 <?php 833 _e( 'Oops, there was a problem creating a configuration file. ', 'buddypress' ); 834 835 if ( !empty( $iis7_permalinks ) ) { 836 837 if ( !empty( $permalink_structure ) && empty( $usingpi ) && empty( $writable ) ) { 838 839 _e( 'If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.' ); ?> 840 841 <br /><br /> 842 843 <textarea rows="9" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea> 844 845 <?php 846 847 } else if ( !empty( $permalink_structure ) && empty( $usingpi ) && !empty( $writable ) ); { 848 _e( 'Permalink structure updated. Remove write access on web.config file now!' ); 849 } 850 851 } else { 852 853 _e( 'If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.' ); ?> 854 855 <br /><br /> 856 857 <textarea rows="6" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php echo esc_html( $wp_rewrite->mod_rewrite_rules() ); ?></textarea> 858 859 <?php } ?> 860 861 <br /><br /> 862 863 <?php 864 if ( empty( $iis7_permalinks ) ) 865 _e( 'Paste all these rules into a new <code>.htaccess</code> file in the root of your WordPress installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress' ); 866 ?> 867 868 </p></div> 869 870 <?php 871 } 872 873 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && !empty( $_POST['skip-htaccess'] ) ) { 874 return true; 875 } else { 876 add_action( 'bp_admin_notices', '_bp_core_wizard_step_permalinks_message' ); 877 return false; 878 } 879 } 880 881 return true; 882 } 883 884 return false; 885 } 886 887 function step_theme_save() { 888 global $bp; 889 890 if ( isset( $_POST['submit'] ) && isset( $_POST['theme'] ) ) { 891 check_admin_referer( 'bpwizard_theme' ); 892 893 if ( is_multisite() && bp_get_root_blog_id() != get_current_blog_id() ) 894 switch_to_blog( bp_get_root_blog_id() ); 895 896 switch ( $_POST['theme'] ) { 897 898 // Activate the bp-default theme 899 case 'bp_default' : 900 register_theme_directory( $bp->themes_dir ); 901 switch_theme( 'bp-default', 'bp-default' ); 902 break; 903 904 // Activate Template Pack plugin 905 case 'manual_wp' : 906 907 // Include 908 require_once( ABSPATH . WPINC . '/plugin.php' ); 909 $installed_plugins = get_plugins(); 910 911 foreach ( $installed_plugins as $key => $plugin ) { 912 if ( 'BuddyPress Template Pack' == $plugin['Name'] ) { 913 activate_plugin( $key ); 914 } 915 } 916 break; 917 918 // Pick a theme from the repo 919 case '3rd_party' : 920 if ( empty( $_POST['3rd_party_theme'] ) ) 921 return false; 922 923 $theme = explode( ',', $_POST['3rd_party_theme'] ); 924 switch_theme( $theme[0], $theme[1] ); 925 break; 926 927 // Keep existing theme 928 case 'do_not_change' : 929 return true; 930 break; 931 } 932 933 if ( is_multisite() ) 934 restore_current_blog(); 935 936 return true; 937 } 938 939 return false; 734 } 735 736 return true; 940 737 } 941 738 … … 947 744 */ 948 745 function step_admin_bar_save() { 949 if ( isset( $_POST['submit'] ) ) { 950 check_admin_referer( 'bpwizard_admin_bar' ); 951 952 if ( !empty( $_POST['keep_buddybar'] ) ) { 953 bp_update_option( '_bp_force_buddybar', 1 ); 954 } 955 956 return true; 957 } 958 959 return false; 746 if ( ! isset( $_POST['submit'] ) ) 747 return false; 748 749 check_admin_referer( 'bpwizard_admin_bar' ); 750 751 if ( !empty( $_POST['keep_buddybar'] ) ) 752 bp_update_option( '_bp_force_buddybar', 1 ); 753 754 return true; 960 755 } 961 756 962 757 function step_finish_save() { 963 758 964 if ( isset( $_POST['submit'] ) ) { 965 966 check_admin_referer( 'bpwizard_finish' ); 967 968 // Update the DB version in the database 969 bp_version_bump(); 970 971 // Delete the setup cookie 972 @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); 973 974 // Redirect to the BuddyPress dashboard 975 $redirect = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' ); 976 $redirect = add_query_arg( array( 'page' => 'bp-components' ), $redirect ); 977 978 wp_safe_redirect( $redirect ); 979 980 // That's all! 981 exit(); 982 } 983 984 return false; 759 if ( ! isset( $_POST['submit'] ) ) 760 return false; 761 762 check_admin_referer( 'bpwizard_finish' ); 763 764 // Update the DB version in the database 765 bp_version_bump(); 766 767 // Delete the setup cookie 768 @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); 769 770 // Redirect to the BuddyPress dashboard 771 $redirect = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' ); 772 $redirect = add_query_arg( array( 'page' => 'bp-components' ), $redirect ); 773 774 wp_safe_redirect( $redirect ); 775 776 // That's all! 777 exit(); 985 778 } 986 779 … … 989 782 $bp_pages = array(); 990 783 784 // Delete any existing pages 785 foreach ( (array) bp_core_get_directory_page_ids() as $page_id ) { 786 wp_delete_post( $page_id, true ); 787 } 788 bp_delete_option( 'bp-pages' ); 789 991 790 foreach ( $pages as $key => $value ) { 791 792 // Check for the selected page 992 793 if ( 'page' == $value ) { 993 // Check for the selected page 994 if ( !empty( $_POST['bp-' . $key . '-page'] ) ) 794 if ( !empty( $_POST['bp-' . $key . '-page'] ) ) { 995 795 $bp_pages[$key] = (int) $_POST['bp-' . $key . '-page']; 996 else796 } else { 997 797 $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $key ), 'post_status' => 'publish', 'post_type' => 'page' ) ); 798 } 799 800 // Create a new page 998 801 } else { 999 // Create a new page1000 802 $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $value ), 'post_status' => 'publish', 'post_type' => 'page' ) ); 1001 803 } … … 1007 809 // Database update methods based on version numbers 1008 810 function update_1_5() { 1009 1010 // Delete old database version options1011 811 delete_site_option( 'bp-activity-db-version' ); 1012 812 delete_site_option( 'bp-blogs-db-version' ); … … 1044 844 * Get the wizard 1045 845 * 1046 * @global type $bp1047 846 * @return boolean 1048 847 */ 1049 848 function bp_get_wizard() { 1050 global $bp;849 $bp = buddypress(); 1051 850 1052 851 if ( !empty( $bp->admin->wizard ) )
Note: See TracChangeset
for help on using the changeset viewer.