Changeset 3482032
- Timestamp:
- 03/13/2026 01:35:53 PM (3 weeks ago)
- Location:
- floyi
- Files:
-
- 26 added
- 3 edited
-
tags/1.1.0 (added)
-
tags/1.1.0/admin (added)
-
tags/1.1.0/admin/class-floyi-admin.php (added)
-
tags/1.1.0/admin/index.php (added)
-
tags/1.1.0/assets (added)
-
tags/1.1.0/assets/css (added)
-
tags/1.1.0/assets/css/admin.css (added)
-
tags/1.1.0/assets/css/index.php (added)
-
tags/1.1.0/assets/index.php (added)
-
tags/1.1.0/assets/js (added)
-
tags/1.1.0/assets/js/admin.js (added)
-
tags/1.1.0/assets/js/index.php (added)
-
tags/1.1.0/floyi.php (added)
-
tags/1.1.0/includes (added)
-
tags/1.1.0/includes/class-floyi-api.php (added)
-
tags/1.1.0/includes/class-floyi-capabilities.php (added)
-
tags/1.1.0/includes/class-floyi-publisher.php (added)
-
tags/1.1.0/includes/class-floyi-security.php (added)
-
tags/1.1.0/includes/class-floyi-settings.php (added)
-
tags/1.1.0/includes/class-floyi-webhook-queue.php (added)
-
tags/1.1.0/includes/index.php (added)
-
tags/1.1.0/index.php (added)
-
tags/1.1.0/languages (added)
-
tags/1.1.0/languages/index.php (added)
-
tags/1.1.0/readme.txt (added)
-
tags/1.1.0/uninstall.php (added)
-
trunk/floyi.php (modified) (4 diffs)
-
trunk/includes/class-floyi-publisher.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
floyi/trunk/floyi.php
r3477390 r3482032 4 4 * Plugin URI: https://floyi.com/wordpress-plugin 5 5 * Description: Connect your WordPress site to Floyi for seamless content publishing from your topical authority platform. 6 * Version: 1. 0.26 * Version: 1.1.0 7 7 * Author: Floyi 8 8 * Author URI: https://floyi.com … … 23 23 24 24 // Plugin constants 25 define('FLOYI_CONNECT_VERSION', '1. 0.2');25 define('FLOYI_CONNECT_VERSION', '1.1.0'); 26 26 define('FLOYI_CONNECT_PLUGIN_DIR', plugin_dir_path(__FILE__)); 27 27 define('FLOYI_CONNECT_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 100 100 // Webhook retry cron 101 101 add_action('floyi_process_webhook_queue', array('Floyi_Webhook_Queue', 'process_queue')); 102 103 // Render JSON-LD structured data in page <head> 104 add_action('wp_head', array(__CLASS__, 'render_json_ld'), 1); 105 106 // Expose _floyi_json_ld in the Custom Fields panel so users can view/edit it 107 add_filter('is_protected_meta', array(__CLASS__, 'unprotect_floyi_meta'), 10, 2); 102 108 103 109 // Track post status changes for Floyi-managed posts … … 198 204 // Text domain loading is handled automatically by WordPress 4.6+ 199 205 // for plugins hosted on WordPress.org. 206 207 // Register Floyi JSON-LD meta field for REST API access 208 $post_types = get_post_types(array('public' => true, 'show_in_rest' => true)); 209 foreach ($post_types as $post_type) { 210 register_post_meta($post_type, '_floyi_json_ld', array( 211 'show_in_rest' => true, 212 'single' => true, 213 'type' => 'string', 214 'auth_callback' => function () { 215 return current_user_can('edit_posts'); 216 }, 217 )); 218 } 219 } 220 221 /** 222 * Render Floyi JSON-LD structured data in the page <head>. 223 * 224 * Outputs <script type="application/ld+json"> from the _floyi_json_ld 225 * post meta field. This runs on singular pages (posts, pages, CPTs). 226 */ 227 public static function render_json_ld() { 228 if (!is_singular()) { 229 return; 230 } 231 232 $schema = get_post_meta(get_the_ID(), '_floyi_json_ld', true); 233 if (!$schema) { 234 return; 235 } 236 237 // get_post_meta returns the value as stored. The JSON from Floyi contains 238 // properly escaped inner quotes (e.g. \"deliverable\"). Do NOT wp_unslash() 239 // as that strips the escaping and breaks json_decode. 240 $decoded = json_decode($schema); 241 if (json_last_error() !== JSON_ERROR_NONE || $decoded === null) { 242 return; 243 } 244 245 // Output each schema as its own <script> tag (Google-recommended approach). 246 // Single object → one tag. Array of objects → one tag per schema type. 247 $items = is_array($decoded) ? $decoded : array($decoded); 248 foreach ($items as $item) { 249 $clean_json = wp_json_encode($item, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); 250 if ($clean_json) { 251 echo '<script type="application/ld+json">' . $clean_json . '</script>' . "\n"; 252 } 253 } 254 } 255 256 /** 257 * Allow _floyi_json_ld to appear in the Custom Fields panel. 258 * 259 * WordPress hides underscore-prefixed meta keys by default. This filter 260 * makes _floyi_json_ld visible so users can view and edit schema directly 261 * in the WordPress editor. 262 * 263 * @param bool $protected Whether the meta key is protected. 264 * @param string $meta_key The meta key. 265 * @return bool 266 */ 267 public static function unprotect_floyi_meta($protected, $meta_key) { 268 if ($meta_key === '_floyi_json_ld') { 269 return false; 270 } 271 return $protected; 200 272 } 201 273 -
floyi/trunk/includes/class-floyi-publisher.php
r3477390 r3482032 114 114 if (!empty($params['meta']) && is_array($params['meta'])) { 115 115 foreach ($params['meta'] as $key => $value) { 116 update_post_meta($post_id, sanitize_key($key), $value); 116 // wp_slash counteracts the wp_unslash that update_post_meta 117 // applies internally, preserving backslash escaping in JSON strings. 118 update_post_meta($post_id, sanitize_key($key), wp_slash($value)); 117 119 } 118 120 } … … 212 214 if (!empty($params['meta']) && is_array($params['meta'])) { 213 215 foreach ($params['meta'] as $key => $value) { 214 update_post_meta($post_id, sanitize_key($key), $value); 216 // wp_slash counteracts the wp_unslash that update_post_meta 217 // applies internally, preserving backslash escaping in JSON strings. 218 update_post_meta($post_id, sanitize_key($key), wp_slash($value)); 215 219 } 216 220 } -
floyi/trunk/readme.txt
r3477390 r3482032 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1. 0.27 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 125 125 == Changelog == 126 126 127 = 1.1.0 = 128 * Added JSON-LD structured data support — Floyi can now push schema markup to WordPress 129 * Schema is rendered in the page head via wp_head hook for SEO and AI search engines 130 * Floyi JSON-LD meta field visible in Custom Fields panel for viewing and manual editing 131 * Registered _floyi_json_ld post meta for all public post types via REST API 132 127 133 = 1.0.2 = 128 134 * Preserve link target and rel attributes when publishing from Floyi (fixes "open in new tab" links losing target="_blank" after publishing) … … 149 155 == Upgrade Notice == 150 156 157 = 1.1.0 = 158 Adds JSON-LD structured data support. Floyi can now push Article, FAQ, HowTo, Organization, LocalBusiness, and Breadcrumb schema to your WordPress pages. 159 151 160 = 1.0.2 = 152 161 Fixes link attributes (target, rel) being stripped when publishing content to WordPress.
Note: See TracChangeset
for help on using the changeset viewer.