diff --git a/plugins/bcc-login/includes/class-bcc-login-site-report.php b/plugins/bcc-login/includes/class-bcc-login-site-report.php index 5314e26..b815e3f 100644 --- a/plugins/bcc-login/includes/class-bcc-login-site-report.php +++ b/plugins/bcc-login/includes/class-bcc-login-site-report.php @@ -15,6 +15,12 @@ class BCC_Login_Site_Report { private $plugin; private $plugin_version; + /** + * @var array|WP_Error|null What pressing "Send site report now" gave: the report that was sent, or why it + * couldn't be sent. + */ + private $sent_now; + function __construct( BCC_Login_Settings $settings, $plugin, $plugin_version ) { $this->_settings = $settings; $this->plugin = $plugin; @@ -22,6 +28,9 @@ function __construct( BCC_Login_Settings $settings, $plugin, $plugin_version ) { // After the daily cleanup, so the leftover count shows what it couldn't remove yet. add_action( BCC_Login_Cleanup::CRON_HOOK, array( $this, 'send' ), 20 ); + // Before the settings page (Settings > BCC Login) is printed, so the browser keeps showing "Sending…" + // until the result is ready, instead of the top of the page. + add_action( 'load-settings_page_bcc_login', array( $this, 'send_now_handler' ) ); add_action( 'bcc_login_settings_maintenance', array( $this, 'render_send_now_button' ) ); } @@ -102,52 +111,81 @@ function render_send_now_button() { if ( ! current_user_can( 'administrator' ) ) { return; } + // After sending, the page comes back to this section and shows the result under the button. WordPress + // moves other notices to the top of the page, out of sight from down here. ?> -
+ - + + + sent_now ) ) : ?> ++
sent_now->get_error_message() ); ?>
++
sent_now['siteUrl'], + $this->sent_now['pluginVersion'], + $this->sent_now['wordpressVersion'], + $this->sent_now['phpVersion'], + null === $this->sent_now['users'] ? '?' : number_format_i18n( $this->sent_now['users'] ), + null === $this->sent_now['subscribers'] ? '?' : number_format_i18n( $this->sent_now['subscribers'] ) + ) ); ?>
+