AMP for WP – Accelerated Mobile Pages - Version 0.9.93

Version Description

Download this release

Release Info

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

Code changes from version 0.9.92 to 0.9.93

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: 4.9.6
7
- Stable tag: 0.9.92
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 4.9.6
7
+ Stable tag: 0.9.93
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
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.92
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
@@ -19,7 +19,7 @@ define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
19
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
20
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
21
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
22
- define('AMPFORWP_VERSION','0.9.92');
23
 
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
@@ -458,14 +458,16 @@ function ampforwp_load_plugin_last() {
458
  array_push($active_plugins, $this_plugin);
459
  update_option('active_plugins', $active_plugins);
460
  }
461
- add_action("activated_plugin", "ampforwp_load_plugin_last");
 
 
462
 
463
  /*
464
  * Including core AMP plugin files and removing any other things if necessary
465
  */
466
  function ampforwp_bundle_core_amp_files(){
467
  // Bundling Default plugin
468
- if($GLOBALS['pagenow'] === 'plugins.php'){
469
  return false;
470
  }
471
  require_once AMPFORWP_PLUGIN_DIR .'/includes/vendor/vendor-compatibility.php';
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.93
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
19
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
20
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
21
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
22
+ define('AMPFORWP_VERSION','0.9.93');
23
 
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
458
  array_push($active_plugins, $this_plugin);
459
  update_option('active_plugins', $active_plugins);
460
  }
461
+ if( file_exists(realpath(plugin_dir_path(FILE).'../amp/amp.php')) ){
462
+ add_action("activated_plugin", "ampforwp_load_plugin_last");
463
+ }
464
 
465
  /*
466
  * Including core AMP plugin files and removing any other things if necessary
467
  */
468
  function ampforwp_bundle_core_amp_files(){
469
  // Bundling Default plugin
470
+ if($GLOBALS['pagenow'] === 'plugins.php' && file_exists( realpath(plugin_dir_path(FILE).'../amp/amp.php') ) ){
471
  return false;
472
  }
473
  require_once AMPFORWP_PLUGIN_DIR .'/includes/vendor/vendor-compatibility.php';
includes/vendor/vendor-compatibility.php CHANGED
@@ -123,20 +123,26 @@ function content_sanitizers_remove_blacklist($sanitizer_classes){
123
  unset($sanitizer_classes['AMP_Blacklist_Sanitizer']);
124
  $sanitizer_classes['AMP_Tag_And_Attribute_Sanitizer']= array();
125
  }
126
- if(isset($sanitizer_classes['AMP_Base_Sanitizer'])) {
127
- unset($sanitizer_classes['AMP_Base_Sanitizer']);
128
- }
129
  // New image sanitizer For Lightbox and FooGallery support
130
  if( isset( $sanitizer_classes['AMP_Img_Sanitizer']) ) {
131
  require_once( AMPFORWP_PLUGIN_DIR. 'classes/class-ampforwp-img-sanitizer.php' );
132
- unset($sanitizer_classes['AMP_Img_Sanitizer']);
133
- $sanitizer_classes['AMPforWP_Img_Sanitizer']= array();
 
 
 
 
134
  }
135
  // New Iframe sanitizer to allow popups
136
  if(isset( $sanitizer_classes['AMP_Iframe_Sanitizer'] ) ) {
137
  require_once( AMPFORWP_PLUGIN_DIR. 'classes/class-ampforwp-iframe-sanitizer.php' );
138
- unset($sanitizer_classes['AMP_Iframe_Sanitizer']);
139
- $sanitizer_classes['AMPforWP_Iframe_Sanitizer']= array();
 
 
 
 
140
  }
141
  return $sanitizer_classes;
142
  }
@@ -364,3 +370,7 @@ function ampforwp_is_amp_inURL($url){
364
  return true;
365
  }
366
 
 
 
 
 
123
  unset($sanitizer_classes['AMP_Blacklist_Sanitizer']);
124
  $sanitizer_classes['AMP_Tag_And_Attribute_Sanitizer']= array();
