Skip to content

Commit

Permalink
fix: limit multisizes of sticky ads (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoo authored Feb 24, 2021
1 parent ffb661b commit 481fccc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions includes/class-newspack-ads-model.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,19 @@ public static function amp_code_for_ad_unit( $ad_unit ) {
$multisizes = [];
foreach ( $sizes as $size ) {
$multisize = $size[0] . 'x' . $size[1];
if ( $multisize !== $ad_size_as_multisize ) {
if (
( $multisize !== $ad_size_as_multisize ) &&
( ! self::is_sticky( $ad_unit ) || ( self::is_sticky( $ad_unit ) && $size[0] < 600 ) )
) {
$multisizes[] = $multisize;
}
}
$multisize_attribute = '';
if ( count( $multisizes ) ) {
$multisize_attribute = sprintf(
'data-multi-size=\'%s\' data-multi-size-validation=\'false\'',
implode( ',', $multisizes )
$multisize_attribute = sprintf(
'data-multi-size=\'%s\' data-multi-size-validation=\'false\'%s',
implode( ',', $multisizes ),
self::is_sticky( $ad_unit ) ? ' data-override-width=\'600\'' : ''
);
}

Expand Down

0 comments on commit 481fccc

Please sign in to comment.