AMP for WP – Accelerated Mobile Pages - Version 1.0.77.52

Version Description

(14th October 2022) = * Fixed: Duplicate canonical URL when AIOSEO Pro is active. #5320 * Fixed: Youtube embedded videos via elementor is not displaying in the AMP version #5322 * Fixed: Slide Anything image src not loading properly. #5315 * Fixed: PHP Warning Attempt to read property "post_type" on null #5323 * Fixed: While adding the multiple Webstories on the website page, the image is not showing of the web stories the AMP Pages. #5301 * Fixed: Author names are not shown in AMP when the Co-Authors Plus plugin is activated #5319

Download this release

Release Info

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

Code changes from version 1.0.77.51 to 1.0.77.52

README.md 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: 6.0
7
- Stable tag: 1.0.77.50
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -197,6 +197,19 @@ Device testing done through [BrowserStack](https://www.browserstack.com)
197
 
198
  == Changelog ==
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  = 1.0.77.50 (24th August 2022) =
201
  * Fixed: "Back to Top link" option adds amp-animation & amp-position-observer script without its usage on page #5305
202
  * Fixed: AMPforWP is creating "/amp" as an endpoint in Addon mode. #5303
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 6.0
7
+ Stable tag: 1.0.77.52
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
197
 
198
  == Changelog ==
199
 
200
+ = 1.0.77.52 (14th October 2022) =
201
+ * Fixed: Duplicate canonical URL when AIOSEO Pro is active. #5320
202
+ * Fixed: Youtube embedded videos via elementor is not displaying in the AMP version #5322
203
+ * Fixed: Slide Anything image src not loading properly. #5315
204
+ * Fixed: PHP Warning Attempt to read property "post_type" on null #5323
205
+ * Fixed: While adding the multiple Webstories on the website page, the image is not showing of the web stories the AMP Pages. #5301
206
+ * Fixed: Author names are not shown in AMP when the Co-Authors Plus plugin is activated #5319
207
+
208
+ = 1.0.77.51 (9th September 2022) =
209
+ * Fixed: Infinite scroll doesn't work with custom post type. #5309
210
+ * Fixed: Need to make it compatible with the Co-Authors Plus plugin #5313
211
+ * Fixed: Slide Anything image src not loading properly. #5315
212
+
213
  = 1.0.77.50 (24th August 2022) =
214
  * Fixed: "Back to Top link" option adds amp-animation & amp-position-observer script without its usage on page #5305
215
  * Fixed: AMPforWP is creating "/amp" as an endpoint in Addon mode. #5303
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.51
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.51');
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.52
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.52');
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,13 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
3
  = 1.0.77.51 (9th September 2022) =
4
  * Fixed: Infinite scroll doesn't work with custom post type. #5309
5
  * Fixed: Need to make it compatible with the Co-Authors Plus plugin #5313
1
  == Changelog ==
2
 
3
+ = 1.0.77.52 (14th October 2022) =
4
+ * Fixed: Duplicate canonical URL when AIOSEO Pro is active. #5320
5
+ * Fixed: Youtube embedded videos via elementor is not displaying in the AMP version #5322
6
+ * Fixed: Slide Anything image src not loading properly. #5315
7
+ * Fixed: PHP Warning Attempt to read property "post_type" on null #5323
8
+ * Fixed: While adding the multiple Webstories on the website page, the image is not showing of the web stories the AMP Pages. #5301
9
+ * Fixed: Author names are not shown in AMP when the Co-Authors Plus plugin is activated #5319
10
+
11
  = 1.0.77.51 (9th September 2022) =
12
  * Fixed: Infinite scroll doesn't work with custom post type. #5309
13
  * Fixed: Need to make it compatible with the Co-Authors Plus plugin #5313
classes/class-ampforwp-slide-anything-embed.php CHANGED
@@ -211,6 +211,7 @@ class AMPFORWP_Slide_Anything_Embed_Handler extends AMPforWP\AMPVendor\AMP_Base_
211
  $slide_data['num_slides'] = $metadata['sa_num_slides'][0];
212
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
213
  if (isset($metadata["sa_slide".$i."_content"][0])) {
 
214
  $amp_images[$i-1] = AMP_HTML_Utils::build_tag(
215
  'div', array( 'slideampcontent' => esc_attr($metadata["sa_slide".$i."_content"][0]))
216
  );
@@ -218,6 +219,7 @@ class AMPFORWP_Slide_Anything_Embed_Handler extends AMPforWP\AMPVendor\AMP_Base_
218
  }
219
  }
