AMP for WP – Accelerated Mobile Pages - Version 1.0.17

Version Description

(27th January 2020) = * Improvement: Compatibility with the Imagify plugin #3908 * Improvement: EWWW Image Optimizer plugin Compatibility #3984 * Improvement: Accessibility score of Amp Layouts improved in Lighthouse test #4078 * Fixed: Admin toolbar is not showing on custom amp page #3718 * Fixed: Bug in Instant article's Single option #3891 * Fixed: If the user adds the social share link in the users section then we need to show social share icon #3976 * Fixed: Treeshaking is enabled then " Content sneak to peek " button is showing below the content. #4069 * Fixed: AMP take over is not working on home page when user have no posts. #4056

Download this release

Release Info

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

Code changes from version 1.0.16 to 1.0.17

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: 5.3.2
7
- Stable tag: 1.0.16
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -194,6 +194,16 @@ Device testing done through [BrowserStack](https://www.browserstack.com)
194
 
195
  == Changelog ==
196
 
 
 
 
 
 
 
 
 
 
 
197
  = 1.0.16 (24th January 2020) =
198
  * Improvement: Need to built compatibility with "Mistape" plugin. #3974
199
  * Improvement: Need to make compatibility with "Transposh WordPress Translation" plugin #3895
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.3.2
7
+ Stable tag: 1.0.17
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.17 (27th January 2020) =
198
+ * Improvement: Compatibility with the Imagify plugin #3908
199
+ * Improvement: EWWW Image Optimizer plugin Compatibility #3984
200
+ * Improvement: Accessibility score of Amp Layouts improved in Lighthouse test #4078
201
+ * Fixed: Admin toolbar is not showing on custom amp page #3718
202
+ * Fixed: Bug in Instant article's Single option #3891
203
+ * Fixed: If the user adds the social share link in the users section then we need to show social share icon #3976
204
+ * Fixed: Treeshaking is enabled then " Content sneak to peek " button is showing below the content. #4069
205
+ * Fixed: AMP take over is not working on home page when user have no posts. #4056
206
+
207
  = 1.0.16 (24th January 2020) =
208
  * Improvement: Need to built compatibility with "Mistape" plugin. #3974
209
  * Improvement: Need to make compatibility with "Transposh WordPress Translation" plugin #3895
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.16
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.16');
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.17
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.17');
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,15 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
 
 
3
  = 1.0.16 (24th January 2020) =
4
  * Improvement: Need to built compatibility with "Mistape" plugin. #3974
5
  * Improvement: Need to make compatibility with "Transposh WordPress Translation" plugin #3895
1
  == Changelog ==
2
 
3
+ = 1.0.17 (27th January 2020) =
4
+ * Improvement: Compatibility with the Imagify plugin #3908
5
+ * Improvement: EWWW Image Optimizer plugin Compatibility #3984
6
+ * Improvement: Accessibility score of Amp Layouts improved in Lighthouse test #4078
7
+ * Fixed: Admin toolbar is not showing on custom amp page #3718
8
+ * Fixed: Bug in Instant article's Single option #3891
9
+ * Fixed: If the user adds the social share link in the users section then we need to show social share icon #3976
10
+ * Fixed: Treeshaking is enabled then " Content sneak to peek " button is showing below the content. #4069
11
+ * Fixed: AMP take over is not working on home page when user have no posts. #4056
12
+
13
  = 1.0.16 (24th January 2020) =
14
  * Improvement: Need to built compatibility with "Mistape" plugin. #3974
15
  * Improvement: Need to make compatibility with "Transposh WordPress Translation" plugin #3895
components/components-core.php CHANGED
@@ -402,6 +402,7 @@ function amp_header_core(){
402
  </head>
403
  <body <?php ampforwp_body_class($bodyClass); ?>>
404
  <?php do_action('amp_start', $thisTemplate); ?>
 
405
  <?php do_action('ampforwp_body_beginning', $thisTemplate);
406
  }
407
 
402
  </head>
403
  <body <?php ampforwp_body_class($bodyClass); ?>>
404
  <?php do_action('amp_start', $thisTemplate); ?>
405
+ <?php do_action('ampforwp_admin_menu_bar_front'); ?>
406
  <?php do_action('ampforwp_body_beginning', $thisTemplate);
407
  }
408
 
components/loop/loop.php CHANGED
@@ -515,7 +515,11 @@ function amp_loop_image( $data=array() ) {
515
  }
516
  echo '<'.esc_attr($tag).' class="loop-img '.esc_attr($tag_class).'">';
517
  echo '<a href="'.esc_url($imageLink).'" title="'.esc_html(get_the_title()).'">';
518
- echo '<amp-img src="'. esc_url($thumb_url) .'" width="'.esc_attr($thumb_width).'" height="'.esc_attr($thumb_height).'" '. esc_attr($layout_responsive) .' class="'.esc_attr($imageClass).'" alt="'. esc_html(get_the_title()) .'"></amp-img>';
 
 
 
 
519
  echo '</a>';
520
  echo '</'.esc_attr($tag).'>';
521
  }
515
  }
516
  echo '<'.esc_attr($tag).' class="loop-img '.esc_attr($tag_class).'">';
