AMP for WP – Accelerated Mobile Pages - Version 1.0.77.43

Version Description

(10th May 2022) = * Updated: TPD feature updated #5257 * Fixed: Resolved the issue of Image Gallery Carousel in AMP does not change the gallery view in posts/pages #5259

Download this release

Release Info

Developer mohammed_kaludi
Plugin Icon 128x128 AMP for WP – Accelerated Mobile Pages
Version 1.0.77.43
Comparing to
See all releases

Code changes from version 1.0.77.42 to 1.0.77.43

accelerated-moblie-pages.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
- Version: 1.0.77.42
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
@@ -20,7 +20,7 @@ define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
20
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
21
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
22
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
23
- define('AMPFORWP_VERSION','1.0.77.42');
24
  define('AMPFORWP_EXTENSION_DIR',plugin_dir_path(__FILE__).'includes/options/extensions');
25
  if(!defined('AMPFROWP_HOST_NAME')){
26
  $urlinfo = get_bloginfo('url');
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
+ Version: 1.0.77.43
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
20
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
21
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
22
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
23
+ define('AMPFORWP_VERSION','1.0.77.43');
24
  define('AMPFORWP_EXTENSION_DIR',plugin_dir_path(__FILE__).'includes/options/extensions');
25
  if(!defined('AMPFROWP_HOST_NAME')){
26
  $urlinfo = get_bloginfo('url');
changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  == Changelog ==
2
 
 
 
 
 
3
  = 1.0.77.42 (16th April 2022) =
4
  * Improvements: Added REHub Comparison charts, tables Compatibility #5250
5
  * Fixed: Debug Warnings - Undefined index: amp-license #5251
1
  == Changelog ==
2
 
3
+ = 1.0.77.43 (10th May 2022) =
4
+ * Updated: TPD feature updated #5257
5
+ * Fixed: Resolved the issue of Image Gallery Carousel in AMP does not change the gallery view in posts/pages #5259
6
+
7
  = 1.0.77.42 (16th April 2022) =
8
  * Improvements: Added REHub Comparison charts, tables Compatibility #5250
9
  * Fixed: Debug Warnings - Undefined index: amp-license #5251
includes/vendor/amp/includes/sanitizers/class-amp-gallery-block-sanitizer-5-3.php CHANGED
@@ -36,7 +36,7 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
36
  * @var string Ul tag to identify wrapper around gallery block.
37
  * @since 1.0
38
  */
39
- public static $tag = 'ul';
40
  /**
41
  * Array of flags used to control sanitization.
42
  *
@@ -80,62 +80,89 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
80
  ]
81
  )
82
  );
 
 
83
  $query = $xpath->query( $expr );
84
- foreach ( $query as $node ) {
85
- /**
86
- * Element
87
- *
88
- * @var DOMElement $node
89
- */
90
- // In WordPress 5.3, the Gallery block's <ul> is wrapped in a <figure class="wp-block-gallery">, so look for that node also.
91
- $gallery_node = isset( $node->parentNode ) && AMP_DOM_Utils::has_class( $node->parentNode, self::$class ) ? $node->parentNode : $node;
92
- $attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $gallery_node );
93
- $is_amp_lightbox = isset( $attributes['data-amp-lightbox'] ) && true === filter_var( $attributes['data-amp-lightbox'], FILTER_VALIDATE_BOOLEAN );
94
- $is_amp_carousel = (
95
- ! empty( $this->args['carousel_required'] )
96
- ||
97
- filter_var( $node->getAttribute( 'data-amp-carousel' ), FILTER_VALIDATE_BOOLEAN )
98
- ||
99
- filter_var( $node->parentNode->getAttribute( 'data-amp-carousel' ), FILTER_VALIDATE_BOOLEAN )
100
  );
101
- // We are only looking for <ul> elements which have amp-carousel / amp-lightbox true.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  if ( ! $is_amp_carousel && ! $is_amp_lightbox ) {
103
  continue;
104
  }
 
105
  // If lightbox is set, we should add lightbox feature to the gallery images.
