Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/04/2012 02:24:31 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Core Update:

  • Port _is_activation() and _is_deactivation() code from bbPress.
  • Includes handling for bulk plugin activation/deactivation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-update.php

    r6093 r6301  
    3838 * @since BuddyPress (1.6)
    3939 *
    40  * @global BuddyPress $bp
     40 * @uses buddypress()
    4141 * @return bool True if activating BuddyPress, false if not
    4242 */
    4343function bp_is_activation( $basename = '' ) {
    44     global $bp;
     44    $bp = buddypress();
    4545
    46     // Baif if action or plugin are empty
    47     if ( empty( $_GET['action'] ) || empty( $_GET['plugin'] ) )
     46    $action = false;
     47    if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) )
     48        $action = $_REQUEST['action'];
     49    elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) )
     50        $action = $_REQUEST['action2'];
     51
     52    // Bail if not activating
     53    if ( empty( $action ) || !in_array( $action, array( 'activate', 'activate-selected' ) ) )
    4854        return false;
    4955
    50     // Bail if not activating
    51     if ( 'activate' !== $_GET['action'] )
    52         return false;
    53 
    54     // The plugin being activated
    55     $plugin = isset( $_GET['plugin'] ) ? $_GET['plugin'] : '';
     56    // The plugin(s) being activated
     57    if ( $action == 'activate' )
     58        $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
     59    else
     60        $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    5661
    5762    // Set basename if empty
     
    6368        return false;
    6469
    65     // Bail if plugin is not BuddyPress
    66     if ( $basename !== $plugin )
    67         return false;
    68 
    69     return true;
     70    // Is BuddyPress being activated?
     71    return in_array( $basename, $plugins );
    7072}
    7173
     
    7577 * @since BuddyPress (1.6)
    7678 *
    77  * @global BuddyPress $bp
     79 * @uses buddypress()
    7880 * @return bool True if deactivating BuddyPress, false if not
    7981 */
    8082function bp_is_deactivation( $basename = '' ) {
    81     global $bp;
     83    $bp = buddypress();
    8284
    83     // Baif if action or plugin are empty
    84     if ( empty( $_GET['action'] ) || empty( $_GET['plugin'] ) )
     85    $action = false;
     86    if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) )
     87        $action = $_REQUEST['action'];
     88    elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) )
     89        $action = $_REQUEST['action2'];
     90
     91    // Bail if not deactivating
     92    if ( empty( $action ) || !in_array( $action, array( 'deactivate', 'deactivate-selected' ) ) )
    8593        return false;
    8694
    87     // Bail if not deactivating
    88     if ( 'deactivate' !== $_GET['action'] )
    89         return false;
    90 
    91     // The plugin being deactivated
    92     $plugin = isset( $_GET['plugin'] ) ? $_GET['plugin'] : '';
     95    // The plugin(s) being deactivated
     96    if ( $action == 'deactivate' )
     97        $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
     98    else
     99        $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    93100
    94101    // Set basename if empty
     
    100107        return false;
    101108
    102     // Bail if plugin is not BuddyPress
    103     if ( $basename !== $plugin )
    104         return false;
    105 
    106     return true;
     109    // Is bbPress being deactivated?
     110    return in_array( $basename, $plugins );
    107111}
    108112
     
    194198    do_action( 'bp_uninstall' );
    195199}
    196 
    197 ?>
Note: See TracChangeset for help on using the changeset viewer.