AMP for WP – Accelerated Mobile Pages - Version 0.9.97.44.2

Version Description

(1st April 2019) = * Added: Element folder files override in the Design One, Design Two and Design Three for the Child theme #2770 * Added: High-resolution Images [Additional image guidelines] option added in structure data #2259 * Fixed: Hide by default option from bulk tools is not working when amp takeover option is enabled #2832 * Fixed: Space removed while checking in the ampforwp_onesignal_notifications_widget function #2569 * Fixed: Display on User Avatar option #2942 * Fixed: Edit page is getting blank when product module is used #2944 * Fixed: YoastSEO post analysis broke & getting Uncaught TypeError: $ is not a function #2948 * Fixed: Yoast meta data are not renderring correct content for custom homepage #2928 * Fixed: Date format in Swift theme homepage/loop #2965 * Fixed: Published Date Disappear When selecting Horizontal Design in Related Post [swift-theme] #2957

Full changelog available in changelog.txt

Download this release

Release Info

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

Code changes from version 0.9.97.44.1 to 0.9.97.44.2

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.1
7
- Stable tag: 0.9.97.44.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -183,6 +183,18 @@ Device testing done through [BrowserStack](https://www.browserstack.com)
183
 
184
  == Changelog ==
185
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  = 0.9.97.44.1 (29th March 2019) =
187
  * Added: Advertisement AMP panel improved #2724
188
  * Fixed: Vuukle AMP integration code updated #2600
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.1
7
+ Stable tag: 0.9.97.44.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
183
 
184
  == Changelog ==
185
 
186
+ = 0.9.97.44.2 (1st April 2019) =
187
+ * Added: Element folder files override in the Design One, Design Two and Design Three for the Child theme #2770
188
+ * Added: High-resolution Images [Additional image guidelines] option added in structure data #2259
189
+ * Fixed: Hide by default option from bulk tools is not working when amp takeover option is enabled #2832
190
+ * Fixed: Space removed while checking in the ampforwp_onesignal_notifications_widget function #2569
191
+ * Fixed: Display on User Avatar option #2942
192
+ * Fixed: Edit page is getting blank when product module is used #2944
193
+ * Fixed: YoastSEO post analysis broke & getting Uncaught TypeError: $ is not a function #2948
194
+ * Fixed: Yoast meta data are not renderring correct content for custom homepage #2928
195
+ * Fixed: Date format in Swift theme homepage/loop #2965
196
+ * Fixed: Published Date Disappear When selecting Horizontal Design in Related Post [swift-theme] #2957
197
+
198
  = 0.9.97.44.1 (29th March 2019) =
199
  * Added: Advertisement AMP panel improved #2724
200
  * Fixed: Vuukle AMP integration code updated #2600
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: 0.9.97.44.1
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','0.9.97.44.1');
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
26
  $ampforwp_slug = '';
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: 0.9.97.44.2
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','0.9.97.44.2');
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
26
  $ampforwp_slug = '';
changelog.txt CHANGED
@@ -1,5 +1,17 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 0.9.97.44.1 (29th March 2019) =
4
  * Added: Advertisement AMP panel improved #2724
5
  * Fixed: Vuukle AMP integration code updated #2600
1
  == Changelog ==
2
 
3
+ = 0.9.97.44.2 (1st April 2019) =
4
+ * Added: Element folder files override in the Design One, Design Two and Design Three for the Child theme #2770
5
+ * Added: High-resolution Images [Additional image guidelines] option added in structure data #2259
6
+ * Fixed: Hide by default option from bulk tools is not working when amp takeover option is enabled #2832
7
+ * Fixed: Space removed while checking in the ampforwp_onesignal_notifications_widget function #2569
8
+ * Fixed: Display on User Avatar option #2942
9
+ * Fixed: Edit page is getting blank when product module is used #2944
10
+ * Fixed: YoastSEO post analysis broke & getting Uncaught TypeError: $ is not a function #2948
11
+ * Fixed: Yoast meta data are not renderring correct content for custom homepage #2928
12
+ * Fixed: Date format in Swift theme homepage/loop #2965
13
+ * Fixed: Published Date Disappear When selecting Horizontal Design in Related Post [swift-theme] #2957
14
+
15
  = 0.9.97.44.1 (29th March 2019) =
16
  * Added: Advertisement AMP panel improved #2724
17
  * Fixed: Vuukle AMP integration code updated #2600
components/logo/logo.php CHANGED
@@ -28,9 +28,9 @@ function ampforwp_framework_get_logo(){
28
  $alt = $logo_url = "";
29
  $alt = ampforwp_default_logo('alt');
30
  $logo_url = __( $redux_builder_amp['opt-media']['url'], 'accelerated-mobile-pages' );
31
- ?><a href="<?php echo esc_url( $ampforwp_home_url ); ?>" <?php if($set_rel_to_noamp){ echo esc_attr(' rel="nofollow"'); } ?>><amp-img src="<?php echo esc_url( $logo_url ); ?>" width="<?php echo esc_attr(ampforwp_default_logo('width')); ?>" height="<?php echo esc_attr(ampforwp_default_logo('height')); ?>" alt="<?php echo esc_attr($alt); ?>" class="amp-logo" layout="responsive"></amp-img></a><?php } else { if(is_single()){ ?>
32
  <h2> <?php } else{?><h1><?php }?>
33
- <a href="<?php echo esc_url( $ampforwp_home_url ); ?>" <?php if($set_rel_to_noamp){ echo esc_attr(' rel="nofollow"'); } ?> ><?php bloginfo('name'); ?></a><?php if(is_single()){?></h2><?php } else{?></h1><?php }
34
  } ?></div>
35
  <?php }