220
 
 
221
  //Small Thumbnail Images
222
  $thumb_url = ampforwp_aq_resize( $image['url'], 120, 60, true, false ); //resize & crop the image
223
  if($thumb_url!=false){
@@ -306,8 +308,9 @@ class AMPFORWP_Slide_Anything_Embed_Handler extends AMPforWP\AMPVendor\AMP_Base_
306
  $returnCompleteHtml = str_replace('{{amp_image_lightbox}}', $amp_image_lightbox, $returnCompleteHtml);
307
  $returnCompleteHtml = str_replace('{{with_images}}', implode( PHP_EOL, $images ), $returnCompleteHtml);
308
  $returnCompleteHtml = preg_replace('/<div slideampcontent="(.*?)"><\/div>/s', '<div>$1</div>', $returnCompleteHtml);
309
- $returnCompleteHtml = str_replace('&lt;', '<', $returnCompleteHtml);
310
- $returnCompleteHtml = str_replace('&gt;', '>', $returnCompleteHtml);
 
311
  return $returnCompleteHtml;
312
  }
313
  }// Class closed
211
  $slide_data['num_slides'] = $metadata['sa_num_slides'][0];
212
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
213
  if (isset($metadata["sa_slide".$i."_content"][0])) {
214
+ $metadata["sa_slide".$i."_content"][0] = preg_replace('/\[[caption|\/].*?\]/', '', $metadata["sa_slide".$i."_content"][0]);
215
  $amp_images[$i-1] = AMP_HTML_Utils::build_tag(
216
  'div', array( 'slideampcontent' => esc_attr($metadata["sa_slide".$i."_content"][0]))
217
  );
219
  }
220
  }
221
 
222
+
223
  //Small Thumbnail Images
224
  $thumb_url = ampforwp_aq_resize( $image['url'], 120, 60, true, false ); //resize & crop the image
225
  if($thumb_url!=false){
308
  $returnCompleteHtml = str_replace('{{amp_image_lightbox}}', $amp_image_lightbox, $returnCompleteHtml);
309
  $returnCompleteHtml = str_replace('{{with_images}}', implode( PHP_EOL, $images ), $returnCompleteHtml);
310
  $returnCompleteHtml = preg_replace('/<div slideampcontent="(.*?)"><\/div>/s', '<div>$1</div>', $returnCompleteHtml);
311
+ //$returnCompleteHtml = str_replace('&lt;', '<', $returnCompleteHtml);
312
+ //$returnCompleteHtml = str_replace('&gt;', '>', $returnCompleteHtml);
313
+ $returnCompleteHtml = htmlspecialchars_decode($returnCompleteHtml);
314
  return $returnCompleteHtml;
315
  }
316
  }// Class closed
components/components-core.php CHANGED
@@ -982,7 +982,12 @@ function ampforwp_backtotop_global_css(){?>
982
  html {
983
  scroll-behavior: smooth;
984
  }
985
- <?php } }
 
 
 
 
 
986
  // Fallback for amp_call_now #2782
987
  if ( !function_exists('amp_call_now') ) {
988
  function amp_call_now(){
982
  html {
983
  scroll-behavior: smooth;
984
  }
985
+ <?php } ?>
986
+ .web-stories-list__story-poster amp-img {
987
+ width: 100%;
988
+ height: 100%;
989
+ }
990
+ <?php }
991
  // Fallback for amp_call_now #2782
