From a99494a854855a3fd1388d7821db7aeef549adb9 Mon Sep 17 00:00:00 2001 From: Miguel Peixe Date: Thu, 15 Aug 2024 08:34:32 -0300 Subject: [PATCH 1/2] fix(gam): add 1x1 size to all viewports (#888) --- includes/providers/gam/class-gam-model.php | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/includes/providers/gam/class-gam-model.php b/includes/providers/gam/class-gam-model.php index b126e442..a0cd7771 100644 --- a/includes/providers/gam/class-gam-model.php +++ b/includes/providers/gam/class-gam-model.php @@ -855,11 +855,6 @@ public static function get_ad_unit_size_map( $ad_unit, $sizes = [] ) { $sizes = $ad_unit['sizes']; } - // Ensure that 1x1 is always available. - if ( ! in_array( [ 1, 1 ], $sizes, true ) ) { - $sizes[] = [ 1, 1 ]; - } - /** * Filters the ad unit size map difference ratio. * @@ -878,6 +873,15 @@ public static function get_ad_unit_size_map( $ad_unit, $sizes = [] ) { */ $width_threshold = apply_filters( 'newspack_ads_gam_size_map_width_threshold', 600, $ad_unit, $sizes ); + $size_map = self::get_responsive_size_map( $sizes, $width_diff_ratio, $width_threshold ); + + // Add 1x1 size to all viewports. + foreach ( $size_map as $viewport => $sizes ) { + if ( ! in_array( [ 1, 1 ], $sizes, true ) ) { + array_unshift( $size_map[ $viewport ], [ 1, 1 ] ); + } + } + /** * Filters the ad unit size map rules. * @@ -885,14 +889,7 @@ public static function get_ad_unit_size_map( $ad_unit, $sizes = [] ) { * @param array $ad_unit The ad unit config. * @param array[] $sizes The sizes being used. */ - $size_map = apply_filters( - 'newspack_ads_gam_size_map', - self::get_responsive_size_map( $sizes, $width_diff_ratio, $width_threshold ), - $ad_unit, - $sizes - ); - - return $size_map; + return apply_filters( 'newspack_ads_gam_size_map', $size_map, $ad_unit, $sizes ); } /** From 6a4ffaae41adfcd0673d7057f7c015dcacb07de2 Mon Sep 17 00:00:00 2001 From: matticbot Date: Thu, 15 Aug 2024 11:36:42 +0000 Subject: [PATCH 2/2] chore(release): 3.0.1 [skip ci] ## [3.0.1](https://github.com/Automattic/newspack-ads/compare/v3.0.0...v3.0.1) (2024-08-15) ### Bug Fixes * **gam:** add 1x1 size to all viewports ([#888](https://github.com/Automattic/newspack-ads/issues/888)) ([a99494a](https://github.com/Automattic/newspack-ads/commit/a99494a854855a3fd1388d7821db7aeef549adb9)) --- CHANGELOG.md | 7 +++++++ newspack-ads.php | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e1ddae9..b4f1246f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.0.1](https://github.com/Automattic/newspack-ads/compare/v3.0.0...v3.0.1) (2024-08-15) + + +### Bug Fixes + +* **gam:** add 1x1 size to all viewports ([#888](https://github.com/Automattic/newspack-ads/issues/888)) ([a99494a](https://github.com/Automattic/newspack-ads/commit/a99494a854855a3fd1388d7821db7aeef549adb9)) + # [3.0.0](https://github.com/Automattic/newspack-ads/compare/v2.1.0...v3.0.0) (2024-08-13) diff --git a/newspack-ads.php b/newspack-ads.php index 910cec60..9b97a238 100755 --- a/newspack-ads.php +++ b/newspack-ads.php @@ -5,7 +5,7 @@ * Description: Ad services integration. * Author: Automattic * License: GPL2 - * Version: 3.0.0 + * Version: 3.0.1 * * @package Newspack */ diff --git a/package-lock.json b/package-lock.json index d411b2fe..bc83a0c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "newspack-ads", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "newspack-ads", - "version": "3.0.0", + "version": "3.0.1", "license": "GPL-3.0-or-later", "dependencies": { "newspack-components": "^3.0.0", diff --git a/package.json b/package.json index 83b29b0f..1bb16392 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "newspack-ads", - "version": "3.0.0", + "version": "3.0.1", "author": "Automattic", "private": true, "scripts": {