36
 
28
  $alt = $logo_url = "";
29
  $alt = ampforwp_default_logo('alt');
30
  $logo_url = __( $redux_builder_amp['opt-media']['url'], 'accelerated-mobile-pages' );
31
+ ?><a href="<?php echo esc_url( $ampforwp_home_url ); ?>" <?php if($set_rel_to_noamp){ echo ' rel="nofollow"'; } ?>><amp-img src="<?php echo esc_url( $logo_url ); ?>" width="<?php echo esc_attr(ampforwp_default_logo('width')); ?>" height="<?php echo esc_attr(ampforwp_default_logo('height')); ?>" alt="<?php echo esc_attr($alt); ?>" class="amp-logo" layout="responsive"></amp-img></a><?php } else { if(is_single()){ ?>
32
  <h2> <?php } else{?><h1><?php }?>
33
+ <a href="<?php echo esc_url( $ampforwp_home_url ); ?>" <?php if($set_rel_to_noamp){ echo ' rel="nofollow"'; } ?> ><?php bloginfo('name'); ?></a><?php if(is_single()){?></h2><?php } else{?></h1><?php }
34
  } ?></div>
35
  <?php }
36
 
includes/admin-script.js CHANGED
@@ -596,10 +596,10 @@ AmpForWpYoastAnalysis = function() {
596
  * @param data The data to modify
597
  */
598
  AmpForWpYoastAnalysis.prototype.myContentModification = function(data) {
599
- if($('#amp-page-builder-ready').length){
600
- var pbdata = $('#amp-page-builder-ready').html();
601
  var takeover = redux_data['ampforwp-amp-takeover'];
602
- var pb2 = $('input[name="ampforwp_page_builder_enable"]:checked').val();
603
  if ( takeover == 1 && 'yes' == pb2 ) {
604
  data = pbdata;
605
  }
596
  * @param data The data to modify
597
  */
598
  AmpForWpYoastAnalysis.prototype.myContentModification = function(data) {
599
+ if(jQuery('#amp-page-builder-ready').length){
600
+ var pbdata = jQuery('#amp-page-builder-ready').html();
601
  var takeover = redux_data['ampforwp-amp-takeover'];
602
+ var pb2 = jQuery('input[name="ampforwp_page_builder_enable"]:checked').val();
603
  if ( takeover == 1 && 'yes' == pb2 ) {
604
  data = pbdata;
605
  }
includes/options/admin-config.php CHANGED
@@ -1944,6 +1944,15 @@ if ( !is_plugin_active('ads-for-wp/ads-for-wp.php') ) {
1944
  'default' => 0,
1945
  'required' => array('ampforwp-seo-selection', '=' , 'yoast'),
1946
  ),
 
 
 
 
 
 
 
 
 
1947
  array(
1948
  'id' => 'ampforwp-seo-aioseo',
1949
  'type' => 'info',
@@ -2744,6 +2753,13 @@ function ampforwp_add_sd_fields($fields){
2744
  'tooltip-subtitle' => esc_html__('Upload the Thumbnail you want to show as Video Thumbnail.', 'accelerated-mobile-pages'),
2745
  'placeholder' => esc_html__('When there is no thumbnail set for the video','accelerated-mobile-pages'),
2746
  );
 
 
 
 
 
 
 
2747
  }// is_plugin_active('schema-and-structured-data-for-wp/structured-data-for-wp.php') Closed
2748
 
2749
  return $fields;
1944
  'default' => 0,
1945
  'required' => array('ampforwp-seo-selection', '=' , 'yoast'),
1946
  ),
1947
+ array(
1948
+ 'class' => 'child_opt',
1949
+ 'id' => 'ampforwp-yoast-seo-analysis',
1950
+ 'type' => 'switch',
1951
+ 'tooltip-subtitle' => esc_html__('Get the Yoast Analysis from AMP PageBuilder Content', 'accelerated-mobile-pages'),
1952
+ 'title' => esc_html__( 'Yoast Analysis for AMP PageBuilder', 'accelerated-mobile-pages' ),
1953
+ 'default' => 1,
1954
+ 'required' => array(array('ampforwp-seo-selection', '=' , 'yoast'),array('ampforwp-amp-takeover', '=' , '1')),
1955
+ ),
1956
  array(
1957
  'id' => 'ampforwp-seo-aioseo',
1958
  'type' => 'info',
2753
  'tooltip-subtitle' => esc_html__('Upload the Thumbnail you want to show as Video Thumbnail.', 'accelerated-mobile-pages'),
2754
  'placeholder' => esc_html__('When there is no thumbnail set for the video','accelerated-mobile-pages'),
2755
  );
2756
+ $fields[] = array(
2757
+ 'id' => 'ampforwp-sd-multiple-images',
2758
+ 'title' => esc_html__('High-resolution Images', 'accelerated-mobile-pages'),
2759
+ 'type' => 'switch',
2760
+ 'default' => 0,
2761
+ 'tooltip-subtitle' => esc_html__('For best results, provide multiple high-resolution images (minimum of 800,000 pixels when multiplying width and height) with the following aspect ratios: 16x9, 4x3, and 1x1 ', 'accelerated-mobile-pages'). '<a href="https://developers.google.com/search/docs/data-types/article#article_types" target="_blank">'.esc_html__('Read more','accelerated-mobile-pages').'</a>'
2762
+ );
2763
  }// is_plugin_active('schema-and-structured-data-for-wp/structured-data-for-wp.php') Closed
2764
 
2765
  return $fields;
includes/thirdparty-compatibility.php CHANGED
@@ -168,6 +168,39 @@ if(!function_exists('ampforwp_amp_nonamp_convert')){
168
  $file = $filePath . '/search.php';
169
  }
170
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  //For template pages
172
  switch ( true ) {
173
  case ampforwp_is_front_page():
168
  $file = $filePath . '/search.php';
169
  }
170
  }
171
+ // Template parts
172
+ if ( 4 != ampforwp_get_setting('amp-design-selector') ) {
173
+ if ( 'ampforwp-the-title' === $type ) {
174
+ $file = $filePath .'/elements/title.php' ;
175
+ }
176
+ if ( 'ampforwp-meta-info' === $type ) {
177
+ $file = $filePath .'/elements/meta-info.php' ;
178
+ }
179
+ if ( 'ampforwp-featured-image' === $type ) {
180
+ $file = $filePath .'/elements/featured-image.php' ;
181
+ }
182
+ if ( 'ampforwp-bread-crumbs' === $type ) {
183
+ $file = $filePath .'/elements/bread-crumbs.php' ;
184
+ }
185
+ if ( 'ampforwp-the-content' === $type ) {
186
+ $file = $filePath .'/elements/content.php' ;
187
+ }
188
+ if ( 'ampforwp-meta-taxonomy' === $type ) {
189
+ $file = $filePath .'/elements/meta-taxonomy.php' ;
190
+ }
191
+ if ( 'ampforwp-social-icons' === $type ) {
192
+ $file = $filePath .'/elements/social-icons.php' ;
193
+ }
194
+ if ( 'ampforwp-comments' === $type ) {
195
+ $file = $filePath .'/elements/comments.php' ;
196
+ }
197
+ if ( 'ampforwp-simple-comment-button' === $type ) {
198
+ $file = $filePath .'/elements/simple-comment-button.php' ;
199
+ }
200
+ if ( 'ampforwp-related-posts' === $type ) {
201
+ $file = $filePath .'/elements/related-posts.php' ;
202
+ }
203
+ }
204
  //For template pages
205
  switch ( true ) {
206
  case ampforwp_is_front_page():
pagebuilder/amp-page-builder.php CHANGED
@@ -131,8 +131,9 @@ function ampforwp_call_page_builder(){
131
  unset($backendRowSetting['front_common_css']);
132
  wp_nonce_field( basename( __FILE__) , 'amp_content_editor_nonce' );
133
 
134
- if(class_exists('WPSEO_Frontend')) { ?>
135
- <div class="hide" id="amp-page-builder-ready"><?php echo stripcslashes( amppb_post_content('') ); ?></div><?php } ?>
 
136
  <div id="ampForWpPageBuilder_container">
137
  <div id="start_amp_pb_post" class="start_amp_pb" data-postId="<?php echo esc_attr(get_the_ID()) ?>" v-if="startPagebuilder==0" @click="amppb_startFunction($event)"><?php echo esc_html__('Start the AMP Page Builder','accelerated-mobile-pages'); ?></div>
138
  <div class="enable_ampforwp_page_builder" v-if="startPagebuilder==1">
131
  unset($backendRowSetting['front_common_css']);
132
  wp_nonce_field( basename( __FILE__) , 'amp_content_editor_nonce' );
133
 
134
+ if(class_exists('WPSEO_Frontend') && true == ampforwp_get_setting('ampforwp-yoast-seo-analysis') && true == ampforwp_get_setting('ampforwp-amp-takeover') ) { ?>
135
+ <div class="hide" id="amp-page-builder-ready"><?php echo stripcslashes( amppb_post_content('') ); ?></div>
136
+ <?php } ?>
137
  <div id="ampForWpPageBuilder_container">
138
  <div id="start_amp_pb_post" class="start_amp_pb" data-postId="<?php echo esc_attr(get_the_ID()) ?>" v-if="startPagebuilder==0" @click="amppb_startFunction($event)"><?php echo esc_html__('Start the AMP Page Builder','accelerated-mobile-pages'); ?></div>
139
  <div class="enable_ampforwp_page_builder" v-if="startPagebuilder==1">
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.1
7
- Stable tag: 0.9.97.44.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -184,9 +184,16 @@ You can contact us from [here](https://ampforwp.com/contact/)
184
 
185
  == Changelog ==
186
 
187
- = 0.9.97.44.1 (29th March 2019) =
188
- * Added: Advertisement AMP panel improved #2724
189
- * Fixed: Vuukle AMP integration code updated #2600
190
- * Fixed: Fatal Error with old Plugins manager v1.0 #2976
 
 
 
 
 
 
 
191
 
192
  Full changelog available in changelog.txt
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.1
7
+ Stable tag: 0.9.97.44.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
184
 
185
  == Changelog ==
186
 
187
+ = 0.9.97.44.2 (1st April 2019) =
188
+ * Added: Element folder files override in the Design One, Design Two and Design Three for the Child theme #2770
189
+ * Added: High-resolution Images [Additional image guidelines] option added in structure data #2259
190
+ * Fixed: Hide by default option from bulk tools is not working when amp takeover option is enabled #2832
191
+ * Fixed: Space removed while checking in the ampforwp_onesignal_notifications_widget function #2569
192
+ * Fixed: Display on User Avatar option #2942
193
+ * Fixed: Edit page is getting blank when product module is used #2944
194
+ * Fixed: YoastSEO post analysis broke & getting Uncaught TypeError: $ is not a function #2948
195
+ * Fixed: Yoast meta data are not renderring correct content for custom homepage #2928
196
+ * Fixed: Date format in Swift theme homepage/loop #2965
197
+ * Fixed: Published Date Disappear When selecting Horizontal Design in Related Post [swift-theme] #2957
198
 
199
  Full changelog available in changelog.txt
templates/design-manager/swift/single.php CHANGED
@@ -65,15 +65,14 @@
65
  <div class="tags">
66
  <?php amp_tags_list();?>
67
  </div>
68
- <?php } ?>
69
- <?php if($redux_builder_amp['rp_design_type'] == '1'){
70
  if( true == $redux_builder_amp['swift-date'] ) { ?>
71
  <div class="post-date">
72
  <?php amp_date(); ?><?php edit_post_link(); ?>
73
  </div>
74
 
75
  <?php }
76
- if ( isset($redux_builder_amp['ampforwp-single-related-posts-switch']) && $redux_builder_amp['ampforwp-single-related-posts-switch'] ) {
77
  $my_query = ampforwp_related_post_loop_query();
78
  if( $my_query->have_posts() ) { $r_count = 1;?>
79
  <div class="srp">
@@ -105,13 +104,13 @@
105
  } ?>
106
  </ul>
107
  </div>
108
- <?php wp_reset_postdata(); } }?>
109
  </div>
110
  <?php } ?>
111
  </div>
112
  </div>
113
  </div>
114
- <?php }
115
  do_action("ampforwp_single_design_type_handle");
116
  ?>
117
  <?php if($redux_builder_amp['rp_design_type'] == '2' || $redux_builder_amp['rp_design_type'] == '3'){
65
  <div class="tags">
66
  <?php amp_tags_list();?>
67
  </div>
68
+ <?php }
 
69
  if( true == $redux_builder_amp['swift-date'] ) { ?>
70
  <div class="post-date">
71
  <?php amp_date(); ?><?php edit_post_link(); ?>
72
  </div>
73
 
74
  <?php }
75
+ if ( ampforwp_get_setting('rp_design_type') == '1' && true == ampforwp_get_setting('ampforwp-single-related-posts-switch')) {
76
  $my_query = ampforwp_related_post_loop_query();
77
  if( $my_query->have_posts() ) { $r_count = 1;?>
78
  <div class="srp">
104
  } ?>
105
  </ul>
106
  </div>
107
+ <?php wp_reset_postdata(); } ?>
108
  </div>
109
  <?php } ?>
110
  </div>
111
  </div>
112
  </div>
113
+ <?php }
114
  do_action("ampforwp_single_design_type_handle");
