BBP_Admin::network_update_screen()
Update all forums across all sites
Description
Source
File: bp-forums/admin/admin.php
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', 'buddyboss' ); ?></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!', 'buddyboss' ); ?></p> <a class="button" href="update-core.php?page=bbpress-update"><?php esc_html_e( 'Go Back', 'buddyboss' ); ?></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 Forums 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>', 'buddyboss' ), $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' ] ); endforeach; ?> </ul> <p> <?php esc_html_e( 'If your browser doesn\'t start loading the next page automatically, click this link:', 'buddyboss' ); ?> <a class="button" href="update-core.php?page=bbpress-update&action=bbpress-update&n=<?php echo ( $n + 5 ); ?>"><?php esc_html_e( 'Next Forums', 'buddyboss' ); ?></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 endif; 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.', 'buddyboss' ); ?></p> <p><a class="button" href="update-core.php?page=bbpress-update&action=bbpress-update"><?php esc_html_e( 'Update Forums', 'buddyboss' ); ?></a></p> <?php break; } ?> </div><?php }
Changelog
Version | Description |
---|---|
bbPress (r3689) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.