125
  }
126
+
 
 
127
  // New image sanitizer For Lightbox and FooGallery support
128
  if( isset( $sanitizer_classes['AMP_Img_Sanitizer']) ) {
129
  require_once( AMPFORWP_PLUGIN_DIR. 'classes/class-ampforwp-img-sanitizer.php' );
130
+ $result = array();
131
+ array_walk($sanitizer_classes, function (&$value,$key) use (&$result) {
132
+ if($key=="AMP_Img_Sanitizer") $key="AMPforWP_Img_Sanitizer";
133
+ $result[ $key ] = $value;
134
+ });
135
+ $sanitizer_classes = $result;
136
  }
137
  // New Iframe sanitizer to allow popups
138
  if(isset( $sanitizer_classes['AMP_Iframe_Sanitizer'] ) ) {
139
  require_once( AMPFORWP_PLUGIN_DIR. 'classes/class-ampforwp-iframe-sanitizer.php' );
140
+ $result = array();
141
+ array_walk($sanitizer_classes, function (&$value,$key) use (&$result) {
142
+ if($key=="AMP_Iframe_Sanitizer") $key="AMPforWP_Iframe_Sanitizer";
143
+ $result[ $key ] = $value;
144
+ });
145
+ $sanitizer_classes = $result;
146
  }
147
  return $sanitizer_classes;
148
  }
370
  return true;
371
  }
372
 
373
+ add_action("pre_amp_render_post", "ampforwp_remove_unwanted_wp_print_scripts_hooks");
374
+ function ampforwp_remove_unwanted_wp_print_scripts_hooks(){
375
+ remove_all_actions( "wp_print_scripts" );
376
+ }
pagebuilder/modules/contents-module.php CHANGED
@@ -204,7 +204,11 @@ require_once ABSPATH . WPINC . '/category.php';
204
  default:
205
  break;
206
  }