115
  ?>
116
  <?php if($redux_builder_amp['rp_design_type'] == '2' || $redux_builder_amp['rp_design_type'] == '3'){
templates/features.php CHANGED
@@ -2292,28 +2292,24 @@ function ampforwp_sticky_social_icons(){
2292
  <?php }
2293
  }
2294
 
2295
- // 25. Yoast meta Support
2296
- function ampforwp_custom_yoast_meta(){
2297
- global $redux_builder_amp;
2298
- if ($redux_builder_amp['ampforwp-seo-yoast-meta']) {
2299
- if(! class_exists('YoastSEO_AMP') ) {
2300
- if ( class_exists('WPSEO_Options')) {
2301
- $options = WPSEO_Options::get_option( 'wpseo_social' );
2302
- if ( $options['twitter'] === true ) {
2303
- WPSEO_Twitter::get_instance();
2304
- }
2305
- if ( $options['opengraph'] === true ) {
2306
- $GLOBALS['wpseo_og'] = new WPSEO_OpenGraph;
2307
- }
2308
- do_action( 'wpseo_opengraph' );
2309
- }
2310
- }//execute only if Glue is deactive
2311
- if(isset($redux_builder_amp['ampforwp-seo-custom-additional-meta']) && $redux_builder_amp['ampforwp-seo-custom-additional-meta']){
2312
- echo strip_tags($redux_builder_amp['ampforwp-seo-custom-additional-meta'], '<link><meta>' );
2313
- }
2314
- } else {
2315
- if(isset($redux_builder_amp['ampforwp-seo-custom-additional-meta']) && $redux_builder_amp['ampforwp-seo-custom-additional-meta']){
2316
- echo strip_tags($redux_builder_amp['ampforwp-seo-custom-additional-meta'], '<link><meta>' );
2317
  }
2318
  }
2319
  }
