Plugin Directory

Changeset 3335385


Ignore:
Timestamp:
07/28/2025 01:03:06 PM (8 months ago)
Author:
advancedads
Message:

Update to version 2.0.10 from GitHub

Location:
advanced-ads
Files:
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • advanced-ads/tags/2.0.10/advanced-ads.php

    r3298118 r3335385  
    1111 * @wordpress-plugin
    1212 * Plugin Name:       Advanced Ads
    13  * Version:           2.0.9
     13 * Version:           2.0.10
    1414 * Description:       Manage and optimize your ads in WordPress
    1515 * Plugin URI:        https://wpadvancedads.com
     
    3838
    3939define( 'ADVADS_FILE', __FILE__ );
    40 define( 'ADVADS_VERSION', '2.0.9' );
     40define( 'ADVADS_VERSION', '2.0.10' );
    4141
    4242// Load the autoloader.
  • advanced-ads/tags/2.0.10/classes/display-conditions.php

    r3298118 r3335385  
    22
    33use AdvancedAds\Abstracts\Ad;
     4use AdvancedAds\Utilities\WordPress;
    45use AdvancedAds\Framework\Utilities\Params;
    5 use AdvancedAds\Utilities\WordPress;
    66
    77/**
     
    1212class Advanced_Ads_Display_Conditions {
    1313    /**
    14      * Conditonis
     14     * Conditions
    1515     *
    1616     * Registered display conditions.
     
    941941            $operator = 'is';
    942942        }
     943
    943944        $post      = $ad->get_prop( 'ad_args.post' ) ?? null;
    944945        $post_type = $post['post_type'] ?? false;
     
    11021103     */
    11031104    public static function check_post_ids( $options, Ad $ad ) {
     1105        $operator = 'is';
    11041106        if ( isset( $options['operator'] ) && 'is_not' === $options['operator'] ) {
    11051107            $operator = 'is_not';
    1106         } else {
    1107             $operator = 'is';
    1108         }
    1109 
    1110         $post    = $ad->get_prop( 'ad_args.post' );
    1111         $post_id = $post['id'];
     1108        }
     1109
     1110        $post    = $ad->get_prop( 'ad_args.post' ) ?? null;
     1111        $post_id = $post['id'] ?? 0;
    11121112
    11131113        // fixes page id on BuddyPress pages.
     
    11251125         */
    11261126        if ( function_exists( 'is_shop' ) && is_shop() && isset( $options['value'] ) && is_array( $options['value'] ) ) {
    1127             $post_id = get_option( 'woocommerce_shop_page_id' );
     1127            $post_id = wc_get_page_id( 'shop' );
    11281128
    11291129            return self::can_display_ids( $post_id, $options['value'], $operator );
  • advanced-ads/tags/2.0.10/includes/admin/class-ajax.php

    r3253289 r3335385  
    2222use Advanced_Ads_Visitor_Conditions;
    2323use AdvancedAds\Utilities\Conditional;
     24use AdvancedAds\Framework\Utilities\Arr;
    2425use AdvancedAds\Framework\Utilities\Params;
    2526use AdvancedAds\Framework\Interfaces\Integration_Interface;
     
    718719
    719720            if ( $placement ) {
    720                 $placement->set_item( 'ad_' . $ad_id );
    721                 $placement->save();
     721                $current_item = $placement->get_item();
     722                // Check if current item is a group and new item is an ad.
     723                if ( is_string( $current_item ) && strpos( $current_item, 'group_' ) === 0 ) {
     724                    $group = wp_advads_get_group( (int) str_replace( 'group_', '', $current_item ) );
     725                    if ( $group ) {
     726                        $ad_weights           = $group->get_ad_weights();
     727                        $ad_weights[ $ad_id ] = Constants::GROUP_AD_DEFAULT_WEIGHT;
     728                        $group->set_ad_weights( $ad_weights );
     729                        $group->save();
     730                    }
     731                } else {
     732                    $placement->set_item( 'ad_' . $ad_id );
     733                    $placement->save();
     734                }
    722735                echo esc_attr( $placement_id );
    723736            }
     
    739752
    740753        // set content specific options.
    741         $options = Params::request( 'options', [], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
    742754        if ( $new_placement->is_type( 'post_content' ) ) {
    743             $index             = ! empty( $options['index'] ) ? absint( $options['index'] ) : 1;
     755            $options           = Params::request( 'options', [], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
     756            $index             = (int) Arr::get( $options, 'index', 1 );
    744757            $props['position'] = 'after';
    745758            $props['index']    = $index;
     
    748761
    749762        $new_placement->set_props( $props );
    750         $p_id = $new_placement->save();
    751 
    752         echo $p_id; // phpcs:ignore
     763        echo $new_placement->save();; // phpcs:ignore
    753764    }
    754765
  • advanced-ads/tags/2.0.10/includes/ads/class-ad-group.php

    r3253289 r3335385  
    4141        }
    4242
    43         return get_the_group( $this->get_group_id(), '', $this->get_prop( 'ad_args' ) ?? [] );
     43        // Disable the ad label for the ad group wrapper itself to avoid duplicate labels.
     44        $ad_args             = $this->get_prop( 'ad_args' ) ?? [];
     45        $ad_args['ad_label'] = 'disabled';
     46
     47        return get_the_group( $this->get_group_id(), '', $ad_args );
    4448    }
    4549}
  • advanced-ads/tags/2.0.10/includes/class-widget.php

    r3253289 r3335385  
    188188        }
    189189
    190         if ( ! empty( $select ) ) {
    191             sort( $select );
     190        if ( ! empty( $select['placements'] ) ) {
     191            asort( $select['placements'] );
    192192        }
    193193
     
    214214        if ( empty( $item_id ) ) {
    215215            return;
    216         }
    217 
    218         if ( 'placement' === $item[0] ) {
    219             return get_the_placement( $item_id );
    220216        }
    221217
  • advanced-ads/tags/2.0.10/includes/compatibility/class-compatibility.php

    r3269753 r3335385  
    7878     */
    7979    public function mailpoet_ad_shortcode( $shortcode ): string {
    80         preg_match( '/\d+/', $shortcode, $matches );
    81         $entity_id = empty( $matches[0] ) ? false : $matches[0];
    82 
    8380        // Display an ad group.
    84         if ( Str::starts_with( '[custom:ad_group:', $shortcode ) && $entity_id ) {
    85             $ad_group = wp_advads_get_group( $entity_id );
    86             if ( $ad_group->is_type( [ 'default', 'ordered' ] ) ) {
    87                 return get_the_group( $ad_group );
    88             }
    89 
    90             return '';
     81        if ( sscanf( $shortcode, '[custom:ad_group:%d]', $id ) === 1 ) {
     82            $ad_group = wp_advads_get_group( $id );
     83
     84            return ( $ad_group && $ad_group->is_type( [ 'default', 'ordered' ] ) )
     85                ? get_the_group( $ad_group )
     86                : '';
    9187        }
    9288
    9389        // Display individual ad.
    94         if ( Str::starts_with( '[custom:ad:', $shortcode ) && $entity_id ) {
    95             $ad = wp_advads_get_ad( $entity_id );
    96             if ( $ad->is_type( [ 'plain', 'image' ] ) ) {
     90        if ( sscanf( $shortcode, '[custom:ad:%d]', $id ) === 1 ) {
     91            $ad = wp_advads_get_ad( $id );
     92
     93            if ( $ad && $ad->is_type( [ 'plain', 'image' ] ) ) {
    9794                $ad_content = get_the_ad( $ad );
    9895                // Add responsive styles for email compatibility.
    9996                if ( $ad->is_type( 'image' ) ) {
    100                     $ad_content = str_replace(
     97                    return str_replace(
    10198                        '<img',
    10299                        '<img style="max-width: 100%; height: auto; display: block;"',
     
    104101                    );
    105102                }
    106 
    107103                return $ad_content;
    108104            }
  • advanced-ads/tags/2.0.10/includes/frontend/class-scripts.php

    r3298118 r3335385  
    8686            wp_enqueue_script( ADVADS_SLUG . '-frontend-picker' );
    8787        }
     88
     89        wp_advads()->registry->enqueue_script( 'find-adblocker' );
    8890    }
    8991
  • advanced-ads/tags/2.0.10/includes/utilities/class-wordpress.php

    r3253826 r3335385  
    264264                continue;
    265265            }
    266 
     266            // skip paginated_post from value check.
     267            if ( isset( $condition['type'] ) && 'paginated_post' === $condition['type'] ) {
     268                continue;
     269            }
    267270            if ( empty( $condition['value'] ) ) {
    268271                unset( $conditions[ $index ] );
  • advanced-ads/tags/2.0.10/packages/composer/platform_check.php

    r3253289 r3335385  
    2020        }
    2121    }
    22     trigger_error(
    23         'Composer detected issues in your platform: ' . implode(' ', $issues),
    24         E_USER_ERROR
     22    throw new \RuntimeException(
     23        'Composer detected issues in your platform: ' . implode(' ', $issues)
    2524    );
    2625}
  • advanced-ads/tags/2.0.10/readme.txt

    r3298118 r3335385  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 2.0.9
     7Stable tag: 2.0.10
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    361361== Changelog ==
    362362
     363= 2.0.10 (July 28, 2025) =
     364
     365- Fix: add null check in display conditions
     366- Fix: optimize ad handling and performance for MailPoet
     367- Fix: restore placement in widget dropdown
     368- Fix: resolve issue with ad blocker detection
     369- Fix: save pagination display condition in placements
     370- Fix: duplicate ad labels when using group as ad type
     371- Fix: append ad to existing group when selecting placement from ad edit screen
     372
    363373= 2.0.9 (May 21, 2025) =
    364374
  • advanced-ads/tags/2.0.10/wp.advads

    r3298118 r3335385  
    33    "name": "Advanced Ads",
    44    "description": "Manage and optimize your ads in WordPress",
    5     "version": "2.0.9",
     5    "version": "2.0.10",
    66    "requireWP": "5.7",
    77    "requirePHP": "7.4",
  • advanced-ads/trunk/advanced-ads.php

    r3298118 r3335385  
    1111 * @wordpress-plugin
    1212 * Plugin Name:       Advanced Ads
    13  * Version:           2.0.9
     13 * Version:           2.0.10
    1414 * Description:       Manage and optimize your ads in WordPress
    1515 * Plugin URI:        https://wpadvancedads.com
     
    3838
    3939define( 'ADVADS_FILE', __FILE__ );
    40 define( 'ADVADS_VERSION', '2.0.9' );
     40define( 'ADVADS_VERSION', '2.0.10' );
    4141
    4242// Load the autoloader.
  • advanced-ads/trunk/classes/display-conditions.php

    r3298118 r3335385  
    22
    33use AdvancedAds\Abstracts\Ad;
     4use AdvancedAds\Utilities\WordPress;
    45use AdvancedAds\Framework\Utilities\Params;
    5 use AdvancedAds\Utilities\WordPress;
    66
    77/**
     
    1212class Advanced_Ads_Display_Conditions {
    1313    /**
    14      * Conditonis
     14     * Conditions
    1515     *
    1616     * Registered display conditions.
     
    941941            $operator = 'is';
    942942        }
     943
    943944        $post      = $ad->get_prop( 'ad_args.post' ) ?? null;
    944945        $post_type = $post['post_type'] ?? false;
     
    11021103     */
    11031104    public static function check_post_ids( $options, Ad $ad ) {
     1105        $operator = 'is';
    11041106        if ( isset( $options['operator'] ) && 'is_not' === $options['operator'] ) {
    11051107            $operator = 'is_not';
    1106         } else {
    1107             $operator = 'is';
    1108         }
    1109 
    1110         $post    = $ad->get_prop( 'ad_args.post' );
    1111         $post_id = $post['id'];
     1108        }
     1109
     1110        $post    = $ad->get_prop( 'ad_args.post' ) ?? null;
     1111        $post_id = $post['id'] ?? 0;
    11121112
    11131113        // fixes page id on BuddyPress pages.
     
    11251125         */
    11261126        if ( function_exists( 'is_shop' ) && is_shop() && isset( $options['value'] ) && is_array( $options['value'] ) ) {
    1127             $post_id = get_option( 'woocommerce_shop_page_id' );
     1127            $post_id = wc_get_page_id( 'shop' );
    11281128
    11291129            return self::can_display_ids( $post_id, $options['value'], $operator );
  • advanced-ads/trunk/includes/admin/class-ajax.php

    r3253289 r3335385  
    2222use Advanced_Ads_Visitor_Conditions;
    2323use AdvancedAds\Utilities\Conditional;
     24use AdvancedAds\Framework\Utilities\Arr;
    2425use AdvancedAds\Framework\Utilities\Params;
    2526use AdvancedAds\Framework\Interfaces\Integration_Interface;
     
    718719
    719720            if ( $placement ) {
    720                 $placement->set_item( 'ad_' . $ad_id );
    721                 $placement->save();
     721                $current_item = $placement->get_item();
     722                // Check if current item is a group and new item is an ad.
     723                if ( is_string( $current_item ) && strpos( $current_item, 'group_' ) === 0 ) {
     724                    $group = wp_advads_get_group( (int) str_replace( 'group_', '', $current_item ) );
     725                    if ( $group ) {
     726                        $ad_weights           = $group->get_ad_weights();
     727                        $ad_weights[ $ad_id ] = Constants::GROUP_AD_DEFAULT_WEIGHT;
     728                        $group->set_ad_weights( $ad_weights );
     729                        $group->save();
     730                    }
     731                } else {
     732                    $placement->set_item( 'ad_' . $ad_id );
     733                    $placement->save();
     734                }
    722735                echo esc_attr( $placement_id );
    723736            }
     
    739752
    740753        // set content specific options.
    741         $options = Params::request( 'options', [], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
    742754        if ( $new_placement->is_type( 'post_content' ) ) {
    743             $index             = ! empty( $options['index'] ) ? absint( $options['index'] ) : 1;
     755            $options           = Params::request( 'options', [], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
     756            $index             = (int) Arr::get( $options, 'index', 1 );
    744757            $props['position'] = 'after';
    745758            $props['index']    = $index;
     
    748761
    749762        $new_placement->set_props( $props );
    750         $p_id = $new_placement->save();
    751 
    752         echo $p_id; // phpcs:ignore
     763        echo $new_placement->save();; // phpcs:ignore
    753764    }
    754765
  • advanced-ads/trunk/includes/ads/class-ad-group.php

    r3253289 r3335385  
    4141        }
    4242
    43         return get_the_group( $this->get_group_id(), '', $this->get_prop( 'ad_args' ) ?? [] );
     43        // Disable the ad label for the ad group wrapper itself to avoid duplicate labels.
     44        $ad_args             = $this->get_prop( 'ad_args' ) ?? [];
     45        $ad_args['ad_label'] = 'disabled';
     46
     47        return get_the_group( $this->get_group_id(), '', $ad_args );
    4448    }
    4549}
  • advanced-ads/trunk/includes/class-widget.php

    r3253289 r3335385  
    188188        }
    189189
    190         if ( ! empty( $select ) ) {
    191             sort( $select );
     190        if ( ! empty( $select['placements'] ) ) {
     191            asort( $select['placements'] );
    192192        }
    193193
     
    214214        if ( empty( $item_id ) ) {
    215215            return;
    216         }
    217 
    218         if ( 'placement' === $item[0] ) {
    219             return get_the_placement( $item_id );
    220216        }
    221217
  • advanced-ads/trunk/includes/compatibility/class-compatibility.php

    r3269753 r3335385  
    7878     */
    7979    public function mailpoet_ad_shortcode( $shortcode ): string {
    80         preg_match( '/\d+/', $shortcode, $matches );
    81         $entity_id = empty( $matches[0] ) ? false : $matches[0];
    82 
    8380        // Display an ad group.
    84         if ( Str::starts_with( '[custom:ad_group:', $shortcode ) && $entity_id ) {
    85             $ad_group = wp_advads_get_group( $entity_id );
    86             if ( $ad_group->is_type( [ 'default', 'ordered' ] ) ) {
    87                 return get_the_group( $ad_group );
    88             }
    89 
    90             return '';
     81        if ( sscanf( $shortcode, '[custom:ad_group:%d]', $id ) === 1 ) {
     82            $ad_group = wp_advads_get_group( $id );
     83
     84            return ( $ad_group && $ad_group->is_type( [ 'default', 'ordered' ] ) )
     85                ? get_the_group( $ad_group )
     86                : '';
    9187        }
    9288
    9389        // Display individual ad.
    94         if ( Str::starts_with( '[custom:ad:', $shortcode ) && $entity_id ) {
    95             $ad = wp_advads_get_ad( $entity_id );
    96             if ( $ad->is_type( [ 'plain', 'image' ] ) ) {
     90        if ( sscanf( $shortcode, '[custom:ad:%d]', $id ) === 1 ) {
     91            $ad = wp_advads_get_ad( $id );
     92
     93            if ( $ad && $ad->is_type( [ 'plain', 'image' ] ) ) {
    9794                $ad_content = get_the_ad( $ad );
    9895                // Add responsive styles for email compatibility.
    9996                if ( $ad->is_type( 'image' ) ) {
    100                     $ad_content = str_replace(
     97                    return str_replace(
    10198                        '<img',
    10299                        '<img style="max-width: 100%; height: auto; display: block;"',
     
    104101                    );
    105102                }
    106 
    107103                return $ad_content;
    108104            }
  • advanced-ads/trunk/includes/frontend/class-scripts.php

    r3298118 r3335385  
    8686            wp_enqueue_script( ADVADS_SLUG . '-frontend-picker' );
    8787        }
     88
     89        wp_advads()->registry->enqueue_script( 'find-adblocker' );
    8890    }
    8991
  • advanced-ads/trunk/includes/utilities/class-wordpress.php

    r3253826 r3335385  
    264264                continue;
    265265            }
    266 
     266            // skip paginated_post from value check.
     267            if ( isset( $condition['type'] ) && 'paginated_post' === $condition['type'] ) {
     268                continue;
     269            }
    267270            if ( empty( $condition['value'] ) ) {
    268271                unset( $conditions[ $index ] );
  • advanced-ads/trunk/packages/composer/platform_check.php

    r3253289 r3335385  
    2020        }
    2121    }
    22     trigger_error(
    23         'Composer detected issues in your platform: ' . implode(' ', $issues),
    24         E_USER_ERROR
     22    throw new \RuntimeException(
     23        'Composer detected issues in your platform: ' . implode(' ', $issues)
    2524    );
    2625}
  • advanced-ads/trunk/readme.txt

    r3298118 r3335385  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 2.0.9
     7Stable tag: 2.0.10
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    361361== Changelog ==
    362362
     363= 2.0.10 (July 28, 2025) =
     364
     365- Fix: add null check in display conditions
     366- Fix: optimize ad handling and performance for MailPoet
     367- Fix: restore placement in widget dropdown
     368- Fix: resolve issue with ad blocker detection
     369- Fix: save pagination display condition in placements
     370- Fix: duplicate ad labels when using group as ad type
     371- Fix: append ad to existing group when selecting placement from ad edit screen
     372
    363373= 2.0.9 (May 21, 2025) =
    364374
  • advanced-ads/trunk/wp.advads

    r3298118 r3335385  
    33    "name": "Advanced Ads",
    44    "description": "Manage and optimize your ads in WordPress",
    5     "version": "2.0.9",
     5    "version": "2.0.10",
    66    "requireWP": "5.7",
    77    "requirePHP": "7.4",
Note: See TracChangeset for help on using the changeset viewer.