PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 1.25.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v1.25.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 / class-abilities-registrar.php

class-abilities-registrar.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 1.25.0, at includes/abilities/class-abilities-registrar.php

219 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Abilities registrar.
4 *
5 * @package ThinkRank\Abilities
6 */
7
8 declare(strict_types=1);
9
10 namespace ThinkRank\Abilities;
11
12 use ThinkRank\Abilities\Analysis\Get_Post_Seo_Checks;
13 use ThinkRank\Abilities\Analysis\Get_Term_Seo_Checks;
14 use ThinkRank\Abilities\Content\Get_Post_Seo;
15 use ThinkRank\Abilities\Content\Get_Term_Seo;
16 use ThinkRank\Abilities\Content\List_Content_Items;
17 use ThinkRank\Abilities\Content\List_Content_Types;
18 use ThinkRank\Abilities\Content\Update_Post_Seo;
19 use ThinkRank\Abilities\Content\Update_Term_Seo;
20 use ThinkRank\Abilities\Content\Generate_Content_Brief;
21 use ThinkRank\Abilities\Content\Get_Pillar_Content;
22 use ThinkRank\Abilities\Content\Update_Pillar_Content;
23 use ThinkRank\Abilities\Import\Detect_Import_Sources;
24 use ThinkRank\Abilities\Import\Get_Import_Status;
25 use ThinkRank\Abilities\Import\Run_Seo_Import;
26 use ThinkRank\Abilities\Import\Preview_Seo_Import;
27 use ThinkRank\Abilities\Settings\Get_Global_Settings;
28 use ThinkRank\Abilities\Settings\Get_Robots_Txt;
29 use ThinkRank\Abilities\Settings\Get_Sitemap_Settings;
30 use ThinkRank\Abilities\Settings\Update_Global_Settings;
31 use ThinkRank\Abilities\Settings\Update_Robots_Txt;
32 use ThinkRank\Abilities\Settings\Update_Sitemap_Settings;
33 use ThinkRank\Abilities\Settings\Get_Schema_Settings;
34 use ThinkRank\Abilities\Settings\Update_Schema_Settings;
35 use ThinkRank\Abilities\Settings\Get_Site_Identity_Settings;
36 use ThinkRank\Abilities\Settings\Update_Site_Identity_Settings;
37 use ThinkRank\Abilities\Settings\Get_Social_Meta_Settings;
38 use ThinkRank\Abilities\Settings\Update_Social_Meta_Settings;
39 use ThinkRank\Abilities\Settings\Get_Image_Seo_Settings;
40 use ThinkRank\Abilities\Settings\Update_Image_Seo_Settings;
41 use ThinkRank\Abilities\Settings\Get_Llms_Txt_Settings;
42 use ThinkRank\Abilities\Settings\Update_Llms_Txt_Settings;
43 use ThinkRank\Abilities\Settings\Get_Robots_Meta_Settings;
44 use ThinkRank\Abilities\Settings\Update_Robots_Meta_Settings;
45 use ThinkRank\Abilities\Settings\Get_Instant_Indexing_Settings;
46 use ThinkRank\Abilities\Settings\Update_Instant_Indexing_Settings;
47 use ThinkRank\Abilities\Settings\Get_Author_Archives_Settings;
48 use ThinkRank\Abilities\Settings\Update_Author_Archives_Settings;
49 use ThinkRank\Abilities\Settings\Get_Email_Report_Settings;
50 use ThinkRank\Abilities\Settings\Update_Email_Report_Settings;
51 use ThinkRank\Abilities\Settings\Send_Email_Report_Test;
52 use ThinkRank\Abilities\Settings\Get_Social_Platforms_Settings;
53 use ThinkRank\Abilities\Settings\Update_Social_Platforms_Settings;
54 use ThinkRank\Abilities\Indexing\Submit_Urls_To_Index;
55 use ThinkRank\Abilities\Indexing\Get_Instant_Indexing_History;
56 use ThinkRank\Abilities\Analysis\Get_Llms_Txt_Status;
57 use ThinkRank\Abilities\Analysis\Generate_Llms_Txt;
58 use ThinkRank\Abilities\Analysis\Publish_Llms_Txt;
59 use ThinkRank\Abilities\Analysis\Get_Seo_Analytics_Data;
60 use ThinkRank\Abilities\Analysis\Get_Seo_Insights;
61 use ThinkRank\Abilities\Analysis\Get_Seo_Opportunities;
62 use ThinkRank\Abilities\Analysis\Get_Seo_Score;
63 use ThinkRank\Abilities\Analysis\Get_Seo_Analyzer;
64 use ThinkRank\Abilities\Analysis\Run_Seo_Analyzer;
65 use ThinkRank\Abilities\Analysis\Get_Performance_Data;
66 use ThinkRank\Abilities\Analysis\Get_Integrations_Status;
67 use ThinkRank\Abilities\Analysis\Get_Connection_Status;
68 use ThinkRank\Abilities\Analysis\Bulk_Analyze_And_Save;
69 use ThinkRank\Core\Settings;
70
71 if ( ! defined( 'ABSPATH' ) ) {
72 exit; // Exit if accessed directly.
73 }
74
75 /**
76 * Registers ThinkRank abilities with the WordPress Abilities API.
77 *
78 * Abilities are **always** registered when the Abilities API is available —
79 * registration is decoupled from the `enable_mcp` toggle (see #187). Each
80 * ability is a permission-checked read/write surface (its own
81 * `current_user_can()` callback runs on every call), so registration alone
82 * exposes nothing; it only makes ThinkRank discoverable to generic WordPress
83 * Abilities clients (e.g. an external connector) the same way WordPress core
84 * abilities are. The `enable_mcp` toggle gates only ThinkRank's own MCP server
85 * ({@see \ThinkRank\Mcp\Mcp_Manager}) — the endpoint, discovery documents, and
86 * OAuth surface. The MCP server reads this abilities registry as its tool
87 * catalog. The Abilities API itself ships in `dependencies/` and no-ops
88 * gracefully when missing.
89 *
90 * A kill switch remains available via the `thinkrank_abilities_api_enabled`
91 * filter (defaults to `true`; see {@see Ability_Base::abilities_enabled()}).
92 */
93 class Abilities_Registrar {
94
95 /**
96 * Initialize the registrar (called by the plugin's component container).
97 *
98 * @return void
99 */
100 public function init() {
101 if ( ! function_exists( 'wp_register_ability' ) ) {
102 return;
103 }
104
105 add_action( 'wp_abilities_api_categories_init', [ $this, 'register_category' ] );
106 add_action( 'wp_abilities_api_init', [ $this, 'register_abilities' ] );
107 }
108
109 /**
110 * Register the ThinkRank ability category.
111 *
112 * @return void
113 */
114 public function register_category() {
115 if ( function_exists( 'wp_has_ability_category' ) && wp_has_ability_category( 'thinkrank' ) ) {
116 return;
117 }
118
119 if ( function_exists( 'wp_register_ability_category' ) ) {
120 wp_register_ability_category(
121 'thinkrank',
122 [
123 'label' => __( 'ThinkRank', 'thinkrank' ),
124 'description' => __( 'SEO settings, metadata, and analysis abilities powered by ThinkRank.', 'thinkrank' ),
125 ]
126 );
127 }
128 }
129
130 /**
131 * Register ThinkRank abilities.
132 *
133 * @return void
134 */
135 public function register_abilities() {
136 if ( ! Ability_Base::abilities_enabled() ) {
137 return;
138 }
139
140 $abilities = [
141 new List_Content_Types(),
142 new List_Content_Items(),
143 new Get_Global_Settings(),
144 new Update_Global_Settings(),
145 new Get_Post_Seo(),
146 new Update_Post_Seo(),
147 new Get_Term_Seo(),
148 new Update_Term_Seo(),
149 new Get_Post_Seo_Checks(),
150 new Get_Term_Seo_Checks(),
151 new Get_Robots_Txt(),
152 new Update_Robots_Txt(),
153 new Get_Sitemap_Settings(),
154 new Update_Sitemap_Settings(),
155 new Get_Schema_Settings(),
156 new Update_Schema_Settings(),
157 new Get_Site_Identity_Settings(),
158 new Update_Site_Identity_Settings(),
159 new Get_Social_Meta_Settings(),
160 new Update_Social_Meta_Settings(),
161 new Get_Image_Seo_Settings(),
162 new Update_Image_Seo_Settings(),
163 new Get_Llms_Txt_Settings(),
164 new Update_Llms_Txt_Settings(),
165 new Get_Robots_Meta_Settings(),
166 new Update_Robots_Meta_Settings(),
167 new Get_Instant_Indexing_Settings(),
168 new Update_Instant_Indexing_Settings(),
169 new Get_Author_Archives_Settings(),
170 new Update_Author_Archives_Settings(),
171 new Get_Email_Report_Settings(),
172 new Update_Email_Report_Settings(),
173 new Send_Email_Report_Test(),
174 new Get_Social_Platforms_Settings(),
175 new Update_Social_Platforms_Settings(),
176 new Submit_Urls_To_Index(),
177 new Get_Instant_Indexing_History(),
178 new Get_Llms_Txt_Status(),
179 new Generate_Llms_Txt(),
180 new Publish_Llms_Txt(),
181 new Get_Seo_Analytics_Data(),
182 new Get_Seo_Insights(),
183 new Get_Seo_Opportunities(),
184 new Get_Seo_Score(),
185 new Get_Seo_Analyzer(),
186 new Run_Seo_Analyzer(),
187 new Get_Performance_Data(),
188 new Get_Integrations_Status(),
189 new Get_Connection_Status(),
190 new Bulk_Analyze_And_Save(),
191 new Generate_Content_Brief(),
192 new Get_Pillar_Content(),
193 new Update_Pillar_Content(),
194 new Detect_Import_Sources(),
195 new Get_Import_Status(),
196 new Run_Seo_Import(),
197 new Preview_Seo_Import(),
198 ];
199
200 $abilities = apply_filters( 'thinkrank_register_abilities', $abilities );
201
202 foreach ( $abilities as $ability ) {
203 if ( ! $ability instanceof Ability_Base ) {
204 continue;
205 }
206
207 if ( ! $ability->meets_capability_policy() || ! $ability->is_enabled() ) {
208 continue;
209 }
210
211 if ( function_exists( 'wp_has_ability' ) && wp_has_ability( $ability->get_id() ) ) {
212 continue;
213 }
214
215 $ability->register();
216 }
217 }
218 }
219