'Decommission module unavailable.' ) ); } $job = isset( $_POST['job'] ) ? sanitize_key( wp_unslash( (string) $_POST['job'] ) ) : ''; switch ( $job ) { case 'birthdays': wp_send_json_success( AIEO_AW_Decommission::migrate_birthdays() ); break; case 'coupons': wp_send_json_success( AIEO_AW_Decommission::import_coupons() ); break; case 'optouts': wp_send_json_success( AIEO_AW_Decommission::import_optouts() ); break; case 'workflows': wp_send_json_success( AIEO_AW_Decommission::migrate_workflows( array( 'include_disabled' => ! empty( $_POST['include_disabled'] ) ) ) ); break; default: wp_send_json_error( array( 'message' => 'Unknown job.' ) ); } } public static function settings() { $s = get_option( self::OPTION_KEY, array() ); if ( ! is_array( $s ) ) { $s = array(); } return array_merge( array( 'enabled' => 'no', 'label' => '', 'message' => '', ), $s ); } public function ajax_save() { AIEO_DMM::verify_ajax_request(); $enabled = ( isset( $_POST['enabled'] ) && '1' === (string) $_POST['enabled'] ) ? 'yes' : 'no'; $label = isset( $_POST['label'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['label'] ) ) : ''; $message = isset( $_POST['message'] ) ? wp_kses( wp_unslash( (string) $_POST['message'] ), array( 'strong' => array(), 'em' => array(), 'br' => array() ) ) : ''; update_option( self::OPTION_KEY, array( 'enabled' => $enabled, 'label' => $label, 'message' => $message ), false ); wp_send_json_success( array( 'enabled' => $enabled, 'label' => $label, 'message' => $message ) ); } private function captured_count() { global $wpdb; return (int) $wpdb->get_var( "SELECT COUNT(DISTINCT user_id) FROM {$wpdb->usermeta} WHERE meta_key IN ('aieo_birthday_md','_automatewoo_birthday_md') AND meta_value <> ''" ); } public function render_subtab() { $s = self::settings(); $count = $this->captured_count(); $nonce = wp_create_nonce( AIEO_DMM::NONCE_ACTION ); ?> 2 ) ); list( $open, $close ) = AIEO_DMM_UI::card( array( 'anchor' => 'birthday-checkout-field', 'title' => __( 'Birthday field', 'ai-eshop-optimizer' ), 'description' => __( 'Add an optional birthday field to the checkout. Captured birthdays feed the Birthday campaign trigger. Values persist to the customer profile (MM-DD).', 'ai-eshop-optimizer' ), 'footer' => \Rooster\Admin\States::save_button( $form_id ), ) ); echo $open; ob_start(); ?>

'; echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-bday-enabled', 'label' => __( 'Enable field', 'ai-eshop-optimizer' ), 'control' => '', ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-bday-label', 'label' => __( 'Field label', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::input( 'label', (string) $s['label'], array( 'id' => 'aieo-bday-label', 'medium' => true ) ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-bday-message', 'label' => __( 'Explanatory message', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::textarea( 'message', isset( $s['message'] ) ? (string) $s['message'] : '', array( 'id' => 'aieo-bday-message', 'rows' => 2 ) ), 'help' => __( 'Shown under the birthday\'s selects at checkout and in My Account: say why you ask (the birthday gift). Leave it empty for the default sentence. , ,
allowed.', 'ai-eshop-optimizer' ), ) ); echo ''; echo AIEO_DMM_UI::card_form( 'aieo_dmm_birthday_save', $this->get_id(), $form_id, (string) ob_get_clean() ); echo $close; list( $open, $close ) = AIEO_DMM_UI::card( array( 'anchor' => 'birthday-migrate-from-automatewoo', 'icon' => 'import', 'title' => __( 'Migrate from AutomateWoo', 'ai-eshop-optimizer' ), 'description' => __( 'Idempotent + retryable. Copies AutomateWoo birthdays into the AIEO keys, imports outstanding AutomateWoo coupons into the ledger, imports AutomateWoo unsubscribes into the suppression list, and recreates your ACTIVE AutomateWoo workflows as AIEO Campaign drafts (nothing sends — they arrive as drafts, engines paused). Run these before deactivating AutomateWoo (see the decommission runbook), then review + activate the migrated Campaigns.', 'ai-eshop-optimizer' ), ) ); echo $open; ?>