Skip to:
Content

BuddyPress.org

Changeset 3706


Ignore:
Timestamp:
01/14/2011 07:35:58 AM (16 years ago)
Author:
johnjamesjacoby
Message:

First round of WordPress 3.1 adjustments for BuddyPress installer/upgrader.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r3675 r3706  
    299299        require ( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin.php' );
    300300}
    301 add_action( 'admin_menu', 'bp_core_admin_menu_init' );
     301is_multisite() ? add_action( 'network_admin_menu', 'bp_core_admin_menu_init' ) : add_action( 'admin_menu', 'bp_core_admin_menu_init' );
    302302
    303303/**
    … …  
    315315                return false;
    316316
    317         /* Add the administration tab under the "Site Admin" tab for site administrators */
     317        // Add the administration tab under the "Site Admin" tab for site administrators
    318318        $hook = bp_core_add_admin_menu_page( array(
    319                 'menu_title' => __( 'BuddyPress', 'buddypress' ),
    320                 'page_title' => __( 'BuddyPress', 'buddypress' ),
    321                 'access_level' => 10, 'file' => 'bp-general-settings',
    322                 'function' => 'bp_core_admin_dashboard',
    323                 'position' => 2
     319                'menu_title'   => __( 'BuddyPress', 'buddypress' ),
     320                'page_title'   => __( 'BuddyPress', 'buddypress' ),
     321                'capability'   => 'manage_options',
     322                'file'         => 'bp-general-settings',
     323                'function'     => 'bp_core_admin_dashboard',
     324                'position'     => 2
    324325        ) );
    325326
    326327        add_submenu_page( 'bp-general-settings', __( 'BuddyPress Dashboard', 'buddypress' ), __( 'Dashboard', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_dashboard' );
    327         add_submenu_page( 'bp-general-settings', __( 'Settings', 'buddypress' ), __( 'Settings', 'buddypress' ), 'manage_options', 'bp-settings', 'bp_core_admin_settings' );
    328 
    329         /* Add a hook for css/js */
     328        add_submenu_page( 'bp-general-settings', __( 'Settings', 'buddypress' ),             __( 'Settings',  'buddypress' ), 'manage_options', 'bp-settings',         'bp_core_admin_settings' );
     329
     330        // Add a hook for css/js
    330331        add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    331332}
    332 add_action( 'admin_menu', 'bp_core_add_admin_menu' );
     333is_multisite() ? add_action( 'network_admin_menu', 'bp_core_add_admin_menu' ) : add_action( 'admin_menu', 'bp_core_add_admin_menu' );
    333334
    334335/**
    … …  
    18161817
    18171818        $defaults = array(
    1818                 'page_title' => '',
    1819                 'menu_title' => '',
    1820                 'access_level' => 2,
    1821                 'file' => false,
    1822                 'function' => false,
    1823                 'icon_url' => false,
    1824                 'position' => 100
     1819                'page_title'   => '',
     1820                'menu_title'   => '',
     1821                'capability'   => 'manage_options',
     1822                'file'         => false,
     1823                'function'     => false,
     1824                'icon_url'     => false,
     1825                'position'     => 100
    18251826        );
    18261827
    … …  
    18451846        } while ( !empty( $menu[$position] ) );
    18461847
    1847         $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
     1848        $menu[$position] = array ( $menu_title, $capability, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
    18481849
    18491850        $_registered_pages[$hookname] = true;
  • trunk/bp-core/admin/bp-core-upgrade.php

    r3613 r3706  
    5353
    5454        function bp_core_setup_wizard() {
    55                 if ( !$this->current_version = get_site_option( 'bp-db-version' ) )
    56                         if ( $this->current_version = get_option( 'bp-db-version' ) )
     55                // Look for current DB version
     56                if ( !$this->current_version = get_site_option( 'bp-db-version' ) ) {
     57                        if ( $this->current_version = get_option( 'bp-db-version' ) ) {
    5758                                $this->is_network_activate = true;
    58 
    59                 $this->new_version = constant( 'BP_DB_VERSION' );
    60                 $this->setup_type = ( empty( $this->current_version ) && !(int)get_site_option( 'bp-core-db-version' ) ) ? 'new' : 'upgrade';
     59                        } else {
     60                                setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH );
     61                                $_COOKIE['bp-wizard-step'] = 0;
     62                        }
     63                }
     64
     65                $this->new_version  = constant( 'BP_DB_VERSION' );
     66                $this->setup_type   = ( empty( $this->current_version ) && !(int)get_site_option( 'bp-core-db-version' ) ) ? 'new' : 'upgrade';
    6167                $this->current_step = $this->current_step();
    6268
    63                 /* Call the save method that will save data and modify $current_step */
     69                // Call the save method that will save data and modify $current_step
    6470                if ( isset( $_POST['save'] ) )
    6571                        $this->save( $_POST['save'] );
    6672
    67                 /* Build the steps needed for upgrade or new installations */
     73                // Build the steps needed for upgrade or new installations
    6874                $this->steps = $this->add_steps();
    6975        }
    … …  
    121127
    122128        function save( $step_name ) {
    123                 /* Save any posted values */
     129                // Save any posted values
    124130                switch ( $step_name ) {
    125131                        case 'db_upgrade': default:
    … …  
    185191                        </div>
    186192
    187                         <?php do_action( 'bp_admin_notices' ) ?>
    188 
    189                         <form action="<?php echo site_url( '/wp-admin/admin.php?page=bp-wizard' ) ?>" method="post" id="bp-admin-form">
     193                        <?php
     194                                do_action( 'bp_admin_notices' );
     195                                $step_count  = count( $this->steps ) - 1;
     196                                $wiz_or_set  = $this->current_step >= $step_count ? 'bp-general-settings' : 'bp-wizard';
     197                                $form_action = is_multisite() ? 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' ) );
     198                        ?>
     199
     200                        <form action="<?php echo $form_action; ?>" method="post" id="bp-admin-form">
    190201                                <div id="bp-admin-content">
    191202                                        <?php switch ( $this->steps[$this->current_step] ) {
    … …  
    489500
    490501                <?php if ( 'new' == $this->setup_type ) : ?>
     502
    491503                        <p><?php _e( "BuddyPress needs to use pages to display content and directories.", 'buddypress' ) ?></p>
     504
    492505                <?php else : ?>
     506
    493507                        <p><?php _e( "New versions of BuddyPress use WordPress pages to display content. This allows you to easily change the names of pages or move them to a sub page.", 'buddypress' ) ?></p>
     508
    494509                <?php endif; ?>
    495510
    … …  
    506521                                </th>
    507522                                <td>
    508                                         <p><input type="radio" name="bp_pages[members]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-members-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['members'] ) ?></p>
    509                                         <p><input type="radio" name="bp_pages[members]" checked="checked" value="<?php echo $members_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $members_slug ) ?>/</p>
     523                                        <p><input type="radio" name="bp_pages[members]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-members-page&echo=0&show_option_none=" . __('- Select -') . "&selected=" . $existing_pages['members'] ) ?></p>
     524                                        <p><input type="radio" name="bp_pages[members]" checked="checked" value="<?php echo $members_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo home_url( $members_slug ) ?>/</p>
    510525                                </td>
    511526                        </tr>
    512527
    513528                        <?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?>
    514                         <tr valign="top">
    515                                 <th scope="row">
    516                                         <h5><?php _e( 'Site Activity', 'buddypress' ) ?></h5>
    517                                         <p><?php _e( "Displays the activity for the entire site, a member's friends, groups and @mentions.", 'buddypress' ) ?></p>
    518                                 </th>
    519                                 <td>
    520                                         <p><input type="radio" name="bp_pages[activity]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-activity-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['activity'] ) ?></p>
    521                                         <p><input type="radio" name="bp_pages[activity]" checked="checked" value="<?php echo $activity_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $activity_slug ) ?>/</p>
    522                                 </td>
    523                         </tr>
     529
     530                                <tr valign="top">
     531                                        <th scope="row">
     532                                                <h5><?php _e( 'Site Activity', 'buddypress' ) ?></h5>
     533                                                <p><?php _e( "Displays the activity for the entire site, a member's friends, groups and @mentions.", 'buddypress' ) ?></p>
     534                                        </th>
     535                                        <td>
     536                                                <p><input type="radio" name="bp_pages[activity]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-activity-page&echo=0&show_option_none=" . __('- Select -') . "&selected=" . $existing_pages['activity'] ) ?></p>
     537                                                <p><input type="radio" name="bp_pages[activity]" checked="checked" value="<?php echo $activity_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo home_url( $activity_slug ) ?>/</p>
     538                                        </td>
     539                                </tr>
     540
    524541                        <?php endif; ?>
    525542
    526543                        <?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?>
    527                         <tr valign="top">
    528                                 <th scope="row">
    529                                         <h5><?php _e( 'Groups', 'buddypress' ) ?></h5>
    530                                         <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ) ?></p>
    531                                 </th>
    532                                 <td>
    533                                         <p><input type="radio" name="bp_pages[groups]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-groups-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['groups'] ) ?></p>
    534                                         <p><input type="radio" name="bp_pages[groups]" checked="checked" value="<?php echo $groups_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $groups_slug ) ?>/</p>
    535                                 </td>
    536                         </tr>
     544
     545                                <tr valign="top">
     546                                        <th scope="row">
     547                                                <h5><?php _e( 'Groups', 'buddypress' ) ?></h5>
     548                                                <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ) ?></p>
     549                                        </th>
     550                                        <td>
     551                                                <p><input type="radio" name="bp_pages[groups]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-groups-page&echo=0&show_option_none=" . __('- Select -') . "&selected=" . $existing_pages['groups'] ) ?></p>
     552                                                <p><input type="radio" name="bp_pages[groups]" checked="checked" value="<?php echo $groups_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo home_url( $groups_slug ) ?>/</p>
     553                                        </td>
     554                                </tr>
     555                               
    537556                        <?php endif; ?>
    538557
    539558                        <?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?>
    540                         <tr valign="top">
    541                                 <th scope="row">
    542                                         <h5><?php _e( 'Forums', 'buddypress' ) ?></h5>
    543                                         <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ) ?></p>
    544                                 </th>
    545                                 <td>
    546                                         <p><input type="radio" name="bp_pages[forums]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-forums-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['forums'] ) ?></p>
    547                                         <p><input type="radio" name="bp_pages[forums]" checked="checked" value="<?php echo $forums_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $forums_slug ) ?>/</p>
    548                                 </td>
    549                         </tr>
     559
     560                                <tr valign="top">
     561                                        <th scope="row">
     562                                                <h5><?php _e( 'Forums', 'buddypress' ) ?></h5>
     563                                                <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ) ?></p>
     564                                        </th>
     565                                        <td>
     566                                                <p><input type="radio" name="bp_pages[forums]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-forums-page&echo=0&show_option_none=" . __('- Select -') . "&selected=" . $existing_pages['forums'] ) ?></p>
     567                                                <p><input type="radio" name="bp_pages[forums]" checked="checked" value="<?php echo $forums_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo home_url( $forums_slug ) ?>/</p>
     568                                        </td>
     569                                </tr>
     570
    550571                        <?php endif; ?>
    551572
    552573                        <?php if ( is_multisite() && !isset( $disabled_components['bp-blogs.php'] ) ) : ?>
    553                         <tr valign="top">
    554                                 <th scope="row">
    555                                         <h5><?php _e( 'Blogs', 'buddypress' ) ?></h5>
    556                                         <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ) ?></p>
    557                                 </th>
    558                                 <td>
    559                                         <p><input type="radio" name="bp_pages[blogs]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-blogs-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['blogs'] ) ?></p>
    560                                         <p><input type="radio" name="bp_pages[blogs]" checked="checked" value="<?php echo $blogs_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $blogs_slug ) ?>/</p>
    561                                 </td>
    562                         </tr>
     574
     575                                <tr valign="top">
     576                                        <th scope="row">
     577                                                <h5><?php _e( 'Blogs', 'buddypress' ) ?></h5>
     578                                                <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ) ?></p>
     579                                        </th>
     580                                        <td>
     581                                                <p><input type="radio" name="bp_pages[blogs]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-blogs-page&echo=0&show_option_none=" . __('- Select -') . "&selected=" . $existing_pages['blogs'] ) ?></p>
     582                                                <p><input type="radio" name="bp_pages[blogs]" checked="checked" value="<?php echo $blogs_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo home_url( $blogs_slug ) ?>/</p>
     583                                        </td>
     584                                </tr>
     585
    563586                        <?php endif; ?>
    564587
    … …  
    569592                                </th>
    570593                                <td>
    571                                         <p><input type="radio" name="bp_pages[register]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-register-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['register'] ) ?></p>
    572                                         <p><input type="radio" name="bp_pages[register]" checked="checked" value="<?php echo $register_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $register_slug ) ?>/</p>
     594                                        <p><input type="radio" name="bp_pages[register]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-register-page&echo=0&show_option_none=" . __('- Select -') . "&selected=" . $existing_pages['register'] ) ?></p>
     595                                        <p><input type="radio" name="bp_pages[register]" checked="checked" value="<?php echo $register_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo home_url( $register_slug ) ?>/</p>
    573596                                </td>
    574597                        </tr>
    … …  
    580603                                </th>
    581604                                <td>
    582                                         <p><input type="radio" name="bp_pages[activate]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-activate-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['activate'] ) ?></p>
    583                                         <p><input type="radio" name="bp_pages[activate]" checked="checked" value="<?php echo $activation_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $activation_slug ) ?>/</p>
     605                                        <p><input type="radio" name="bp_pages[activate]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-activate-page&echo=0&show_option_none=" . __('- Select -') . "&selected=" . $existing_pages['activate'] ) ?></p>
     606                                        <p><input type="radio" name="bp_pages[activate]" checked="checked" value="<?php echo $activation_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo home_url( $activation_slug ) ?>/</p>
    584607                                </td>
    585608                        </tr>
    … …  
    591614                        <input type="hidden" name="save" value="pages" />
    592615                        <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
     616
    593617                        <?php wp_nonce_field( 'bpwizard_pages' )?>
     618
    594619                </div>
    595620
    … …  
    753778                        <input type="hidden" name="save" value="theme" />
    754779                        <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
     780
    755781                        <?php wp_nonce_field( 'bpwizard_theme' ) ?>
     782
    756783                </div>
    757784
    … …  
    773800
    774801                <?php if ( 'new' == $this->setup_type ) :
    775                         $type = __( 'setup', 'buddypress' );
    776                 ?>
     802                        $type = __( 'setup', 'buddypress' ); ?>
     803
    777804                        <h2>Setup Complete!</h2>
     805
    778806                <?php else :
    779                         $type = __( 'upgrade', 'buddypress' );
    780                 ?>
     807                        $type = __( 'upgrade', 'buddypress' ); ?>
     808
    781809                        <h2>Upgrade Complete!</h2>
     810
    782811                <?php endif; ?>
    783812
    … …  
    790819                        <input type="hidden" name="save" value="finish" />
    791820                        <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
     821
    792822                        <?php wp_nonce_field( 'bpwizard_finish' ) ?>
     823
    793824                </div>
    794825
    … …  
    9911022                        check_admin_referer( 'bpwizard_theme' );
    9921023
     1024                        // Update the DB version in the database
     1025                        update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) );
     1026                        delete_site_option( 'bp-core-db-version' );
     1027
    9931028                        require_once( ABSPATH . WPINC . '/plugin.php' );
    9941029                        $installed_plugins = get_plugins();
    … …  
    9961031                        switch ( $_POST['theme'] ) {
    9971032                                case 'bp_default':
    998                                         /* Activate the bp-default theme */
     1033                                        // Activate the bp-default theme
    9991034                                        switch_theme( 'bp-default', 'bp-default' );
    10001035                                        break;
    … …  
    10301065                        check_admin_referer( 'bpwizard_finish' );
    10311066
    1032                         /* Update the DB version in the database */
    1033                         update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) );
    1034                         delete_site_option( 'bp-core-db-version' );
    1035 
    1036                         /* Delete the setup cookie */
     1067                        // Delete the setup cookie
    10371068                        @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
    10381069
    1039                         /* Redirect to the BuddyPress dashboard */
    1040                         wp_redirect( admin_url( 'admin.php?page=bp-general-settings' ) );
     1070                        // Redirect to the BuddyPress dashboard
     1071                        $redirect = is_multisite() ? network_admin_url( add_query_arg( array( 'page' => 'bp-general-settings' ) ) ) : admin_url( add_query_arg( array( 'page' => 'bp-general-settings' ) ) );
     1072
     1073                        wp_redirect( $redirect );
    10411074
    10421075                        return true;
    … …  
    10491082                foreach ( $pages as $key => $value ) {
    10501083                        if ( 'page' == $value ) {
    1051                                 /* Check for the selected page */
     1084                                // Check for the selected page
    10521085                                if ( !empty( $_POST['bp-' . $key . '-page'] ) )
    10531086                                        $bp_pages[$key] = (int)$_POST['bp-' . $key . '-page'];
    … …  
    10551088                                        $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $key ), 'post_status' => 'publish', 'post_type' => 'page' ) );
    10561089                        } else {
    1057                                 /* Create a new page */
     1090                                // Create a new page
    10581091                                $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $value ), 'post_status' => 'publish', 'post_type' => 'page' ) );
    10591092                        }
    … …  
    10651098        /* Database upgrade methods based on version numbers */
    10661099        function upgrade_1_3() {
    1067                 /* Run the schema install to upgrade tables */
     1100                // Run the schema install to upgrade tables
    10681101                bp_core_install();
    10691102
    1070                 /* Delete old database version options */
     1103                // Delete old database version options
    10711104                delete_site_option( 'bp-activity-db-version' );
    10721105                delete_site_option( 'bp-blogs-db-version' );
    … …  
    10761109                delete_site_option( 'bp-xprofile-db-version' );
    10771110        }
     1111       
     1112        /**
     1113         * Reset the cookie so the install script starts over
     1114         */
     1115        function reset_cookie() {
     1116                @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
     1117        }
    10781118}
    10791119
    … …  
    10831123        $bp_wizard = new BP_Core_Setup_Wizard;
    10841124}
    1085 add_action( 'admin_menu', 'bp_core_setup_wizard_init' );
     1125is_multisite() ? add_action( 'network_admin_menu', 'bp_core_setup_wizard_init' ) : add_action( 'admin_menu', 'bp_core_setup_wizard_init' );
     1126       
    10861127
    10871128function bp_core_install( $disabled = false ) {
    … …  
    10931134        require_once( dirname( __FILE__ ) . '/bp-core-schema.php' );
    10941135
    1095         /* Core DB Tables */
     1136        // Core DB Tables
    10961137        bp_core_install_notifications();
    10971138
    1098         /* Activity Streams */
     1139        // Activity Streams
    10991140        if ( empty( $disabled['bp-activity.php'] ) )
    11001141                bp_core_install_activity_streams();
    11011142
    1102         /* Friend Connections */
     1143        // Friend Connections
    11031144        if ( empty( $disabled['bp-friends.php'] ) )
    11041145                bp_core_install_friends();
    11051146
    1106         /* Extensible Groups */
     1147        // Extensible Groups
    11071148        if ( empty( $disabled['bp-groups.php'] ) )
    11081149                bp_core_install_groups();
    11091150
    1110         /* Private Messaging */
     1151        // Private Messaging
    11111152        if ( empty( $disabled['bp-messages.php'] ) )
    11121153                bp_core_install_private_messaging();
    11131154
    1114         /* Extended Profiles */
     1155        // Extended Profiles
    11151156        if ( empty( $disabled['bp-xprofile.php'] ) )
    11161157                bp_core_install_extended_profiles();
    11171158
    1118         /* Only install blog tables if this is a multisite installation */
     1159        // Only install blog tables if this is a multisite installation
    11191160        if ( is_multisite() && empty( $disabled['bp-blogs.php'] ) )
    11201161                bp_core_install_blog_tracking();
    … …  
    11281169
    11291170function bp_upgrade_db_stuff() {
    1130         /* Rename the old user activity cached table if needed. */
     1171        // Rename the old user activity cached table if needed.
    11311172        if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_activity_user_activity_cached%'" ) )
    11321173                $wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
    11331174
    1134         /* Rename fields from pre BP 1.2 */
     1175        // Rename fields from pre BP 1.2
    11351176        if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {
    11361177                if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) )
    … …  
    11501191                bp_core_add_illegal_names();
    11511192
    1152         /* Upgrade and remove the message threads table if it exists */
     1193        // Upgrade and remove the message threads table if it exists
    11531194        if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_messages_threads%'" ) ) {
    11541195                $upgrade = BP_Messages_Thread::upgrade_tables();
    … …  
    11711212
    11721213        $defaults = array(
    1173                 'page_title' => '',
    1174                 'menu_title' => '',
    1175                 'access_level' => 2,
    1176                 'file' => false,
    1177                 'function' => false,
    1178                 'icon_url' => false,
    1179                 'position' => 100
     1214                'page_title'   => '',
     1215                'menu_title'   => '',
     1216                'capability'   => 'manage_options',
     1217                'menu_slug'    => '',
     1218                'function'     => false,
     1219                'icon_url'     => false,
     1220                'position'     => 100
    11801221        );
    11811222
    … …  
    11831224        extract( $r, EXTR_SKIP );
    11841225
    1185         $file = plugin_basename( $file );
    1186 
    1187         $admin_page_hooks[$file] = sanitize_title( $menu_title );
    1188 
    1189         $hookname = get_plugin_page_hookname( $file, '' );
    1190         if ( ! empty( $function ) && !empty ( $hookname ) )
    1191                 add_action( $hookname, $function );
    1192 
    1193         if ( empty($icon_url) )
    1194                 $icon_url = 'images/generic.png';
    1195         elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
    1196                 $icon_url = 'https://' . substr($icon_url, 7);
    1197 
    1198         do {
    1199                 $position++;
    1200         } while ( !empty( $menu[$position] ) );
    1201 
    1202         $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
    1203 
    1204         $_registered_pages[$hookname] = true;
    1205 
    1206         return $hookname;
     1226        if ( is_multisite() )
     1227                add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
     1228        else
     1229                add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
    12071230}
    12081231
    … …  
    12611284                $status = __( 'Upgrade', 'buddypress' );
    12621285
    1263         /* Add the administration tab under the "Site Admin" tab for site administrators */
     1286        // Add the administration tab under the "Site Admin" tab for site administrators
    12641287        bp_core_add_admin_menu_page( array(
    1265                 'menu_title' => __( 'BuddyPress', 'buddypress' ),
    1266                 'page_title' => __( 'BuddyPress', 'buddypress' ),
    1267                 'access_level' => 10, 'file' => 'bp-wizard',
    1268                 'function' => '',
    1269                 'position' => 2
     1288                'menu_title'   => __( 'BuddyPress', 'buddypress' ),
     1289                'page_title'   => __( 'BuddyPress', 'buddypress' ),
     1290                'capability'   => 'manage_options',
     1291                'menu_slug'    => 'bp-wizard',
     1292                'function'     => '',
     1293                'position'     => 3
    12701294        ) );
    12711295
    12721296        $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
    12731297
    1274         /* Add a hook for css/js */
     1298        // Add a hook for css/js
    12751299        add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    12761300}
    1277 add_action( 'admin_menu', 'bp_core_add_admin_menu' );
     1301is_multisite() ? add_action( 'network_admin_menu', 'bp_core_add_admin_menu' ) : add_action( 'admin_menu', 'bp_core_add_admin_menu' );
    12781302
    12791303function bp_core_add_admin_menu_styles() {
    … …  
    12871311?>
    12881312        <style type="text/css">
     1313                /* Wizard Icon */
     1314                ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a img { display: none; }
    12891315                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; }
    1290                 ul#adminmenu li.toplevel_page_bp-wizard:hover .wp-menu-image a { background-position: -1px 0; }
    1291                 ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a img { display: none; }
     1316                ul#adminmenu li.toplevel_page_bp-wizard:hover .wp-menu-image a,
     1317                ul#adminmenu li.toplevel_page_bp-wizard.wp-has-current-submenu .wp-menu-image a {
     1318                        background-position: -1px 0;
     1319                }
     1320
     1321                /* Settings Icon */
     1322                ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img { display: none; }
     1323                ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
     1324                ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a,
     1325                ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a {
     1326                        background-position: -1px 0;
     1327                }
    12921328        </style>
    12931329<?php
    12941330}
     1331add_action( 'admin_head', 'bp_core_add_admin_menu_styles' );
    12951332?>
  • trunk/bp-core/bp-core-cssjs.php

    r3702 r3706  
    3434 */
    3535function bp_core_admin_menu_icon_css() {
    36         global $bp;
    37 ?>
     36        global $bp; ?>
    3837
    3938        <style type="text/css">
    40                 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a { background-image: url( <?php echo BP_PLUGIN_URL . '/bp-core/images/admin_menu_icon.png' ?> ) !important; background-position: -1px -32px; }
    41                 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a, ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a { background-position: -1px 0; }
     39                /* Wizard Icon */
     40                ul#adminmenu li.toplevel_page_bp-wizard .wp-menu-image a img { display: none; }
     41                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; }
     42                ul#adminmenu li.toplevel_page_bp-wizard:hover .wp-menu-image a,
     43                ul#adminmenu li.toplevel_page_bp-wizard.wp-has-current-submenu .wp-menu-image a {
     44                        background-position: -1px 0;
     45                }
     46
     47                /* Settings Icon */
    4248                ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img { display: none; }
     49                ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
     50                ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a,
     51                ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a {
     52                        background-position: -1px 0;
     53                }
    4354        </style>
    4455
    … …  
    8596        $image = apply_filters( 'bp_inline_cropper_image', getimagesize( BP_AVATAR_UPLOAD_PATH . $bp->avatar_admin->image->dir ) );
    8697        $aspect_ratio = 1;
     98       
     99        $full_height = (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
     100        $full_width  = (int) constant( 'BP_AVATAR_FULL_WIDTH'  );
    87101
    88102        // Calculate Aspect Ratio
    89         if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) )
    90                 $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
     103        if ( $full_height && ( $full_width != $full_height ) )
     104                $aspect_ratio = $full_width / $full_height;
    91105
    92106        $width  = $image[0] / 2;
    … …  
    115129                function showPreview(coords) {
    116130                        if ( parseInt(coords.w) > 0 ) {
    117                                 var rx = <?php echo (int) constant( 'BP_AVATAR_FULL_WIDTH' ) ?> / coords.w;
    118                                 var ry = <?php echo (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ?> / coords.h;
     131                                var rx = <?php echo $full_width; ?> / coords.w;
     132                                var ry = <?php echo $full_height; ?> / coords.h;
    119133
    120134                                jQuery('#avatar-crop-preview').css({
    121135                                <?php if ( $image ) : ?>
    122                                         width: Math.round(rx * <?php echo $image[0] ?>) + 'px',
    123                                         height: Math.round(ry * <?php echo $image[1] ?>) + 'px',
     136                                        width: Math.round(rx * <?php echo $image[0]; ?>) + 'px',
     137                                        height: Math.round(ry * <?php echo $image[1]; ?>) + 'px',
    124138                                <?php endif; ?>
    125139                                        marginLeft: '-' + Math.round(rx * coords.x) + 'px',
Note: See TracChangeset for help on using the changeset viewer.