Changeset 3461540
- Timestamp:
- 02/14/2026 10:34:15 PM (6 weeks ago)
- Location:
- draftseo-ai
- Files:
-
- 26 added
- 4 edited
-
tags/1.0.3 (added)
-
tags/1.0.3/LICENSE.txt (added)
-
tags/1.0.3/README.md (added)
-
tags/1.0.3/admin (added)
-
tags/1.0.3/admin/css (added)
-
tags/1.0.3/admin/css/admin-styles.css (added)
-
tags/1.0.3/admin/css/index.php (added)
-
tags/1.0.3/admin/index.php (added)
-
tags/1.0.3/admin/js (added)
-
tags/1.0.3/admin/js/admin-scripts.js (added)
-
tags/1.0.3/admin/js/index.php (added)
-
tags/1.0.3/admin/settings-page.php (added)
-
tags/1.0.3/draftseo-ai.php (added)
-
tags/1.0.3/includes (added)
-
tags/1.0.3/includes/class-api-client.php (added)
-
tags/1.0.3/includes/class-content-processor.php (added)
-
tags/1.0.3/includes/class-image-handler.php (added)
-
tags/1.0.3/includes/class-rest-api.php (added)
-
tags/1.0.3/includes/class-seo-handler.php (added)
-
tags/1.0.3/includes/class-settings.php (added)
-
tags/1.0.3/includes/index.php (added)
-
tags/1.0.3/index.php (added)
-
tags/1.0.3/languages (added)
-
tags/1.0.3/languages/index.php (added)
-
tags/1.0.3/readme.txt (added)
-
tags/1.0.3/uninstall.php (added)
-
trunk/README.md (modified) (1 diff)
-
trunk/draftseo-ai.php (modified) (2 diffs)
-
trunk/includes/class-content-processor.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
draftseo-ai/trunk/README.md
r3461526 r3461540 173 173 ## Changelog 174 174 175 ### 1.0.3 176 177 Content rendering and sanitization fixes for YouTube videos, headings, and citations. 178 179 - **YouTube embeds — Gutenberg blocks** — YouTube video references (iframes, markdown links, HTML links, bare URLs) are now converted to native WordPress Gutenberg `wp:embed` blocks on the platform side before sending to WordPress. This is the same format WordPress's own block editor uses, ensuring videos render as responsive players on all themes and survive all sanitization steps. 180 - **Gutenberg block preservation in sanitizer** — The `wp_kses` sanitizer now extracts Gutenberg blocks (e.g., `<!-- wp:embed -->...<!-- /wp:embed -->`) before sanitization and restores them after, preventing the block markup from being stripped. This uses a placeholder-based approach that is safe and does not modify the block content. 181 - **Removed legacy `[embed]` shortcode conversion** — The old `convert_youtube_oembed_to_embeds()` method has been removed from the content processor. It previously wrapped YouTube URLs in `[embed]...[/embed]` shortcodes, which were then stripped by `wp_kses` before WordPress could process them — this was the root cause of YouTube videos being stripped. 182 - **Heading unwrapping** — AI models sometimes generate markdown headings inside `<p>` tags (e.g., `<p>## Heading Text</p>`). These are now detected and converted to proper HTML heading elements (`<h2>`, `<h3>`, etc.) before the main content processing runs. 183 - **Citation link normalization** — AI-generated citation formats like `[[1]](https://example.com)` are now normalized to clean `[1]` references early in the pipeline, preventing downstream processors from creating malformed HTML. 184 175 185 ### 1.0.2 176 186 -
draftseo-ai/trunk/draftseo-ai.php
r3461526 r3461540 4 4 * Plugin URI: https://draftseo.ai/wp-plugin 5 5 * Description: Publish AI-generated blogs from DraftSEO.AI platform directly to WordPress. Transfers images from Nebius CDN to WordPress media library while maintaining SEO optimization. 6 * Version: 1.0. 26 * Version: 1.0.3 7 7 * Author: DraftSEO.AI 8 8 * Author URI: https://draftseo.ai … … 38 38 39 39 // Define plugin constants 40 define('DRAFTSEO_VERSION', '1.0. 2');40 define('DRAFTSEO_VERSION', '1.0.3'); 41 41 define('DRAFTSEO_PLUGIN_DIR', plugin_dir_path(__FILE__)); 42 42 define('DRAFTSEO_PLUGIN_URL', plugin_dir_url(__FILE__)); -
draftseo-ai/trunk/includes/class-content-processor.php
r3461526 r3461540 30 30 */ 31 31 public static function process($content) { 32 $content = self::convert_youtube_oembed_to_embeds($content);33 32 $content = self::format_quotes($content); 34 33 $content = self::sanitize_content($content); … … 50 49 */ 51 50 private static function sanitize_content($content) { 51 $gutenberg_blocks = array(); 52 $placeholder_prefix = '<!--DRAFTSEO_BLOCK_'; 53 54 $content = preg_replace_callback( 55 '/<!-- wp:embed\s.*?<!-- \/wp:embed -->/s', 56 function($match) use (&$gutenberg_blocks, $placeholder_prefix) { 57 $index = count($gutenberg_blocks); 58 $gutenberg_blocks[$index] = $match[0]; 59 return $placeholder_prefix . $index . '-->'; 60 }, 61 $content 62 ); 63 52 64 $allowed = wp_kses_allowed_html('post'); 53 65 … … 116 128 $allowed = array_merge($allowed, $extra_tags); 117 129 118 return wp_kses($content, $allowed); 119 } 120 121 /** 122 * Convert YouTube oEmbed URLs to WordPress embed shortcodes 123 * 124 * YouTube URLs on their own line are converted to WordPress [embed] shortcodes 125 * which WordPress processes into responsive video players. 126 * 127 * @param string $content HTML content with YouTube URLs 128 * @return string Content with YouTube URLs wrapped in [embed] shortcodes 129 */ 130 private static function convert_youtube_oembed_to_embeds($content) { 131 $content = preg_replace( 132 '/^\s*(https:\/\/www\.youtube\.com\/watch\?v=[a-zA-Z0-9_-]+)\s*$/m', 133 "\n" . '[embed]$1[/embed]' . "\n", 134 $content 135 ); 130 $content = wp_kses($content, $allowed); 136 131 137 $content = preg_replace( 138 '/<p>\s*(https:\/\/www\.youtube\.com\/watch\?v=[a-zA-Z0-9_-]+)\s*<\/p>/i', 139 "\n" . '[embed]$1[/embed]' . "\n", 140 $content 141 ); 132 foreach ($gutenberg_blocks as $index => $block) { 133 $content = str_replace( 134 $placeholder_prefix . $index . '-->', 135 $block, 136 $content 137 ); 138 } 142 139 143 140 return $content; 144 141 } 142 145 143 146 144 /** -
draftseo-ai/trunk/readme.txt
r3461526 r3461540 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 27 Stable tag: 1.0.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 106 106 107 107 == Changelog == 108 109 = 1.0.3 = 110 111 Content rendering and sanitization fixes for YouTube videos, headings, and citations. 112 113 * YouTube video embeds now use WordPress Gutenberg embed blocks instead of plain URLs or [embed] shortcodes, ensuring videos survive wp_kses sanitization and render as responsive players on all themes 114 * Content sanitizer updated to extract and preserve Gutenberg blocks before running wp_kses, then restore them after — prevents stripping of embed markup 115 * Removed legacy [embed] shortcode conversion (convert_youtube_oembed_to_embeds) — no longer needed since the platform now sends native Gutenberg block format 116 * Markdown headings wrapped in paragraph tags (e.g., <p>## Heading</p>) are now detected and converted to proper HTML heading elements before processing 117 * Citation link normalization added to handle AI-generated [[n]](url) format, converting them to clean [n] references before downstream processing 108 118 109 119 = 1.0.2 = … … 207 217 == Upgrade Notice == 208 218 219 = 1.0.3 = 220 Fixes YouTube videos being stripped when publishing to WordPress. Also fixes headings rendering as plain text and malformed citation links. 221 209 222 = 1.0.2 = 210 223 Hotfix: Fixes in-text citations, references list, external links, and adds FAQ structured data (JSON-LD) for SEO rich results.
Note: See TracChangeset
for help on using the changeset viewer.