106
  if ( $is_amp_lightbox ) {
107
  $this->add_lightbox_attributes_to_image_nodes( $node );
108
  $this->maybe_add_amp_image_lightbox_node();
109
  }
 
110
  // If amp-carousel is not set, nothing else to do here.
111
  if ( ! $is_amp_carousel ) {
112
  continue;
113
  }
114
- $images = [];
115
- // If not linking to anything then look for <amp-img>.
116
- if ( empty( $images ) ) {
117
- foreach ( $node->getElementsByTagName( 'amp-img' ) as $element ) {
 
 
118
  $images[] = $element;
119
  }
120
  }
121
- // Skip if no images found.
122
- if ( empty( $images ) ) {
123
- continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
- list( $width, $height ) = $this->get_carousel_dimensions( $node );
126
- $amp_carousel = AMP_DOM_Utils::create_node(
127
- $this->dom,
128
- 'amp-carousel',
129
- [
130
- 'width' => $width,
131
- 'height' => $height,
132
- 'type' => 'slides',
133
- 'layout' => 'responsive',
134
- ]
135
- );
136
- $urls = array();
137
- foreach ( $images as $element ) {
138
- $possible_caption_text = $this->possibly_get_caption_text( $element );
139
  $url = $element->getAttribute('src');
140
  $width = $element->getAttribute('width');
141
  $height = $element->getAttribute('height');
@@ -143,20 +170,24 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
143
  $images[] = $element;
144
  }
145
  $urls[] = array(
146
- 'url' => $url,
147
- 'width' => $width,
148
- 'height' => $height,
149
- 'caption' => $possible_caption_text
150
- );
151
  }
 
 
152
  if ( empty( $images ) ) {
153
  continue;
154
  }
155
  $amp_carousel_node = $this->render( array(
156
- 'images' => $urls,
157
- ), $gallery_node );
158
- $gallery_node->parentNode->replaceChild( $amp_carousel_node, $gallery_node );
 
159
  }
 
160
  $this->did_convert_elements = true;
161
  }
