config = $config; add_action( 'admin_notices', [ $this, 'render_optin_notice' ] ); add_action( 'wp_ajax_' . $this->config->get_prefix() . 'news_optin', [ $this, 'ajax_optin' ] ); add_action( 'wp_ajax_' . $this->config->get_prefix() . 'news_settings', [ $this, 'ajax_settings' ] ); } public function is_enabled(): bool { return (bool) get_option( $this->config->get_service_enabled_option(), false ); } public function should_show_optin_notice(): bool { return ! $this->is_enabled() && ! get_option( $this->config->get_optin_notice_dismissed_option(), false ) && current_user_can( 'activate_plugins' ); } /** * First-activation opt-in notice: what connects, what is sent, why. */ public function render_optin_notice(): void { return; // Temporarily disabled - re-enable in a future release if( ! NewsModule::is_notice_page() ) return; if( ! $this->should_show_optin_notice() ) return; ?>

config->get_settings_page_url() ) . '">' . esc_html__( 'News & Emails', 'gvectors' ) . '' ); ?>

config->get_nonce_action(), 'nonce' ); if( ! current_user_can( 'activate_plugins' ) ) { wp_send_json_error( [ 'message' => 'Permission denied' ], 403 ); } $enable = ! empty( $_POST['enable'] ); if( $enable ) { update_option( $this->config->get_service_enabled_option(), true ); // First sync right away so news/reminders appear without waiting a day if( ! wp_next_scheduled( $this->config->get_cron_hook() ) ) { wp_schedule_single_event( time() + 10, $this->config->get_cron_hook() ); } } update_option( $this->config->get_optin_notice_dismissed_option(), true ); wp_send_json_success( [ 'enabled' => $enable ] ); } /** * AJAX: master service switch toggle. Category-level control lives in the * PrefsService matrices, managed from the News & Emails settings page. */ public function ajax_settings(): void { check_ajax_referer( $this->config->get_nonce_action(), 'nonce' ); if( ! current_user_can( 'activate_plugins' ) ) { wp_send_json_error( [ 'message' => 'Permission denied' ], 403 ); } if( isset( $_POST['service_enabled'] ) ) { update_option( $this->config->get_service_enabled_option(), (bool) (int) $_POST['service_enabled'] ); } wp_send_json_success( [ 'service_enabled' => $this->is_enabled() ] ); } }