Changeset 3335385
- Timestamp:
- 07/28/2025 01:03:06 PM (8 months ago)
- Location:
- advanced-ads
- Files:
-
- 22 edited
- 1 copied
-
tags/2.0.10 (copied) (copied from advanced-ads/trunk)
-
tags/2.0.10/advanced-ads.php (modified) (2 diffs)
-
tags/2.0.10/classes/display-conditions.php (modified) (5 diffs)
-
tags/2.0.10/includes/admin/class-ajax.php (modified) (4 diffs)
-
tags/2.0.10/includes/ads/class-ad-group.php (modified) (1 diff)
-
tags/2.0.10/includes/class-widget.php (modified) (2 diffs)
-
tags/2.0.10/includes/compatibility/class-compatibility.php (modified) (2 diffs)
-
tags/2.0.10/includes/frontend/class-scripts.php (modified) (1 diff)
-
tags/2.0.10/includes/utilities/class-wordpress.php (modified) (1 diff)
-
tags/2.0.10/packages/composer/platform_check.php (modified) (1 diff)
-
tags/2.0.10/readme.txt (modified) (2 diffs)
-
tags/2.0.10/wp.advads (modified) (1 diff)
-
trunk/advanced-ads.php (modified) (2 diffs)
-
trunk/classes/display-conditions.php (modified) (5 diffs)
-
trunk/includes/admin/class-ajax.php (modified) (4 diffs)
-
trunk/includes/ads/class-ad-group.php (modified) (1 diff)
-
trunk/includes/class-widget.php (modified) (2 diffs)
-
trunk/includes/compatibility/class-compatibility.php (modified) (2 diffs)
-
trunk/includes/frontend/class-scripts.php (modified) (1 diff)
-
trunk/includes/utilities/class-wordpress.php (modified) (1 diff)
-
trunk/packages/composer/platform_check.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp.advads (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
advanced-ads/tags/2.0.10/advanced-ads.php
r3298118 r3335385 11 11 * @wordpress-plugin 12 12 * Plugin Name: Advanced Ads 13 * Version: 2.0. 913 * Version: 2.0.10 14 14 * Description: Manage and optimize your ads in WordPress 15 15 * Plugin URI: https://wpadvancedads.com … … 38 38 39 39 define( 'ADVADS_FILE', __FILE__ ); 40 define( 'ADVADS_VERSION', '2.0. 9' );40 define( 'ADVADS_VERSION', '2.0.10' ); 41 41 42 42 // Load the autoloader. -
advanced-ads/tags/2.0.10/classes/display-conditions.php
r3298118 r3335385 2 2 3 3 use AdvancedAds\Abstracts\Ad; 4 use AdvancedAds\Utilities\WordPress; 4 5 use AdvancedAds\Framework\Utilities\Params; 5 use AdvancedAds\Utilities\WordPress;6 6 7 7 /** … … 12 12 class Advanced_Ads_Display_Conditions { 13 13 /** 14 * Condit onis14 * Conditions 15 15 * 16 16 * Registered display conditions. … … 941 941 $operator = 'is'; 942 942 } 943 943 944 $post = $ad->get_prop( 'ad_args.post' ) ?? null; 944 945 $post_type = $post['post_type'] ?? false; … … 1102 1103 */ 1103 1104 public static function check_post_ids( $options, Ad $ad ) { 1105 $operator = 'is'; 1104 1106 if ( isset( $options['operator'] ) && 'is_not' === $options['operator'] ) { 1105 1107 $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; 1112 1112 1113 1113 // fixes page id on BuddyPress pages. … … 1125 1125 */ 1126 1126 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' ); 1128 1128 1129 1129 return self::can_display_ids( $post_id, $options['value'], $operator ); -
advanced-ads/tags/2.0.10/includes/admin/class-ajax.php
r3253289 r3335385 22 22 use Advanced_Ads_Visitor_Conditions; 23 23 use AdvancedAds\Utilities\Conditional; 24 use AdvancedAds\Framework\Utilities\Arr; 24 25 use AdvancedAds\Framework\Utilities\Params; 25 26 use AdvancedAds\Framework\Interfaces\Integration_Interface; … … 718 719 719 720 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 } 722 735 echo esc_attr( $placement_id ); 723 736 } … … 739 752 740 753 // set content specific options. 741 $options = Params::request( 'options', [], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );742 754 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 ); 744 757 $props['position'] = 'after'; 745 758 $props['index'] = $index; … … 748 761 749 762 $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 753 764 } 754 765 -
advanced-ads/tags/2.0.10/includes/ads/class-ad-group.php
r3253289 r3335385 41 41 } 42 42 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 ); 44 48 } 45 49 } -
advanced-ads/tags/2.0.10/includes/class-widget.php
r3253289 r3335385 188 188 } 189 189 190 if ( ! empty( $select ) ) {191 sort( $select);190 if ( ! empty( $select['placements'] ) ) { 191 asort( $select['placements'] ); 192 192 } 193 193 … … 214 214 if ( empty( $item_id ) ) { 215 215 return; 216 }217 218 if ( 'placement' === $item[0] ) {219 return get_the_placement( $item_id );220 216 } 221 217 -
advanced-ads/tags/2.0.10/includes/compatibility/class-compatibility.php
r3269753 r3335385 78 78 */ 79 79 public function mailpoet_ad_shortcode( $shortcode ): string { 80 preg_match( '/\d+/', $shortcode, $matches );81 $entity_id = empty( $matches[0] ) ? false : $matches[0];82 83 80 // 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 : ''; 91 87 } 92 88 93 89 // 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' ] ) ) { 97 94 $ad_content = get_the_ad( $ad ); 98 95 // Add responsive styles for email compatibility. 99 96 if ( $ad->is_type( 'image' ) ) { 100 $ad_content =str_replace(97 return str_replace( 101 98 '<img', 102 99 '<img style="max-width: 100%; height: auto; display: block;"', … … 104 101 ); 105 102 } 106 107 103 return $ad_content; 108 104 } -
advanced-ads/tags/2.0.10/includes/frontend/class-scripts.php
r3298118 r3335385 86 86 wp_enqueue_script( ADVADS_SLUG . '-frontend-picker' ); 87 87 } 88 89 wp_advads()->registry->enqueue_script( 'find-adblocker' ); 88 90 } 89 91 -
advanced-ads/tags/2.0.10/includes/utilities/class-wordpress.php
r3253826 r3335385 264 264 continue; 265 265 } 266 266 // skip paginated_post from value check. 267 if ( isset( $condition['type'] ) && 'paginated_post' === $condition['type'] ) { 268 continue; 269 } 267 270 if ( empty( $condition['value'] ) ) { 268 271 unset( $conditions[ $index ] ); -
advanced-ads/tags/2.0.10/packages/composer/platform_check.php
r3253289 r3335385 20 20 } 21 21 } 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) 25 24 ); 26 25 } -
advanced-ads/tags/2.0.10/readme.txt
r3298118 r3335385 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 2.0. 97 Stable tag: 2.0.10 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 361 361 == Changelog == 362 362 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 363 373 = 2.0.9 (May 21, 2025) = 364 374 -
advanced-ads/tags/2.0.10/wp.advads
r3298118 r3335385 3 3 "name": "Advanced Ads", 4 4 "description": "Manage and optimize your ads in WordPress", 5 "version": "2.0. 9",5 "version": "2.0.10", 6 6 "requireWP": "5.7", 7 7 "requirePHP": "7.4", -
advanced-ads/trunk/advanced-ads.php
r3298118 r3335385 11 11 * @wordpress-plugin 12 12 * Plugin Name: Advanced Ads 13 * Version: 2.0. 913 * Version: 2.0.10 14 14 * Description: Manage and optimize your ads in WordPress 15 15 * Plugin URI: https://wpadvancedads.com … … 38 38 39 39 define( 'ADVADS_FILE', __FILE__ ); 40 define( 'ADVADS_VERSION', '2.0. 9' );40 define( 'ADVADS_VERSION', '2.0.10' ); 41 41 42 42 // Load the autoloader. -
advanced-ads/trunk/classes/display-conditions.php
r3298118 r3335385 2 2 3 3 use AdvancedAds\Abstracts\Ad; 4 use AdvancedAds\Utilities\WordPress; 4 5 use AdvancedAds\Framework\Utilities\Params; 5 use AdvancedAds\Utilities\WordPress;6 6 7 7 /** … … 12 12 class Advanced_Ads_Display_Conditions { 13 13 /** 14 * Condit onis14 * Conditions 15 15 * 16 16 * Registered display conditions. … … 941 941 $operator = 'is'; 942 942 } 943 943 944 $post = $ad->get_prop( 'ad_args.post' ) ?? null; 944 945 $post_type = $post['post_type'] ?? false; … … 1102 1103 */ 1103 1104 public static function check_post_ids( $options, Ad $ad ) { 1105 $operator = 'is'; 1104 1106 if ( isset( $options['operator'] ) && 'is_not' === $options['operator'] ) { 1105 1107 $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; 1112 1112 1113 1113 // fixes page id on BuddyPress pages. … … 1125 1125 */ 1126 1126 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' ); 1128 1128 1129 1129 return self::can_display_ids( $post_id, $options['value'], $operator ); -
advanced-ads/trunk/includes/admin/class-ajax.php
r3253289 r3335385 22 22 use Advanced_Ads_Visitor_Conditions; 23 23 use AdvancedAds\Utilities\Conditional; 24 use AdvancedAds\Framework\Utilities\Arr; 24 25 use AdvancedAds\Framework\Utilities\Params; 25 26 use AdvancedAds\Framework\Interfaces\Integration_Interface; … … 718 719 719 720 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 } 722 735 echo esc_attr( $placement_id ); 723 736 } … … 739 752 740 753 // set content specific options. 741 $options = Params::request( 'options', [], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );742 754 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 ); 744 757 $props['position'] = 'after'; 745 758 $props['index'] = $index; … … 748 761 749 762 $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 753 764 } 754 765 -
advanced-ads/trunk/includes/ads/class-ad-group.php
r3253289 r3335385 41 41 } 42 42 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 ); 44 48 } 45 49 } -
advanced-ads/trunk/includes/class-widget.php
r3253289 r3335385 188 188 } 189 189 190 if ( ! empty( $select ) ) {191 sort( $select);190 if ( ! empty( $select['placements'] ) ) { 191 asort( $select['placements'] ); 192 192 } 193 193 … … 214 214 if ( empty( $item_id ) ) { 215 215 return; 216 }217 218 if ( 'placement' === $item[0] ) {219 return get_the_placement( $item_id );220 216 } 221 217 -
advanced-ads/trunk/includes/compatibility/class-compatibility.php
r3269753 r3335385 78 78 */ 79 79 public function mailpoet_ad_shortcode( $shortcode ): string { 80 preg_match( '/\d+/', $shortcode, $matches );81 $entity_id = empty( $matches[0] ) ? false : $matches[0];82 83 80 // 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 : ''; 91 87 } 92 88 93 89 // 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' ] ) ) { 97 94 $ad_content = get_the_ad( $ad ); 98 95 // Add responsive styles for email compatibility. 99 96 if ( $ad->is_type( 'image' ) ) { 100 $ad_content =str_replace(97 return str_replace( 101 98 '<img', 102 99 '<img style="max-width: 100%; height: auto; display: block;"', … … 104 101 ); 105 102 } 106 107 103 return $ad_content; 108 104 } -
advanced-ads/trunk/includes/frontend/class-scripts.php
r3298118 r3335385 86 86 wp_enqueue_script( ADVADS_SLUG . '-frontend-picker' ); 87 87 } 88 89 wp_advads()->registry->enqueue_script( 'find-adblocker' ); 88 90 } 89 91 -
advanced-ads/trunk/includes/utilities/class-wordpress.php
r3253826 r3335385 264 264 continue; 265 265 } 266 266 // skip paginated_post from value check. 267 if ( isset( $condition['type'] ) && 'paginated_post' === $condition['type'] ) { 268 continue; 269 } 267 270 if ( empty( $condition['value'] ) ) { 268 271 unset( $conditions[ $index ] ); -
advanced-ads/trunk/packages/composer/platform_check.php
r3253289 r3335385 20 20 } 21 21 } 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) 25 24 ); 26 25 } -
advanced-ads/trunk/readme.txt
r3298118 r3335385 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 2.0. 97 Stable tag: 2.0.10 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 361 361 == Changelog == 362 362 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 363 373 = 2.0.9 (May 21, 2025) = 364 374 -
advanced-ads/trunk/wp.advads
r3298118 r3335385 3 3 "name": "Advanced Ads", 4 4 "description": "Manage and optimize your ads in WordPress", 5 "version": "2.0. 9",5 "version": "2.0.10", 6 6 "requireWP": "5.7", 7 7 "requirePHP": "7.4",
Note: See TracChangeset
for help on using the changeset viewer.