@@ -2342,54 +2338,125 @@ function ampforwp_custom_yoast_meta_homepage(){
2342
  }
2343
  }
2344
 
2345
- function ampforwp_add_proper_post_meta(){
2346
- $check_custom_front_page = get_option('show_on_front');
2347
- if ( $check_custom_front_page == 'page' ) {
2348
- add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta_homepage' );
2349
- if(is_home()){
2350
- add_filter('wpseo_opengraph_title', 'ampforwp_custom_twitter_title_homepage');
2351
- add_filter('wpseo_twitter_title', 'ampforwp_custom_twitter_title_homepage');
2352
-
2353
-
2354
- add_filter('wpseo_opengraph_desc', 'ampforwp_custom_twitter_description_homepage');
2355
- add_filter('wpseo_twitter_description', 'ampforwp_custom_twitter_description_homepage');
2356
-
2357
- add_filter('wpseo_opengraph_url', 'ampforwp_custom_og_url_homepage');
2358
-
2359
-
2360
- // This is causing the 2nd debug issue reported in #740
2361
- add_filter('wpseo_opengraph_image', 'ampforwp_custom_og_image_homepage');
2362
  }
2363
- } else {
2364
- add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta' );
 
 
 
 
2365
  }
 
2366
  }
2367
- add_action('pre_amp_render_post','ampforwp_add_proper_post_meta');
2368
 
