PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.10.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.10.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 1.25.0 trunk 1.0.0 1.0.1 All 51 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.10.0, at includes/config/schema-settings-config.php

309 lines 9.9 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 // Removed post/page-specific schema settings (Product, Event, Article, Software Application, HowTo, FAQ)
93 // These are now handled only at the post/page level via metabox
94
95 // Person schema settings (site-wide)
96 'person_name' => '',
97 'person_job_title' => '',
98 'person_description' => '',
99 'person_image' => '',
100 'person_url' => '',
101 'person_email' => '',
102 'person_telephone' => '',
103 'person_address' => '',
104 'person_birth_date' => '',
105 'person_nationality' => '',
106 'person_works_for' => '',
107 'person_same_as' => [],
108
109 // Removed FAQPage schema settings (now handled at post/page level)
110 ];
111
112 // Context-specific defaults
113 switch ($context_type) {
114 case 'site':
115 $defaults['enabled_schema_types'] = ['Organization', 'LocalBusiness'];
116 $defaults['auto_deploy'] = true;
117 break;
118 case 'post':
119 $defaults['enabled_schema_types'] = ['Article', 'Person'];
120 $defaults['validation_level'] = 'strict';
121 break;
122 case 'page':
123 $defaults['enabled_schema_types'] = ['Article', 'FAQPage'];
124 $defaults['rich_snippets_optimization'] = true;
125 break;
126 case 'product':
127 $defaults['enabled_schema_types'] = ['Product'];
128 $defaults['validation_level'] = 'strict';
129 $defaults['rich_snippets_optimization'] = true;
130 break;
131 }
132
133 return $defaults;
134 }
135
136 /**
137 * Get settings schema definition
138 *
139 * @since 1.0.0
140 *
141 * @param string $context_type Context type
142 * @return array Settings schema definition
143 */
144 public static function get_settings_schema(string $context_type = 'site'): array {
145 return [
146 'enabled' => [
147 'type' => 'boolean',
148 'title' => 'Enable Schema Management',
149 'description' => 'Enable automated schema markup generation and management',
150 'default' => true
151 ],
152 'auto_generate_schema' => [
153 'type' => 'boolean',
154 'title' => 'Auto-Generate Schema',
155 'description' => 'Automatically generate schema markup based on content',
156 'default' => true
157 ],
158 'enabled_schema_types' => [
159 'type' => 'array',
160 'title' => 'Enabled Schema Types',
161 'description' => 'Select which schema types to generate',
162 'items' => [
163 'type' => 'string',
164 'enum' => self::get_supported_schema_types($context_type)
165 ],
166 'default' => []
167 ],
168 'deployment_method' => [
169 'type' => 'string',
170 'title' => 'Deployment Method',
171 'description' => 'Schema markup output format (JSON-LD)',
172 'enum' => ['json_ld'],
173 'default' => 'json_ld'
174 ],
175 'validation_level' => [
176 'type' => 'string',
177 'title' => 'Validation Level',
178 'description' => 'Schema validation strictness level',
179 'enum' => ['strict', 'moderate', 'lenient'],
180 'default' => 'moderate'
181 ],
182 'rich_snippets_optimization' => [
183 'type' => 'boolean',
184 'title' => 'Rich Snippets Optimization',
185 'description' => 'Optimize schema for rich snippets in search results',
186 'default' => true
187 ],
188 'cache_duration' => [
189 'type' => 'integer',
190 'title' => 'Cache Duration',
191 'description' => 'Schema cache duration in seconds',
192 'minimum' => 300,
193 'maximum' => 86400,
194 'default' => 3600
195 ],
196 'auto_deploy' => [
197 'type' => 'boolean',
198 'title' => 'Auto Deploy',
199 'description' => 'Automatically deploy generated schema markup',
200 'default' => true
201 ]
202 ];
203 }
204
205 /**
206 * Get supported schema types for context
207 *
208 * @since 1.0.0
209 *
210 * @param string $context_type Context type
211 * @return array Supported schema types
212 */
213 public static function get_supported_schema_types(string $context_type = 'site'): array {
214 $all_types = [
215 'Article', 'Product', 'Organization', 'LocalBusiness',
216 'Person', 'WebSite', 'FAQPage', 'SoftwareApplication',
217 'Event', 'HowTo', 'Review', 'VideoObject',
218 // The WebPage family, which the per-page selector can now offer
219 // (#624). Kept last so an existing site's ordering is unchanged.
220 'WebPage', 'AboutPage', 'ContactPage', 'ProfilePage'
221 ];
222
223 // Context-specific filtering can be added here if needed
224 return $all_types;
225 }
226
227 /**
228 * Get validation level options
229 *
230 * @since 1.0.0
231 *
232 * @return array Validation level options
233 */
234 public static function get_validation_level_options(): array {
235 return [
236 ['value' => 'strict', 'label' => 'Strict'],
237 ['value' => 'moderate', 'label' => 'Moderate'],
238 ['value' => 'lenient', 'label' => 'Lenient']
239 ];
240 }
241
242 /**
243 * Get deployment method options
244 *
245 * @since 1.0.0
246 *
247 * @return array Deployment method options
248 */
249 public static function get_deployment_method_options(): array {
250 return [
251 ['value' => 'json_ld', 'label' => 'JSON-LD']
252 ];
253 }
254
255 /**
256 * Get boolean settings list
257 *
258 * @since 1.0.0
259 *
260 * @return array List of boolean setting keys
261 */
262 public static function get_boolean_settings(): array {
263 return [
264 'enabled',
265 'auto_generate_schema',
266 'rich_snippets_optimization',
267 'auto_deploy',
268 'organization_schema',
269 'knowledge_graph',
270 'enable_breadcrumbs_schema',
271 'enable_article_schema',
272 'enable_product_schema',
273 'enable_local_business',
274 'enable_faq_schema',
275 'enable_howto_schema'
276 ];
277 }
278
279 /**
280 * Get array settings list
281 *
282 * @since 1.0.0
283 *
284 * @return array List of array setting keys
285 */
286 public static function get_array_settings(): array {
287 return [
288 'enabled_schema_types',
289 'business_opening_hours',
290 'software_operating_systems',
291 'software_features',
292 'howto_supply'
293 ];
294 }
295
296 /**
297 * Get integer settings list
298 *
299 * @since 1.0.0
300 *
301 * @return array List of integer setting keys
302 */
303 public static function get_integer_settings(): array {
304 return [
305 'cache_duration'
306 ];
307 }
308 }
309