Plugin Directory

Changeset 3364907


Ignore:
Timestamp:
09/20/2025 09:07:16 AM (6 months ago)
Author:
eugenezolo
Message:

Version 1.0.2 - Fixed YouTube video embedding in synced articles

Location:
outrank
Files:
4 edited
10 copied

Legend:

Unmodified
Added
Removed
  • outrank/tags/1.0.2/libs/api.php

    r3337904 r3364907  
    44define('OUTRANK_API_SECRET', '7d775a0fd0bc1d92e4d3db1fe313d72e');
    55require_once plugin_dir_path(__FILE__) . '../includes/image-functions.php';
     6
     7function sanitize_content($content) {
     8    $allowed_html = wp_kses_allowed_html('post');
     9
     10    $allowed_html['iframe'] = array(
     11        'src' => array(),
     12        'width' => array(),
     13        'height' => array(),
     14        'frameborder' => array(),
     15        'allowfullscreen' => array(),
     16        'allow' => array(),
     17        'style' => array(),
     18    );
     19
     20    $sanitized = wp_kses($content, $allowed_html);
     21
     22    $sanitized = preg_replace_callback(
     23        '/<iframe[^>]*>/i',
     24        function($matches) {
     25            $iframe = $matches[0];
     26
     27            if (preg_match('/src=["\']([^"\']*)["\']/', $iframe, $src_matches)) {
     28                $src = trim($src_matches[1]);
     29
     30                if (preg_match('/^https:\/\/(www\.)?youtube\.com\/embed\/[a-zA-Z0-9_-]{11}(\?[^"\'<>]*)?$/i', $src) ||
     31                    preg_match('/^https:\/\/(www\.)?youtube-nocookie\.com\/embed\/[a-zA-Z0-9_-]{11}(\?[^"\'<>]*)?$/i', $src)) {
     32                    return $iframe;
     33                }
     34            }
     35
     36            return '';
     37        },
     38        $sanitized
     39    );
     40
     41    return $sanitized;
     42}
    643
    744add_action('rest_api_init', function () {
     
    103140    }
    104141
     142    remove_filter('content_save_pre', 'wp_filter_post_kses');
     143
     144    $sanitized_content = sanitize_content($params['content'] ?? '');
     145
    105146    // Insert post
    106147    $post_id = wp_insert_post([
    107148        'post_title'    => $title,
    108         'post_content'  => wp_kses_post($params['content'] ?? ''),
     149        'post_content'  => $sanitized_content,
    109150        'post_status'   => get_option('outrank_post_as_draft', 'yes') === 'yes' ? 'draft' : 'publish',
    110151        'post_type'     => 'post',
     
    114155        'post_author'   => $author_id,
    115156    ]);
     157
     158    add_filter('content_save_pre', 'wp_filter_post_kses');
    116159
    117160    if (is_wp_error($post_id)) {
  • outrank/tags/1.0.2/outrank.php

    r3337904 r3364907  
    66 * Plugin URI: https://outrank.so
    77 * Description: Get traffic and outrank competitors with automatic SEO-optimized content generation published to your WordPress site.
    8  * Version: 1.0.1
     8 * Version: 1.0.2
    99 * Author: Outrank
    1010 * License: GPLv2 or later
  • outrank/tags/1.0.2/readme.txt

    r3337904 r3364907  
    55Tested up to: 6.8 
    66Requires PHP: 8.0 
    7 Stable tag: 1.0.1 
     7Stable tag: 1.0.2 
    88License: GPLv2 or later 
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html 
     
    7474== Changelog ==
    7575
     76= 1.0.2 =
     77* Fixed YouTube video embedding in synced articles
     78
    7679= 1.0.1 =
    7780* Added posts fetching endpoint for retrieving published blog posts
  • outrank/trunk/libs/api.php

    r3337904 r3364907  
    44define('OUTRANK_API_SECRET', '7d775a0fd0bc1d92e4d3db1fe313d72e');
    55require_once plugin_dir_path(__FILE__) . '../includes/image-functions.php';
     6
     7function sanitize_content($content) {
     8    $allowed_html = wp_kses_allowed_html('post');
     9
     10    $allowed_html['iframe'] = array(
     11        'src' => array(),
     12        'width' => array(),
     13        'height' => array(),
     14        'frameborder' => array(),
     15        'allowfullscreen' => array(),
     16        'allow' => array(),
     17        'style' => array(),
     18    );
     19
     20    $sanitized = wp_kses($content, $allowed_html);
     21
     22    $sanitized = preg_replace_callback(
     23        '/<iframe[^>]*>/i',
     24        function($matches) {
     25            $iframe = $matches[0];
     26
     27            if (preg_match('/src=["\']([^"\']*)["\']/', $iframe, $src_matches)) {
     28                $src = trim($src_matches[1]);
     29
     30                if (preg_match('/^https:\/\/(www\.)?youtube\.com\/embed\/[a-zA-Z0-9_-]{11}(\?[^"\'<>]*)?$/i', $src) ||
     31                    preg_match('/^https:\/\/(www\.)?youtube-nocookie\.com\/embed\/[a-zA-Z0-9_-]{11}(\?[^"\'<>]*)?$/i', $src)) {
     32                    return $iframe;
     33                }
     34            }
     35
     36            return '';
     37        },
     38        $sanitized
     39    );
     40
     41    return $sanitized;
     42}
    643
    744add_action('rest_api_init', function () {
     
    103140    }
    104141
     142    remove_filter('content_save_pre', 'wp_filter_post_kses');
     143
     144    $sanitized_content = sanitize_content($params['content'] ?? '');
     145
    105146    // Insert post
    106147    $post_id = wp_insert_post([
    107148        'post_title'    => $title,
    108         'post_content'  => wp_kses_post($params['content'] ?? ''),
     149        'post_content'  => $sanitized_content,
    109150        'post_status'   => get_option('outrank_post_as_draft', 'yes') === 'yes' ? 'draft' : 'publish',
    110151        'post_type'     => 'post',
     
    114155        'post_author'   => $author_id,
    115156    ]);
     157
     158    add_filter('content_save_pre', 'wp_filter_post_kses');
    116159
    117160    if (is_wp_error($post_id)) {
  • outrank/trunk/outrank.php

    r3337904 r3364907  
    66 * Plugin URI: https://outrank.so
    77 * Description: Get traffic and outrank competitors with automatic SEO-optimized content generation published to your WordPress site.
    8  * Version: 1.0.1
     8 * Version: 1.0.2
    99 * Author: Outrank
    1010 * License: GPLv2 or later
  • outrank/trunk/readme.txt

    r3337904 r3364907  
    55Tested up to: 6.8 
    66Requires PHP: 8.0 
    7 Stable tag: 1.0.1 
     7Stable tag: 1.0.2 
    88License: GPLv2 or later 
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html 
     
    7474== Changelog ==
    7575
     76= 1.0.2 =
     77* Fixed YouTube video embedding in synced articles
     78
    7679= 1.0.1 =
    7780* Added posts fetching endpoint for retrieving published blog posts
Note: See TracChangeset for help on using the changeset viewer.