2369
-
2370
- function ampforwp_custom_twitter_title_homepage() {
2371
- //Added the opengraph for frontpage in AMP #2454
2372
- if(ampforwp_is_front_page()){
2373
- $get_title = ampforwp_get_setting('amp-frontpage-select-option-pages');
2374
- return get_the_title($get_title);
2375
- }
2376
- return esc_attr( get_bloginfo( 'name' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2377
  }
2378
- function ampforwp_custom_twitter_description_homepage() {
2379
- if(ampforwp_is_front_page()){
2380
- $get_excerpt = ampforwp_get_setting('amp-frontpage-select-option-pages');
2381
- return wp_trim_words(get_post_field('post_content', $get_excerpt), 26);
2382
-
 
 
 
 
 
2383
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2384
  return esc_attr( get_bloginfo( 'description' ) );
2385
  }
2386
  function ampforwp_custom_og_url_homepage() {
2387
  return esc_url( get_bloginfo( 'url' ) );
2388
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2389
  function ampforwp_custom_og_image_homepage() {
2390
  if ( class_exists('WPSEO_Options') ) {
2391
- $options = WPSEO_Options::get_option( 'wpseo_social' );
2392
- return $options['og_default_image'] ;
 
 
 
 
 
 
 
 
 
 
 
 
 
2393
  }
2394
  }
2395
 
@@ -6088,9 +6155,9 @@ if( ! function_exists('ampforwp_get_comments_gravatar') ){
6088
  // Gravatar Checker
6089
  if ( ! function_exists('ampforwp_gravatar_checker') ) {
6090
  function ampforwp_gravatar_checker( $email ) {
 
6091
  // Craft a potential url and test its headers
6092
  $hash = md5(strtolower(trim($email)));
6093
- //$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
6094
  $gravatar_server = 0;
6095
  if ( $hash ) {
6096
  $gravatar_server = hexdec( $hash[0] ) % 3;
@@ -6102,15 +6169,16 @@ if ( ! function_exists('ampforwp_gravatar_checker') ) {
6102
  } else {
6103
  $uri = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $hash );
6104
  }
6105
- $headers = @get_headers($uri);
6106
- // If its 404
6107
- if (!preg_match("|200|", $headers[0])) {
6108
- $has_valid_avatar = FALSE;
6109
- }
6110
- // Else if it is 200
6111
- else {
6112
- $has_valid_avatar = TRUE;
6113
- }
 
6114
  return $has_valid_avatar;
6115
  }
6116
  }
@@ -6291,7 +6359,7 @@ if( ! function_exists( 'ampforwp_onesignal_notifications_widget_position' ) ){
6291
  }
6292
  }
6293
  }
6294
- if( ! function_exists(' ampforwp_onesignal_notifications_widget') ){
6295
  function ampforwp_onesignal_notifications_widget(){
6296
  global $redux_builder_amp;
6297
  if(isset($redux_builder_amp['ampforwp-web-push-onesignal']) && $redux_builder_amp['ampforwp-web-push-onesignal'] && !checkAMPforPageBuilderStatus(get_the_ID()) ){ ?>
@@ -8015,4 +8083,55 @@ function ampforwp_embedly_sanitizer( $sanitizer_classes ) {
8015
  $sanitizer_classes[ 'AMPforWP_Embedly_Sanitizer' ] = array();
8016
  }
8017
  return $sanitizer_classes;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8018
  }
2292
  <?php }
2293
  }
2294
 
2295
+ // 25. Yoast meta Support
2296
+ add_action('pre_amp_render_post','ampforwp_add_proper_post_meta');
2297
+ function ampforwp_add_proper_post_meta(){
2298
+ if ( class_exists('WPSEO_Options') ) {
2299
+ add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta_homepage' );
2300
+ // Homepage/Frontpage/Blog
2301
+ if(is_home()){
2302
+ // Title
2303
+ add_filter('wpseo_opengraph_title', 'ampforwp_yoast_opengraph_title');
2304
+ add_filter('wpseo_twitter_title', 'ampforwp_yoast_twitter_title');
2305
+ // Description
2306
+ add_filter('wpseo_opengraph_desc', 'ampforwp_yoast_opengraph_desc');
2307
+ add_filter('wpseo_twitter_description', 'ampforwp_yoast_twitter_desc');
2308
+ // og url
2309
+ add_filter('wpseo_opengraph_url', 'ampforwp_custom_og_url_homepage');
2310
+ // This is causing the 2nd debug issue reported in #740
2311
+ add_action('wpseo_twitter', 'ampforwp_custom_twitter_image_homepage');
2312
+ add_action('wpseo_add_opengraph_images', 'ampforwp_custom_og_image_homepage');
 
 
 
 
2313
  }
2314
  }
2315
  }
2338
  }
2339
  }
2340
 
2341
+ // Title
2342
+ function ampforwp_yoast_opengraph_title($title){
2343
+ $new_title = ampforwp_yoast_social_title('og');
2344
+ if(!empty($new_title)){
2345
+ $title = $new_title;
 
 
 
 
 
 
 
 
 
 
 
 
2346
  }
2347
+ return $title;
2348
+ }
2349
+ function ampforwp_yoast_twitter_title($title){
2350
+ $new_title = ampforwp_yoast_social_title('twitter');
2351
+ if(!empty($new_title)){
2352
+ $title = $new_title;
2353
  }
2354
+ return $title;
2355
  }
 
2356
 
2357
+ function ampforwp_yoast_social_title($type) {
2358
+ //Added the opengraph for frontpage in AMP #2454
2359
+ if(ampforwp_is_front_page() || ampforwp_is_blog() ){
2360
+ $title = $page_id = '';
2361
+ if ( ampforwp_is_front_page() ) {
2362
+ $page_id = ampforwp_get_frontpage_id();
2363
+ }
2364
+ if ( ampforwp_is_blog() ){
2365
+ $page_id = ampforwp_get_blog_details('id');
2366
+ }
2367
+ if( 'og' == $type ) {
2368
+ $title = WPSEO_Meta::get_value( 'opengraph-title', $page_id );
2369
+ }
2370
+ if( 'twitter' == $type ) {
2371
+ $title = WPSEO_Meta::get_value('twitter-title',$page_id );
2372
+ }
2373
+ if (empty($title) ){
2374
+ $title = get_the_title($page_id);
2375
+ }
2376
+ return esc_attr($title);
2377
+ }
2378
+ return esc_attr( get_bloginfo( 'name' ) );
2379
  }
2380
+ // Description
2381
+ function ampforwp_yoast_opengraph_desc($desc){
2382
+ if ( ampforwp_yoast_social_desc('og') ){
2383
+ $desc = ampforwp_yoast_social_desc('og');
2384
+ }
2385
+ return $desc;
2386
+ }
2387
+ function ampforwp_yoast_twitter_desc($desc){
2388
+ if ( ampforwp_yoast_social_desc('twitter') ){
2389
+ $desc = ampforwp_yoast_social_desc('twitter');
2390
  }
2391
+ return $desc;
2392
+ }
2393
+ function ampforwp_yoast_social_desc($type) {
2394
+ if(ampforwp_is_front_page() || ampforwp_is_blog()){
2395
+ $desc = $page_id = '';
2396
+ if ( ampforwp_is_front_page() ) {
2397
+ $page_id = ampforwp_get_frontpage_id();
2398
+ }
2399
+ if ( ampforwp_is_blog() ){
2400
+ $page_id = ampforwp_get_blog_details('id');
2401
+ }
2402
+ if ( 'og' == $type ) {
2403
+ $desc = trim( WPSEO_Meta::get_value( 'opengraph-description', $page_id ) );
2404
+ }
2405
+ if ( 'twitter' == $type ) {
2406
+ $desc = trim( WPSEO_Meta::get_value( 'twitter-description', $page_id ) );
2407
+ }
2408
+ if (empty($desc)){
2409
+ $desc = wp_trim_words(get_post_field('post_content', $page_id), 26);
2410
+ }
2411
+ return esc_attr($desc);
2412
+ }
2413
  return esc_attr( get_bloginfo( 'description' ) );
2414
  }
2415
  function ampforwp_custom_og_url_homepage() {
2416
  return esc_url( get_bloginfo( 'url' ) );
2417
  }
2418
+ function ampforwp_custom_twitter_image_homepage($image){
2419
+ $twitter = '';
2420
+ if ( ampforwp_get_the_ID() ) {
2421
+ $post_id = ampforwp_get_the_ID();
2422
+ $post = get_post($post_id);
2423
+ // twitter:image
2424
+ $img = WPSEO_Meta::get_value('twitter-image', $post_id );
2425
+ if ( $img !== '' ) {
2426
+ $metatag_key = apply_filters( 'wpseo_twitter_metatag_key', 'name' );
2427
+ $name = 'image';
2428
+ $value = esc_url($img);
2429
+ // Output meta.
2430
+ echo '<meta ', esc_attr( $metatag_key ), '="twitter:', esc_attr( $name ), '" content="', $value, '" />', "\n";
2431
+ }
2432
+ // twitter:creator
2433
+ $twitter = ltrim( trim( get_the_author_meta( 'twitter', $post->post_author ) ), '@' );
2434
+ $twitter = apply_filters( 'wpseo_twitter_creator_account', $twitter );
2435
+ }
2436
+ if ( is_string( $twitter ) && $twitter !== '' ) {
2437
+ echo '<meta ', esc_attr( 'name' ), '="twitter:', esc_attr( 'creator' ), '" content="','@' . esc_attr($twitter), '" />', "\n";
2438
+ }
2439
+ elseif ( WPSEO_Options::get( 'twitter_site', '' ) !== '' && is_string( WPSEO_Options::get( 'twitter_site' ) ) ) {
2440
+ echo '<meta ', esc_attr( 'name' ), '="twitter:', esc_attr( 'creator'), '" content="', '@' . esc_attr(WPSEO_Options::get( 'twitter_site' )), '" />', "\n";
2441
+ }
2442
+ }
2443
  function ampforwp_custom_og_image_homepage() {
2444
  if ( class_exists('WPSEO_Options') ) {
2445
+ global $wpseo_og;
2446
+ $post_id = ampforwp_get_frontpage_id();
2447
+ $image_url = WPSEO_Meta::get_value( 'opengraph-image', $post_id );
2448
+ $image_id = WPSEO_Meta::get_value( 'opengraph-image-id', $post_id );
2449
+ $image = wp_get_attachment_image_src($image_id,'full');
2450
+ $image_tags = array(
2451
+ 'width' => esc_attr($image[1]),
2452
+ 'height' => esc_attr($image[2]),
2453
+ );
2454
+ $wpseo_og->og_tag( 'og:image', esc_url( $image_url ) );
2455
+ foreach ( $image_tags as $key => $value ) {
2456
+ if ( ! empty( $value ) ) {
2457
+ $wpseo_og->og_tag( 'og:image:' . $key, $value );
2458
+ }
2459
+ }
2460
  }
2461
  }
2462
 
6155
  // Gravatar Checker
6156
  if ( ! function_exists('ampforwp_gravatar_checker') ) {
6157
  function ampforwp_gravatar_checker( $email ) {
6158
+ $uri = "";
6159
  // Craft a potential url and test its headers
6160
  $hash = md5(strtolower(trim($email)));
 
6161
  $gravatar_server = 0;
6162
  if ( $hash ) {
6163
  $gravatar_server = hexdec( $hash[0] ) % 3;
6169
  } else {
6170
  $uri = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $hash );
6171
  }
6172
+ if($uri){
6173
+ $response = wp_remote_get(esc_url_raw($uri));
6174
+ $response_code = wp_remote_retrieve_response_code($response);
6175
+ }
6176
+ //If its 404
6177
+ if ($response_code!=200) {
6178
+ $has_valid_avatar = FALSE;
6179
+ }else {
6180
+ $has_valid_avatar = TRUE;
6181
+ }
6182
  return $has_valid_avatar;
6183
  }
6184
  }
