Skip to:
Content

bbPress.org

Changeset 4390


Ignore:
Timestamp:
11/11/2012 07:14:21 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Activation:

  • When activating bbPress, redirect to the "What's New" page.
  • Replaces incomplete code in /admin/functions.php with update action and activation hook helper.
  • See #2018.
Location:
trunk/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/actions.php

    r4347 r4390  
    5555add_action( 'bbp_admin_init', 'bbp_register_admin_style'        );
    5656add_action( 'bbp_admin_init', 'bbp_register_admin_settings'     );
     57add_action( 'bbp_admin_init', 'bbp_do_activation_redirect', 1   );
    5758
    5859// Initialize the admin area
     
    6364
    6465// Activation
    65 add_action( 'bbp_activation', 'bbp_delete_rewrite_rules' );
     66add_action( 'bbp_activation', 'bbp_delete_rewrite_rules'    );
    6667
    6768// Deactivation
    6869add_action( 'bbp_deactivation', 'bbp_remove_caps'          );
    6970add_action( 'bbp_deactivation', 'bbp_delete_rewrite_rules' );
    70 add_action( 'bbp_deactivation', 'bbp_deactivated'          );
    7171
    7272// New Site
  • trunk/includes/admin/functions.php

    r4347 r4390  
    144144
    145145/**
    146  * We are activating bbPress
    147  *
    148  * @since bbPress (r4152)
    149  */
    150 function bbp_activating() {
    151     update_option( '_bbp_activated', '0' );
    152 }
    153 
    154 /**
    155  * bbPress is activated
    156  *
    157  * @since bbPress (r4152)
    158  */
    159 function bbp_activated() {
    160     update_option( '_bbp_activated', '1' );
    161 }
    162 
    163 /**
    164  * bbPress is deactivated
    165  *
    166  * @since bbPress (r4152)
    167  */
    168 function bbp_deactivated() {
    169     delete_option( '_bbp_activated' );
    170 }
    171 
    172 function bbp_activation_redirect() {
    173     if ( ! get_option( '_bbp_activated' ) || bbp_is_activation() )
    174         return;
    175 
    176     wp_safe_redirect( admin_url( add_query_arg( array( 'page' => 'bbp-about' ), 'index.php' ) ) );
    177     exit();
     146 * Redirect user to bbPress's What's New page on activation
     147 *
     148 * @since bbPress (r4389)
     149 *
     150 * @internal Used internally to redirect bbPress to the about page on activation
     151 *
     152 * @uses get_transient() To see if transient to redirect exists
     153 * @uses delete_transient() To delete the transient if it exists
     154 * @uses is_network_admin() To bail if being network activated
     155 * @uses wp_safe_redirect() To redirect
     156 * @uses add_query_arg() To help build the URL to redirect to
     157 * @uses admin_url() To get the admin URL to index.php
     158 *
     159 * @return If no transient, or in network admin, or is bulk activation
     160 */
     161function bbp_do_activation_redirect() {
     162
     163    // Bail if no activation redirect
     164    if ( ! get_transient( '_bbp_activation_redirect' ) )
     165        return;
     166
     167    // Delete the redirect transient
     168    delete_transient( '_bbp_activation_redirect' );
     169
     170    // Bail if activating from network, or bulk
     171    if ( is_network_admin() || isset( $_GET['activate-multi'] ) )
     172        return;
     173
     174    // Redirect to bbPress about page
     175    wp_safe_redirect( add_query_arg( array( 'page' => 'bbp-about' ), admin_url( 'index.php' ) ) );
    178176}
    179177
  • trunk/includes/core/actions.php

    r4375 r4390  
    293293add_action( 'bbp_login_form_login', 'bbp_user_maybe_convert_pass' );
    294294
     295add_action( 'bbp_activation', 'bbp_add_activation_redirect' );
     296
    295297/**
    296298 * Requires and creates the BuddyPress extension, and adds component creation
  • trunk/includes/core/update.php

    r4334 r4390  
    268268    bbp_delete_rewrite_rules();
    269269}
     270
     271/**
     272 * Redirect user to bbPress's What's New page on activation
     273 *
     274 * @since bbPress (r4389)
     275 *
     276 * @internal Used internally to redirect bbPress to the about page on activation
     277 *
     278 * @uses is_network_admin() To bail if being network activated
     279 * @uses set_transient() To drop the activation transient for 30 seconds
     280 *
     281 * @return If network admin or bulk activation
     282 */
     283function bbp_add_activation_redirect() {
     284
     285    // Bail if activating from network, or bulk
     286    if ( is_network_admin() || isset( $_GET['activate-multi'] ) )
     287        return;
     288
     289    // Add the transient to redirect
     290    set_transient( '_bbp_activation_redirect', true, 30 );
     291}
Note: See TracChangeset for help on using the changeset viewer.