PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.14.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.14.0
2.14.0 2.13.0 2.12.0 2.11.0 2.10.0 2.9.0 2.8.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 All 55 releases
thinkrank / includes / config / schema-settings-config.php

schema-settings-config.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.14.0, at includes/config/schema-settings-config.php

319 lines 10.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Schema Settings Configuration
4 *
5 * Shared configuration for schema settings between frontend and backend.
6 * This eliminates duplication and ensures consistency across the application.
7 *
8 * @package ThinkRank
9 * @subpackage Config
10 * @since 1.0.0
11 */
12
13 declare(strict_types=1);
14
15 namespace ThinkRank\Config;
16
17 // Prevent direct access
18 if (!defined('ABSPATH')) {
19 exit;
20 }
21
22 /**
23 * Schema Settings Configuration Class
24 *
25 * Provides centralized schema settings configuration for both frontend and backend.
26 * Eliminates duplication between SchemaTab.js and Schema_Management_System.
27 *
28 * @since 1.0.0
29 */
30 class Schema_Settings_Config {
31
32 /**
33 * Get default schema settings
34 *
35 * @since 1.0.0
36 *
37 * @param string $context_type Context type ('site', 'post', 'page', 'product')
38 * @return array Default settings array
39 */
40 public static function get_default_settings(string $context_type = 'site'): array {
41 $defaults = [
42 // Core settings
43 'enabled' => true,
44 'auto_generate_schema' => true,
45 'enabled_schema_types' => [],
46 'validation_level' => 'moderate',
47 'rich_snippets_optimization' => true,
48 'cache_duration' => 3600, // 1 hour
49 'auto_deploy' => true,
50
51 // Basic schema settings (moved from Site Identity)
52 'organization_schema' => true,
53 'knowledge_graph' => true,
54
55 // Organization schema settings
56 'organization_name' => '',
57 'organization_type' => 'Organization',
58 'organization_logo' => '',
59 'organization_url' => '',
60 'organization_description' => '',
61 'organization_social_facebook' => '',
62 'organization_social_twitter' => '',
63 'organization_social_linkedin' => '',
64 'organization_social_instagram' => '',
65 'organization_social_youtube' => '',
66 'organization_social_pinterest' => '',
67 'organization_social_whatsapp' => '',
68 'organization_social_telegram' => '',
69 'organization_contact_type' => 'customer service',
70 'organization_contact_phone' => '',
71 'organization_contact_email' => '',
72 'organization_contact_hours' => '',
73
74 // Website schema settings
75 'website_name' => '',
76 'website_url' => '',
77 'website_description' => '',
78 'website_author' => '',
79 'website_enable_search' => true,
80 'website_search_url' => '',
81
82 // LocalBusiness schema settings
83 'business_price_range' => '',
84 'business_geo_latitude' => '',
85 'business_geo_longitude' => '',
86 'business_opening_hours' => [],
87
88 // Content schema settings (site-wide only)
89 'enable_breadcrumbs_schema' => true,
90 'enable_local_business' => false,
91
92 // Read an Oxygen or Breakdance accordion as FAQ content. Off, and it
93 // has to stay off by default: those are the builders' own elements
94 // rather than a ThinkRank FAQ module, so an accordion may hold
95 // questions or may hold product specifications, and turning this on
96 // for every existing site would publish FAQPage markup nobody asked
97 // for. ThinkRank reads and reports the accordion either way; this
98 // switch only decides whether it reaches the schema graph (#831).
99 'enable_accordion_faq_schema' => false,
100
101 // Removed post/page-specific schema settings (Product, Event, Article, Software Application, HowTo, FAQ)
102 // These are now handled only at the post/page level via metabox
103
104 // Person schema settings (site-wide)
105 'person_name' => '',
106 'person_job_title' => '',
107 'person_description' => '',
108 'person_image' => '',
109 'person_url' => '',
110 'person_email' => '',
111 'person_telephone' => '',
112 'person_address' => '',
113 'person_birth_date' => '',
114 'person_nationality' => '',
115 'person_works_for' => '',
116 'person_same_as' => [],
117
118 // Removed FAQPage schema settings (now handled at post/page level)
119 ];
120
121 // Context-specific defaults
122 switch ($context_type) {
123 case 'site':
124 $defaults['enabled_schema_types'] = ['Organization', 'LocalBusiness'];
125 $defaults['auto_deploy'] = true;
126 break;
127 case 'post':
128 $defaults['enabled_schema_types'] = ['Article', 'Person'];
129 $defaults['validation_level'] = 'strict';
130 break;
131 case 'page':
132 $defaults['enabled_schema_types'] = ['Article', 'FAQPage'];
133 $defaults['rich_snippets_optimization'] = true;
134 break;
135 case 'product':
136 $defaults['enabled_schema_types'] = ['Product'];
137 $defaults['validation_level'] = 'strict';
138 $defaults['rich_snippets_optimization'] = true;
139 break;
140 }
141
142 return $defaults;
143 }
144
145 /**
146 * Get settings schema definition
147 *
148 * @since 1.0.0
149 *
150 * @param string $context_type Context type
151 * @return array Settings schema definition
152 */
153 public static function get_settings_schema(string $context_type = 'site'): array {
154 return [
155 'enabled' => [
156 'type' => 'boolean',
157 'title' => 'Enable Schema Management',
158 'description' => 'Enable automated schema markup generation and management',
159 'default' => true
160 ],
161 'auto_generate_schema' => [
162 'type' => 'boolean',
163 'title' => 'Auto-Generate Schema',
164 'description' => 'Automatically generate schema markup based on content',
165 'default' => true
166 ],
167 'enabled_schema_types' => [
168 'type' => 'array',
169 'title' => 'Enabled Schema Types',
170 'description' => 'Select which schema types to generate',
171 'items' => [
172 'type' => 'string',
173 'enum' => self::get_supported_schema_types($context_type)
174 ],
175 'default' => []
176 ],
177 'deployment_method' => [
178 'type' => 'string',
179 'title' => 'Deployment Method',
180 'description' => 'Schema markup output format (JSON-LD)',
181 'enum' => ['json_ld'],
182 'default' => 'json_ld'
183 ],
184 'validation_level' => [
185 'type' => 'string',
186 'title' => 'Validation Level',
187 'description' => 'Schema validation strictness level',
188 'enum' => ['strict', 'moderate', 'lenient'],
189 'default' => 'moderate'
190 ],
191 'rich_snippets_optimization' => [
192 'type' => 'boolean',
193 'title' => 'Rich Snippets Optimization',
194 'description' => 'Optimize schema for rich snippets in search results',
195 'default' => true
196 ],
197 'cache_duration' => [
198 'type' => 'integer',
199 'title' => 'Cache Duration',
200 'description' => 'Schema cache duration in seconds',
201 'minimum' => 300,
202 'maximum' => 86400,
203 'default' => 3600
204 ],
205 'auto_deploy' => [
206 'type' => 'boolean',
207 'title' => 'Auto Deploy',
208 'description' => 'Automatically deploy generated schema markup',
209 'default' => true
210 ]
211 ];
212 }
213
214 /**
215 * Get supported schema types for context
216 *
217 * @since 1.0.0
218 *
219 * @param string $context_type Context type
220 * @return array Supported schema types
221 */
222 public static function get_supported_schema_types(string $context_type = 'site'): array {
223 $all_types = [
224 'Article', 'Product', 'Organization', 'LocalBusiness',
225 'Person', 'WebSite', 'FAQPage', 'SoftwareApplication',
226 'Event', 'HowTo', 'Review', 'VideoObject',
227 // The WebPage family, which the per-page selector can now offer
228 // (#624). Kept last so an existing site's ordering is unchanged.
229 'WebPage', 'AboutPage', 'ContactPage', 'ProfilePage'
230 ];
231
232 // Context-specific filtering can be added here if needed
233 return $all_types;
234 }
235
236 /**
237 * Get validation level options
238 *
239 * @since 1.0.0
240 *
241 * @return array Validation level options
242 */
243 public static function get_validation_level_options(): array {
244 return [
245 ['value' => 'strict', 'label' => 'Strict'],
246 ['value' => 'moderate', 'label' => 'Moderate'],
247 ['value' => 'lenient', 'label' => 'Lenient']
248 ];
249 }
250
251 /**
252 * Get deployment method options
253 *
254 * @since 1.0.0
255 *
256 * @return array Deployment method options
257 */
258 public static function get_deployment_method_options(): array {
259 return [
260 ['value' => 'json_ld', 'label' => 'JSON-LD']
261 ];
262 }
263
264 /**
265 * Get boolean settings list
266 *
267 * @since 1.0.0
268 *
269 * @return array List of boolean setting keys
270 */
271 public static function get_boolean_settings(): array {
272 return [
273 'enabled',
274 'auto_generate_schema',
275 'rich_snippets_optimization',
276 'auto_deploy',
277 'organization_schema',
278 'knowledge_graph',
279 'enable_breadcrumbs_schema',
280 'enable_article_schema',
281 'enable_product_schema',
282 'enable_local_business',
283 'enable_faq_schema',
284 'enable_howto_schema',
285 'enable_accordion_faq_schema'
286 ];
287 }
288
289 /**
290 * Get array settings list
291 *
292 * @since 1.0.0
293 *
294 * @return array List of array setting keys
295 */
296 public static function get_array_settings(): array {
297 return [
298 'enabled_schema_types',
299 'business_opening_hours',
300 'software_operating_systems',
301 'software_features',
302 'howto_supply'
303 ];
304 }
305
306 /**
307 * Get integer settings list
308 *
309 * @since 1.0.0
310 *
311 * @return array List of integer setting keys
312 */
313 public static function get_integer_settings(): array {
314 return [
315 'cache_duration'
316 ];
317 }
318 }
319