> */ private const LEGACY_FIELDS = array( Generators::DESCRIPTION => array( array( 'key' => 'full_system_prompt' ), array( 'key' => 'full_user_prompt' ), array( 'key' => 'short_system_prompt' ), array( 'key' => 'short_user_prompt' ), array( 'key' => 'system_prompt', 'fallbackFor' => array( 'short_system_prompt', 'full_system_prompt' ), ), array( 'key' => 'user_prompt', 'fallbackFor' => array( 'short_user_prompt', 'full_user_prompt' ), ), ), Generators::TITLE => array( array( 'key' => 'title_additional_prompt' ), ), Generators::SEO_META => array( array( 'key' => 'seo_meta_additional_prompt' ), ), Generators::FAQ => array( array( 'key' => 'faq_additional_prompt' ), ), Generators::TAXONOMY => array( array( 'key' => 'taxonomy_additional_prompt' ), ), Generators::IMAGE_ALT => array( array( 'key' => 'image_alt_additional_prompt' ), ), ); /** * Whether a generator's legacy prompt options have been customized * (differ from the Activator default after the same normalization the * Settings save uses). * * @param string $generator One of Generators::all(). * @return bool */ public function isCustomized( string $generator ): bool { foreach ( self::LEGACY_FIELDS[ $generator ] ?? array() as $field ) { $live_raw = get_option( 'aipt_' . $field['key'], null ); if ( null === $live_raw ) { continue; } $live = (string) $live_raw; $live_normalized = SettingsService::normalizePromptText( $live ); $is_customized = isset( $field['fallbackFor'] ) ? $this->isFallbackCustomized( $live_normalized, $field['fallbackFor'] ) : $live_normalized !== SettingsService::normalizePromptText( (string) Activator::get_default_value( $field['key'] ) ); if ( $is_customized ) { return true; } } return false; } /** * Whether a fallback-only legacy prompt still shapes generation with a * non-default text: it must be non-empty, and at least one option it * stands in for must be missing or blank (otherwise nothing reads it), * with the fallback differing from that option's own default. * * @param string $live_normalized Normalized fallback text. * @param string[] $targets Option keys (no `aipt_` prefix) it falls back for. * @return bool */ private function isFallbackCustomized( string $live_normalized, array $targets ): bool { if ( '' === trim( $live_normalized ) ) { return false; } foreach ( $targets as $target ) { $target_raw = get_option( 'aipt_' . $target, null ); if ( null !== $target_raw && '' !== trim( (string) $target_raw ) ) { continue; } $target_default = SettingsService::normalizePromptText( (string) Activator::get_default_value( $target ) ); if ( $live_normalized !== $target_default ) { return true; } } return false; } }