Plugin Directory

Changeset 3461540


Ignore:
Timestamp:
02/14/2026 10:34:15 PM (6 weeks ago)
Author:
klimentp
Message:

Version 1.0.3 - Hotfix: Youtube videos, Headings, Citations

Location:
draftseo-ai
Files:
26 added
4 edited

Legend:

Unmodified
Added
Removed
  • draftseo-ai/trunk/README.md

    r3461526 r3461540  
    173173## Changelog
    174174
     175### 1.0.3
     176
     177Content 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
    175185### 1.0.2
    176186
  • draftseo-ai/trunk/draftseo-ai.php

    r3461526 r3461540  
    44 * Plugin URI: https://draftseo.ai/wp-plugin
    55 * 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.2
     6 * Version: 1.0.3
    77 * Author: DraftSEO.AI
    88 * Author URI: https://draftseo.ai
     
    3838
    3939// Define plugin constants
    40 define('DRAFTSEO_VERSION', '1.0.2');
     40define('DRAFTSEO_VERSION', '1.0.3');
    4141define('DRAFTSEO_PLUGIN_DIR', plugin_dir_path(__FILE__));
    4242define('DRAFTSEO_PLUGIN_URL', plugin_dir_url(__FILE__));
  • draftseo-ai/trunk/includes/class-content-processor.php

    r3461526 r3461540  
    3030     */
    3131    public static function process($content) {
    32         $content = self::convert_youtube_oembed_to_embeds($content);
    3332        $content = self::format_quotes($content);
    3433        $content = self::sanitize_content($content);
     
    5049     */
    5150    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       
    5264        $allowed = wp_kses_allowed_html('post');
    5365       
     
    116128        $allowed = array_merge($allowed, $extra_tags);
    117129       
    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);
    136131       
    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        }
    142139       
    143140        return $content;
    144141    }
     142   
    145143   
    146144    /**
  • draftseo-ai/trunk/readme.txt

    r3461526 r3461540  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.2
     7Stable tag: 1.0.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    106106
    107107== Changelog ==
     108
     109= 1.0.3 =
     110
     111Content 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
    108118
    109119= 1.0.2 =
     
    207217== Upgrade Notice ==
    208218
     219= 1.0.3 =
     220Fixes YouTube videos being stripped when publishing to WordPress. Also fixes headings rendering as plain text and malformed citation links.
     221
    209222= 1.0.2 =
    210223Hotfix: 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.