162
  /**
@@ -257,6 +288,7 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
257
  'src' => $image['url'],
258
  'width' => $image['width'],
259
  'height' => $image['height'],
 
260
  'layout' => 'fill',
261
  'class' => 'amp-carousel-img',
262
  );
@@ -271,13 +303,10 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
271
  if ( 3 != ampforwp_get_setting('ampforwp-gallery-design-type') ) {
272
  $image_div = AMP_DOM_Utils::create_node( $this->dom, 'div', array('class'=>'ampforwp-gallery-item amp-carousel-container') );
273
  $image_div->appendChild($amp_image_node);
274
- if ( isset($image['caption']) && is_object($image['caption'])) {
275
  $figure_node = AMP_DOM_Utils::create_node($this->dom, 'figure', array());
276
  $fig_caption = AMP_DOM_Utils::create_node($this->dom, 'figcaption', array('on'=>"tap:AMP.setState({expanded: !expanded})",'tabindex'=>0,'role'=>'button'));
277
- $captionlength = $image['caption']->length;
278
- for ($i=0 ;$i < $captionlength;$i++){
279
- $fig_caption->appendChild($image['caption']->item(0));
280
- }
281
  $figure_node->appendChild($image_div);
282
  $figure_node->appendChild($fig_caption);
283
  $amp_images[$key] = $figure_node;
@@ -287,7 +316,15 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
287
  }
288
  if ( 2 == ampforwp_get_setting('ampforwp-gallery-design-type') ) {
289
  //Small Thumbnail Images
290
- $thumb_url = ampforwp_aq_resize( $image['url'], 120, 60, true, false ); //resize & crop the image
 
 
 
 
 
 
 
 
291
  if($thumb_url!=false){
292
  $smallimage = $thumb_url[0];
293
  $smallwidth = $thumb_url[1];
@@ -313,56 +350,42 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
313
  //replacements
314
  $r = rand(1,100);
315
  if ( 3 != ampforwp_get_setting('ampforwp-gallery-design-type') ){
316
- $amp_carousel = AMP_DOM_Utils::create_node($this->dom,
317
- 'amp-carousel',
318
- array(
319
- 'width' => 600,
320
- 'height' => 480,
321
- 'type' => 'slides',
322
- 'layout' => 'responsive',
323
- 'class' => 'collapsible-captions',
324
- 'id' => 'carousel-with-carousel-preview-'.$r
325
- )
326
- );
 
 
 
 
 
 
327
  foreach ($amp_images as $amp_image) {
328
  $amp_carousel->appendChild( $amp_image );
329
  }
330
- $captiondom = $this->ampforwp_set_block_gallery_caption($node,$node->parentNode);
331
- if ($captiondom) {
332
- $main_dic = AMP_DOM_Utils::create_node($this->dom, 'div', array('class'=>'amp-carousel-wrapper') );
333
- $main_dic->appendChild( $amp_carousel );
334
- $main_dic->appendChild( $captiondom );
335
- $amp_carousel = $main_dic;
336
- }
337
  }
338
  if ( 2 == ampforwp_get_setting('ampforwp-gallery-design-type') ) {
339
  $button_nodes = array();
340
-
341
- $carousel_args = array(
342
- 'width' => 'auto',
343
- 'height' => 48,
344
- 'type' => 'carousel',
345
- 'layout' => 'fixed-height',
346
- 'class' => 'carousel-preview'
347
- );
348
-
349
- $c_args = array('loop'=>'', 'autoplay'=>'');
350
- $carousel_filter = apply_filters('ampforwp_carousel_args',$c_args);
351
- $carousel_args = array_merge($carousel_args,$carousel_filter);
352
-
353
  $amp_carousel_thumbnail = AMP_DOM_Utils::create_node(
354
- $this->dom,
355
- 'amp-carousel',
356
- $carousel_args
357
- );
 
358
  foreach ($amp_images_small as $key => $value) {
359
  $button_node = AMP_DOM_Utils::create_node(
360
- $this->dom,
361
- 'button',
362
- array(
363
- 'on'=>'tap:carousel-with-carousel-preview-'.$r.'.goToSlide(index='.$key.')',
364
- 'class'=>'amp-carousel-slide amp-scrollable-carousel-slide')
365
- );
366
  $button_node->appendChild($value);
367
  $amp_carousel_thumbnail->appendChild($button_node);
368
  }
@@ -376,8 +399,12 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
376
  $figure_node = AMP_DOM_Utils::create_node($this->dom, 'figure', array('class'=>'ampforwp-gallery-item amp-carousel-containerd3'));
377
  $figure_node->appendChild($amp_image);
378
  $fig_caption = AMP_DOM_Utils::create_node($this->dom, 'figcaption', array());
379
- if ( isset($image['caption']) && is_object($image['caption']) ) {
380
- $captionlength = $image['caption']->length;
 
 
 
 
381
  for ($i=0 ;$i < $captionlength;$i++){
382
  $fig_caption->appendChild($image['caption']->item(0));
383
  }
@@ -423,6 +450,7 @@ class AMP_Gallery_Block_Sanitizer extends AMP_Base_Sanitizer {
423
  * }
424
  */
