generator => state. */ public static function all(): array { $result = array(); foreach ( Generators::all() as $generator ) { $result[ $generator ] = self::state( $generator ); } return $result; } /** * Set one generator's compare-notice state. * * @param string $generator One of Generators::all(). * @param string $state One of self::WRITABLE_STATES. * @return bool True when the generator and state are valid and the * option now reflects the requested state; false otherwise * (no write is attempted for an invalid input). */ public static function set( string $generator, string $state ): bool { if ( ! Generators::isValid( $generator ) || ! in_array( $state, self::WRITABLE_STATES, true ) ) { return false; } $states = self::rawStates(); $states[ $generator ] = $state; update_option( self::OPTION, $states, true ); return self::state( $generator ) === $state; } /** * The raw stored option, defensively coerced to an array. * * @return array */ private static function rawStates(): array { $stored = get_option( self::OPTION, array() ); return is_array( $stored ) ? $stored : array(); } }