__( 'Unauthorized.', 'forge-trueconversion' ) ), 403 ); } $step = isset( $_POST['step'] ) ? absint( $_POST['step'] ) : 0; switch ( $step ) { case 2: // Form Detection $enabled_forms = isset( $_POST['ftcon_enabled_forms'] ) ? array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['ftcon_enabled_forms'] ) ) : array(); update_option( 'ftcon_enabled_forms', $enabled_forms ); update_option( 'ftcon_wizard_current_step', $step + 1 ); break; case 3: // Settings $email = isset( $_POST['ftcon_notification_email'] ) ? sanitize_email( wp_unslash( $_POST['ftcon_notification_email'] ) ) : get_option( 'admin_email' ); update_option( 'ftcon_notification_email', $email ); $allowed_freqs = array_keys( FTCON_Admin_Settings::get_email_frequency_options() ); $email_freq = isset( $_POST['ftcon_email_frequency'] ) ? array_values( array_intersect( array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['ftcon_email_frequency'] ) ), $allowed_freqs ) ) : array( 'each' ); update_option( 'ftcon_email_frequency', $email_freq ); update_option( 'ftcon_wizard_current_step', $step + 1 ); break; default: // Steps 1, 4, 5 — no fields to save, just advance. update_option( 'ftcon_wizard_current_step', $step + 1 ); break; } wp_send_json_success( array( 'message' => sprintf( /* translators: %d: step number */ __( 'Step %d saved.', 'forge-trueconversion' ), $step ), 'step' => $step, ) ); } /** * Render the Wizard Page */ public static function render_page() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to access this page.', 'forge-trueconversion' ) ); } $current_step = (int) get_option( 'ftcon_wizard_current_step', 1 ); $notification_email = get_option( 'ftcon_notification_email', get_option( 'admin_email' ) ); $enabled_forms = get_option( 'ftcon_enabled_forms', array() ); $installed_plugins = FTCON_Form_Integrations::detect_installed_plugins(); $all_plugins = FTCON_Form_Integrations::get_supported_plugins(); $installed_slugs = array_column( $installed_plugins, 'slug' ); ?>