blueprint|advanced`). * Nothing reads it to decide a run any more; only * {@see ContentModeUpgrader} reads it once to tell which sites ran * custom prompts, and it stays in place so a downgrade to 2.8.0 keeps * that release's own choices. */ const LEGACY_OPTION = 'aipt_content_structure_modes'; /** * Valid mode values. */ const BLUEPRINT = 'blueprint'; const ADVANCED = 'advanced'; /** * The plugin-wide content mode. A missing or invalid option resolves to * `'advanced'`, the same defensive default 2.8.0 used, but no site * stays there: `Core\Activator` stores `'blueprint'` on a fresh * activation and {@see ContentModeUpgrader} stores it for every * existing site the first time 2.8.1 runs, before any generation. * * @return string self::BLUEPRINT | self::ADVANCED. */ public static function globalMode(): string { return self::BLUEPRINT === get_option( self::OPTION, self::ADVANCED ) ? self::BLUEPRINT : self::ADVANCED; } /** * The execution mode for one generator: the plugin-wide mode for every * known generator, `'advanced'` for an unknown key. * * @param string $generator One of Generators::all(). * @return string self::BLUEPRINT | self::ADVANCED. */ public static function mode( string $generator ): string { return Generators::isValid( $generator ) ? self::globalMode() : self::ADVANCED; } /** * Whether a generator currently runs the Blueprint path. * * @param string $generator One of Generators::all(). * @return bool */ public static function isBlueprint( string $generator ): bool { return self::BLUEPRINT === self::mode( $generator ); } /** * The execution mode for every known generator (always a complete map, * every entry equal to the plugin-wide mode). * * @return array generator => self::BLUEPRINT|self::ADVANCED. */ public static function all(): array { $result = array(); foreach ( Generators::all() as $generator ) { $result[ $generator ] = self::mode( $generator ); } return $result; } /** * Set the plugin-wide content mode. * * @param string $mode self::BLUEPRINT | self::ADVANCED. * @return bool True when the mode is valid and the option now holds it; * false otherwise (no write is attempted for an invalid mode). */ public static function setGlobal( string $mode ): bool { if ( ! in_array( $mode, array( self::BLUEPRINT, self::ADVANCED ), true ) ) { return false; } update_option( self::OPTION, $mode, true ); return self::globalMode() === $mode; } }