*/
use RankMath\Helper;
use RankMath\Google\Console;
defined( 'ABSPATH' ) || exit;
/**
 * Set defaults for the new options added in this version.
 */
function rank_math_1_0_65_default_options() {
	$all_opts = rank_math()->settings->all_raw();
	$general  = $all_opts['general'];
	// Turn this option off by default after updating.
	$general['console_email_reports'] = 'off';
	Helper::update_all_settings( $general, null, null );
	rank_math()->settings->reset();
}
rank_math_1_0_65_default_options();
/**
 * Add admin notice to inform users about the new Email Reports feature.
 */
function rank_math_1_0_65_reports_notice() {
	$active_modules = get_option( 'rank_math_modules', [] );
	if ( ! is_array( $active_modules ) || ! in_array( 'analytics', $active_modules, true ) ) {
		return;
	}
	if ( ! Console::is_console_connected() ) {
		return;
	}
	Helper::add_notification(
		sprintf(
			// Translators: placeholders are the opening and closing anchor tags.
			'' . esc_html__( 'Rank Math: Introducing SEO Performance Reports via Email. %1$sClick here to enable it%2$s.', 'rank-math' ) . '',
			'',
			''
		),
		[
			'type'       => 'warning',
			'id'         => 'rank_math_analytics_new_email_reports',
			'capability' => 'rank_math_analytics',
		]
	);
}
rank_math_1_0_65_reports_notice();
/**
 * Clear scheduled event added in version 1.0.65-beta.
 *
 * @return void
 */
function rank_math_1_0_65_clear_beta_scheduled_event() {
	$event = 'rank_math/analytics/email_report_event';
	$timestamp = wp_next_scheduled( $event );
	if ( $timestamp ) {
		wp_unschedule_event( $timestamp, $event );
	}
}
rank_math_1_0_65_clear_beta_scheduled_event();