Plugin Directory

Changeset 3435129


Ignore:
Timestamp:
01/08/2026 12:55:52 PM (3 months ago)
Author:
assafadscale
Message:

Enhancement: use WooCommerce price precision in helper formatting function.

Location:
adscale-ai
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • adscale-ai/trunk/adscale-ai.php

    r3429458 r3435129  
    88 * Plugin URI: https://www.adscale.com/integration/#woocommerce
    99 * Description: AdScale plugin allows you to automate Ecommerce advertising across all channels and drive more sales to your store. Easily create, manage & optimize ads on one platform.
    10  * Version: 2.2.12
     10 * Version: 2.2.13
    1111 * Author: AdScale LTD
    1212 * Author URI: https://www.adscale.com
     
    2323defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
    2424use AdScale\App;
    25 define( 'ADSCALE_INTERNAL_MODULE_VERSION', 'v20251229' );
     25define( 'ADSCALE_INTERNAL_MODULE_VERSION', 'v20260108-M' );
    2626define( 'ADSCALE_PLUGIN_DIR', __DIR__ );
    2727define( 'ADSCALE_PLUGIN_FILE', __FILE__ );
     
    4444        'adscale/config',
    4545        array( $config ),
    46         '2.1.19',
     46        '2.2.13',
    4747        'adscale_config'
    4848    );
  • adscale-ai/trunk/changelog.txt

    r3429458 r3435129  
    11*** AdScale AI Changelog ***
     2
     32026-01-08 - version 2.2.13
     4* Fix: prevent HPOS fatal error by switching wc_get_orders() date filters to WooCommerce string format.
     5* Enhancement: use WooCommerce price precision in helper formatting function.
     6
     72026-01-05 - version 2.2.13
     8* Fix: sanitize product descriptions to remove media blocks (video/audio/images), links and shortcodes to prevent malformed API payloads.
    29
    3102025-12-29 - version 2.2.12
  • adscale-ai/trunk/readme.txt

    r3429458 r3435129  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.2.12
     7Stable tag: 2.2.13
    88License: GPL-2.0+
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • adscale-ai/trunk/src/Helpers/Helper.php

    r3425442 r3435129  
    122122    public static function get_sanitize_description( $desc ) {
    123123        $clean = wp_check_invalid_utf8( $desc ?? '' );
     124        // Remove embedded media blocks (video/audio/images) from rich editors like Elementor.
     125        // Strip full blocks first to avoid leaving media URLs in the resulting plain text.
     126        $clean = preg_replace( '/<div[^>]*class=[\"\\\'][^\"\\\']*wp-video[^\"\\\']*[\"\\\'][^>]*>.*?<\\/div>/is', ' ', $clean );
     127        $clean = preg_replace( '/<figure[^>]*class=[\"\\\'][^\"\\\']*wp-block-(video|audio|embed)[^\"\\\']*[\"\\\'][^>]*>.*?<\\/figure>/is', ' ', $clean );
     128        $clean = preg_replace( '/<(video|audio)\\b[^>]*>.*?<\\/(video|audio)>/is', ' ', $clean );
     129        $clean = preg_replace( '/<source\\b[^>]*>/is', ' ', $clean );
     130        $clean = preg_replace( '/<img\\b[^>]*>/is', ' ', $clean );
     131        // Remove anchor links entirely (href + linked text), so URLs don't leak into plain text.
     132        $clean = preg_replace( '/<a\b[^>]*>.*?<\/a>/is', ' ', $clean );
    124133        // Remove all HTML tags but keep text
    125134        $clean = wp_strip_all_tags( $clean );
    126135        // Decode HTML entities to plain text
    127136        $clean = html_entity_decode( $clean, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8' );
     137        // Then remove the marker when it precedes a number.
     138        $clean = preg_replace( '/[<<]\s*(?=\d)/u', '', $clean );
    128139        // Normalize real newlines
    129140        $clean = str_replace( [ "\r\n", "\n", "\r" ], ' ', $clean );
    130         // Remove literal escaped \n and \r if present
    131         $clean = str_replace( [ '\\n', '\\r' ], ' ', $clean );
    132         // Remove stray backslashes that can break JSON if the string is re-encoded or concatenated
    133         $clean = str_replace( '\\', '', $clean );
    134         // Optionally, normalize quotes so they don't interfere with JSON if someone concatenates the string
    135         $clean = str_replace( [ '"', "\'" ], "'", $clean );
    136         // Collapse multiple spaces
     141        // Strip ASCII control characters that can break some JSON parsers.
     142        $clean = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/u', '', $clean );
     143        // Remove WordPress shortcodes (e.g., [gallery], [video src=...]).
     144        $clean = preg_replace( '/\[[^\]]+\]/', ' ', $clean );
     145        // Remove plain URLs.
     146        $clean = preg_replace( '#https?://[^\s<>"]+#i', ' ', $clean );
     147        // Remove common www-style URLs.
     148        $clean = preg_replace( '#\bwww\.[^\s]+#i', ' ', $clean );
     149        // Collapse whitespace.
    137150        $clean = preg_replace( '/\s+/', ' ', $clean );
    138         $clean = trim( $clean );
    139         return $clean;
     151        return trim( $clean );
    140152    }
    141153
  • adscale-ai/trunk/src/PluginApi/Orders.php

    r3425442 r3435129  
    343343        }
    344344
    345         // Apply created date range (start/end).
     345        // Apply created date range (start/end) using WooCommerce string-based date filters.
    346346        $start = !empty(self::$requestParams['start']) ? Helper::reformat_date(self::$requestParams['start'], 'dmY', 'Y-m-d') : '';
    347347        $end = !empty(self::$requestParams['end']) ? Helper::reformat_date(self::$requestParams['end'], 'dmY', 'Y-m-d') : '';
    348         if ($start || $end) {
    349             $date_created = array();
    350             if ($start) {
    351                 $date_created['after'] = $start . ' 00:00:00';
    352             }
    353             if ($end) {
    354                 $date_created['before'] = $end . ' 23:59:59';
    355             }
    356             $date_created['inclusive'] = true;
    357             $args['date_created'] = $date_created;
    358         }
    359 
    360         // Apply modified-after filter.
     348        if ($start && $end) {
     349            $args['date_created'] = $start . '...' . $end;
     350        } elseif ($start) {
     351            $args['date_created'] = '>=' . $start;
     352        } elseif ($end) {
     353            $args['date_created'] = '<=' . $end;
     354        }
     355
     356        // Apply modified-after filter using WooCommerce string-based date filter.
    361357        $changed_after = !empty(self::$requestParams['changed_after']) ? Helper::reformat_date(self::$requestParams['changed_after'], 'dmY', 'Y-m-d') : '';
    362358        if ($changed_after) {
    363             $args['date_modified'] = array(
    364                 'after' => $changed_after . ' 00:00:00',
    365                 'inclusive' => true,
    366             );
     359            $args['date_modified'] = '>=' . $changed_after;
    367360        }
    368361
Note: See TracChangeset for help on using the changeset viewer.