6359
  }
6360
  }
6361
  }
6362
+ if( ! function_exists('ampforwp_onesignal_notifications_widget') ){
6363
  function ampforwp_onesignal_notifications_widget(){
6364
  global $redux_builder_amp;
6365
  if(isset($redux_builder_amp['ampforwp-web-push-onesignal']) && $redux_builder_amp['ampforwp-web-push-onesignal'] && !checkAMPforPageBuilderStatus(get_the_ID()) ){ ?>
8083
  $sanitizer_classes[ 'AMPforWP_Embedly_Sanitizer' ] = array();
8084
  }
8085
  return $sanitizer_classes;
8086
+ }
8087
+ add_filter('ampforwp_is_amp_endpoint_takeover', "ampforwp_bulktool_takeover");
8088
+ if (! function_exists('ampforwp_bulktool_takeover') ) {
8089
+ function ampforwp_bulktool_takeover($data){
8090
+ $bulk_option = ampforwp_get_setting('amp-pages-meta-default');
8091
+ if(is_page() && $bulk_option == "hide" && ( true == ampforwp_get_setting('ampforwp-amp-takeover') || true == ampforwp_get_setting('ampforwp-amp-convert-to-wp'))){
8092
+ remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
8093
+ return false;
8094
+ }
8095
+ return $data;
8096
+ }
8097
+ }
8098
+
8099
+ // Multiple Images #2259
8100
+ add_filter( 'amp_post_template_metadata', 'ampforwp_sd_multiple_images', 20, 1 );
8101
+ if ( ! function_exists('ampforwp_sd_multiple_images') ) {
8102
+ function ampforwp_sd_multiple_images($metadata){
8103
+ if ( ampforwp_get_setting('ampforwp-sd-multiple-images') ) {
8104
+ if ( isset($metadata['image']['width']) && 1200 <= $metadata['image']['width'] ){
8105
+ // 16x9
8106
+ $image1_width = 1280;
8107
+ $image1_height = 720;
8108
+ $image1 = ampforwp_aq_resize( $metadata['image']['url'], $image1_width, $image1_height, true, false, true );
8109
+ $image1_url = $image1[0];
8110
+ // 4x3
8111
+ $image2_width = 640;
8112
+ $image2_height = 480;
8113
+ $image2 = ampforwp_aq_resize( $metadata['image']['url'], $image2_width, $image2_height, true, false, true );
8114
+ $image2_url = $image2[0];
8115
+ // 1x1
8116
+ $image3_width = 300;
8117
+ $image3_height = 300;
8118
+ $image3 = ampforwp_aq_resize( $metadata['image']['url'], $image3_width, $image3_height, true, false, true );
8119
+ $image3_url = $image3[0];
8120
+ $metadata['image'] = array($image3_url, $image2_url, $image1_url);
8121
+ }
8122
+ }
8123
+ return $metadata;
8124
+ }
8125
+ }
8126
+
8127
+ // Get The ID for AMP #2867
8128
+ function ampforwp_get_the_ID($post_id=''){
8129
+ $post_id = get_the_ID();
8130
+ if(ampforwp_is_front_page()){
8131
+ $post_id = ampforwp_get_frontpage_id();
8132
+ }
8133
+ if(ampforwp_is_blog()){
8134
+ $post_id = ampforwp_get_blog_details('id');
8135
+ }
8136
+ return $post_id;
8137
  }