425
  protected function get_carousel_dimensions( $element ) {
 
426
  /**
427
  * Elements.
428
  *
@@ -456,10 +484,10 @@ function ampforwp_gal_des_1(){
456
  echo '.cls-btn{background:#0d0d0d;border:none;position: absolute;right: 10px;}.cls-btn:after{content:"X";display:inline-block;color:#fff;font-size:20px;padding:20px;}';
457
  }
458
  function ampforwp_gal_des_2(){
459
- echo ".carousel-preview button{padding:0;}.carousel-preview amp-img{height:40px;width:60px;position:relative;}.carousel-preview {width: 100%;display: inline-block;text-align: center;margin: 20px 0px;}.cls-btn{background:#0d0d0d;border:none;position: absolute;right: 10px;}.cls-btn:after{content:\"X\";display:inline-block;color:#fff;font-size:20px;padding:20px;}";
460
  }
461
  function ampforwp_gal_des_3(){
462
- echo '.gal_w{display:inline-block;width:100%}.gal_w amp-img{background:#f1f1f1;height:134px;width:150px;position: relative;float:left;margin:10px;}.cls-btn{background:#0d0d0d;border:none;position: absolute;right: 10px;}.cls-btn:after{content:"X";display:inline-block;color:#fff;font-size:20px;padding:20px;}';
463
  }
464
  function ampforwp_gallery_lightbox(){
465
  $amp_image_lightbox = '';
36
  * @var string Ul tag to identify wrapper around gallery block.
37
  * @since 1.0
38
  */
39
+ public static $tag = 'figure';
40
  /**
41
  * Array of flags used to control sanitization.
42
  *
80
  ]
81
  )
82
  );
83
+
84
+
85
  $query = $xpath->query( $expr );
86
+
87
+ if(empty($query->length)){
88
+ $expr = sprintf(
89
+ '//figure[ %s ]',
90
+ implode(
91
+ ' or ',
92
+ [
93
+ sprintf( '( parent::figure[ %s ] )', $class_query ),
94
+ $class_query,
95
+ ]
96
+ )
 
 
 
 
 
97
  );
98
+ $query = $xpath->query( $expr );
99
+ }
100
+
101
+ $num_nodes = $query->length;
102
+ $nodes = $this->dom->getElementsByTagName( self::$tag );
103
+ for ( $i = $num_nodes - 1; $i >= 0; $i-- ) {
104
+ $node = $nodes->item( $i );
105
+ // We're looking for figure elements that at least one child.
106
+ if ( 0 === count( $node->childNodes ) ) {
107
+ continue;
108
+ }
109
+
110
+ $attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $node );
111
+ if ( !isset($attributes['class']) || ( isset($attributes['class']) && ! preg_match('/wp-block-gallery/', $attributes['class']) ) ) {
112
+ continue;
113
+ }
114
+ $is_amp_lightbox = isset( $attributes['data-amp-lightbox'] ) && true === filter_var( $attributes['data-amp-lightbox'], FILTER_VALIDATE_BOOLEAN );
115
+ $is_amp_carousel = ! empty( $this->args['carousel_required'] ) || ( isset( $attributes['data-amp-carousel'] ) && true === filter_var( $attributes['data-amp-carousel'], FILTER_VALIDATE_BOOLEAN ) );
116
+
117
+ // We are only looking for figure elements which have amp-carousel / amp-lightbox true.
118
  if ( ! $is_amp_carousel && ! $is_amp_lightbox ) {
119
  continue;
120
  }
121
+
122
  // If lightbox is set, we should add lightbox feature to the gallery images.
123
  if ( $is_amp_lightbox ) {
124
  $this->add_lightbox_attributes_to_image_nodes( $node );
125
  $this->maybe_add_amp_image_lightbox_node();
126
  }
127
+
128
  // If amp-carousel is not set, nothing else to do here.
129
  if ( ! $is_amp_carousel ) {
130
  continue;
131
  }
132
+
133
+ $images = array();
134
+ $urls = array();
135
+ // If it's not AMP lightbox, look for links first.
136
+ if ( ! $is_amp_lightbox ) {
137
+ foreach ( $node->getElementsByTagName( 'a' ) as $element ) {
138
  $images[] = $element;
139
  }
140
  }
141
+
142
+ if( $node->getElementsByTagName( 'amp-anim' )){
143
+ foreach ( $node->getElementsByTagName( 'amp-anim' ) as $element ) {
144
+ $url = $element->getAttribute('src');
145
+ $width = $element->getAttribute('width');
146
+ $height = $element->getAttribute('height');
147
+ $attachment_id = attachment_url_to_postid($url);
148
+ if ( empty( $images ) ) {
149
+ $images[] = $element;
150
+ }
151
+ $urls[] = apply_filters('amp_gallery_image_params', array(
152
+ 'url' => $url,
153
+ 'width' => $width,
154
+ 'height' => $height,
155
+ ),$attachment_id);
156
+
157
+ }
158
  }
159
+
160
+ $fig_item = $node->getElementsByTagName( 'figure');
161
+ $ni =0;
162
+ // If not linking to anything then look for <amp-img>.
163
+ foreach ( $node->getElementsByTagName( 'amp-img' ) as $element ) {
164
+ $caption = $fig_item->item($ni)->nodeValue;
165
+ $ni++;
 
 
 
 
 
 
 
166
  $url = $element->getAttribute('src');
167
  $width = $element->getAttribute('width');
168
  $height = $element->getAttribute('height');
170
  $images[] = $element;
171
  }
172
  $urls[] = array(
173
+ 'url' => $url,
174
+ 'width' => $width,
175
+ 'height' => $height,
176
+ 'caption' => $caption
177
+ );
178
  }
179
+
180
+ // Skip if no images found.
181
  if ( empty( $images ) ) {
182
  continue;
183
  }
184
  $amp_carousel_node = $this->render( array(
185
+ 'images' => $urls,
186
+ ), $node );
187
+
188
+ $node->parentNode->replaceChild( $amp_carousel_node, $node );
189
  }
190
+
191
  $this->did_convert_elements = true;
192
  }
193
  /**
288
  'src' => $image['url'],
289
  'width' => $image['width'],
290
  'height' => $image['height'],
291
+ 'caption' => $image['caption'],
292
  'layout' => 'fill',
293
  'class' => 'amp-carousel-img',
294
  );
303
  if ( 3 != ampforwp_get_setting('ampforwp-gallery-design-type') ) {
304
  $image_div = AMP_DOM_Utils::create_node( $this->dom, 'div', array('class'=>'ampforwp-gallery-item amp-carousel-container') );
305
  $image_div->appendChild($amp_image_node);
306
+ if ( isset($image['caption']) ) {
307
  $figure_node = AMP_DOM_Utils::create_node($this->dom, 'figure', array());
308
  $fig_caption = AMP_DOM_Utils::create_node($this->dom, 'figcaption', array('on'=>"tap:AMP.setState({expanded: !expanded})",'tabindex'=>0,'role'=>'button'));
309
+ $fig_caption->nodeValue = $image['caption'];
 
 
 
310
  $figure_node->appendChild($image_div);
311
  $figure_node->appendChild($fig_caption);
312
  $amp_images[$key] = $figure_node;
316
  }
317
  if ( 2 == ampforwp_get_setting('ampforwp-gallery-design-type') ) {
318
  //Small Thumbnail Images
319
+ $explod_imgext = explode('.',$image['url']);
320
+ $image_extension = end($explod_imgext);
321
+ if($image_extension =='svg' || $image_extension=='SVG'){
322
+ $thumb_url[0] =$image['url'];
323
+ $thumb_url[1] = 120;
324
+ $thumb_url[2] = 60;
325
+ }else{
326
+ $thumb_url = ampforwp_aq_resize( $image['url'], 120, 60, true, false ); //resize & crop the image
327
+ }
328
  if($thumb_url!=false){
329
  $smallimage = $thumb_url[0];
330
  $smallwidth = $thumb_url[1];
350
  //replacements
351
  $r = rand(1,100);
352
  if ( 3 != ampforwp_get_setting('ampforwp-gallery-design-type') ){
353
+ $carousel_args = array(
354
+ 'width' => 600,
355
+ 'height' => 480,
356
+ 'type' => 'slides',
357
+ 'layout' => 'responsive',
358
+ 'class' => 'collapsible-captions',
359
+ 'id' => 'carousel-with-carousel-preview-'.$r
360
+ );
361
+ $c_args = array('loop'=>'', 'autoplay'=>'');
362
+ $carousel_filter = apply_filters('ampforwp_carousel_args',$c_args);
363
+ $carousel_args = array_merge($carousel_args,$carousel_filter);
364
+
365
+ $amp_carousel = AMP_DOM_Utils::create_node($this->dom,
366
+ 'amp-carousel',
367
+ $carousel_args
368
+ );
369
+
370
  foreach ($amp_images as $amp_image) {
371
  $amp_carousel->appendChild( $amp_image );
372
  }
 
 
 
 
 
 
 
373
  }
374
  if ( 2 == ampforwp_get_setting('ampforwp-gallery-design-type') ) {
375
  $button_nodes = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  $amp_carousel_thumbnail = AMP_DOM_Utils::create_node(
377
+ $this->dom,
378
+ 'div',
379
+ array(
380
+ 'class'=>'carousel-preview')
381
+ );
382
  foreach ($amp_images_small as $key => $value) {
383
  $button_node = AMP_DOM_Utils::create_node(
384
+ $this->dom,
385
+ 'button',
386
+ array(
387
+ 'on'=>'tap:carousel-with-carousel-preview-'.$r.'.goToSlide(index='.$key.')')
388
+ );
 
389
  $button_node->appendChild($value);
390
  $amp_carousel_thumbnail->appendChild($button_node);
391
  }
399
  $figure_node = AMP_DOM_Utils::create_node($this->dom, 'figure', array('class'=>'ampforwp-gallery-item amp-carousel-containerd3'));
400
  $figure_node->appendChild($amp_image);
401
  $fig_caption = AMP_DOM_Utils::create_node($this->dom, 'figcaption', array());
402
+ if ( isset($image['caption'])) {
403
+ if(!empty($image['caption']->length)){
404
+ $captionlength = $image['caption']->length;
405
+ }else{
406
+ $captionlength = 0;
407
+ }
408
  for ($i=0 ;$i < $captionlength;$i++){
409
  $fig_caption->appendChild($image['caption']->item(0));
410
  }
450
  * }
451
  */
452
  protected function get_carousel_dimensions( $element ) {
453
+
454
  /**
455
  * Elements.
456
  *
484
  echo '.cls-btn{background:#0d0d0d;border:none;position: absolute;right: 10px;}.cls-btn:after{content:"X";display:inline-block;color:#fff;font-size:20px;padding:20px;}';
485
  }
486
  function ampforwp_gal_des_2(){
487
+ echo ".carousel-preview button{padding:0;margin:0 3px;}.carousel-preview amp-img{height:40px;width:80px;position:relative;}.carousel-preview {width: 100%;display: inline-block;text-align: center;margin: 20px 0px;}.cls-btn{background:#0d0d0d;border:none;position: absolute;right: 10px;}.cls-btn:after{content:\"X\";display:inline-block;color:#fff;font-size:20px;padding:20px;}.carousel-preview .amp-carousel-img img {object-fit: fill;}";
488
  }
489
  function ampforwp_gal_des_3(){
490
+ echo '.gal_w{display:inline-block;width:100%}.gal_w amp-img{height:134px;width:150px;position: relative;float:left;margin:10px;}.cls-btn{background:#0d0d0d;border:none;position: absolute;right: 10px;}.cls-btn:after{content:"X";display:inline-block;color:#fff;font-size:20px;padding:20px;}';
491
  }
492
  function ampforwp_gallery_lightbox(){
493
  $amp_image_lightbox = '';
includes/vendor/aq_resizer.php CHANGED
@@ -151,8 +151,17 @@ if(!class_exists('Aq_Resize')) {
151
 
152
  // Get image size after cropping.
153
  $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
154
- $dst_w = $dims[4];
155
- $dst_h = $dims[5];
 
 
 
 
 
 
 
 
 
156
 
157
  // Return the original image only if it exactly fits the needed measures.
158
  if ( ! $dims || ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
151
 
152
  // Get image size after cropping.
153
  $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
154
+ if(!empty($dims[4])){
155
+ $dst_w = $dims[4];
156
+ }else{
157
+ $dst_w = '';
158
+ }
159
+ if(!empty($dims[5])){
160
+ $dst_h = $dims[5];
161
+ }else{
162
+ $dst_h = '';
163
+ }
164
+
165
 
166
  // Return the original image only if it exactly fits the needed measures.
167
  if ( ! $dims || ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.9.3
7
- Stable tag: 1.0.77.42
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -194,6 +194,10 @@ You can contact us from [here](https://ampforwp.com/contact/)
194
 
195
  == Changelog ==
196
 
 
 
 
 
197
  = 1.0.77.42 (16th April 2022) =
198
  * Improvements: Added REHub Comparison charts, tables Compatibility #5250
199
  * Fixed: Debug Warnings - Undefined index: amp-license #5251
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.9.3
7
+ Stable tag: 1.0.77.43
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
194
 
195
  == Changelog ==
196
 
197
+ = 1.0.77.43 (10th May 2022) =
198
+ * Updated: TPD feature updated #5257
199
+ * Fixed: Resolved the issue of Image Gallery Carousel in AMP does not change the gallery view in posts/pages #5259
200
+
201
  = 1.0.77.42 (16th April 2022) =
202
  * Improvements: Added REHub Comparison charts, tables Compatibility #5250
203
  * Fixed: Debug Warnings - Undefined index: amp-license #5251
templates/features.php CHANGED
@@ -9705,17 +9705,36 @@ function ampforwp_publisher_desk_ads( $content ) {
9705
  $url = 'https://cdn.tpdads.com/json/amp-tags/'.esc_html($pub_id).'.json';
9706
  }
9707
 
9708
- $data_api = wp_remote_get($url);
9709
- $json_data_api = json_decode( $data_api['body'] );
9710
- if ( is_single() && !empty($pub_id) && !empty($json_data_api) ) {
9711
- $content = ampforwp_publisher_desk_ads_insert( array(
9712
- '3' => $json_data_api->customHTMLInContentAds[0],
9713
- '6' => $json_data_api->customHTMLInContentAds[1],
9714
- '9' => $json_data_api->customHTMLInContentAds[2]
9715
- ), $content );
9716
- $content .= $json_data_api->stickyCustomHTMLAd[0];
9717
- $content = preg_replace('/json="/', 'json=\"' , $content);
9718
- $content = preg_replace('/rtc-config="/', 'rtc-config=\"' , $content);
9719
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9720
  return $content;
9721
  }
9705
  $url = 'https://cdn.tpdads.com/json/amp-tags/'.esc_html($pub_id).'.json';
9706
  }
9707
 
9708
+ $data_api = wp_remote_get($url);
9709
+ if (is_array($data_api) && !empty($data_api['body'])) {
9710
+ $json_data_api = json_decode( $data_api['body'] );
9711
+
9712
+ $addList = array();
9713
+ if(!empty($json_data_api->customHTMLAboveContentAd)){
9714
+ $content = $json_data_api->customHTMLAboveContentAd[0]." ".$content;
9715
+ }
9716
+
9717
+ if(!empty($json_data_api->customHTMLBelowContentAd)){
9718
+ $content .= $json_data_api->customHTMLBelowContentAd[0];
9719
+ }
9720
+ if ( is_single() && !empty($pub_id) && !empty($json_data_api) ) {
9721
+ if($json_data_api->inContentPlacementMethod=='Auto'){
9722
+
9723
+ $addList[3] = $json_data_api->customHTMLInContentAds[0];
9724
+ $addList[6] = $json_data_api->customHTMLInContentAds[1];
9725
+ $addList[9] = $json_data_api->customHTMLInContentAds[2];
9726
+ }
9727
+ else{
9728
+
9729
+ for ($i=0; $i < count($json_data_api->afterParagraphNumbers); $i++) {
9730
+ $addList[$json_data_api->afterParagraphNumbers[$i]] = $json_data_api->customHTMLInContentAds[$i];
9731
+ }
9732
+ }
9733
+ $content = ampforwp_publisher_desk_ads_insert( $addList, $content );
9734
+ $content .= $json_data_api->stickyCustomHTMLAd[0];
9735
+ $content = preg_replace('/json="/', 'json=\"' , $content);
9736
+ $content = preg_replace('/rtc-config="/', 'rtc-config=\"' , $content);
9737
+ }
9738
+ }
9739
  return $content;
9740
  }