PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.7.1
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.7.1
2.7.1 2.7.2 2.7.0 2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 All 141 releases
← All changes | includes/class-metasync-settings-fields.php +221 -97 2.6.23 → 2.7.1 View file →
@@ -46,9 +46,15 @@
46 46 // Accordion / Section helpers
47 47 // ────────────────────────────────────────────────────────────────
48 48
49 49 public function get_accordion_sections_config() {
50 - return array(
50 + // Consent switch for writing into other SEO plugins. Loaded here rather
51 + // than through the committed classmap so a stale autoload map can never
52 + // make the switch — and with it the user's only way to stop those
53 + // writes — silently disappear from the page.
54 + require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-metasync-seo-sync-settings.php';
55 +
56 + $sections = array(
51 57 'connection' => array(
52 58 'title' => 'Connection & Authentication',
53 59 'description' => 'Manage your API connection and authentication settings',
54 60 'icon' => 'admin-network',
@@ -68,8 +74,9 @@
68 74 'fields' => array(
69 75 'otto_pixel_uuid',
70 76 'otto_disable_on_loggedin',
71 77 'otto_disable_preview_button',
78 + 'seo_priority',
72 79 'otto_wp_rocket_compat',
73 80 'otto_sg_optimizer_compat',
74 81 'bookingpress_session_compat',
75 82 )
@@ -81,8 +88,16 @@
81 88 'priority' => 22,
82 89 'default_open' => false,
83 90 'render_callback' => array('Metasync_Edge_Cache_Settings', 'render'),
84 91 ),
92 + 'seo_plugin_sync' => array(
93 + 'title' => 'Sync to Other SEO Plugins',
94 + 'description' => 'Control whether ' . Metasync::get_whitelabel_otto_name() . '\'s SEO values are written into Yoast, Rank Math or All in One SEO',
95 + 'icon' => 'update',
96 + 'priority' => 23,
97 + 'default_open' => false,
98 + 'render_callback' => array('Metasync_Seo_Sync_Settings', 'render'),
99 + ),
85 100 'bot_detection' => array(
86 101 'title' => 'Bot Detection & Filtering',
87 102 'description' => 'Manage bot traffic and reduce unnecessary API calls',
88 103 'icon' => 'filter',
@@ -94,16 +109,8 @@
94 109 'otto_bot_blacklist',
95 110 'otto_bot_statistics_link'
96 111 )
97 112 ),
98 - 'breadcrumbs' => array(
99 - 'title' => 'Breadcrumbs',
100 - 'description' => 'Configure breadcrumb navigation display',
101 - 'icon' => 'format-links',
102 - 'priority' => 35,
103 - 'default_open' => false,
104 - 'render_callback' => array($this, 'render_breadcrumbs_section')
105 - ),
106 113 'open_graph' => array(
107 114 'title' => 'Open Graph',
108 115 'description' => 'Control which Open Graph and article meta tags are output',
109 116 'icon' => 'share',
@@ -130,8 +137,9 @@
130 137 'disable_redirection_metabox',
131 138 'disable_canonical_metabox',
132 139 'disable_social_opengraph_metabox',
133 140 'disable_schema_markup_metabox',
141 + 'disable_language_alternates_metabox',
134 142 'disable_seo_metabox',
135 143 'open_external_links'
136 144 )
137 145 ),
@@ -172,13 +180,22 @@
172 180 'fields' => array(
173 181 'permalink_structure',
174 182 'hide_dashboard_framework',
175 183 'show_admin_bar_status',
176 - 'enable_auto_updates',
177 184 'import_external_data'
178 185 )
179 186 )
180 187 );
188 +
189 + // Hidden only when there is nothing to say: no SEO plugin installed, the
190 + // switch off, and no saved originals. It is never hidden by the
191 + // access-control or whitelabel flags that can conceal Advanced Settings
192 + // — a switch that rewrites another plugin's data must stay reachable.
193 + if (!Metasync_Seo_Sync_Settings::should_display()) {
194 + unset($sections['seo_plugin_sync']);
195 + }
196 +
197 + return $sections;
181 198 }
182 199
183 200 public function get_advanced_accordion_config() {
184 201 $config = array();
@@ -203,8 +220,17 @@
203 220 'default_open' => false,
204 221 'render_callback' => array($this->admin_instance, 'render_debug_mode_section')
205 222 );
206 223
224 + $config['headless_mode'] = array(
225 + 'title' => 'Headless Mode',
226 + 'description' => 'Connect WordPress content to a separate public frontend',
227 + 'icon' => 'admin-site-alt3',
228 + 'priority' => 29,
229 + 'default_open' => false,
230 + 'render_callback' => array(Metasync_Settings_Registration::instance(), 'render_headless_mode_section')
231 + );
232 +
207 233 $config['error_logs'] = array(
208 234 'title' => 'Error Logs',
209 235 'description' => 'View and manage error logs to troubleshoot issues',
210 236 'icon' => 'warning',
@@ -277,9 +303,9 @@
277 303 $content_state = $is_open ? 'open' : 'closed';
278 304
279 305 echo '<div class="metasync-accordion-section" data-section="' . esc_attr($section_key) . '">';
280 306
281 - echo '<div class="metasync-accordion-header" role="button" tabindex="0" aria-expanded="' . $aria_expanded . '" aria-controls="' . $section_id . '">';
307 + echo '<div class="metasync-accordion-header" role="button" tabindex="0" aria-expanded="' . esc_attr($aria_expanded) . '" aria-controls="' . esc_attr($section_id) . '">';
282 308 echo '<div class="metasync-accordion-title">';
283 309 echo '<span class="metasync-accordion-icon"><span class="dashicons dashicons-' . esc_attr($section_data['icon']) . '"></span></span>';
284 310 echo '<div class="metasync-accordion-text">';
285 311 echo '<h3>' . esc_html($section_data['title']) . '</h3>';
@@ -290,9 +316,9 @@
290 316 echo '<span class="toggle-icon">▼</span>';
291 317 echo '</button>';
292 318 echo '</div>';
293 319
294 - echo '<div class="metasync-accordion-content" id="' . $section_id . '" data-state="' . $content_state . '">';
320 + echo '<div class="metasync-accordion-content" id="' . esc_attr($section_id) . '" data-state="' . esc_attr($content_state) . '">';
295 321
296 322 if (isset($section_data['render_callback']) && is_callable($section_data['render_callback'])) {
297 323 call_user_func($section_data['render_callback']);
298 324 }
@@ -331,8 +357,31 @@
331 357 <span class="dashicons dashicons-trash" style="margin-top:3px;font-size:15px;width:15px;height:15px;"></span> Clear All Settings
332 358 </button>
333 359 </form>
334 360 </div>
361 + <div style="background: var(--dashboard-card-bg); padding: 20px; border-radius: 8px; margin-top: 20px;">
362 + <h4 style="color: var(--dashboard-text-primary, #1e1e1e); margin: 0 0 12px 0; display: flex; align-items: center; gap: 8px;">
363 + <span class="dashicons dashicons-universal-access-alt" style="font-size:18px;width:18px;height:18px;"></span>
364 + <span>Delete data on uninstall</span>
365 + </h4>
366 + <p style="color: var(--dashboard-text-secondary); margin: 0 0 12px 0;">
367 + By default, deleting the plugin keeps your data: sitemap and redirection settings, per-post SEO values, and the plugin's database tables stay in place in case you reinstall. Enable this to also remove all of that when the plugin itself is deleted from the Plugins screen.
368 + </p>
369 + <p style="color: var(--dashboard-text-secondary); margin: 0 0 12px 0;">
370 + The Google service account and the IndexNow API key are always deleted on uninstall, regardless of this setting.
371 + </p>
372 + <form method="post" action="">
373 + <?php wp_nonce_field('metasync_uninstall_data_toggle_nonce', 'uninstall_data_toggle_nonce'); ?>
374 + <input type="hidden" name="metasync_uninstall_data_toggle_form" value="1" />
375 + <label style="color: var(--dashboard-text-primary, #1e1e1e); display: flex; align-items: center; gap: 8px; margin: 0 0 12px 0; cursor: pointer;">
376 + <input type="checkbox" name="metasync_delete_data_on_uninstall" value="yes" <?php checked(get_option('metasync_delete_data_on_uninstall', 'no'), 'yes'); ?> />
377 + Delete all plugin data (tables, settings, per-post SEO values, logs) when the plugin is uninstalled
378 + </label>
379 + <button type="submit" class="button button-secondary">
380 + Save Uninstall Setting
381 + </button>
382 + </form>
383 + </div>
335 384 <script>
336 385 function confirmClearSettings(event) {
337 386 event.preventDefault();
338 387
@@ -363,14 +412,18 @@
363 412 if (!function_exists('google_index_direct')) {
364 413 if (file_exists(plugin_dir_path(dirname(__FILE__)) . 'google-index/google-index-init.php')) {
365 414 require_once plugin_dir_path(dirname(__FILE__)) . 'google-index/google-index-init.php';
366 415 } else {
367 - error_log('MetaSync Google Index: google-index-init.php not found at ' . plugin_dir_path(dirname(__FILE__)) . 'google-index/google-index-init.php');
416 + error_log('MetaSync Google Index: google-index-init.php not found at ' . plugin_dir_path(dirname(__FILE__)) . 'google-index/google-index-init.php'); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- genuine failure path, bounded, no secrets
368 417 return;
369 418 }
370 419 }
371 420
372 421 $google_index = google_index_direct();
422 + if (!$google_index) {
423 + // Nothing to render against, and calling through would be fatal.
424 + return;
425 + }
373 426 $service_info = $google_index->get_service_account_info();
374 427 $is_configured = !isset($service_info['error']);
375 428
376 429 $saved_json_display = $is_configured ? $google_index->get_redacted_config_json() : '';
@@ -649,9 +702,9 @@
649 702 <p style="color: var(--dashboard-text-secondary); margin: 0 0 20px 0;">
650 703 Select which user roles can see and access this plugin's menu, settings, and options in the WordPress admin area.
651 704 </p>
652 705
653 - <form method="post" action="<?php echo admin_url('admin.php?page=' . Metasync_Admin::$page_slug . '&tab=advanced'); ?>" id="plugin-access-roles-form">
706 + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=' . Metasync_Admin::$page_slug . '&tab=advanced')); ?>" id="plugin-access-roles-form">
654 707 <?php wp_nonce_field('metasync_plugin_access_roles_nonce', 'plugin_access_roles_nonce'); ?>
655 708 <input type="hidden" name="save_plugin_access_roles" value="yes" />
656 709
657 710 <div class="metasync-role-selector-container" style="background: var(--dashboard-card-bg-alt, rgba(255,255,255,0.05)); border: 1px solid var(--dashboard-border); border-radius: 8px; padding: 16px; max-height: 300px; overflow-y: auto;">
@@ -769,9 +822,9 @@
769 822
770 823 public function can_change_memory_limit() {
771 824 $current_limit = ini_get('memory_limit');
772 825
773 - $test_result = @ini_set('memory_limit', $current_limit);
826 + $test_result = @ini_set('memory_limit', $current_limit); // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged -- runtime PHP setting with no WordPress API
774 827
775 828 return $test_result !== false;
776 829 }
777 830
@@ -823,9 +876,9 @@
823 876 }
824 877
825 878 $memory_limit_mb = $this->get_execution_setting('max_memory_limit');
826 879
827 - $result = @ini_set('memory_limit', $memory_limit_mb . 'M');
880 + $result = @ini_set('memory_limit', $memory_limit_mb . 'M'); // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged -- runtime PHP setting with no WordPress API
828 881
829 882 return $result !== false;
830 883 }
831 884
@@ -1077,8 +1130,9 @@
1077 1130 'apikey' => sprintf('Auto-generated authentication token used for secure API communication between your WordPress site and %s services. You can refresh this token if needed for security purposes.', $plugin_name),
1078 1131 'otto_pixel_uuid' => sprintf('Your unique %s tracking pixel identifier. This UUID is used to track %s modifications and analytics on your website pages.', $otto_name, $otto_name),
1079 1132 'otto_disable_on_loggedin' => sprintf('Disable %s modifications when you are logged in to WordPress. This allows you to see and edit the original content without %s\'s enhancements during editing sessions.', $otto_name, $otto_name),
1080 1133 'otto_disable_preview_button' => sprintf('Hide the %s frontend toolbar that displays the status indicator, preview button, and debug button. Enable this for a cleaner frontend experience.', $otto_name),
1134 + 'seo_priority' => sprintf('Choose which value appears first on a page when both your custom SEO value and an approved %s suggestion are available. This changes what visitors see; it does not delete or overwrite saved values.', $otto_name),
1081 1135 'otto_wp_rocket_compat' => sprintf('WP Rocket Compatibility Mode: Controls how %s interacts with WP Rocket. "Auto" (recommended) allows both to work together by avoiding DONOTCACHEPAGE constant unless necessary for Brizy pages or SG Optimizer conflicts. This ensures WP Rocket\'s JavaScript delay and optimization features continue working.', $otto_name),
1082 1136 'otto_sg_optimizer_compat' => sprintf('SiteGround Optimizer Compatibility Mode: Controls how %s renders on SiteGround hosting. "Auto" (recommended) uses the internal HTTP fetch, which protects themes that defer inline CSS to the footer (e.g. Divi). "Buffer Mode" renders in-process with no internal fetch — faster on sites whose pages can never be host-cached, for example when a plugin starts a PHP session on every request (BookingPress sessions are removed automatically, so this does not apply to them).', $otto_name),
1083 1137 'bookingpress_session_compat' => 'BookingPress Session Compatibility: Controls whether MetaSync removes the PHP session BookingPress starts on every public page, so hosts such as SiteGround can page-cache the site again.',
1084 1138 'otto_disable_for_bots' => sprintf('Enable bot detection to automatically skip %s processing for search engine crawlers, SEO tools, and other bots. This reduces unnecessary API calls and improves performance.', $otto_name),
@@ -1084,14 +1138,15 @@
1084 1138 'otto_disable_for_bots' => sprintf('Enable bot detection to automatically skip %s processing for search engine crawlers, SEO tools, and other bots. This reduces unnecessary API calls and improves performance.', $otto_name),
1085 1139 'otto_bot_whitelist' => sprintf('Enter bot names or user-agent patterns (one per line) that should always be processed by %s, even when "Disable for Bots" is enabled. For example: Googlebot, Bingbot. This allows you to ensure specific search engines always see your optimized content.', $otto_name),
1086 1140 'otto_bot_blacklist' => sprintf('Enter bot names or user-agent patterns (one per line) that should always be blocked from %s processing, regardless of other settings. For example: BadBot, MaliciousCrawler. Use this to exclude problematic crawlers or unwanted traffic sources.', $otto_name),
1087 1141 'otto_bot_statistics_link' => 'View detailed bot detection statistics including total hits, API calls saved, breakdown by bot type, and unique bot entries with hit counts.',
1088 - 'disable_common_robots_metabox' => 'Hide the Common Robots meta box from post and page edit screens. This removes the robots meta tag controls (index/noindex, follow/nofollow) from the editor interface.',
1089 - 'disable_advance_robots_metabox' => 'Hide the Advanced Robots meta box from post and page edit screens. This removes advanced robots directives like max-snippet, max-image-preview, and max-video-preview settings.',
1090 - 'disable_redirection_metabox' => 'Hide the Redirection meta box from post and page edit screens. This removes the URL redirect configuration options from the editor interface.',
1091 - 'disable_canonical_metabox' => 'Hide the Canonical URL meta box from post and page edit screens. This removes the canonical URL override field from the editor interface.',
1092 - 'disable_social_opengraph_metabox' => 'Hide the Social Media & Open Graph meta box from post and page edit screens. This removes Facebook, Twitter, and other social media meta tag controls from the editor.',
1093 - 'disable_schema_markup_metabox' => 'Hide the Schema Markup meta box from post and page edit screens. This removes the structured data (Article, FAQ, Product, Recipe, etc.) configuration from the editor interface.',
1142 + 'disable_common_robots_metabox' => sprintf('Hide the Common Robots meta box and stop %1$s emitting index/noindex and follow/nofollow directives on the front end. %1$s also stops overriding WordPress core or another SEO plugin\'s robots tag. Saved values are kept and restored if you re-enable this.', Metasync::get_effective_plugin_name('MetaSync')),
1143 + 'disable_advance_robots_metabox' => sprintf('Hide the Advanced Robots meta box and stop %1$s emitting max-snippet, max-image-preview and max-video-preview directives, including the site-wide advanced defaults. Saved values are kept and restored if you re-enable this.', Metasync::get_effective_plugin_name('MetaSync')),
1144 + 'disable_redirection_metabox' => 'Hide the Redirection meta box and stop redirects configured through it from running. Rules added by hand on the Redirections screen keep working. Saved redirects are kept and resume if you re-enable this.',
1145 + 'disable_canonical_metabox' => sprintf('Hide the Canonical meta box and stop %1$s emitting or overriding the canonical URL on every render path. WordPress core and third-party canonicals are left in place. Saved values are kept and restored if you re-enable this.', Metasync::get_effective_plugin_name('MetaSync')),
1146 + 'disable_social_opengraph_metabox' => sprintf('Hide the Social Media & Open Graph meta box and stop %1$s emitting any Open Graph, Twitter or article tags. Tags from another SEO plugin are left in place. Saved values are kept and restored if you re-enable this.', Metasync::get_effective_plugin_name('MetaSync')),
1147 + 'disable_schema_markup_metabox' => sprintf('Hide the Schema Markup meta box and stop %1$s emitting any JSON-LD, including the site-wide Local SEO markup and OTTO structured data. Breadcrumb markup has its own setting. Saved values are kept and restored if you re-enable this.', Metasync::get_effective_plugin_name('MetaSync')),
1148 + 'disable_language_alternates_metabox' => sprintf('Hide the Language Alternates (hreflang) panel in the block editor and stop %1$s emitting any hreflang tags on the front end, including the auto-detected WPML entries. While disabled, %1$s does not manage or override this data — another SEO plugin, or WPML itself, is free to handle it. Saved values are kept and restored if you re-enable this.', Metasync::get_effective_plugin_name('MetaSync')),
1094 1149 'disable_seo_metabox' => 'Hide the SEO Title & Meta Description meta box from post and page edit screens. This removes the Classic editor SEO fields (the Gutenberg sidebar is unaffected).',
1095 1150 'open_external_links' => sprintf('Automatically add target="_blank" attribute to external links appearing in your posts, pages, and other post types when rendered by %s.', $otto_name),
1096 1151 'content_genius_sync_roles' => 'Select which WordPress user roles should be synchronized with Content Genius. This determines which users will have their profiles and permissions synced for content collaboration.',
1097 1152 'permalink_structure' => sprintf('Displays your current WordPress permalink structure. %s works best with pretty permalinks (not "Plain"). If you see a warning, visit Settings > Permalinks to change your structure.', $plugin_name),
@@ -1096,9 +1151,8 @@
1096 1151 'content_genius_sync_roles' => 'Select which WordPress user roles should be synchronized with Content Genius. This determines which users will have their profiles and permissions synced for content collaboration.',
1097 1152 'permalink_structure' => sprintf('Displays your current WordPress permalink structure. %s works best with pretty permalinks (not "Plain"). If you see a warning, visit Settings > Permalinks to change your structure.', $plugin_name),
1098 1153 'hide_dashboard_framework' => sprintf('Hide the main %s dashboard from the WordPress admin menu. This is useful if you want to reduce menu clutter but still keep the plugin active.', $plugin_name),
1099 1154 'show_admin_bar_status' => sprintf('Display the %s status indicator in the WordPress admin bar at the top of your screen. This provides quick visibility of plugin status and key metrics.', $plugin_name),
1100 - 'enable_auto_updates' => sprintf('Allow WordPress to automatically update the %s plugin when new versions are released. Recommended for security patches, but you may prefer manual updates for major versions.', $plugin_name),
1101 1155 'import_external_data' => sprintf('Import your existing SEO settings and metadata from other popular SEO plugins like Yoast, Rank Math, or All in One SEO. This makes migration to %s seamless without losing your SEO data.', $plugin_name),
1102 1156 'import_seo_metadata' => sprintf('Migrate your existing SEO titles and meta descriptions from Yoast, Rank Math, or All in One SEO. This one-click import preserves your search rankings by copying your optimized meta data to %s, even if the source plugin is deactivated.', $plugin_name),
1103 1157 'default_page_builder' => 'Choose how Content Genius stores synced articles. "Gutenberg" works with all themes and page builders. Selecting a specific builder converts content to that builder\'s widget format, which inherits the builder\'s global typography and layout styles.',
1104 1158 'og_image_dimensions' => 'Adds your share image\'s width, height, and file type to the Open Graph tags so Facebook, LinkedIn, and others render your preview instantly at the right size instead of guessing. Leave on unless another plugin already outputs these.',
@@ -1144,9 +1198,9 @@
1144 1198 $content_state = $is_open ? 'open' : 'closed';
1145 1199
1146 1200 echo '<div class="metasync-accordion-section" data-section="' . esc_attr($section_key) . '">';
1147 1201
1148 - echo '<div class="metasync-accordion-header" role="button" tabindex="0" aria-expanded="' . $aria_expanded . '" aria-controls="' . $section_id . '">';
1202 + echo '<div class="metasync-accordion-header" role="button" tabindex="0" aria-expanded="' . esc_attr($aria_expanded) . '" aria-controls="' . esc_attr($section_id) . '">';
1149 1203 echo '<div class="metasync-accordion-title">';
1150 1204 echo '<span class="metasync-accordion-icon"><span class="dashicons dashicons-' . esc_attr($section_data['icon']) . '"></span></span>';
1151 1205 echo '<div class="metasync-accordion-text">';
1152 1206 echo '<h3>' . esc_html($section_data['title']) . '</h3>';
@@ -1157,9 +1211,9 @@
1157 1211 echo '<span class="toggle-icon">▼</span>';
1158 1212 echo '</button>';
1159 1213 echo '</div>';
1160 1214
1161 - echo '<div class="metasync-accordion-content" id="' . $section_id . '" data-state="' . $content_state . '">';
1215 + echo '<div class="metasync-accordion-content" id="' . esc_attr($section_id) . '" data-state="' . esc_attr($content_state) . '">';
1162 1216
1163 1217 if (isset($section_data['render_callback']) && is_callable($section_data['render_callback'])) {
1164 1218 call_user_func($section_data['render_callback']);
1165 1219 } elseif (isset($section_data['fields']) && is_array($section_data['fields'])) {
@@ -1174,9 +1228,9 @@
1174 1228 echo '<tr>';
1175 1229 echo '<th scope="row">';
1176 1230 if (!empty($field['title'])) {
1177 1231 echo '<div class="metasync-field-label-wrapper">';
1178 - echo '<label for="' . esc_attr($field['id']) . '">' . $field['title'] . '</label>';
1232 + echo '<label for="' . esc_attr($field['id']) . '">' . esc_html($field['title']) . '</label>';
1179 1233
1180 1234 if (isset($tooltips[$field_id])) {
1181 1235 echo '<button type="button" class="metasync-tooltip-trigger" data-tooltip-id="' . esc_attr($field_id) . '" aria-label="More information">';
1182 1236 echo '<svg class="metasync-info-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">';
@@ -1231,9 +1285,9 @@
1231 1285 echo '<tr>';
1232 1286 echo '<th scope="row">';
1233 1287 if (!empty($field['title'])) {
1234 1288 echo '<div class="metasync-field-label-wrapper">';
1235 - echo '<label for="' . esc_attr($field['id']) . '">' . $field['title'] . '</label>';
1289 + echo '<label for="' . esc_attr($field['id']) . '">' . esc_html($field['title']) . '</label>';
1236 1290 if (isset($llms_tooltips[$field['id']])) {
1237 1291 Metasync::render_tooltip_icon($field['id'], $llms_tooltips[$field['id']]);
1238 1292 }
1239 1293 echo '</div>';
@@ -1287,32 +1341,32 @@
1287 1341 $display_value = $current_token;
1288 1342 $status_message = 'Plugin Auth Token is active and ready for authentication.';
1289 1343 $refresh_help = 'Click refresh to generate a new token and update the heartbeat API.';
1290 1344 } else {
1291 - $display_value = 'Auto-generated when connecting to ' . esc_html(Metasync::get_effective_plugin_name());
1292 - $status_message = 'Plugin Auth Token will be automatically generated when you click "Connect to ' . esc_html(Metasync::get_effective_plugin_name()) . '".';
1345 + $display_value = 'Auto-generated when connecting to ' . Metasync::get_effective_plugin_name();
1346 + $status_message = 'Plugin Auth Token will be automatically generated when you click "Connect to ' . Metasync::get_effective_plugin_name() . '".';
1293 1347 $refresh_help = 'You can also manually generate a token by clicking refresh.';
1294 1348 }
1295 1349
1296 1350 printf('<div class="metasync-auth-token-row">');
1297 1351 printf(
1298 - '<input type="text" id="apikey" name="' . Metasync_Admin::option_key . '[general][apikey]" value="%s" size="40" class="regular-text" readonly="readonly" />',
1352 + '<input type="text" id="apikey" name="' . esc_attr(Metasync_Admin::option_key) . '[general][apikey]" value="%s" size="40" class="regular-text" readonly="readonly" />',
1299 1353 esc_attr($display_value)
1300 1354 );
1301 1355 printf('<button type="button" id="refresh-plugin-auth-token" class="button button-secondary metasync-refresh-token-btn"><span class="dashicons dashicons-controls-repeat"></span> Refresh Token</button>');
1302 1356 printf('</div>');
1303 - printf('<p class="description">%s %s</p>', $status_message, $refresh_help);
1357 + printf('<p class="description">%s %s</p>', esc_html($status_message), esc_html($refresh_help));
1304 1358 }
1305 1359
1306 1360 public function linkgraph_token_callback()
1307 1361 {
1308 1362 printf(
1309 - '<input type="text" id="linkgraph_token" name="' . Metasync_Admin::option_key . '[general][linkgraph_token]" value="%s" size="25" readonly="readonly" />',
1363 + '<input type="text" id="linkgraph_token" name="' . esc_attr(Metasync_Admin::option_key) . '[general][linkgraph_token]" value="%s" size="25" readonly="readonly" />',
1310 1364 isset(Metasync::get_option('general')['linkgraph_token']) ? esc_attr(Metasync::get_option('general')['linkgraph_token']) : ''
1311 1365 );
1312 1366
1313 1367 printf(
1314 - '<input type="text" id="linkgraph_customer_id" name="' . Metasync_Admin::option_key . '[general][linkgraph_customer_id]" value="%s" size="25" readonly="readonly" />',
1368 + '<input type="text" id="linkgraph_customer_id" name="' . esc_attr(Metasync_Admin::option_key) . '[general][linkgraph_customer_id]" value="%s" size="25" readonly="readonly" />',
1315 1369 isset(Metasync::get_option('general')['linkgraph_customer_id']) ? esc_attr(Metasync::get_option('general')['linkgraph_customer_id']) : ''
1316 1370 );
1317 1371
1318 1372 ?>
@@ -1437,9 +1491,9 @@
1437 1491 printf('• The authentication window will open in a popup - please allow popups<br/>');
1438 1492 printf('• The process typically takes 15-30 seconds to complete<br/>');
1439 1493 printf('• Your API key will be stored securely and shown masked below<br/>');
1440 1494 printf('• If you encounter issues, try disabling ad blockers temporarily<br/>');
1441 - printf('• Contact <a href="mailto:%s">%s</a> if you need assistance', Metasync::SUPPORT_EMAIL, Metasync::SUPPORT_EMAIL);
1495 + printf('• Contact <a href="mailto:%s">%s</a> if you need assistance', esc_attr(Metasync::SUPPORT_EMAIL), esc_html(Metasync::SUPPORT_EMAIL));
1442 1496 printf('</div>');
1443 1497 printf('</details>');
1444 1498 printf('</div>');
1445 1499
@@ -1491,9 +1545,9 @@
1491 1545 $timestamp = @Metasync::get_option('general')['send_auth_token_timestamp'];
1492 1546 printf(
1493 1547 '<p id="sendAuthTokenTimestamp" class="descriptionValue">%s (%s)</p>',
1494 1548 esc_attr($timestamp),
1495 - $this->time_elapsed_string($timestamp)
1549 + esc_html($this->time_elapsed_string($timestamp))
1496 1550 );
1497 1551
1498 1552
1499 1553 }
@@ -1501,9 +1555,9 @@
1501 1555
1502 1556 public function bing_site_verification_callback()
1503 1557 {
1504 1558 printf(
1505 - '<input type="text" id="bing_site_verification" name="' . Metasync_Admin::option_key . '[searchengines][bing_site_verification]" value="%s" size="50" />',
1559 + '<input type="text" id="bing_site_verification" name="' . esc_attr(Metasync_Admin::option_key) . '[searchengines][bing_site_verification]" value="%s" size="50" />',
1506 1560 isset(Metasync::get_option('searchengines')['bing_site_verification']) ? esc_attr(Metasync::get_option('searchengines')['bing_site_verification']) : ''
1507 1561 );
1508 1562
1509 1563 printf(' <br> <span class="description"> Enter Bing Webmaster Tools verification code: </span> ');
@@ -1512,9 +1566,9 @@
1512 1566
1513 1567 public function yandex_site_verification_callback()
1514 1568 {
1515 1569 printf(
1516 - '<input type="text" id="yandex_site_verification" name="' . Metasync_Admin::option_key . '[searchengines][yandex_site_verification]" value="%s" size="50" />',
1570 + '<input type="text" id="yandex_site_verification" name="' . esc_attr(Metasync_Admin::option_key) . '[searchengines][yandex_site_verification]" value="%s" size="50" />',
1517 1571 isset(Metasync::get_option('searchengines')['yandex_site_verification']) ? esc_attr(Metasync::get_option('searchengines')['yandex_site_verification']) : ''
1518 1572 );
1519 1573
1520 1574 printf(' <br> <span class="description"> Enter Yandex verification code: </span>');
@@ -1523,9 +1577,9 @@
1523 1577
1524 1578 public function google_site_verification_callback()
1525 1579 {
1526 1580 printf(
1527 - '<input type="text" id="google_site_verification" name="' . Metasync_Admin::option_key . '[searchengines][google_site_verification]" value="%s" size="50" />',
1581 + '<input type="text" id="google_site_verification" name="' . esc_attr(Metasync_Admin::option_key) . '[searchengines][google_site_verification]" value="%s" size="50" />',
1528 1582 isset(Metasync::get_option('searchengines')['google_site_verification']) ? esc_attr(Metasync::get_option('searchengines')['google_site_verification']) : ''
1529 1583 );
1530 1584
1531 1585 printf(' <br> <span class="description"> Enter Google Search Console verification code: </span>');
@@ -1534,9 +1588,9 @@
1534 1588
1535 1589 public function pinterest_site_verification_callback()
1536 1590 {
1537 1591 printf(
1538 - '<input type="text" id="pinterest_site_verification" name="' . Metasync_Admin::option_key . '[searchengines][pinterest_site_verification]" value="%s" size="50" />',
1592 + '<input type="text" id="pinterest_site_verification" name="' . esc_attr(Metasync_Admin::option_key) . '[searchengines][pinterest_site_verification]" value="%s" size="50" />',
1539 1593 isset(Metasync::get_option('searchengines')['pinterest_site_verification']) ? esc_attr(Metasync::get_option('searchengines')['pinterest_site_verification']) : ''
1540 1594 );
1541 1595
1542 1596 printf(' <br> <span class="description"> Enter Pinterest verification code: </span>');
@@ -1545,12 +1599,16 @@
1545 1599
1546 1600 public function local_seo_person_organization_callback()
1547 1601 {
1548 1602 $person_organization = Metasync::get_option('localseo')['local_seo_person_organization'] ?? '';
1603 + $valid_person_organizations = array('Person', 'Organization');
1549 1604 ?>
1550 1605 <div class="metasync-type-select-wrap">
1551 1606 <select id="local_seo_person_organization" name="<?php echo esc_attr(Metasync_Admin::option_key . '[localseo][local_seo_person_organization]') ?>">
1552 1607 <?php
1608 + if (!in_array($person_organization, $valid_person_organizations, true)) {
1609 + printf('<option value="0" selected="selected">Select Type</option>');
1610 + }
1553 1611 printf('<option value="Person" %s >Person</option>', selected('Person', esc_attr($person_organization)));
1554 1612 printf('<option value="Organization" %s >Organization</option>', selected('Organization', esc_attr($person_organization)));
1555 1613 ?>
1556 1614 </select>
@@ -1561,10 +1619,10 @@
1561 1619
1562 1620 public function local_seo_name_callback()
1563 1621 {
1564 1622 printf(
1565 - '<input type="text" id="local_seo_name" name="' . Metasync_Admin::option_key . '[localseo][local_seo_name]" value="%s" size="50" />',
1566 - isset(Metasync::get_option('localseo')['local_seo_name']) ? esc_attr(Metasync::get_option('localseo')['local_seo_name']) : get_bloginfo()
1623 + '<input type="text" id="local_seo_name" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_name]" value="%s" size="50" />',
1624 + isset(Metasync::get_option('localseo')['local_seo_name']) ? esc_attr(Metasync::get_option('localseo')['local_seo_name']) : esc_attr(get_bloginfo())
1567 1625 );
1568 1626
1569 1627 printf(' <br> <span class="description"> Your name or company name </span>');
1570 1628 }
@@ -1572,11 +1630,18 @@
1572 1630 public function local_seo_logo_callback()
1573 1631 {
1574 1632 $local_seo_logo = Metasync::get_option('localseo')['local_seo_logo'] ?? '';
1575 1633
1634 + // Rows saved by the legacy sanitizer hold the corrupted form of
1635 + // an attachment ID ("http://45589"). Repair it before anything reads
1636 + // the value — both so the preview resolves and so the hidden input
1637 + // re-submits the recovered ID instead of the corrupted string, which
1638 + // would otherwise survive every subsequent Save Settings.
1639 + $local_seo_logo = metasync_repair_scheme_prefixed_media_id($local_seo_logo);
1640 +
1576 1641 printf(
1577 - '<input type="hidden" id="local_seo_logo" name="' . Metasync_Admin::option_key . '[localseo][local_seo_logo]" value="%s" size="50" />',
1578 - isset(Metasync::get_option('localseo')['local_seo_logo']) ? esc_attr(Metasync::get_option('localseo')['local_seo_logo']) : ''
1642 + '<input type="hidden" id="local_seo_logo" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_logo]" value="%s" size="50" />',
1643 + esc_attr((string) $local_seo_logo)
1579 1644 );
1580 1645
1581 1646 printf(' <br> <input class="button-secondary no-loading" type="button" id="logo_upload_button" value="Add or Upload File">');
1582 1647
@@ -1582,23 +1647,65 @@
1582 1647
1583 1648 printf(' <br><br> <span class="description bold"> Min Size: 160Χ90px, Max Size: 1920X1080px. </span> <br> <span class="description"> A squared image is preferred by the search engines. </span> <br><br> ');
1584 1649
1585 1650 printf('<span class="metasync-logo-preview-wrap">');
1586 - printf('<img src="%s" id="local_seo_business_logo" width="300">', wp_get_attachment_image_src($local_seo_logo, 'medium')[0] ?? '');
1587 1651
1588 - $button_type = 'hidden';
1589 - if ($local_seo_logo) {
1590 - $button_type = 'button';
1652 + // The stored value may be an attachment ID or a raw URL, so resolve
1653 + // both the way the front-end schema output already does. Anything that
1654 + // resolves to nothing — a deleted attachment, a legacy value mangled by
1655 + // an earlier save — must render no preview at all, rather than an empty
1656 + // src next to an orphaned remove button.
1657 + $logo_url = $this->resolve_media_url($local_seo_logo, 'medium');
1658 +
1659 + printf(
1660 + '<img src="%s" id="local_seo_business_logo" width="300"%s>',
1661 + esc_url($logo_url),
1662 + $logo_url ? '' : ' style="display:none"'
1663 + );
1664 +
1665 + $button_type = $logo_url ? 'button' : 'hidden';
1666 + printf('<input type="%s" class="button-secondary no-loading metasync-logo-remove-btn" id="local_seo_logo_close_btn" value="X">', esc_attr($button_type));
1667 + printf('</span>');
1668 + }
1669 +
1670 + /**
1671 + * Resolve a stored media setting to a displayable URL.
1672 + *
1673 + * These settings accept either a media-library attachment ID or a raw URL;
1674 + * returns an empty string when the value resolves to neither, so callers
1675 + * can distinguish "no image" from "image we could not resolve".
1676 + *
1677 + * @param mixed $value Attachment ID or URL as stored in the options.
1678 + * @param string $size Registered image size to request for an attachment.
1679 + * @return string Resolved URL, or '' when there is nothing to show.
1680 + */
1681 + private function resolve_media_url($value, $size = 'medium')
1682 + {
1683 + if (empty($value)) {
1684 + return '';
1591 1685 }
1592 - printf('<input type="%s" class="button-secondary no-loading metasync-logo-remove-btn" id="local_seo_logo_close_btn" value="X">', $button_type);
1593 - printf('</span>');
1686 +
1687 + // A row saved by the legacy sanitizer stores a corrupted attachment ID ("http://45589"),
1688 + // which is neither resolvable as an ID nor a usable image URL.
1689 + $value = metasync_repair_scheme_prefixed_media_id($value);
1690 +
1691 + if (empty($value)) {
1692 + return '';
1693 + }
1694 +
1695 + if (is_numeric($value)) {
1696 + $url = wp_get_attachment_image_url((int) $value, $size);
1697 + return $url ? $url : '';
1698 + }
1699 +
1700 + return (string) $value;
1594 1701 }
1595 1702
1596 1703 public function local_seo_url_callback()
1597 1704 {
1598 1705 printf(
1599 - '<input type="text" id="local_seo_url" name="' . Metasync_Admin::option_key . '[localseo][local_seo_url]" value="%s" size="50" />',
1600 - isset(Metasync::get_option('localseo')['local_seo_url']) ? esc_attr(Metasync::get_option('localseo')['local_seo_url']) : home_url()
1706 + '<input type="text" id="local_seo_url" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_url]" value="%s" size="50" />',
1707 + isset(Metasync::get_option('localseo')['local_seo_url']) ? esc_attr(Metasync::get_option('localseo')['local_seo_url']) : esc_attr(home_url())
1601 1708 );
1602 1709
1603 1710 printf(' <br> <span class="description"> URL of the item. </span>');
1604 1711 }
@@ -1605,9 +1712,9 @@
1605 1712
1606 1713 public function local_seo_email_callback()
1607 1714 {
1608 1715 printf(
1609 - '<input type="text" id="local_seo_email" name="' . Metasync_Admin::option_key . '[localseo][local_seo_email]" value="%s" size="50" />',
1716 + '<input type="text" id="local_seo_email" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_email]" value="%s" size="50" />',
1610 1717 isset(Metasync::get_option('localseo')['local_seo_email']) ? esc_attr(Metasync::get_option('localseo')['local_seo_email']) : ''
1611 1718 );
1612 1719
1613 1720 printf(' <br> <span class="description"> Search engines display your email address. </span>');
@@ -1615,9 +1722,9 @@
1615 1722
1616 1723 public function local_seo_phone_callback()
1617 1724 {
1618 1725 printf(
1619 - '<input type="text" id="local_seo_phone" name="' . Metasync_Admin::option_key . '[localseo][local_seo_phone]" value="%s" size="50" />',
1726 + '<input type="text" id="local_seo_phone" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_phone]" value="%s" size="50" />',
1620 1727 isset(Metasync::get_option('localseo')['local_seo_phone']) ? esc_attr(Metasync::get_option('localseo')['local_seo_phone']) : ''
1621 1728 );
1622 1729
1623 1730 printf(' <br> <span class="description"> Search engines may prominently display your contact phone number for mobile users. </span>');
@@ -1625,29 +1732,29 @@
1625 1732
1626 1733 public function local_seo_address_callback()
1627 1734 {
1628 1735 printf(
1629 - '<input type="text" id="local_seo_address_street" name="' . Metasync_Admin::option_key . '[localseo][address][street]" value="%s" size="50" placeholder="Street Address"/> <br>',
1736 + '<input type="text" id="local_seo_address_street" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][address][street]" value="%s" size="50" placeholder="Street Address"/> <br>',
1630 1737 isset(Metasync::get_option('localseo')['address']['street']) ? esc_attr(Metasync::get_option('localseo')['address']['street']) : ''
1631 1738 );
1632 1739
1633 1740 printf(
1634 - '<input type="text" id="local_seo_address_locality" name="' . Metasync_Admin::option_key . '[localseo][address][locality]" value="%s" size="50" placeholder="Locality"/> <br>',
1741 + '<input type="text" id="local_seo_address_locality" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][address][locality]" value="%s" size="50" placeholder="Locality"/> <br>',
1635 1742 isset(Metasync::get_option('localseo')['address']['locality']) ? esc_attr(Metasync::get_option('localseo')['address']['locality']) : ''
1636 1743 );
1637 1744
1638 1745 printf(
1639 - '<input type="text" id="local_seo_address_region" name="' . Metasync_Admin::option_key . '[localseo][address][region]" value="%s" size="50" placeholder="Region"/> <br>',
1746 + '<input type="text" id="local_seo_address_region" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][address][region]" value="%s" size="50" placeholder="Region"/> <br>',
1640 1747 isset(Metasync::get_option('localseo')['address']['region']) ? esc_attr(Metasync::get_option('localseo')['address']['region']) : ''
1641 1748 );
1642 1749
1643 1750 printf(
1644 - '<input type="text" id="local_seo_address_postalcode" name="' . Metasync_Admin::option_key . '[localseo][address][postalcode]" value="%s" size="50" placeholder="Postal Code"/> <br>',
1751 + '<input type="text" id="local_seo_address_postalcode" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][address][postalcode]" value="%s" size="50" placeholder="Postal Code"/> <br>',
1645 1752 isset(Metasync::get_option('localseo')['address']['postalcode']) ? esc_attr(Metasync::get_option('localseo')['address']['postalcode']) : ''
1646 1753 );
1647 1754
1648 1755 printf(
1649 - '<input type="text" id="local_seo_address_country" name="' . Metasync_Admin::option_key . '[localseo][address][country]" value="%s" size="50" placeholder="Country"/> <br>',
1756 + '<input type="text" id="local_seo_address_country" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][address][country]" value="%s" size="50" placeholder="Country"/> <br>',
1650 1757 isset(Metasync::get_option('localseo')['address']['country']) ? esc_attr(Metasync::get_option('localseo')['address']['country']) : ''
1651 1758 );
1652 1759 }
1653 1760
@@ -1662,9 +1769,9 @@
1662 1769 <select name="<?php echo esc_attr(Metasync_Admin::option_key . '[localseo][local_seo_business_type]') ?>">
1663 1770 <option value='0'>Select Business Type</option>
1664 1771 <?php
1665 1772 foreach ($types as $type) {
1666 - printf('<option value="%s" %s >%s</option>', $type, selected($type, esc_attr($business_type)), $type);
1773 + printf('<option value="%s" %s >%s</option>', esc_attr($type), selected($type, $business_type, false), esc_html($type));
1667 1774 }
1668 1775 ?>
1669 1776 </select>
1670 1777 <?php
@@ -1688,9 +1795,9 @@
1688 1795 <li>
1689 1796 <select name="<?php echo esc_attr(Metasync_Admin::option_key . '[localseo][days][]') ?>">
1690 1797 <?php
1691 1798 foreach ($days_name as $name) {
1692 - printf('<option value="%s" %s >%s</option>', $name, selected(esc_attr($name), esc_attr($day_name)), esc_attr($name));
1799 + printf('<option value="%s" %s >%s</option>', esc_attr($name), selected($name, $day_name, false), esc_html($name));
1693 1800 }
1694 1801 ?>
1695 1802 </select>
1696 1803 <input type="text" name="<?php echo esc_attr(Metasync_Admin::option_key . '[localseo][times][]') ?>" value="<?php echo esc_attr($day_time) ?>">
@@ -1769,9 +1876,9 @@
1769 1876
1770 1877 public function local_seo_price_range_callback()
1771 1878 {
1772 1879 printf(
1773 - '<input type="text" id="local_seo_price_range" name="' . Metasync_Admin::option_key . '[localseo][local_seo_price_range]" value="%s" size="50" />',
1880 + '<input type="text" id="local_seo_price_range" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_price_range]" value="%s" size="50" />',
1774 1881 isset(Metasync::get_option('localseo')['local_seo_price_range']) ? esc_attr(Metasync::get_option('localseo')['local_seo_price_range']) : ''
1775 1882 );
1776 1883 printf(' <br> <span class="description"> The price range of the business, for example $$$. </span>');
1777 1884 }
@@ -1784,9 +1891,9 @@
1784 1891 <?php
1785 1892 $about_page = Metasync::get_option('localseo')['local_seo_about_page'] ?? '';
1786 1893 $pages = get_pages();
1787 1894 foreach ($pages as $page) {
1788 - printf('<option value="%s" %s >%s</option>', $page->ID, selected($page->ID, esc_attr($about_page)), $page->post_title);
1895 + printf('<option value="%s" %s >%s</option>', absint($page->ID), selected($page->ID, $about_page, false), esc_html($page->post_title));
1789 1896 }
1790 1897 ?>
1791 1898 </select>
1792 1899 <?php
@@ -1801,9 +1908,9 @@
1801 1908 <?php
1802 1909 $contact_page = Metasync::get_option('localseo')['local_seo_contact_page'] ?? '';
1803 1910 $pages = get_pages();
1804 1911 foreach ($pages as $page) {
1805 - printf('<option value="%s" %s >%s</option>', $page->ID, selected($page->ID, esc_attr($contact_page)), $page->post_title);
1912 + printf('<option value="%s" %s >%s</option>', absint($page->ID), selected($page->ID, $contact_page, false), esc_html($page->post_title));
1806 1913 }
1807 1914 ?>
1808 1915 </select>
1809 1916 <?php
@@ -1812,9 +1919,9 @@
1812 1919
1813 1920 public function local_seo_map_key_callback()
1814 1921 {
1815 1922 printf(
1816 - '<input type="text" id="local_seo_map_key" name="' . Metasync_Admin::option_key . '[localseo][local_seo_map_key]" value="%s" size="50" />',
1923 + '<input type="text" id="local_seo_map_key" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_map_key]" value="%s" size="50" />',
1817 1924 isset(Metasync::get_option('localseo')['local_seo_map_key']) ? esc_attr(Metasync::get_option('localseo')['local_seo_map_key']) : ''
1818 1925 );
1819 1926
1820 1927 printf(' <br> <span class="description"> An API Key is required to display embedded Google Maps on your site. </span>');
@@ -1822,9 +1929,9 @@
1822 1929
1823 1930 public function local_seo_geo_coordinates_callback()
1824 1931 {
1825 1932 printf(
1826 - '<input type="text" id="local_seo_geo_coordinates" name="' . Metasync_Admin::option_key . '[localseo][local_seo_geo_coordinates]" value="%s" size="50" />',
1933 + '<input type="text" id="local_seo_geo_coordinates" name="' . esc_attr(Metasync_Admin::option_key) . '[localseo][local_seo_geo_coordinates]" value="%s" size="50" />',
1827 1934 isset(Metasync::get_option('localseo')['local_seo_geo_coordinates']) ? esc_attr(Metasync::get_option('localseo')['local_seo_geo_coordinates']) : ''
1828 1935 );
1829 1936
1830 1937 printf(' <br> <span class="description"> Latitude and longitude values separated by comma. </span>');
@@ -1832,9 +1939,9 @@
1832 1939
1833 1940 public function header_snippets_callback()
1834 1941 {
1835 1942 printf(
1836 - '<textarea class="wide-text" id="header_snippets" rows="8" name="' . Metasync_Admin::option_key . '[codesnippets][header_snippet]" >%s</textarea>',
1943 + '<textarea class="wide-text" id="header_snippets" rows="8" name="' . esc_attr(Metasync_Admin::option_key) . '[codesnippets][header_snippet]" >%s</textarea>',
1837 1944 isset(Metasync::get_option('codesnippets')['header_snippet']) ? esc_attr(Metasync::get_option('codesnippets')['header_snippet']) : ''
1838 1945 );
1839 1946 }
1840 1947
@@ -1840,9 +1947,9 @@
1840 1947
1841 1948 public function footer_snippets_callback()
1842 1949 {
1843 1950 printf(
1844 - '<textarea class="wide-text" id="footer_snippets" rows="8" name="' . Metasync_Admin::option_key . '[codesnippets][footer_snippet]" >%s</textarea>',
1951 + '<textarea class="wide-text" id="footer_snippets" rows="8" name="' . esc_attr(Metasync_Admin::option_key) . '[codesnippets][footer_snippet]" >%s</textarea>',
1845 1952 isset(Metasync::get_option('codesnippets')['footer_snippet']) ? esc_attr(Metasync::get_option('codesnippets')['footer_snippet']) : ''
1846 1953 );
1847 1954 }
1848 1955
@@ -1979,9 +2086,9 @@
1979 2086
1980 2087 public function global_open_graph_meta_callback()
1981 2088 {
1982 2089 printf(
1983 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][open_graph_meta_tags]" value="true" %s />',
2090 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][open_graph_meta_tags]" value="true" %s />',
1984 2091 isset(Metasync::get_option('common_meta_settings')['open_graph_meta_tags']) && Metasync::get_option('common_meta_settings')['open_graph_meta_tags'] == 'true' ? 'checked' : ''
1985 2092 );
1986 2093 printf(' <br> <span class="description"> Automatically add the Open Graph meta tags in a page or post.</span>');
1987 2094 }
@@ -1988,9 +2095,9 @@
1988 2095
1989 2096 public function global_facebook_meta_callback()
1990 2097 {
1991 2098 printf(
1992 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][facebook_meta_tags]" value="true" %s />',
2099 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][facebook_meta_tags]" value="true" %s />',
1993 2100 isset(Metasync::get_option('common_meta_settings')['facebook_meta_tags']) && Metasync::get_option('common_meta_settings')['facebook_meta_tags'] == 'true' ? 'checked' : ''
1994 2101 );
1995 2102 printf(' <br> <span class="description"> Automatically add the Facebook meta tags in a page or post.</span>');
1996 2103 }
@@ -1997,9 +2104,9 @@
1997 2104
1998 2105 public function global_twitter_meta_callback()
1999 2106 {
2000 2107 printf(
2001 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][twitter_meta_tags]" value="true" %s />',
2108 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][twitter_meta_tags]" value="true" %s />',
2002 2109 isset(Metasync::get_option('common_meta_settings')['twitter_meta_tags']) && Metasync::get_option('common_meta_settings')['twitter_meta_tags'] == 'true' ? 'checked' : ''
2003 2110 );
2004 2111 printf(' <br> <span class="description"> Automatically add the Twitter meta tags in a page or post.</span>');
2005 2112 }
@@ -2007,9 +2114,9 @@
2007 2114 public function og_image_dimensions_callback()
2008 2115 {
2009 2116 $val = Metasync::get_option('common_meta_settings')['og_image_dimensions'] ?? 'true';
2010 2117 printf(
2011 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][og_image_dimensions]" value="true" %s />',
2118 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][og_image_dimensions]" value="true" %s />',
2012 2119 $val === 'true' ? 'checked' : ''
2013 2120 );
2014 2121 printf('<span class="description"> Output og:image:width, og:image:height, and og:image:type when OG image metadata is available.</span>');
2015 2122 }
@@ -2017,9 +2124,9 @@
2017 2124 public function article_timestamps_callback()
2018 2125 {
2019 2126 $val = Metasync::get_option('common_meta_settings')['article_timestamps'] ?? 'true';
2020 2127 printf(
2021 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][article_timestamps]" value="true" %s />',
2128 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][article_timestamps]" value="true" %s />',
2022 2129 $val === 'true' ? 'checked' : ''
2023 2130 );
2024 2131 printf('<span class="description"> Output article:published_time and article:modified_time from the post publish and modified dates (ISO 8601).</span>');
2025 2132 }
@@ -2027,9 +2134,9 @@
2027 2134 public function article_author_callback()
2028 2135 {
2029 2136 $val = Metasync::get_option('common_meta_settings')['article_author'] ?? 'true';
2030 2137 printf(
2031 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][article_author]" value="true" %s />',
2138 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][article_author]" value="true" %s />',
2032 2139 $val === 'true' ? 'checked' : ''
2033 2140 );
2034 2141 printf('<span class="description"> Output article:author using the post author website URL or archive URL (overridable per-post via _metasync_og_article_author meta).</span>');
2035 2142 }
@@ -2037,9 +2144,9 @@
2037 2144 public function article_section_callback()
2038 2145 {
2039 2146 $val = Metasync::get_option('common_meta_settings')['article_section'] ?? 'true';
2040 2147 printf(
2041 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][article_section]" value="true" %s />',
2148 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][article_section]" value="true" %s />',
2042 2149 $val === 'true' ? 'checked' : ''
2043 2150 );
2044 2151 printf('<span class="description"> Output article:section from the primary category (falls back to first category).</span>');
2045 2152 }
@@ -2047,9 +2154,9 @@
2047 2154 public function article_tags_callback()
2048 2155 {
2049 2156 $val = Metasync::get_option('common_meta_settings')['article_tags'] ?? 'true';
2050 2157 printf(
2051 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][article_tags]" value="true" %s />',
2158 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][article_tags]" value="true" %s />',
2052 2159 $val === 'true' ? 'checked' : ''
2053 2160 );
2054 2161 printf('<span class="description"> Output one article:tag meta tag per WordPress post tag.</span>');
2055 2162 }
@@ -2057,9 +2164,9 @@
2057 2164 public function twitter_image_alt_callback()
2058 2165 {
2059 2166 $val = Metasync::get_option('common_meta_settings')['twitter_image_alt'] ?? 'true';
2060 2167 printf(
2061 - '<input type="checkbox" name="' . Metasync_Admin::option_key . '[common_meta_settings][twitter_image_alt]" value="true" %s />',
2168 + '<input type="checkbox" name="' . esc_attr(Metasync_Admin::option_key) . '[common_meta_settings][twitter_image_alt]" value="true" %s />',
2062 2169 $val === 'true' ? 'checked' : ''
2063 2170 );
2064 2171 printf('<span class="description"> Output twitter:image:alt using the stored alt text or the OG image attachment alt attribute.</span>');
2065 2172 }
@@ -2066,9 +2173,9 @@
2066 2173
2067 2174 public function facebook_page_url_callback()
2068 2175 {
2069 2176 $facebook_page_url = Metasync::get_option('social_meta')['facebook_page_url'] ?? '';
2070 - printf('<input type="text" name="' . Metasync_Admin::option_key . '[social_meta][facebook_page_url]" value="%s" size="50" />', esc_attr($facebook_page_url));
2177 + printf('<input type="text" name="' . esc_attr(Metasync_Admin::option_key) . '[social_meta][facebook_page_url]" value="%s" size="50" />', esc_attr($facebook_page_url));
2071 2178 printf('<br><span class="description"> Enter your Facebook page URL. eg: <code>https://www.facebook.com/MetaSync/</code> </span>');
2072 2179 }
2073 2180
2074 2181 public function facebook_authorship_callback()
@@ -2073,9 +2180,9 @@
2073 2180
2074 2181 public function facebook_authorship_callback()
2075 2182 {
2076 2183 $facebook_authorship = Metasync::get_option('social_meta')['facebook_authorship'] ?? '';
2077 - printf('<input type="text" name="' . Metasync_Admin::option_key . '[social_meta][facebook_authorship]" value="%s" size="50" />', esc_attr($facebook_authorship));
2184 + printf('<input type="text" name="' . esc_attr(Metasync_Admin::option_key) . '[social_meta][facebook_authorship]" value="%s" size="50" />', esc_attr($facebook_authorship));
2078 2185 printf('<br><span class="description"> Enter Facebook profile URL to show Facebook Authorship when your articles are being shared on Facebook. eg: <code>https://www.facebook.com/shahrukh/</code> </span>');
2079 2186 }
2080 2187
2081 2188 public function facebook_admin_callback()
@@ -2080,9 +2187,9 @@
2080 2187
2081 2188 public function facebook_admin_callback()
2082 2189 {
2083 2190 $facebook_admin = Metasync::get_option('social_meta')['facebook_admin'] ?? '';
2084 - printf('<input type="text" name="' . Metasync_Admin::option_key . '[social_meta][facebook_admin]" value="%s" size="50" />', esc_attr($facebook_admin));
2191 + printf('<input type="text" name="' . esc_attr(Metasync_Admin::option_key) . '[social_meta][facebook_admin]" value="%s" size="50" />', esc_attr($facebook_admin));
2085 2192 printf(' <br> <span class="description"> Enter numeric user ID of Facebook. </span>');
2086 2193 }
2087 2194
2088 2195 public function facebook_app_callback()
@@ -2087,9 +2194,9 @@
2087 2194
2088 2195 public function facebook_app_callback()
2089 2196 {
2090 2197 $facebook_app = Metasync::get_option('social_meta')['facebook_app'] ?? '';
2091 - printf('<input type="text" name="' . Metasync_Admin::option_key . '[social_meta][facebook_app]" value="%s" size="50" />', esc_attr($facebook_app));
2198 + printf('<input type="text" name="' . esc_attr(Metasync_Admin::option_key) . '[social_meta][facebook_app]" value="%s" size="50" />', esc_attr($facebook_app));
2092 2199 printf(' <br> <span class="description"> Enter numeric app ID of Facebook </span>');
2093 2200 }
2094 2201
2095 2202 public function facebook_secret_callback()
@@ -2094,9 +2201,9 @@
2094 2201
2095 2202 public function facebook_secret_callback()
2096 2203 {
2097 2204 $facebook_secret = Metasync::get_option('social_meta')['facebook_secret'] ?? '';
2098 - printf('<input type="text" name="' . Metasync_Admin::option_key . '[social_meta][facebook_secret]" value="%s" size="50" />', esc_attr($facebook_secret));
2205 + printf('<input type="text" name="' . esc_attr(Metasync_Admin::option_key) . '[social_meta][facebook_secret]" value="%s" size="50" />', esc_attr($facebook_secret));
2099 2206 printf(' <br> <span class="description"> Enter alphanumeric access token from Facebook. </span>');
2100 2207 }
2101 2208
2102 2209 public function twitter_username_callback()
@@ -2101,9 +2208,9 @@
2101 2208
2102 2209 public function twitter_username_callback()
2103 2210 {
2104 2211 $twitter_username = Metasync::get_option('social_meta')['twitter_username'] ?? '';
2105 - printf('<input type="text" name="' . Metasync_Admin::option_key . '[social_meta][twitter_username]" value="%s" size="50" />', esc_attr($twitter_username));
2212 + printf('<input type="text" name="' . esc_attr(Metasync_Admin::option_key) . '[social_meta][twitter_username]" value="%s" size="50" />', esc_attr($twitter_username));
2106 2213 printf(' <br> <span class="description"> Twitter username of the author to add <code>twitter:creator</code> tag to post. eg: <code>MetaSync</code> </span>');
2107 2214 }
2108 2215
2109 2216 public static function get_business_types()
@@ -2278,8 +2385,14 @@
2278 2385 }
2279 2386
2280 2387 /**
2281 2388 * Render breadcrumbs settings section
2389 + *
2390 + * Rendered by the dedicated Breadcrumbs admin page. The three checkbox
2391 + * fields each ship a hidden companion input so their keys are always
2392 + * present in the submitted payload, which lets the save handlers treat an
2393 + * absent key as "this form does not manage that field" instead of
2394 + * "unchecked".
2282 2395 */
2283 2396 public function render_breadcrumbs_section() {
2284 2397 $options = Metasync::get_option('breadcrumbs', array());
2285 2398
@@ -2284,9 +2397,9 @@
2284 2397 $options = Metasync::get_option('breadcrumbs', array());
2285 2398
2286 2399 $defaults = array(
2287 2400 'enabled' => true,
2288 - 'separator' => '&raquo;',
2401 + 'separator' => '»',
2289 2402 'home_label' => 'Home',
2290 2403 'home_url' => '',
2291 2404 'show_current_page' => true,
2292 2405 'prefix_text' => '',
@@ -2294,8 +2407,19 @@
2294 2407 'disable_schema' => false,
2295 2408 );
2296 2409
2297 2410 $options = wp_parse_args($options, $defaults);
2411 +
2412 + # Older builds stored the separator as an HTML entity (e.g. "&raquo;").
2413 + # Decode before matching so the saved choice still lights up its radio.
2414 + $separator_presets = array('»', '/', '>', '·');
2415 + $separator_current = html_entity_decode((string) $options['separator'], ENT_QUOTES, 'UTF-8');
2416 + if ($separator_current === '') {
2417 + $separator_current = '»';
2418 + }
2419 + # A separator that predates the radio picker (or came from the old free
2420 + # text field) gets its own option so it stays selected and round-trips.
2421 + $separator_custom = in_array($separator_current, $separator_presets, true) ? '' : $separator_current;
2298 2422 ?>
2299 2423 <div style="background: var(--dashboard-card-bg); padding: 20px; border-radius: 8px;">
2300 2424
2301 2425 <!-- Enable/Disable -->
@@ -2300,8 +2424,9 @@
2300 2424
2301 2425 <!-- Enable/Disable -->
2302 2426 <div style="margin-bottom: 24px;">
2303 2427 <label style="display: flex; align-items: center; gap: 12px; cursor: pointer;">
2428 + <input type="hidden" name="metasync_options[breadcrumbs][enabled]" value="0">
2304 2429 <input type="checkbox"
2305 2430 name="metasync_options[breadcrumbs][enabled]"
2306 2431 value="1"
2307 2432 <?php checked($options['enabled'], 1); ?>
@@ -2316,8 +2441,9 @@
2316 2441
2317 2442 <!-- Disable Schema Markup -->
2318 2443 <div style="margin-bottom: 24px;">
2319 2444 <label style="display: flex; align-items: center; gap: 12px; cursor: pointer;">
2445 + <input type="hidden" name="metasync_options[breadcrumbs][disable_schema]" value="0">
2320 2446 <input type="checkbox"
2321 2447 name="metasync_options[breadcrumbs][disable_schema]"
2322 2448 value="1"
2323 2449 <?php checked($options['disable_schema'], 1); ?>
@@ -2335,24 +2461,21 @@
2335 2461 <label for="breadcrumb_separator" style="display: block; margin-bottom: 8px; font-weight: 500; color: var(--dashboard-text);">
2336 2462 Separator Character
2337 2463 </label>
2338 2464 <div style="display: flex; gap: 12px; flex-wrap: wrap;">
2465 + <?php foreach ($separator_presets as $separator_option) : ?>
2339 2466 <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
2340 - <input type="radio" name="metasync_options[breadcrumbs][separator]" value="»" <?php checked($options['separator'], '»'); ?>>
2341 - <span style="color: var(--dashboard-text);">»</span>
2467 + <input type="radio" name="metasync_options[breadcrumbs][separator]" value="<?php echo esc_attr($separator_option); ?>" <?php checked($separator_current, $separator_option); ?>>
2468 + <span style="color: var(--dashboard-text);"><?php echo esc_html($separator_option); ?></span>
2342 2469 </label>
2343 - <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
2344 - <input type="radio" name="metasync_options[breadcrumbs][separator]" value="/" <?php checked($options['separator'], '/'); ?>>
2345 - <span style="color: var(--dashboard-text);">/</span>
2346 - </label>
2347 - <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
2348 - <input type="radio" name="metasync_options[breadcrumbs][separator]" value=">" <?php checked($options['separator'], '>'); ?>>
2349 - <span style="color: var(--dashboard-text);">></span>
2350 - </label>
2351 - <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
2352 - <input type="radio" name="metasync_options[breadcrumbs][separator]" value="·" <?php checked($options['separator'], '·'); ?>>
2353 - <span style="color: var(--dashboard-text);">·</span>
2354 - </label>
2470 + <?php endforeach; ?>
2471 + <div style="display: flex; align-items: center; gap: 8px;">
2472 + <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
2473 + <input type="radio" id="metasync-breadcrumb-separator-custom" name="metasync_options[breadcrumbs][separator]" value="<?php echo esc_attr($separator_custom); ?>" <?php checked($separator_custom !== ''); ?>>
2474 + <span style="color: var(--dashboard-text);">Custom</span>
2475 + </label>
2476 + <input type="text" value="<?php echo esc_attr($separator_custom); ?>" placeholder="~" maxlength="16" aria-label="Custom separator character" oninput="var r=document.getElementById('metasync-breadcrumb-separator-custom');r.value=this.value;r.checked=true" style="width: 80px; padding: 8px 10px; background: var(--dashboard-input-bg); border: 1px solid var(--dashboard-border); border-radius: 6px; color: var(--dashboard-text); font-size: 14px;">
2477 + </div>
2355 2478 </div>
2356 2479 <p style="margin: 8px 0 0 0; font-size: 12px; color: var(--dashboard-text-secondary);">
2357 2480 Choose how to separate breadcrumb items
2358 2481 </p>
@@ -2392,8 +2515,9 @@
2392 2515
2393 2516 <!-- Show Current Page -->
2394 2517 <div style="margin-bottom: 24px;">
2395 2518 <label style="display: flex; align-items: center; gap: 12px; cursor: pointer;">
2519 + <input type="hidden" name="metasync_options[breadcrumbs][show_current_page]" value="0">
2396 2520 <input type="checkbox"
2397 2521 name="metasync_options[breadcrumbs][show_current_page]"
2398 2522 value="1"
2399 2523 <?php checked($options['show_current_page'], 1); ?>