992
  if ( !function_exists('amp_call_now') ) {
993
  function amp_call_now(){
includes/vendor/amp/includes/amp-helper-functions.php CHANGED
@@ -25,18 +25,22 @@ function amp_get_permalink( $post_id ) {
25
  }
26
 
27
  function post_supports_amp( $post ) {
28
- // Because `add_rewrite_endpoint` doesn't let us target specific post_types :(
29
- if ( ! post_type_supports( $post->post_type, AMP_QUERY_VAR ) ) {
30
- return false;
31
- }
32
-
33
- if ( post_password_required( $post ) ) {
34
- return false;
35
- }
36
-
37
- if ( true === apply_filters( 'amp_skip_post', false, $post->ID, $post ) ) {
38
- return false;
39
- }
 
 
 
 
40
 
41
  return true;
42
  }
25
  }
26
 
27
  function post_supports_amp( $post ) {
28
+ // checking for $post->ID and $post->post_type since dynamically generated pages does not have these value set
29
+ if(isset($post))
30
+ {
31
+ // Because `add_rewrite_endpoint` doesn't let us target specific post_types :(
32
+ if ( isset($post->post_type) && ! post_type_supports( $post->post_type, AMP_QUERY_VAR ) ) {
33
+ return false;
34
+ }
35
+
36
+ if ( post_password_required( $post ) ) {
37
+ return false;
38
+ }
39
+
40
+ if ( isset($post->ID) && true === apply_filters( 'amp_skip_post', false, $post->ID, $post ) ) {
41
+ return false;
42
+ }
43
+ }
44
 
45
  return true;
46
  }
includes/vendor/amp/includes/amp-post-template-actions.php CHANGED
@@ -26,9 +26,10 @@ if( (class_exists('Yoast\\WP\\SEO\\Integrations\\Front_End_Integration')) ){
26
  add_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_title' );
27
  }
28
  function amp_post_template_add_canonical( $amp_template ) {
29
- if (function_exists('aioseo_pro_just_activated') && version_compare(AIOSEO_VERSION,'4.2.4', '<')) {
30
- return;
31
- }
 
32
  ?>
33
  <link rel="canonical" href="<?php echo esc_url( apply_filters('ampforwp_modify_rel_url',$amp_template->get( 'canonical_url' ) ) ); ?>" />
34
  <?php
26
  add_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_title' );
27
  }
28
  function amp_post_template_add_canonical( $amp_template ) {
29
+
30
+ if (function_exists('aioseo') && ((aioseo()->pro && (version_compare(AIOSEO_VERSION,'4.2.6')>=0)) || (!aioseo()->pro && (version_compare(AIOSEO_VERSION,'4.2.4')>0)))) {
31
+ return;
32
+ }
33
  ?>
34
  <link rel="canonical" href="<?php echo esc_url( apply_filters('ampforwp_modify_rel_url',$amp_template->get( 'canonical_url' ) ) ); ?>" />
35
  <?php
includes/vendor/amp/includes/embeds/class-amp-dailymotion-embed.php CHANGED
@@ -61,6 +61,7 @@ class AMP_DailyMotion_Embed_Handler extends AMP_Base_Embed_Handler {
61
  }
62
 
63
  return $this->render( array(
 
64
  'video_id' => $video_id,
65
  ) );
66
  }
61
  }
62
 
63
  return $this->render( array(
64
+ 'url'=>$url,
65
  'video_id' => $video_id,
66
  ) );
67
  }
includes/vendor/vendor-changelog.txt CHANGED
@@ -95,4 +95,6 @@ Reason: To extend the functionality of sidebars and Pagebuilder
95
  65. Needs to redirect to 301, not in 302 #3767
96
  66. Whitelisted label and input tags #4054
97
  67. Whitelisted Picture tag #4051
98
- 68. Improvement in input type #4289
 
 
95
  65. Needs to redirect to 301, not in 302 #3767
96
  66. Whitelisted label and input tags #4054
97
  67. Whitelisted Picture tag #4051
