tools = $tools; } /** * Add action & filter hooks. * * @since 4.13.0 */ public function add_hooks(): void { add_action('admin_notices', [ $this, 'show' ]); add_action('mc4wp_admin_dismiss_cron_notice', [ $this, 'dismiss' ]); } /** * Set flag in user meta so notice won't be shown again. * * @since 4.13.0 */ public function dismiss(): void { $user = wp_get_current_user(); update_user_meta($user->ID, $this->meta_key_dismissed, 1); } /** * Show the cron warning notice if the scheduled event is behind. * * @since 4.13.0 */ public function show(): void { // only show on Mailchimp for WordPress' pages if (! $this->tools->on_plugin_page()) { return; } // only show to authorized users if (! $this->tools->is_user_authorized()) { return; } // only show if user did not dismiss before $user = wp_get_current_user(); if (get_user_meta($user->ID, $this->meta_key_dismissed, true)) { return; } // check if cron is behind schedule if (! $this->is_cron_behind_schedule()) { return; } echo '
'; echo esc_html__('Heads up! The scheduled Mailchimp for WordPress cron event appears to be running behind schedule. This could mean WP-Cron is not functioning correctly on your site. Please check your site\'s cron configuration.', 'mailchimp-for-wp'); echo '
'; echo ''; echo '