PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.7.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.7.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / includes / abilities / settings / class-get-author-archives-settings.php

class-get-author-archives-settings.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.7.0, at includes/abilities/settings/class-get-author-archives-settings.php

118 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get author archives settings ability.
4 *
5 * @package ThinkRank\Abilities\Settings
6 */
7
8 declare(strict_types=1);
9
10 namespace ThinkRank\Abilities\Settings;
11
12 use ThinkRank\Abilities\Ability_Base;
13 use ThinkRank\Core\Settings;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Retrieves ThinkRank author archives settings.
21 *
22 * Controls whether author archives are enabled and indexable, whether empty
23 * archives are shown, and the SEO title/meta description templates.
24 */
25 class Get_Author_Archives_Settings extends Ability_Base {
26 /**
27 * Boolean settings: API alias => [ storage_key, default ].
28 */
29 private const BOOL_MAP = [
30 'enabled' => [ 'author_archives_enabled', true ],
31 'show_in_search_results' => [ 'author_archives_index', true ],
32 'show_empty_archives' => [ 'author_archives_show_empty', false ],
33 ];
34
35 /**
36 * String settings: API alias => [ storage_key, default ].
37 */
38 private const STRING_MAP = [
39 'title' => [ 'author_archives_title', Settings::DEFAULT_AUTHOR_ARCHIVES_TITLE ],
40 'meta_description' => [ 'author_archives_meta_desc', Settings::DEFAULT_AUTHOR_ARCHIVES_META_DESC ],
41 ];
42
43 /**
44 * Constructor.
45 */
46 public function __construct() {
47 $this->id = 'thinkrank/get-author-archives-settings';
48 $this->label = __( 'Get ThinkRank Author Archives Settings', 'thinkrank' );
49 $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' );
50 }
51
52 /**
53 * {@inheritDoc}
54 *
55 * @return array<string, bool|float|string>
56 */
57 public function get_annotations() {
58 return [
59 'readonly' => true,
60 'destructive' => false,
61 'idempotent' => true,
62 'priority' => 1.0,
63 'openWorldHint' => false,
64 ];
65 }
66
67 /**
68 * {@inheritDoc}
69 *
70 * @return array<string, mixed>
71 */
72 public function get_input_schema() {
73 return [
74 'type' => 'object',
75 'additionalProperties' => false,
76 'properties' => self::empty_properties(),
77 ];
78 }
79
80 /**
81 * {@inheritDoc}
82 *
83 * @return array<string, mixed>
84 */
85 public function get_output_schema() {
86 return [
87 'type' => 'object',
88 'properties' => [
89 'enabled' => [ 'type' => 'boolean' ],
90 'show_in_search_results' => [ 'type' => 'boolean' ],
91 'show_empty_archives' => [ 'type' => 'boolean' ],
92 'title' => [ 'type' => 'string' ],
93 'meta_description' => [ 'type' => 'string' ],
94 ],
95 ];
96 }
97
98 /**
99 * Execute ability.
100 *
101 * @param array<string, mixed> $input Ability input payload.
102 * @return array<string, mixed>
103 */
104 public function execute( $input ) {
105 $settings = Settings::instance();
106 $out = [];
107
108 foreach ( self::BOOL_MAP as $alias => $config ) {
109 $out[ $alias ] = (bool) $settings->get( $config[0], $config[1] );
110 }
111 foreach ( self::STRING_MAP as $alias => $config ) {
112 $out[ $alias ] = (string) $settings->get( $config[0], $config[1] );
113 }
114
115 return $out;
116 }
117 }
118