207
- list($width, $height) = apply_filters("ampforwp_pb_content_mod_set_height_width", $width, $height, $fieldValues);
 
 
 
 
208
  try{
209
  $thumb_url = ampforwp_aq_resize( $image, $width, $height, true, false ); //resize & crop the image
210
  if($thumb_url!=false){
204
  default:
205
  break;
206
  }
207
+ list($new_width, $new_height) = apply_filters("ampforwp_pb_content_mod_set_height_width", $width, $height, $fieldValues);
208
+ if ( $new_width && $new_height ) {
209
+ $width = $new_width;
210
+ $height = $new_height;
211
+ }
212
  try{
213
  $thumb_url = ampforwp_aq_resize( $image, $width, $height, true, false ); //resize & crop the image
214
  if($thumb_url!=false){
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: 4.9.6
7
- Stable tag: 0.9.92
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 4.9.6
7
+ Stable tag: 0.9.93
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
templates/features.php CHANGED
@@ -3110,28 +3110,22 @@ function ampforwp_add_sidebar_data( $data ) {
3110
  // 44. auto adding /amp for the menu
3111
  add_action('amp_init','ampforwp_auto_add_amp_menu_link_insert');
3112
  function ampforwp_auto_add_amp_menu_link_insert() {
3113
- add_action( 'wp', 'ampforwp_auto_add_amp_in_link_check' );
3114
  }
3115
 
3116
- function ampforwp_auto_add_amp_in_link_check() {
3117
  global $redux_builder_amp;
3118
- $ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
3119
 
 
3120
  if ( $ampforwp_is_amp_endpoint && $redux_builder_amp['ampforwp-auto-amp-menu-link'] == 1 ) {
3121
- add_filter( 'nav_menu_link_attributes', 'ampforwp_auto_add_amp_in_menu_link', 10, 3 );
3122
- }
3123
- }
3124
-
3125
- function ampforwp_auto_add_amp_in_menu_link( $atts, $item, $args ) {
3126
- global $redux_builder_amp;
3127
-
3128
- if(isset($redux_builder_amp['amp-core-end-point']) && $redux_builder_amp['amp-core-end-point'] == 1){
3129
- $atts['href'] = user_trailingslashit(trailingslashit( $atts['href'] ) );
3130
- $atts['href'] = add_query_arg(AMPFORWP_AMP_QUERY_VAR,'1', $atts['href']);
3131
  }
3132
- else{
3133
- $atts['href'] = user_trailingslashit(trailingslashit( $atts['href'] ) . AMPFORWP_AMP_QUERY_VAR);
3134
- }
3135
 
3136
  return $atts;
3137
  }
@@ -4322,111 +4316,107 @@ function ampforwp_add_blacklist_sanitizer($data){
4322
 
4323
  //Meta description #1013
4324
  function ampforwp_generate_meta_desc(){
4325
- global $post;
4326
- global $redux_builder_amp;
4327
- $front = '';
4328
- $desc = '';
4329
- $post_id = '';
4330
- $genesis_description = '';
4331
- if ( $redux_builder_amp['ampforwp-seo-yoast-description'] && class_exists('WPSEO_Frontend') ) {
4332
- // general Description of everywhere
4333
- $front = WPSEO_Frontend::get_instance();
4334
- $desc = addslashes( strip_tags( $front->metadesc( false ) ) );
4335
-
4336
- // Static front page
4337
- // Code for Custom Frontpage Yoast SEO Description
4338
- //WPML Static Front Page Support for title and description with Yoast #1143
4339
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
4340
- if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && is_plugin_active('wordpress-seo/wp-seo.php') ) {
4341
-
4342
- $post_id = get_option( 'page_on_front' );
4343
- }
4344
- else {
4345
- $post_id = ampforwp_get_frontpage_id();
4346
- }
4347
-
4348
- if ( class_exists('WPSEO_Meta') ) {
4349
- if ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) {
4350
- $desc = addslashes( strip_tags( WPSEO_Meta::get_value('metadesc', $post_id ) ) );
4351
- }
4352
- }
4353
- // for search
4354
- if ( is_search() ) {
4355
- $desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
4356
- }
4357
- }
4358
-
4359
- else {
4360
- if ( is_home() ) {
4361
- // normal home page
4362
  $desc = addslashes( strip_tags( get_bloginfo( 'description' ) ) );
4363
  }
4364
-
4365
  if ( is_archive() ) {
4366
  $desc = addslashes( strip_tags( get_the_archive_description() ) );
4367
  }
4368
-
4369
  if ( is_single() || is_page() ) {
4370
- if ( has_excerpt() ) {
4371
- $desc = get_the_excerpt();
4372
- } else {
4373
- global $post;
4374
- $id = $post->ID;
4375
- $desc = $post->post_content;
4376
- }
4377
- $desc = preg_replace('/\[(.*?)\]/',' ', $desc);
4378
- $desc = addslashes( wp_trim_words( strip_tags( $desc ) , '15' ) );
4379
  }
4380
-
4381
  if ( is_search() ) {
4382
  $desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
4383
  }
4384
-
4385
  if ( ampforwp_is_front_page() ) {
4386
  $post_id = ampforwp_get_frontpage_id();
4387
  $desc = addslashes( wp_trim_words( strip_tags( get_post_field('post_content', $post_id) ) , '15' ) );
4388
  }
4389
- }
4390
 
4391
- //Genesis #1013
4392
- if ( function_exists('genesis_meta') ) {
4393
- if ( is_home() && is_front_page() && ! $redux_builder_amp['amp-frontpage-select-option'] ) {
4394
- $genesis_description = genesis_get_seo_option( 'home_description' ) ? genesis_get_seo_option( 'home_description' ) : get_bloginfo( 'description' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4395
  }
4396
- elseif ( is_home() && get_option( 'page_for_posts' ) && get_queried_object_id() ) {
4397
- $post_id = get_option( 'page_for_posts' );
4398
- if ( null !== $post_id || is_singular() ) {
4399
- if ( genesis_get_custom_field( '_genesis_description', $post_id ) ) {
4400
- $genesis_description = genesis_get_custom_field( '_genesis_description', $post_id );
4401
- if ( $genesis_description ) {
4402
- $desc = $genesis_description;
 
 
 
 
 
 
 
 
4403
  }
4404
  }
4405
  }
4406
- }
4407
- elseif ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] && get_option( 'page_on_front' ) ) {
4408
- $post_id = get_option('page_on_front');
4409
- if ( null !== $post_id || is_singular() ) {
4410
- if ( genesis_get_custom_field( '_genesis_description', $post_id ) ) {
4411
- $genesis_description = genesis_get_custom_field( '_genesis_description', $post_id );
4412
  }
4413
  }
 
 
4414
  }
4415
- else {
4416
- $genesis_description = genesis_get_seo_meta_description();
 
 
4417
  }
4418
- if ( $genesis_description ) {
4419
- $desc = $genesis_description;
4420
- }
4421
- }
4422
- // All in One SEO
4423
- if ( class_exists('All_in_One_SEO_Pack') ) {
4424
- $aisop_class = new All_in_One_SEO_Pack();
4425
- $desc = $aisop_class->get_main_description();
4426
  }
4427
- // strip_shortcodes strategy not working here so had to do this way
4428
- // strips shortcodes
4429
- $desc = preg_replace('/\[(.*?)\]/','', $desc);
4430
  return $desc;
4431
  }
4432
 
3110
  // 44. auto adding /amp for the menu
3111
  add_action('amp_init','ampforwp_auto_add_amp_menu_link_insert');
3112
  function ampforwp_auto_add_amp_menu_link_insert() {
3113
+ add_filter( 'nav_menu_link_attributes', 'ampforwp_auto_add_amp_in_menu_link', 10, 3 );
3114
  }
3115
 
3116
+ function ampforwp_auto_add_amp_in_menu_link( $atts, $item, $args ) {
3117
  global $redux_builder_amp;
 
3118
 
3119
+ $ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
3120
  if ( $ampforwp_is_amp_endpoint && $redux_builder_amp['ampforwp-auto-amp-menu-link'] == 1 ) {
3121
+ if(isset($redux_builder_amp['amp-core-end-point']) && $redux_builder_amp['amp-core-end-point'] == 1){
3122
+ $atts['href'] = user_trailingslashit(trailingslashit( $atts['href'] ) );
3123
+ $atts['href'] = add_query_arg(AMPFORWP_AMP_QUERY_VAR,'1', $atts['href']);
3124
+ }
3125
+ else{
3126
+ $atts['href'] = user_trailingslashit(trailingslashit( $atts['href'] ) . AMPFORWP_AMP_QUERY_VAR);
3127
+ }
 
 
 
3128
  }
 
 
 
3129
 
3130
  return $atts;
3131
  }
4316
 
4317
  //Meta description #1013
4318
  function ampforwp_generate_meta_desc(){
4319
+ global $post, $redux_builder_amp;
4320
+ $desc = $post_id = '';
4321
+ if ( $redux_builder_amp['ampforwp-seo-meta-description'] ) {
4322
+ if ( ampforwp_is_home() || ampforwp_is_blog() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4323
  $desc = addslashes( strip_tags( get_bloginfo( 'description' ) ) );
4324
  }
 
4325
  if ( is_archive() ) {
4326
  $desc = addslashes( strip_tags( get_the_archive_description() ) );
4327
  }
 
4328
  if ( is_single() || is_page() ) {
4329
+ if ( has_excerpt() ) {
4330
+ $desc = get_the_excerpt();
4331
+ } else {
4332
+ global $post;
4333
+ $id = $post->ID;
4334
+ $desc = $post->post_content;
4335
+ }
4336
+ $desc = preg_replace('/\[(.*?)\]/',' ', $desc);
4337
+ $desc = addslashes( wp_trim_words( strip_tags( $desc ) , '15' ) );
4338
  }
 
4339
  if ( is_search() ) {
4340
  $desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
4341
  }
 
4342
  if ( ampforwp_is_front_page() ) {
4343
  $post_id = ampforwp_get_frontpage_id();
4344
  $desc = addslashes( wp_trim_words( strip_tags( get_post_field('post_content', $post_id) ) , '15' ) );
4345
  }
 
4346
 
4347
+ // Yoast
4348
+ if ( class_exists('WPSEO_Frontend') && 1 == $redux_builder_amp['ampforwp-seo-selection'] ) {
4349
+ $front = $yoast_desc = '';
4350
+ $front = WPSEO_Frontend::get_instance();
4351
+ $yoast_desc = addslashes( strip_tags( $front->metadesc( false ) ) );
4352
+ // Static front page
4353
+ if ( ampforwp_is_front_page() ) {
4354
+ $post_id = ampforwp_get_frontpage_id();
4355
+ if ( class_exists('WPSEO_Meta') ) {
4356
+ $yoast_desc = addslashes( strip_tags( WPSEO_Meta::get_value('metadesc', $post_id ) ) );
4357
+ }
4358
+ }
4359
+ // for search
4360
+ if ( is_search() ) {
4361
+ $yoast_desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
4362
+ }
4363
+
4364
+ if ( $yoast_desc ) {
4365
+ $desc = $yoast_desc;
4366
+ }
4367
+ }
4368
+
4369
+ // All in One SEO
4370
+ if ( class_exists('All_in_One_SEO_Pack') && 2 == $redux_builder_amp['ampforwp-seo-selection'] ) {
4371
+ $aisop_class = $aisop_desc = $opts = '';
4372
+ $aisop_class = new All_in_One_SEO_Pack();
4373
+ $aisop_desc = $aisop_class->get_main_description();
4374
+ $opts = $aisop_class->get_current_options( array(), 'aiosp' );
4375
+ if ( (is_category() || is_tax() || is_tag()) && $aisop_class->show_page_description() ) {
4376
+ $aisop_desc = $opts['aiosp_description'];
4377
+ }
4378
+ if ( $aisop_desc ) {
4379
+ $desc = $aisop_desc;
4380
+ }
4381
  }
4382
+
4383
+ //Genesis #1013
4384
+ if ( function_exists('genesis_meta') ) {
4385
+ $genesis_description = '';
4386
+ if ( is_home() && is_front_page() && ! $redux_builder_amp['amp-frontpage-select-option'] ) {
4387
+ $genesis_description = genesis_get_seo_option( 'home_description' ) ? genesis_get_seo_option( 'home_description' ) : get_bloginfo( 'description' );
4388
+ }
4389
+ elseif ( is_home() && get_option( 'page_for_posts' ) && get_queried_object_id() ) {
4390
+ $post_id = get_option( 'page_for_posts' );
4391
+ if ( null !== $post_id || is_singular() ) {
4392
+ if ( genesis_get_custom_field( '_genesis_description', $post_id ) ) {
4393
+ $genesis_description = genesis_get_custom_field( '_genesis_description', $post_id );
4394
+ if ( $genesis_description ) {
4395
+ $desc = $genesis_description;
4396
+ }
4397
  }
4398
  }
4399
  }
4400
+ elseif ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] && get_option( 'page_on_front' ) ) {
4401
+ $post_id = get_option('page_on_front');
4402
+ if ( null !== $post_id || is_singular() ) {
4403
+ if ( genesis_get_custom_field( '_genesis_description', $post_id ) ) {
4404
+ $genesis_description = genesis_get_custom_field( '_genesis_description', $post_id );
4405
+ }
4406
  }
4407
  }
4408
+ else {
4409
+ $genesis_description = genesis_get_seo_meta_description();
4410
  }
4411
+
4412
+ if ( $genesis_description ) {
4413
+ $desc = $genesis_description;
4414
+ }
4415
  }
4416
+ // strip_shortcodes strategy not working here so had to do this way
4417
+ // strips shortcodes
4418
+ $desc = preg_replace('/\[(.*?)\]/','', $desc);
 
 
 
 
 
4419
  }
 
 
 
4420
  return $desc;
4421
  }
4422