get_stored_value(); return $value; } /** * Reads the user's real AI setting, bypassing this class's own filter. * * @return bool The stored setting. */ private function get_stored_value(): bool { remove_filter( 'option_' . self::OPTION, array( $this, 'disable' ), PHP_INT_MAX ); remove_filter( 'default_option_' . self::OPTION, array( $this, 'disable' ), PHP_INT_MAX ); $stored = get_option( self::OPTION ); add_filter( 'option_' . self::OPTION, array( $this, 'disable' ), PHP_INT_MAX ); add_filter( 'default_option_' . self::OPTION, array( $this, 'disable' ), PHP_INT_MAX ); // Yoast's own default for this key is true; match it when nothing is stored. if ( ! is_array( $stored ) || ! array_key_exists( self::KEY, $stored ) ) { return true; } return true === $stored[ self::KEY ]; } /** * Forces the AI generator setting off in the returned option. * * @param mixed $value The option value. * @return mixed The option value with AI switched off. */ public function disable( $value ) { if ( ! is_array( $value ) ) { return $value; } $value[ self::KEY ] = false; return $value; } }