[ storage_key, default ]. */ private const BOOL_MAP = [ 'enabled' => [ 'author_archives_enabled', true ], 'show_in_search_results' => [ 'author_archives_index', true ], 'show_empty_archives' => [ 'author_archives_show_empty', false ], ]; /** * String settings: API alias => [ storage_key, default ]. */ private const STRING_MAP = [ 'title' => [ 'author_archives_title', Settings::DEFAULT_AUTHOR_ARCHIVES_TITLE ], 'meta_description' => [ 'author_archives_meta_desc', Settings::DEFAULT_AUTHOR_ARCHIVES_META_DESC ], ]; /** * Constructor. */ public function __construct() { $this->id = 'thinkrank/get-author-archives-settings'; $this->label = __( 'Get ThinkRank Author Archives Settings', 'thinkrank' ); $this->description = __( 'Retrieve ThinkRank author archives settings: enable/index toggles, empty-archive visibility, and the SEO title/meta description templates. Use update-author-archives-settings to change them.', 'thinkrank' ); } /** * {@inheritDoc} * * @return array */ public function get_annotations() { return [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, 'priority' => 1.0, 'openWorldHint' => false, ]; } /** * {@inheritDoc} * * @return array */ public function get_input_schema() { return [ 'type' => 'object', 'additionalProperties' => false, 'properties' => self::empty_properties(), ]; } /** * {@inheritDoc} * * @return array */ public function get_output_schema() { return [ 'type' => 'object', 'properties' => [ 'enabled' => [ 'type' => 'boolean' ], 'show_in_search_results' => [ 'type' => 'boolean' ], 'show_empty_archives' => [ 'type' => 'boolean' ], 'title' => [ 'type' => 'string' ], 'meta_description' => [ 'type' => 'string' ], ], ]; } /** * Execute ability. * * @param array $input Ability input payload. * @return array */ public function execute( $input ) { $settings = Settings::instance(); $out = []; foreach ( self::BOOL_MAP as $alias => $config ) { $out[ $alias ] = (bool) $settings->get( $config[0], $config[1] ); } foreach ( self::STRING_MAP as $alias => $config ) { $out[ $alias ] = (string) $settings->get( $config[0], $config[1] ); } return $out; } }