/**
 * Setup the bbPress updater
 *
 * @since bbPress (r3419)
 *
 * @uses bbp_version_updater()
 * @uses bbp_version_bump()
 * @uses flush_rewrite_rules()
 */
function bbp_setup_updater()
{
    // Bail if no update needed
    if (!bbp_is_update()) {
        return;
    }
    // Call the automated updater
    bbp_version_updater();
}
Beispiel #2
0
        /**
         * Update all bbPress forums across all sites
         *
         * @since bbPress (r3689)
         *
         * @global WPDB $wpdb
         * @uses get_blog_option()
         * @uses wp_remote_get()
         */
        public static function network_update_screen()
        {
            global $wpdb;
            // Get action
            $action = isset($_GET['action']) ? $_GET['action'] : '';
            ?>

		<div class="wrap">
			<div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div>
			<h2><?php 
            esc_html_e('Update Forums', 'bbpress');
            ?>
</h2>

		<?php 
            // Taking action
            switch ($action) {
                case 'bbpress-update':
                    // Site counter
                    $n = isset($_GET['n']) ? intval($_GET['n']) : 0;
                    // Get blogs 5 at a time
                    $blogs = $wpdb->get_results("SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A);
                    // No blogs so all done!
                    if (empty($blogs)) {
                        ?>

					<p><?php 
                        esc_html_e('All done!', 'bbpress');
                        ?>
</p>
					<a class="button" href="update-core.php?page=bbpress-update"><?php 
                        esc_html_e('Go Back', 'bbpress');
                        ?>
</a>

				<?php 
                        // Still have sites to loop through
                    } else {
                        ?>

					<ul>

						<?php 
                        foreach ((array) $blogs as $details) {
                            $siteurl = get_blog_option($details['blog_id'], 'siteurl');
                            ?>

							<li><?php 
                            echo $siteurl;
                            ?>
</li>

							<?php 
                            // Get the response of the bbPress update on this site
                            $response = wp_remote_get(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']);
                        }
                        ?>

					</ul>

					<p>
						<?php 
                        esc_html_e('If your browser doesn&#8217;t start loading the next page automatically, click this link:', 'bbpress');
                        ?>
						<a class="button" href="update-core.php?page=bbpress-update&amp;action=bbpress-update&amp;n=<?php 
                        echo $n + 5;
                        ?>
"><?php 
                        esc_html_e('Next Forums', 'bbpress');
                        ?>
</a>
					</p>
					<script type='text/javascript'>
						<!--
						function nextpage() {
							location.href = 'update-core.php?page=bbpress-update&action=bbpress-update&n=<?php 
                        echo $n + 5;
                        ?>
';
						}
						setTimeout( 'nextpage()', 250 );
						//-->
					</script><?php 
                    }
                    break;
                case 'show':
                default:
                    ?>

				<p><?php 
                    esc_html_e('You can update all the forums on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.', 'bbpress');
                    ?>
</p>
				<p><a class="button" href="update-core.php?page=bbpress-update&amp;action=bbpress-update"><?php 
                    esc_html_e('Update Forums', 'bbpress');
                    ?>
</a></p>

			<?php 
                    break;
            }
            ?>

		</div><?php 
        }
Beispiel #3
0
/**
 * Setup the bbPress updater
 *
 * @since bbPress (r3419)
 *
 * @uses bbp_version_bump()
 * @uses bbp_deactivation()
 * @uses bbp_activation()
 */
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();
        // Run the activation function to reset roles, caps, and rewrite rules
        bbp_activation();
    }
}