98
+ 68. Improvement in input type #4289
99
+ 69. Fixed $url to render function in class-amp-Dailymotion-embed.php line 72
100
+ 70. Checking for $post->ID and $post->post_type since dynamically generated pages does not have these value set (amp-helper-functions.php from line 27) #5323
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: 6.0
7
- Stable tag: 1.0.77.51
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -194,6 +194,14 @@ You can contact us from [here](https://ampforwp.com/contact/)
194
 
195
  == Changelog ==
196
 
 
 
 
 
 
 
 
 
197
  = 1.0.77.51 (9th September 2022) =
198
  * Fixed: Infinite scroll doesn't work with custom post type. #5309
199
  * Fixed: Need to make it compatible with the Co-Authors Plus plugin #5313
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 6.0
7
+ Stable tag: 1.0.77.52
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.52 (14th October 2022) =
198
+ * Fixed: Duplicate canonical URL when AIOSEO Pro is active. #5320
199
+ * Fixed: Youtube embedded videos via elementor is not displaying in the AMP version #5322
200
+ * Fixed: Slide Anything image src not loading properly. #5315
201
+ * Fixed: PHP Warning Attempt to read property "post_type" on null #5323
202
+ * Fixed: While adding the multiple Webstories on the website page, the image is not showing of the web stories the AMP Pages. #5301
203
+ * Fixed: Author names are not shown in AMP when the Co-Authors Plus plugin is activated #5319
204
+
205
  = 1.0.77.51 (9th September 2022) =
206
  * Fixed: Infinite scroll doesn't work with custom post type. #5309
207
  * Fixed: Need to make it compatible with the Co-Authors Plus plugin #5313
templates/features.php CHANGED
@@ -4551,7 +4551,7 @@ function ampforwp_home_archive_canonical_setter(){
4551
  }
4552
 
4553
  function ampforwp_rel_canonical_home_archive(){
4554
- if (function_exists('aioseo_pro_just_activated') && version_compare(AIOSEO_VERSION,'4.2.4', '<')) {
4555
  return;
4556
  }
4557
  global $redux_builder_amp;
@@ -8847,6 +8847,70 @@ if(!function_exists('ampforwp_add_fallback_element')){
8847
  return $content;
8848
  }
8849
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8850
  if(!function_exists('ampforwp_imagify_webp_compatibility')){
8851
  function ampforwp_imagify_webp_compatibility($content){
8852
  if(function_exists('_imagify_init')){
4551
  }
4552
 
4553
  function ampforwp_rel_canonical_home_archive(){
4554
+ if (function_exists('aioseo') && ((aioseo()->pro && (version_compare(AIOSEO_VERSION,'4.2.6')>=0)) || (!aioseo()->pro && (version_compare(AIOSEO_VERSION,'4.2.4')>0)))) {
4555
  return;
4556
  }
4557
  global $redux_builder_amp;
8847
  return $content;
8848
  }
8849
  }
8850
+ // added fix for youtube video not displaying on AMP using Elementor #5322
8851
+ add_filter('ampforwp_modify_the_content','amp_youtube_the_content');
8852
+
8853
+ function amp_youtube_the_content($content){
8854
+ // checking is Elementor is installed and activated
8855
+ if ( did_action( 'elementor/loaded' ) ) {
8856
+ preg_match_all('/<div\s+class="(.*?)elementor-widget-video"(.*?)data-settings=\'(.*?)\'\sdata-widget_type="video.default">/', $content, $matches);
8857
+ foreach($matches[3] as $video){
8858
+ $video_attr = json_decode($video);
8859
+ $get_url = $video_attr->youtube_url;
8860
+ $get_id = get_video_id_from_url($get_url);
8861
+ $content_html = preg_replace('/<div\s+class="(.*?)elementor-widget-video"(.*?)data-settings=\'(.*?)\'\sdata-widget_type="video.default">/','<amp-youtube
8862
+ data-videoid="'.esc_attr($get_id).'"
8863
+ layout="responsive"
8864
+ width="480" height="270"></amp-youtube>', $content);
8865
+ return $content_html;
8866
+ }
8867
+ }
8868
+ return $content;
8869
+ }
8870
+
8871
+ function get_video_id_from_url( $url ) {
8872
+ $short_url_host = 'youtu.be';
8873
+ $video_id = false;
8874
+ $parsed_url = parse_url( $url );
8875
+
8876
+ if(!isset($parsed_url['host'])){
8877
+ $parsed_url['host'] = '';
8878
+ }
8879
+ if ($short_url_host === substr( $parsed_url['host'], -strlen($short_url_host ) ) ) {
8880
+ // youtu.be/{id}
8881
+ $parts = explode( '/', $parsed_url['path'] );
8882
+ if ( ! empty( $parts ) ) {
8883
+ $video_id = $parts[1];
8884
+ }
8885
+ } else {
8886
+ // ?v={id} or ?list={id}
8887
+ if(isset($parsed_url['query'])){
8888
+ parse_str( $parsed_url['query'], $query_args );
8889
+ }
8890
+
8891
+ if ( isset( $query_args['v'] ) ) {
8892
+ if ( false !== strpos( $query_args['v'], '?' ) ) {
8893
+ $video_id = strtok( $query_args['v'], '?' );
8894
+ }
8895
+ else{
8896
+ $video_id = $query_args['v'];
8897
+ }
8898
+ }
8899
+ }
8900
+
8901
+ if ( empty( $video_id ) ) {
8902
+ // /(v|e|embed)/{id}
8903
+ $parts = explode( '/', $parsed_url['path'] );
8904
+
8905
+ if ( in_array( $parts[1], array( 'v', 'e', 'embed' ) ) ) {
8906
+ $video_id = $parts[2];
8907
+ }
8908
+ }
8909
+
8910
+ return $video_id;
8911
+ }
8912
+
8913
+
8914
  if(!function_exists('ampforwp_imagify_webp_compatibility')){
8915
  function ampforwp_imagify_webp_compatibility($content){
8916
  if(function_exists('_imagify_init')){