Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updater:

* Move bbp_is_deactivation() check out of bbPress class, and into bbpress-functions.php loader.
* Enables all functions and actions to run at deactivation time, allowing caps to be removed, etc...
* Re-enable network updater for capable users. Check if bbPress is active before running versioner.
* Introduce bbp_delete_rewrite_rules() to force a flush on the following page-load without priming rules on the current one.

git-svn-id: http://bbpress.svn.wordpress.org/branches/plugin@4198 9866e705-20ec-0310-96e7-cbb4277adcfb
  • Loading branch information...
commit d5e1674681ab625826e6a2277fca039f68d4e44d 1 parent cf6bd0a
johnjamesjacoby authored
View
16 bbp-admin/bbp-actions.php
@@ -63,17 +63,17 @@
add_action( 'bbp_admin_menu', 'bbp_admin_separator' );
// Activation
-add_action( 'bbp_activation', 'bbp_add_options', 1 );
-add_action( 'bbp_activation', 'flush_rewrite_rules' );
+add_action( 'bbp_activation', 'bbp_add_caps' );
+add_action( 'bbp_activation', 'bbp_delete_rewrite_rules' );
// Deactivation
-add_action( 'bbp_deactivation', 'flush_rewrite_rules' );
-add_action( 'bbp_deactivation', 'bbp_deactivated' );
+add_action( 'bbp_deactivation', 'bbp_remove_caps' );
+add_action( 'bbp_deactivation', 'bbp_delete_rewrite_rules' );
+add_action( 'bbp_deactivation', 'bbp_deactivated' );
// New Site
-add_action( 'bbp_new_site', 'bbp_add_options', 6 );
+add_action( 'bbp_new_site', 'bbp_add_caps', 6 );
add_action( 'bbp_new_site', 'bbp_create_initial_content', 8 );
-add_action( 'bbp_new_site', 'flush_rewrite_rules' );
// Contextual Helpers
add_action( 'load-settings_page_bbpress', 'bbp_admin_settings_help' );
@@ -100,6 +100,10 @@
*/
function bbp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
+ // Bail if plugin is not network activated
+ if ( ! is_plugin_active_for_network( bbpress()->basename ) )
+ return;
+
// Switch to the new blog
switch_to_blog( $blog_id );
View
47 bbp-admin/bbp-admin.php
@@ -229,6 +229,19 @@ public function admin_menus() {
array( $this, 'credits_screen' )
);
}
+
+ // Bail if plugin is not network activated
+ if ( ! is_plugin_active_for_network( bbpress()->basename ) )
+ return;
+
+ add_submenu_page(
+ 'index.php',
+ __( 'Update Forums', 'bbpress' ),
+ __( 'Update Forums', 'bbpress' ),
+ 'manage_network',
+ 'bbp-update',
+ array( $this, 'update_screen' )
+ );
}
/**
@@ -238,6 +251,11 @@ public function admin_menus() {
* @uses add_submenu_page() To add the Update Forums page in Updates
*/
public function network_admin_menus() {
+
+ // Bail if plugin is not network activated
+ if ( ! is_plugin_active_for_network( bbpress()->basename ) )
+ return;
+
add_submenu_page(
'upgrade.php',
__( 'Update Forums', 'bbpress' ),
@@ -1183,15 +1201,13 @@ public static function update_screen() {
// Taking action
switch ( $action ) {
- case 'bbpress-update' :
-
- // Ensure proper version in the DB
- bbp_version_bump();
+ case 'bbp-update' :
- ?>
+ // Run the full updater
+ bbp_version_updater(); ?>
<p><?php _e( 'All done!', 'bbpress' ); ?></p>
- <a class="button" href="index.php?page=bbpress-update"><?php _e( 'Go Back', 'bbpress' ); ?></a>
+ <a class="button" href="index.php?page=bbp-update"><?php _e( 'Go Back', 'bbpress' ); ?></a>
<?php
@@ -1201,7 +1217,7 @@ public static function update_screen() {
default : ?>
<p><?php _e( 'You can update your forum through this page. Hit the link below to update.', 'bbpress' ); ?></p>
- <p><a class="button" href="index.php?page=bbpress-update&amp;action=bbpress-update"><?php _e( 'Update Forum', 'bbpress' ); ?></a></p>
+ <p><a class="button" href="index.php?page=bbp-update&amp;action=bbp-update"><?php _e( 'Update Forum', 'bbpress' ); ?></a></p>
<?php break;
@@ -1266,14 +1282,27 @@ public static function network_update_screen() {
// Get the response of the bbPress update on this site
$response = wp_remote_get(
- trailingslashit( $siteurl ) . 'wp-admin/index.php?page=bbpress-update&step=bbpress-update',
- array( 'timeout' => 120, 'httpversion' => '1.1' )
+ trailingslashit( $siteurl ) . 'wp-admin/index.php?page=bbp-update&action=bbp-update',
+ array( 'timeout' => 30, 'httpversion' => '1.1' )
);
// Site errored out, no response?
if ( is_wp_error( $response ) )
wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>', 'bbpress' ), $siteurl, $response->get_error_message() ) );
+ // Switch to the new blog
+ switch_to_blog( $details[ 'blog_id' ] );
+
+ $basename = bbpress()->basename;
+
+ // Run the updater on this site
+ if ( is_plugin_active_for_network( $basename ) || is_plugin_active( $basename ) ) {
+ bbp_version_updater();
+ }
+
+ // restore original blog
+ restore_current_blog();
+
// Do some actions to allow plugins to do things too
do_action( 'after_bbpress_upgrade', $response );
do_action( 'bbp_upgrade_site', $details[ 'blog_id' ] );
View
10 bbp-includes/bbp-core-functions.php
@@ -432,3 +432,13 @@ function bbp_get_user_subscriptions_rewrite_id() {
function bbp_get_view_rewrite_id() {
return bbpress()->view_id;
}
+
+/**
+ * Delete a blogs rewrite rules, so that they are automatically rebuilt on
+ * the subsequent page load.
+ *
+ * @since bbPress (r4198)
+ */
+function bbp_delete_rewrite_rules() {
+ delete_option( 'rewrite_rules' );
+}
View
35 bbp-includes/bbp-core-update.php
@@ -134,27 +134,18 @@ function bbp_version_bump() {
*
* @since bbPress (r3419)
*
+ * @uses bbp_version_updater()
* @uses bbp_version_bump()
- * @uses bbp_deactivation()
- * @uses bbp_activation()
+ * @uses flush_rewrite_rules()
*/
function bbp_setup_updater() {
- // Are we running an outdated version of bbPress?
- if ( bbp_is_update() ) {
-
- // Call the automated updater
- bbp_version_updater();
-
- // Bump the version
- bbp_version_bump();
-
- // Run the deactivation function to wipe roles, caps, and rewrite rules
- bbp_deactivation();
+ // Bail if no update needed
+ if ( ! bbp_is_update() )
+ return;
- // Run the activation function to reset roles, caps, and rewrite rules
- bbp_activation();
- }
+ // Call the automated updater
+ bbp_version_updater();
}
/**
@@ -230,10 +221,6 @@ function bbp_version_updater() {
// Get the raw database version
$raw_db_version = (int) bbp_get_db_version_raw();
- // Bail if no database version exists
- if ( empty( $raw_db_version ) )
- return;
-
/** 2.0 Branch ************************************************************/
// 2.0, 2.0.1, 2.0.2, 2.0.3
@@ -274,4 +261,12 @@ function bbp_version_updater() {
bbp_remove_caps();
bbp_add_caps();
}
+
+ /** All done! *************************************************************/
+
+ // Bump the version
+ bbp_version_bump();
+
+ // Delete rewrite rules to force a flush
+ bbp_delete_rewrite_rules();
}
View
4 bbp-includes/bbp-template-loader.php
@@ -119,6 +119,10 @@ function bbp_template_include_theme_supports( $template = '' ) {
function bbp_load_theme_functions() {
global $pagenow;
+ // If bbPress is being deactivated, do not load any more files
+ if ( bbp_is_deactivation() )
+ return;
+
if ( ! defined( 'WP_INSTALLING' ) || ( !empty( $pagenow ) && ( 'wp-activate.php' !== $pagenow ) ) ) {
bbp_locate_template( 'bbpress-functions.php', true );
}
View
6 bbpress.php
@@ -174,7 +174,7 @@ private function setup_globals() {
/** Versions **********************************************************/
$this->version = '2.1.2-bleeding-r4181'; // bbPress version
- $this->db_version = '213'; // bbPress DB version
+ $this->db_version = '214'; // bbPress DB version
/** Paths *************************************************************/
@@ -271,10 +271,6 @@ private function includes() {
require( $this->plugin_dir . 'bbp-includes/bbp-core-shortcodes.php' ); // Shortcodes for use with pages and posts
require( $this->plugin_dir . 'bbp-includes/bbp-core-update.php' ); // Database updater
- // If bbPress is being deactivated, do not load any more files
- if ( bbp_is_deactivation( $this->basename ) )
- return;
-
/** Templates *********************************************************/
require( $this->plugin_dir . 'bbp-includes/bbp-template-functions.php' ); // Template functions
Please sign in to comment.
Something went wrong with that request. Please try again.