517
  echo '<a href="'.esc_url($imageLink).'" title="'.esc_html(get_the_title()).'">';
518
+ $img_content = '<amp-img src="'. esc_url($thumb_url) .'" width="'.esc_attr($thumb_width).'" height="'.esc_attr($thumb_height).'" '. esc_attr($layout_responsive) .' class="'.esc_attr($imageClass).'" alt="'. esc_html(get_the_title()) .'"></amp-img>';
519
+ if(function_exists('ampforwp_add_fallback_element')){
520
+ $img_content = ampforwp_add_fallback_element($img_content,'amp-img');
521
+ }
522
+ echo $img_content;
523
  echo '</a>';
524
  echo '</'.esc_attr($tag).'>';
525
  }
components/related-posts/related-posts.php CHANGED
@@ -160,9 +160,13 @@ function ampforwp_get_relatedpost_image( $imagetype ='thumbnail', $data=array()
160
  $thumb_height = $thumb_url_array[2];
161
  }
162
 
163
- if ( $thumb_url && $show_image ) { ?>
164
- <amp-img src="<?php echo esc_url( $thumb_url ); ?>" width="<?php echo esc_attr($thumb_width); ?>" height="<?php echo esc_attr($thumb_height); ?>" layout="responsive"></amp-img>
165
- <?php }
 
 
 
 
166
  } ?>
167
  </a>
168
  <?php
160
  $thumb_height = $thumb_url_array[2];
161
  }
162
 
163
+ if ( $thumb_url && $show_image ) {
164
+ $img_content = '<amp-img src="'.esc_url( $thumb_url ).'" width="'.esc_attr($thumb_width).'" height="'.esc_attr($thumb_height).'" layout="responsive"></amp-img>';
165
+ if(function_exists('ampforwp_add_fallback_element')){
166
+ $img_content = ampforwp_add_fallback_element($img_content,'amp-img');
167
+ }
168
+ echo $img_content;
169
+ }
170
  } ?>
171
  </a>
172
  <?php
feeds/instant-article-feed.php CHANGED
@@ -31,12 +31,21 @@ header('Content-Type: ' . esc_attr(feed_content_type('rss2')) . '; charset=' . e
31
  $ia_args['category__not_in'] = $exclude_cats;
32
  }
33
 
34
- $exclude_ids = get_option('ampforwp_ia_exclude_post');
35
  $ia_args = array(
36
- 'post__not_in' => (array) $exclude_ids,
37
  'post_status' => 'publish',
38
  'ignore_sticky_posts' => true,
39
  'posts_per_page' => esc_attr($number_of_articles),
 
 
 
 
 
 
 
 
 
 
 
40
  );
41
  if ( is_category() ) {
42
  $ia_args['category__in'] = get_queried_object_id();
31
  $ia_args['category__not_in'] = $exclude_cats;
32
  }
33
 
 
34
  $ia_args = array(
 
35
  'post_status' => 'publish',
36
  'ignore_sticky_posts' => true,
37
  'posts_per_page' => esc_attr($number_of_articles),
38
+ 'meta_query' => array(
39
+ 'relation' => 'OR',
40
+ array(
41
+ 'key' => 'ampforwp-ia-on-off',
42
+ 'value' => 'hide-ia',
43
+ 'compare' => "!="
44
+ ), array(
45
+ 'key' => 'ampforwp-ia-on-off',
46
+ 'compare' => "NOT EXISTS"
47
+ ),
48
+ )
49
  );
50
  if ( is_category() ) {
51
  $ia_args['category__in'] = get_queried_object_id();
images/twitter-icon.webp ADDED
Binary file
includes/features/functions.php CHANGED
@@ -1084,23 +1084,23 @@ if ( ! function_exists('ampforwp_sanitize_i_amphtml') ) {
1084
  function checkAMPforPageBuilderStatus($postId){
1085
  global $post;
1086
  $postId = (is_object($post)? $post->ID: '');
1087
-
1088
  if( ampforwp_is_front_page() ){
1089
  $postId = ampforwp_get_frontpage_id();
1090
  }
1091
  if ( empty( $postId ) ) {
1092
  $response = false;
1093
  }else{
1094
- $amp_bilder = get_post_field('amp-page-builder',$post->ID);
1095
- $amp_pd_data = json_decode($amp_bilder);
1096
- $ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true);
1097
  if( $ampforwp_pagebuilder_enable=='yes' && true == ampforwp_get_setting('ampforwp-pagebuilder') && ( function_exists('amppb_post_content') && !empty($amp_pd_data->rows))){
1098
  $response = true;
1099
  }else{
1100
  $response = false;
1101
  }
1102
- $response = apply_filters( 'ampforwp_pagebuilder_status_modify', $response, $postId );
1103
  }
 
1104
  return $response;
1105
  }
1106
 
1084
  function checkAMPforPageBuilderStatus($postId){
1085
  global $post;
1086
  $postId = (is_object($post)? $post->ID: '');
1087
+ $response =false;
1088
  if( ampforwp_is_front_page() ){
1089
  $postId = ampforwp_get_frontpage_id();
1090
  }
1091
  if ( empty( $postId ) ) {
1092
  $response = false;
1093
  }else{
1094
+ $amp_builder = get_post_field('amp-page-builder',$postId);
1095
+ $amp_pd_data = json_decode($amp_builder);
1096
+ $ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true);
1097
  if( $ampforwp_pagebuilder_enable=='yes' && true == ampforwp_get_setting('ampforwp-pagebuilder') && ( function_exists('amppb_post_content') && !empty($amp_pd_data->rows))){
1098
  $response = true;
1099
  }else{
1100
  $response = false;
1101
  }
 
1102
  }
1103
+ $response = apply_filters( 'ampforwp_pagebuilder_status_modify', $response, $postId );
1104
  return $response;
1105
  }
1106
 
includes/features/performance/performance-functions.php CHANGED
@@ -200,6 +200,9 @@ function ampforwp_code_to_add_in_htaccess(){
200
 
201
  function ampforwp_white_list_selectors($completeContent){
202
  $white_list = array();
 
 
 
203
  $white_list = (array)apply_filters('ampforwp_tree_shaking_white_list_selector',$white_list);
204
  $w_l_str = '';
205
  for($i=0;$i<count($white_list);$i++){
200
 
201
  function ampforwp_white_list_selectors($completeContent){
202
  $white_list = array();
203
+ if(ampforwp_get_setting('ampforwp_css_tree_shaking')==1 && ampforwp_get_setting('content-sneak-peek')==1 ){
204
+ $white_list[] = '.hide';
205
+ }
206
  $white_list = (array)apply_filters('ampforwp_tree_shaking_white_list_selector',$white_list);
207
  $w_l_str = '';
208
  for($i=0;$i<count($white_list);$i++){
includes/thirdparty-compatibility.php CHANGED
@@ -975,7 +975,18 @@ if ( ! function_exists('ampforwp_yoast_twitter_handle') ) {
975
  if ( function_exists('mvp_setup') ) {
976
  return ' <span><a class="zox_tw" href="https://twitter.com/'.esc_attr($twitter).'" target="_blank"></a></span>';
977
  }else{
978
- return ' <span><a href="https://twitter.com/'.esc_attr($twitter).'" target="_blank">@'.esc_html($twitter).'</a></span>';
 
 
 
 
 
 
 
 
 
 
 
979
  }
980
 
981
  }
975
  if ( function_exists('mvp_setup') ) {
976
  return ' <span><a class="zox_tw" href="https://twitter.com/'.esc_attr($twitter).'" target="_blank"></a></span>';
977
  }else{
978
+ $parse = parse_url($twitter);
979
+ if(isset($parse['host']) && $parse['host'] == 'twitter.com'){
980
+ $twitter_url = $twitter;
981
+ }else{
982
+ $twitter_url = 'https://twitter.com/'.esc_attr($twitter);
983
+ }
984
+ if(ampforwp_design_selector()==4){
985
+ return ' <span><a class="author-tw" href="'.esc_url($twitter_url).'" target="_blank"></a></span>';
986
+ }else{
987
+ return '<a title="twitter share" href="'.esc_url($twitter_url).'" class="amp-social-icon-rounded-author amp-social-twitter">
988
+ <amp-img src="'.AMPFORWP_IMAGE_DIR . '/twitter-icon.webp'.'" width="16" height="16" ></amp-img></a>';
989
+ }
990
  }
991
 
992
  }
includes/vendor/amp/includes/class-amp-post-template.php CHANGED
@@ -325,7 +325,9 @@ class AMP_Post_Template {
325
  if(function_exists('ampforwp_mistape_plugin_compatibility')){
326
  $amp_con = ampforwp_mistape_plugin_compatibility($amp_con);
327
  }
328
- $amp_con = $this->ampforwp_add_fallback_element($amp_con,'amp-img');
 
 
329
  $this->add_data_by_key( 'post_amp_content', $amp_con);
330
  $this->merge_data_for_key( 'amp_component_scripts', $amp_content->get_amp_scripts() );
331
  $this->merge_data_for_key( 'post_amp_styles', $amp_content->get_amp_styles() );
@@ -336,90 +338,7 @@ class AMP_Post_Template {
336
  }
337
  }
338
 
339
- private function ampforwp_imagify_webp_compatibility($content){
340
- if(function_exists('_imagify_init')){
341
- preg_match_all('/src="(.*?)"/', $content,$src);
342
- $imageify_opt = get_option( 'imagify_settings' );
343
- $convert_to_webp = $imageify_opt['convert_to_webp'];
344
- $display_webp = $imageify_opt['display_webp'];
345
- if($convert_to_webp && $display_webp){
346
- $img_url = esc_url($src[1][0]);
347
- $rep_url = esc_url($src[1][0]).".webp";
348
- if(isset($headers[0])){
349
- $is_webp = stripos($headers[0], "200 OK") ? TRUE : FALSE;
350
- if($is_webp){
351
- $content = str_replace($img_url, $rep_url, $content);
352
- }
353
- }
354
- }
355
- }
356
- return $content;
357
- }
358
- private function ampforwp_imagify_fallback_img_src_url($content){
359
- if(!function_exists('_imagify_init')){
360
- preg_match_all('/src=\"(.*?)\.(webp)\"/', $content,$cc); // need to check extenstion for fallback.
361
- if(isset($cc[2][0])){
362
- $ext = esc_attr($cc[2][0]);
363
- $content = str_replace($ext, "jpg", $content); // need to change fallback extenstion.
364
- }
365
-
366
- }
367
- return $content;
368
- }
369
-
370
-
371
- private function ampforwp_add_fallback_element($content='',$tag=''){
372
- preg_match_all('/<'.$tag.' (.*?)<\/'.$tag.'>/', $content, $matches);
373
- if(!empty($matches)){
374
- if(isset($matches[0])){
375
- $con = "";
376
- for($i=0;$i<count($matches[0]);$i++){
377
- $match = $matches[0][$i];
378
- $m_content = $matches[1][$i];
379
- $m_content = $this->ampforwp_imagify_webp_compatibility($m_content);
380
- $m1_content = $this->ampforwp_imagify_fallback_img_src_url($matches[1][$i]);
381
- preg_match_all('/src="(.*?)"/', $m1_content,$fimgsrc);
382
- preg_match_all('/width="(.*?)"/', $m1_content,$fimgwidth);
383
- preg_match_all('/height="(.*?)"/', $m1_content,$fimgheight);
384
- preg_match_all('/alt="(.*?)"/', $m1_content,$fimgalt);
385
- if((isset($fimgsrc[1][0]) && preg_match_all('/http/', $fimgsrc[1][0],$fbi)) && isset($fimgwidth[1][0]) && isset($fimgheight[1][0])){
386
- $data['src'] = $fimgsrc[1][0];
387
- $data['width'] = $fimgwidth[1][0];
388
- $data['height'] = $fimgheight[1][0];
389
- if(isset($fimgalt[1][0])){
390
- $data['alt'] = $fimgalt[1][0];
391
- }else{
392
- $data['alt'] = '';
393
- }
394
- $fallback_data = apply_filters('ampforwp_fallback_image_params',$data);
395
- $fsrc = $fallback_data['src'];
396
- $fwidth = $fallback_data['width'];
397
- $fheight= $fallback_data['height'];
398
- $falt = $fallback_data['alt'];
399
- $ssrc = $fimgsrc[0][0];
400
- $swidth = $fimgwidth[0][0];
401
- $sheight = $fimgheight[0][0];
402
- if(isset($fimgalt[0][0])){
403
- $salt = $fimgalt[0][0];
404
- }else{
405
- $salt = '';
406
- }
407
- $src_rep = 'src="'.esc_url($fsrc).'"';
408
- $width_rep = 'width="'.intval($fwidth).'"';
409
- $height_rep = 'height="'.intval($fheight).'"';
410
- $alt_rep = 'alt="'.esc_attr($falt).'"';
411
- $m1_content = str_replace($ssrc, $src_rep, $m1_content);
412
- $m1_content = str_replace($swidth, $width_rep, $m1_content);
413
- $m1_content = str_replace($sheight, $height_rep, $m1_content);
414
- $m1_content = str_replace($salt, $alt_rep, $m1_content);
415
- $fallback_img = "<amp-img ".$m_content."<amp-img fallback ".$m1_content."</amp-img></amp-img>";//$m_content, $m1_content escaped above.
416
- $content = str_replace("$match", $fallback_img, $content);
417
- }
418
- }
419
- }
420
- }
421
- return $content;
422
- }
423
  private function build_post_featured_image() {
424
  $post_id = $this->ID;
425
  $image_size = apply_filters( 'ampforwp_featured_image_size', 'large' );
325
  if(function_exists('ampforwp_mistape_plugin_compatibility')){
326
  $amp_con = ampforwp_mistape_plugin_compatibility($amp_con);
327
  }
328
+ if(function_exists('ampforwp_add_fallback_element')){
329
+ $amp_con = ampforwp_add_fallback_element($amp_con,'amp-img');
330
+ }
331
  $this->add_data_by_key( 'post_amp_content', $amp_con);
332
  $this->merge_data_for_key( 'amp_component_scripts', $amp_content->get_amp_scripts() );
333
  $this->merge_data_for_key( 'post_amp_styles', $amp_content->get_amp_styles() );
338
  }
339
  }
340
 
341
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  private function build_post_featured_image() {
343
  $post_id = $this->ID;
344
  $image_size = apply_filters( 'ampforwp_featured_image_size', 'large' );
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.3.2
7
- Stable tag: 1.0.16
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -191,6 +191,16 @@ You can contact us from [here](https://ampforwp.com/contact/)
191
 
192
  == Changelog ==
193
 
 
 
 
 
 
 
 
 
 
 
194
  = 1.0.16 (24th January 2020) =
195
  * Improvement: Need to built compatibility with "Mistape" plugin. #3974
196
  * Improvement: Need to make compatibility with "Transposh WordPress Translation" plugin #3895
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.3.2
7
+ Stable tag: 1.0.17
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
191
 
192
  == Changelog ==
193
 
194
+ = 1.0.17 (27th January 2020) =
195
+ * Improvement: Compatibility with the Imagify plugin #3908
196
+ * Improvement: EWWW Image Optimizer plugin Compatibility #3984
197
+ * Improvement: Accessibility score of Amp Layouts improved in Lighthouse test #4078
198
+ * Fixed: Admin toolbar is not showing on custom amp page #3718
199
+ * Fixed: Bug in Instant article's Single option #3891
200
+ * Fixed: If the user adds the social share link in the users section then we need to show social share icon #3976
201
+ * Fixed: Treeshaking is enabled then " Content sneak to peek " button is showing below the content. #4069
202
+ * Fixed: AMP take over is not working on home page when user have no posts. #4056
203
+
204
  = 1.0.16 (24th January 2020) =
205
  * Improvement: Need to built compatibility with "Mistape" plugin. #3974
206
  * Improvement: Need to make compatibility with "Transposh WordPress Translation" plugin #3895
templates/design-manager/design-1/style.php CHANGED
@@ -279,6 +279,8 @@ left:191px;
279
  .ampforwp-ad-above-related-post{padding-top:15px;}
280
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
281
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 22px; font-size: 13px; color:#333;}
 
 
282
  figure.aligncenter amp-img {
283
  margin: 0 auto;
284
  }
279
  .ampforwp-ad-above-related-post{padding-top:15px;}
280
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
281
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 22px; font-size: 13px; color:#333;}
282
+ .amp-social-twitter{background:#1da1f2}
283
+ .amp-social-icon-rounded-author {padding: 10px 0px 10px 10px;display: inline-table;border-radius: 50%;cursor: pointer;}
284
  figure.aligncenter amp-img {
285
  margin: 0 auto;
286
  }
templates/design-manager/design-2/style.php CHANGED
@@ -369,6 +369,8 @@ main .amp-wp-content.featured-image-content{ padding: 0px; border: 0; margin-bot
369
  .amp-wp-article-header.amp-wp-article-category.ampforwp-meta-taxonomy{ margin: 10px auto; max-width: 1030px; } .ampforwp_single_excerpt { margin-bottom:15px; font-size: 15px; text-align:center}
370
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
371
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 2px; font-size: 13px; color:#333;}
 
 
372
  <?php if(is_single()){
373
  if( $redux_builder_amp['ampforwp-single-select-type-of-related'] ){ ?>
374
  /* Related Posts */
369
  .amp-wp-article-header.amp-wp-article-category.ampforwp-meta-taxonomy{ margin: 10px auto; max-width: 1030px; } .ampforwp_single_excerpt { margin-bottom:15px; font-size: 15px; text-align:center}
370
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
371
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 2px; font-size: 13px; color:#333;}
372
+ .amp-social-twitter{background:#1da1f2}
373
+ .amp-social-icon-rounded-author {padding: 10px 0px 10px 10px;display: inline-table;border-radius: 50%;cursor: pointer;}
374
  <?php if(is_single()){
375
  if( $redux_builder_amp['ampforwp-single-select-type-of-related'] ){ ?>
376
  /* Related Posts */
templates/design-manager/design-3/elements/related-posts.php CHANGED
@@ -116,9 +116,13 @@ if( isset($redux_builder_amp['ampforwp-single-related-posts-switch']) && $redux_
116
  $thumb_url = ampforwp_get_post_thumbnail();
117
  $thumb_width = ampforwp_get_post_thumbnail('width');
118
  $thumb_height = ampforwp_get_post_thumbnail('height');
119
- if( $thumb_url && true == $redux_builder_amp['ampforwp-single-related-posts-image'] ) { ?>
120
- <amp-img src="<?php echo esc_url( $thumb_url ); ?>" width=<?php echo esc_attr($thumb_width); ?> height=<?php echo esc_attr($thumb_height); ?> layout="responsive"></amp-img>
121
- <?php }
 
 
 
 
122
  }?>
123
  </a>
124
  </div>
116
  $thumb_url = ampforwp_get_post_thumbnail();
117
  $thumb_width = ampforwp_get_post_thumbnail('width');
118
  $thumb_height = ampforwp_get_post_thumbnail('height');
119
+ if( $thumb_url && true == $redux_builder_amp['ampforwp-single-related-posts-image'] ) {
120
+ $img_content = '<amp-img src="'.esc_url( $thumb_url ).'" width="'.esc_attr($thumb_width).'" height="'.esc_attr($thumb_height).'" layout="responsive"></amp-img>';
121
+ if(function_exists('ampforwp_add_fallback_element')){
122
+ $img_content = ampforwp_add_fallback_element($img_content,'amp-img');
123
+ }
124
+ echo $img_content;
125
+ }
126
  }?>
127
  </a>
128
  </div>
templates/design-manager/design-3/style.php CHANGED
@@ -323,6 +323,7 @@ h1.amp-wp-title{ margin: 0; color: #333333; font-size: 48px; line-height: 58px;}
323
  .single-post .post-pagination-meta span{ font-weight:bold }
324
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 22px; font-size: 16px; color:#333; }
325
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
 
326
  .amp-wp-article-tags .ampforwp-tax-tag, .amp-wp-article-tags .ampforwp-tax-tag a{ font-size: 12px; color: #555; margin: 20px 0 0 0; }
327
  .amp-wp-article-tags span{ background: #eee; margin-right: 10px; padding: 5px 12px 5px 12px; border-radius: 3px; display: inline-block; margin: 5px; }
328
  .ampforwp-social-icons{ margin-bottom: 70px; margin-top: 25px; min-height: 40px; }
323
  .single-post .post-pagination-meta span{ font-weight:bold }
324
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 22px; font-size: 16px; color:#333; }
325
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
326
+ .amp-social-icon-rounded-author {padding: 10px 0px 10px 10px;display: inline-table;border-radius: 60px;cursor: pointer;}
327
  .amp-wp-article-tags .ampforwp-tax-tag, .amp-wp-article-tags .ampforwp-tax-tag a{ font-size: 12px; color: #555; margin: 20px 0 0 0; }
328
  .amp-wp-article-tags span{ background: #eee; margin-right: 10px; padding: 5px 12px 5px 12px; border-radius: 3px; display: inline-block; margin: 5px; }
329
  .ampforwp-social-icons{ margin-bottom: 70px; margin-top: 25px; min-height: 40px; }
templates/design-manager/swift/style.php CHANGED
@@ -616,6 +616,8 @@ table {
616
  overflow-x: auto;
617
  word-break: normal;
618
  }
 
 
619
  .artl-cnt table{ margin: 0 auto; text-align: center; width: 100%; }
620
  p.nocomments {padding: 10px;color: #fff;}
621
  .tl-exc{font-size: 16px;color: #444;margin-top: 10px;line-height:20px;}
@@ -1456,7 +1458,7 @@ if ( isset($redux_builder_amp['footer-type']) && '1' == $redux_builder_amp['foot
1456
  <?php if($redux_builder_amp['footer2-position-type'] == '1'){?>
1457
  .f-menu ul li .sub-menu{display:none;}
1458
  .f-menu ul li{display:inline-block;margin-right:20px;}
1459
- .f-menu ul li a {padding:0;color:#7a7a7a;}
1460
  .f-menu ul > li:hover a{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
1461
  .f-menu{font-size:14px;line-height:1.4;margin-bottom:30px;}
1462
  .rr{font-size: 12px;color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-footer-txt-clr']['rgba']) ?>;}
616
  overflow-x: auto;
617
  word-break: normal;
618
  }
619
+ .author-tw:after {font-family:icomoon;content: "\e942";color: #fff;background: #1da1f2;padding: 4px;border-radius: 3px;margin: 0px 5px;text-decoration: none;}
620
+ .author-tw:hover{text-decoration: none;}
621
  .artl-cnt table{ margin: 0 auto; text-align: center; width: 100%; }
622
  p.nocomments {padding: 10px;color: #fff;}
623
  .tl-exc{font-size: 16px;color: #444;margin-top: 10px;line-height:20px;}
1458
  <?php if($redux_builder_amp['footer2-position-type'] == '1'){?>
1459
  .f-menu ul li .sub-menu{display:none;}
1460
  .f-menu ul li{display:inline-block;margin-right:20px;}
1461
+ .f-menu ul li a {padding:0;color:#575656;}
1462
  .f-menu ul > li:hover a{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
1463
  .f-menu{font-size:14px;line-height:1.4;margin-bottom:30px;}
1464
  .rr{font-size: 12px;color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-footer-txt-clr']['rgba']) ?>;}
templates/features.php CHANGED
@@ -5712,9 +5712,13 @@ function ampforwp_is_non_amp( $type="" ) {
5712
  $supported_types_for_takeover = ampforwp_get_all_post_types();
5713
  if( $supported_types_for_takeover ){
5714
  $current_type = get_post_type(get_the_ID());
5715
- if(!in_array($current_type, $supported_types_for_takeover) && !is_404() && !is_search()){
5716
- return ;
5717
- }
 
 
 
 
5718
  }
5719
  if ( is_front_page() && false == $redux_builder_amp['ampforwp-homepage-on-off-support'] ) {
5720
  return false;
@@ -6366,6 +6370,7 @@ function ampforwp_sneak_peek_css(){
6366
  $txt_color = $redux_builder_amp['content-sneak-peek-txt-color']['color'];?>
6367
  .fd-h{height: <?php echo esc_attr($height); ?>;overflow: hidden;position: relative;}
6368
  .fd-b-c{text-align: center;margin: 0px 0px 30px 0px;}
 
6369
  .fd-b-c .fd-b {border:none;border-radius: 5px;color: <?php echo ampforwp_sanitize_color($txt_color); ?>;font-size: 16px;font-weight: 700;padding: 12px 32px 12px 32px;background-color: <?php echo ampforwp_sanitize_color($btn_color); ?>;
6370
  }
6371
  .fd-h:after {
@@ -6455,7 +6460,7 @@ function ampforwp_ia_meta_callback( $post ) {
6455
  global $redux_builder_amp;
6456
  wp_nonce_field( basename( __FILE__ ), 'ampforwp_ia_nonce' );
6457
  $ampforwp_stored_meta = get_post_meta( $post->ID );
6458
- if ( ! isset($ampforwp_stored_meta['ampforwp-ia-on-off'][0]) && $ampforwp_stored_meta['ampforwp-ia-on-off'][0] == 'hide-ia') {
6459
  $exclude_post_value = get_option('ampforwp_ia_exclude_post');
6460
  if ( $exclude_post_value == null ) {
6461
  $exclude_post_value[] = 0;
@@ -6481,12 +6486,12 @@ function ampforwp_ia_meta_callback( $post ) {
6481
  } ?>
6482
  <p>
6483
  <div class="prfx-row-content">
6484
- <label class="meta-radio-two" for="ampforwp-on-off-meta-radio-one">
6485
- <input type="radio" name="ampforwp-ia-on-off" id="ampforwp-on-off-meta-radio-one" value="default" checked="checked" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-ia-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-ia-on-off'][0], 'default' ); ?>>
6486
  <?php esc_html_e( 'Enable', 'accelerated-mobile-pages' )?>
6487
  </label>
6488
- <label class="meta-radio-two" for="ampforwp-on-off-meta-radio-two">
6489
- <input type="radio" name="ampforwp-ia-on-off" id="ampforwp-on-off-meta-radio-two" value="hide-ia" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-ia-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-ia-on-off'][0], 'hide-ia' ); ?>>
6490
  <?php esc_html_e( 'Disable', 'accelerated-mobile-pages' )?>
6491
  </label>
6492
  </div>
@@ -7777,4 +7782,111 @@ if(!function_exists('ampforwp_get_retina_image_settings')){
7777
  }
7778
  return $data;
7779
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7780
  }
5712
  $supported_types_for_takeover = ampforwp_get_all_post_types();
5713
  if( $supported_types_for_takeover ){
5714
  $current_type = get_post_type(get_the_ID());
5715
+ if( $current_type==false){
5716
+ $non_amp = true;
5717
+ }else{
5718
+ if(!in_array($current_type, $supported_types_for_takeover) && !is_404() && !is_search()){
5719
+ return ;
5720
+ }
5721
+ }
5722
  }
5723
  if ( is_front_page() && false == $redux_builder_amp['ampforwp-homepage-on-off-support'] ) {
5724
  return false;
6370
  $txt_color = $redux_builder_amp['content-sneak-peek-txt-color']['color'];?>
6371
  .fd-h{height: <?php echo esc_attr($height); ?>;overflow: hidden;position: relative;}
6372
  .fd-b-c{text-align: center;margin: 0px 0px 30px 0px;}
6373
+ .fd-b-c .fd-b:hover{cursor:pointer;}
6374
  .fd-b-c .fd-b {border:none;border-radius: 5px;color: <?php echo ampforwp_sanitize_color($txt_color); ?>;font-size: 16px;font-weight: 700;padding: 12px 32px 12px 32px;background-color: <?php echo ampforwp_sanitize_color($btn_color); ?>;
6375
  }
6376
  .fd-h:after {
6460
  global $redux_builder_amp;
6461
  wp_nonce_field( basename( __FILE__ ), 'ampforwp_ia_nonce' );
6462
  $ampforwp_stored_meta = get_post_meta( $post->ID );
6463
+ if ( ! isset($ampforwp_stored_meta['ampforwp-ia-on-off']) && ! isset($ampforwp_stored_meta['ampforwp-ia-on-off'][0]) && $ampforwp_stored_meta['ampforwp-ia-on-off'][0] == 'hide-ia') {
6464
  $exclude_post_value = get_option('ampforwp_ia_exclude_post');
6465
  if ( $exclude_post_value == null ) {
6466
  $exclude_post_value[] = 0;
6486
  } ?>
6487
  <p>
6488
  <div class="prfx-row-content">
6489
+ <label class="meta-radio-two" for="ampforwp-ia-on-off-meta-radio-one">
6490
+ <input type="radio" name="ampforwp-ia-on-off" id="ampforwp-ia-on-off-meta-radio-one" value="default" checked="checked" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-ia-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-ia-on-off'][0], 'default' ); ?>>
6491
  <?php esc_html_e( 'Enable', 'accelerated-mobile-pages' )?>
6492
  </label>
6493
+ <label class="meta-radio-two" for="ampforwp-ia-on-off-meta-radio-two">
6494
+ <input type="radio" name="ampforwp-ia-on-off" id="ampforwp-ia-on-off-meta-radio-two" value="hide-ia" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-ia-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-ia-on-off'][0], 'hide-ia' ); ?>>
6495
  <?php esc_html_e( 'Disable', 'accelerated-mobile-pages' )?>
6496
  </label>
6497
  </div>
7782
  }
7783
  return $data;
7784
  }
7785
+ }
7786
+
7787
+ if(!function_exists('ampforwp_add_fallback_element')){
7788
+ function ampforwp_add_fallback_element($content='',$tag=''){
7789
+ preg_match_all('/<'.$tag.' (.*?)<\/'.$tag.'>/', $content, $matches);
7790
+ if(!empty($matches)){
7791
+ if(isset($matches[0])){
7792
+ $con = "";
7793
+ for($i=0;$i<count($matches[0]);$i++){
7794
+ $match = $matches[0][$i];
7795
+ $m_content = $matches[1][$i];
7796
+ $m_content = ampforwp_imagify_webp_compatibility($m_content);
7797
+ $m_content = ampforwp_ewww_webp_compatibility($m_content);
7798
+ $m1_content = ampforwp_imagify_fallback_img_src_url($matches[1][$i]);
7799
+ preg_match_all('/src="(.*?)"/', $m1_content,$fimgsrc);
7800
+ preg_match_all('/width="(.*?)"/', $m1_content,$fimgwidth);
7801
+ preg_match_all('/height="(.*?)"/', $m1_content,$fimgheight);
7802
+ preg_match_all('/alt="(.*?)"/', $m1_content,$fimgalt);
7803
+ if((isset($fimgsrc[1][0]) && preg_match_all('/http/', $fimgsrc[1][0],$fbi)) && isset($fimgwidth[1][0]) && isset($fimgheight[1][0])){
7804
+ $data['src'] = $fimgsrc[1][0];
7805
+ $data['width'] = $fimgwidth[1][0];
7806
+ $data['height'] = $fimgheight[1][0];
7807
+ if(isset($fimgalt[1][0])){
7808
+ $data['alt'] = $fimgalt[1][0];
7809
+ }else{
7810
+ $data['alt'] = '';
7811
+ }
7812
+ $fallback_data = apply_filters('ampforwp_fallback_image_params',$data);
7813
+ $fsrc = $fallback_data['src'];
7814
+ $fwidth = $fallback_data['width'];
7815
+ $fheight= $fallback_data['height'];
7816
+ $falt = $fallback_data['alt'];
7817
+ $ssrc = $fimgsrc[0][0];
7818
+ $swidth = $fimgwidth[0][0];
7819
+ $sheight = $fimgheight[0][0];
7820
+ $salt = '';
7821
+ if(isset($fimgalt[0][0])){
7822
+ $salt = $fimgalt[0][0];
7823
+ }
7824
+ $src_rep = 'src="'.esc_url($fsrc).'"';
7825
+ $width_rep = 'width="'.intval($fwidth).'"';
7826
+ $height_rep = 'height="'.intval($fheight).'"';
7827
+ $alt_rep = 'alt="'.esc_attr($falt).'"';
7828
+ $m1_content = str_replace($ssrc, $src_rep, $m1_content);
7829
+ $m1_content = str_replace($swidth, $width_rep, $m1_content);
7830
+ $m1_content = str_replace($sheight, $height_rep, $m1_content);
7831
+ $m1_content = str_replace($salt, $alt_rep, $m1_content);
7832
+ $fallback_img = "<amp-img ".$m_content."<amp-img fallback ".$m1_content."</amp-img></amp-img>";//$m_content, $m1_content escaped above.
7833
+ $content = str_replace("$match", $fallback_img, $content);
7834
+ }
7835
+ }
7836
+ }
7837
+ }
7838
+ return $content;
7839
+ }
7840
+ }
7841
+ if(!function_exists('ampforwp_imagify_webp_compatibility')){
7842
+ function ampforwp_imagify_webp_compatibility($content){
7843
+ if(function_exists('_imagify_init')){
7844
+ preg_match_all('/src="(.*?)"/', $content,$src);
7845
+ $imageify_opt = get_option( 'imagify_settings' );
7846
+ $convert_to_webp = $imageify_opt['convert_to_webp'];
7847
+ $display_webp = $imageify_opt['display_webp'];
7848
+ if($convert_to_webp && $display_webp){
7849
+ $img_url = esc_url($src[1][0]);
7850
+ $rep_url = esc_url($src[1][0]).".webp";
7851
+ $headers = get_headers($rep_url);
7852
+ if(isset($headers[0])){
7853
+ $is_webp = stripos($headers[0], "200 OK") ? TRUE : FALSE;
7854
+ if($is_webp){
7855
+ $content = str_replace($img_url, $rep_url, $content);
7856
+ }
7857
+ }
7858
+ }
7859
+ }
7860
+ return $content;
7861
+ }
7862
+ }
7863
+ if(!function_exists('ampforwp_imagify_fallback_img_src_url')){
7864
+ function ampforwp_imagify_fallback_img_src_url($content){
7865
+ if(!function_exists('_imagify_init') && !function_exists('ewww_image_optimizer_webp_initialize')){
7866
+ preg_match_all('/src=\"(.*?)\.(webp)\"/', $content,$cc); // need to check extenstion for fallback.
7867
+ if(isset($cc[2][0])){
7868
+ $ext = esc_attr($cc[2][0]);
7869
+ $content = str_replace($ext, "jpg", $content); // need to change fallback extenstion.
7870
+ }
7871
+
7872
+ }
7873
+ return $content;
7874
+ }
7875
+ }
7876
+ if(!function_exists('ampforwp_ewww_webp_compatibility')){
7877
+ function ampforwp_ewww_webp_compatibility($content){
7878
+ if(defined( 'EWWW_IO_CLOUD_PLUGIN' )){
7879
+ preg_match_all('/src="(.*?)"/', $content,$src);
7880
+ if(isset($src[1][0])){
7881
+ $img_url = esc_url($src[1][0]);
7882
+ $rep_url = esc_url($src[1][0]).".webp";
7883
+ $headers = get_headers($rep_url);
7884
+ $is_webp = stripos($headers[0], "200 OK") ? TRUE : FALSE;
7885
+ if($is_webp){
7886
+ $content = str_replace($img_url, $rep_url, $content);
7887
+ }
7888
+ }
7889
+ }
7890
+ return $content;
7891
+ }
7892
  }