AMP for WP – Accelerated Mobile Pages - Version 0.9.95

Version Description

Download this release

Release Info

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

Code changes from version 0.9.94 to 0.9.95

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.94
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.95
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.94
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.94');
23
 
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
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.95
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.95');
23
 
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
components/loop/loop.php CHANGED
@@ -369,10 +369,17 @@ function amp_loop_image( $data=array() ) {
369
 
370
  // Category
371
  function amp_loop_category(){
 
372
  if(count(get_the_category()) > 0){
373
  echo ' <ul class="loop-category">';
374
  foreach((get_the_category()) as $category) {
375
- echo '<li class="amp-cat-'. $category->term_id.'"><a href="'.ampforwp_url_controller( get_category_link( $category->term_id ) ).'">'. $category->cat_name.'</a></li>';
 
 
 
 
 
 
376
  }
377
  echo '</ul>';
378
  }
369
 
370
  // Category
371
  function amp_loop_category(){
372
+ global $redux_builder_amp;
373
  if(count(get_the_category()) > 0){
374
  echo ' <ul class="loop-category">';
375
  foreach((get_the_category()) as $category) {
376
+ echo '<li class="amp-cat-'. $category->term_id.'">';
377
+ if ( true == $redux_builder_amp['ampforwp-archive-support'] && true == $redux_builder_amp['ampforwp-cats-tags-links-single'] ){
378
+ echo '<a href="'.ampforwp_url_controller( get_category_link( $category->term_id ) ).'">'. $category->cat_name.'</a>';
379
+ }
380
+ else
381
+ echo '<span>'. $category->cat_name.'</span>';
382
+ echo '</li>';
383
  }
384
  echo '</ul>';
385
  }
components/related-posts/related-posts.php CHANGED
@@ -125,7 +125,7 @@ function ampforwp_get_relatedpost_image( $imagetype ='thumbnail', $data=array()
125
  }
126
 
127
  if ( $thumb_url && $show_image ) { ?>
128
- <amp-img data-block-on-consent src="<?php echo esc_url( $thumb_url ); ?>" width="<?php echo $thumb_width; ?>" height="<?php echo $thumb_height; ?>" layout="responsive"></amp-img>
129
  <?php }
130
  } ?>
131
  </a>
125
  }
126
 
127
  if ( $thumb_url && $show_image ) { ?>
128
+ <amp-img src="<?php echo esc_url( $thumb_url ); ?>" width="<?php echo $thumb_width; ?>" height="<?php echo $thumb_height; ?>" layout="responsive"></amp-img>
129
  <?php }
130
  } ?>
131
  </a>
components/theme-loader.php CHANGED
@@ -269,6 +269,5 @@ elseif ( ! defined('AMPFORWP_CUSTOM_THEME') ) {
269
  global $redux_builder_amp;
270
  require_once( AMPFORWP_CUSTOM_THEME . '/style.php' );
271
  // Custom CSS
272
- echo $redux_builder_amp['css_editor'];
273
  }
274
 
269
  global $redux_builder_amp;
270
  require_once( AMPFORWP_CUSTOM_THEME . '/style.php' );
271
  // Custom CSS
 
272
  }
273
 
includes/options/admin-config.php CHANGED
@@ -297,16 +297,19 @@ $extension_listing_array = array(
297
  ),
298
  );
299
 
 
 
 
 
 
 
 
300
  $extension_listing_array = apply_filters( 'ampforwp_extension_lists_filter', $extension_listing_array );
301
  $ampforwp_extension_list_html = '';
302
  $ampforwp_nameOfUser = "";
303
  $ampforwp_is_productActivated = false;
304
- usort($extension_listing_array, function($a, $b){
305
- if ($a['is_activated'] == $b['is_activated']) {
306
- return 0;
307
- }
308
- return ($a['is_activated'] < $b['is_activated']) ? -1 : 1;
309
- });
310
  foreach ($extension_listing_array as $key => $extension) {
311
  $currentStatus = "";
312
 
297
  ),
298
  );
299
 
300
+ function ampforwp_shortExtensionActivatedListing($a, $b){
301
+ if ($a['is_activated'] == $b['is_activated']) {
302
+ return 0;
303
+ }
304
+ return ($a['is_activated'] < $b['is_activated']) ? -1 : 1;
305
+ }
306
+
307
  $extension_listing_array = apply_filters( 'ampforwp_extension_lists_filter', $extension_listing_array );
308
  $ampforwp_extension_list_html = '';
309
  $ampforwp_nameOfUser = "";
310
  $ampforwp_is_productActivated = false;
311
+ usort($extension_listing_array, 'ampforwp_shortExtensionActivatedListing');
312
+
 
 
 
 
313
  foreach ($extension_listing_array as $key => $extension) {
314
  $currentStatus = "";
315
 
includes/vendor/amp/includes/templates/class-amp-content.php CHANGED
@@ -111,7 +111,11 @@ class AMP_Content {
111
 
112
  // First, embeds + the_content filter.
113
  $embed_handlers = $this->register_embed_handlers();
114
- $content = apply_filters( 'the_content', $content );
 
 
 
 
115
  $this->unregister_embed_handlers( $embed_handlers );
116
 
117
  // Then, sanitize to strip and/or convert non-amp content.
111
 
112
  // First, embeds + the_content filter.
113
  $embed_handlers = $this->register_embed_handlers();
114
+ if(isset($this->args['non-content']) && $this->args['non-content']=='non-content'){
115
+ $content = $this->content;
116
+ }else{
117
+ $content = apply_filters( 'the_content', $content );
118
+ }
119
  $this->unregister_embed_handlers( $embed_handlers );
120
 
121
  // Then, sanitize to strip and/or convert non-amp content.
includes/vendor/amp/includes/templates/class-amp-post-template.php CHANGED
@@ -453,7 +453,9 @@ class AMP_Post_Template {
453
  * @return string The template filename if one is located.
454
  */
455
  private function locate_template( $file ) {
456
- $search_file = sprintf( 'amp/%s', basename( $file ) );
 
 
457
  return locate_template( array( $search_file ), false );
458
  }
459
 
453
  * @return string The template filename if one is located.
454
  */
455
  private function locate_template( $file ) {
456
+ $location = 'ampforwp';
457
+ $location = apply_filters("ampforwp_template_locate",$location);
458
+ $search_file = sprintf( $location.'/%s', basename( $file ) );
459
  return locate_template( array( $search_file ), false );
460
  }
461
 
includes/vendor/vendor-changelog.txt CHANGED
@@ -79,9 +79,17 @@ Update: Same change added.
79
 
80
  23. Added: Filter added to modify amp template directory `ampforwp_template_locate` #1982
81
  Update: Added the filter in thirdparty-compatibility instead of the core.
 
82
 
83
  25. data-block-on-consent added in class-amp-dom-utils.php and class-amp-html-utils.php
84
 
85
  26. Section specific class added for subsections in framework.php on line number 3288
86
 
87
- 27. Deactivate Live AMP Validation from post edit page by removing 'AMP_Validation_Utils::init();' in amp.php on line number 113
 
 
 
 
 
 
 
79
 
80
  23. Added: Filter added to modify amp template directory `ampforwp_template_locate` #1982
81
  Update: Added the filter in thirdparty-compatibility instead of the core.
82
+ --Added Same filter in core `locate_template` Function AMP_Post_Template
83
 
84
  25. data-block-on-consent added in class-amp-dom-utils.php and class-amp-html-utils.php
85
 
86
  26. Section specific class added for subsections in framework.php on line number 3288
87
 
88
+ 27. Deactivate Live AMP Validation from post edit page by removing 'AMP_Validation_Utils::init();' in amp.php on line number 113
89
+
90
+ 28. Added non-content condition for other than Main content
91
+ if(isset($this->args['non-content']) && $this->args['non-content']=='non-content'){
92
+ $content = $this->content;
93
+ }else{
94
+ $content = apply_filters( 'the_content', $content );
95
+ }
includes/vendor/vendor-compatibility.php CHANGED
@@ -87,7 +87,10 @@ function ampforwp_enable_support_for_otherpages(){
87
  $hide_cats_amp = '';
88
  $hide_cats_amp = is_category_amp_disabled();
89
  $support_for_archives = '';
90
-
 
 
 
91
  if ( isset($redux_builder_amp['ampforwp-amp-convert-to-wp']) && $redux_builder_amp['ampforwp-amp-convert-to-wp'] && ampforwp_is_non_amp() ) {
92
  add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
93
  }
@@ -99,20 +102,35 @@ function ampforwp_enable_support_for_otherpages(){
99
  }
100
  $amp_frontpage_id = ampforwp_get_frontpage_id();
101
 
102
- if( ( ($support_for_archives && !$hide_cats_amp) || is_search() || is_front_page() || ampforwp_is_blog() || ampforwp_is_home() || is_404() ) && $is_amp_endpoint_needed ){
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  remove_action( 'template_redirect', 'amp_render' );
104
- if ( is_front_page() && $amp_frontpage_id ) {
105
- $amp_frontpage_post = get_post($amp_frontpage_id);
106
- amp_render_post($amp_frontpage_post);
107
- }
108
- elseif(is_404()){
109
- $fourofour = get_post(2);
110
- amp_render_post($fourofour);
111
- }
112
- else
113
- amp_render_post(0);
114
- exit;
115
  }
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
118
  // Sanitizers
@@ -168,6 +186,7 @@ function ampforwp_modified_embed_handlers($handlers){
168
 
169
  function ampforwp_post_status($enabled){
170
  global $redux_builder_amp, $post;
 
171
  if ( ( is_single() && 'post' === $post->post_type && ! $redux_builder_amp['amp-on-off-for-all-posts'] ) || ( is_page() && ! $redux_builder_amp['amp-on-off-for-all-pages'] ) ){
172
  $enabled = false;
173
  }
@@ -287,11 +306,20 @@ function ampforwp_post_template_data( $data ) {
287
 
288
 
289
  function ampforwp_update_class($classList, $currentClass){
290
- $updateClass = array('AMP_Theme_Support',
 
 
 
 
 
 
 
 
 
291
  'AMP_Tag_And_Attribute_Sanitizer',
292
- 'AMP_Style_Sanitizer',
293
  'AMP_Allowed_Tags_Generated',
294
- );
 
295
  if(!in_array($currentClass, $updateClass)){
296
  return true;
297
  }
87
  $hide_cats_amp = '';
88
  $hide_cats_amp = is_category_amp_disabled();
89
  $support_for_archives = '';
90
+ $amp_home = false;
91
+ if ( ampforwp_is_home() && true == $redux_builder_amp['ampforwp-homepage-on-off-support'] ) {
92
+ $amp_home = true;
93
+ }
94
  if ( isset($redux_builder_amp['ampforwp-amp-convert-to-wp']) && $redux_builder_amp['ampforwp-amp-convert-to-wp'] && ampforwp_is_non_amp() ) {
95
  add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
96
  }
102
  }
103
  $amp_frontpage_id = ampforwp_get_frontpage_id();
104
 
105
+
106
+ if ( ampforwp_is_front_page() && $amp_frontpage_id && $is_amp_endpoint_needed ) {
107
+ remove_action('template_redirect','redirect_canonical');
108
+ add_action('template_redirect','redirect_canonical', 11);
109
+ }
110
+
111
+ // If There is no front page setup in reading settings, but needs a custom amp page
112
+ if ( ( ampforwp_is_front_page() && $amp_frontpage_id && $is_amp_endpoint_needed) && (! get_option( 'page_on_front' ) ) ) {
113
+ remove_action( 'template_redirect', 'amp_render' );
114
+ add_action( 'template_redirect', 'ampforwp_amp_render' );
115
+ }
116
+
117
+ // 404 page and homepage (loop)
118
+ if( ( ($support_for_archives && !$hide_cats_amp) || is_search() || ampforwp_is_blog() || $amp_home || is_404() ) && $is_amp_endpoint_needed ){
119
  remove_action( 'template_redirect', 'amp_render' );
120
+ add_action( 'template_redirect', 'ampforwp_amp_render' );
 
 
 
 
 
 
 
 
 
 
121
  }
122
+
123
+ }
124
+
125
+ function ampforwp_amp_render() {
126
+ if( is_404()) {
127
+ $fourofour = get_post(2);
128
+ amp_render_post($fourofour);
129
+ exit;
130
+ } else{
131
+ amp_render_post(0);
132
+ exit;
133
+ }
134
  }
135
 
136
  // Sanitizers
186
 
187
  function ampforwp_post_status($enabled){
188
  global $redux_builder_amp, $post;
189
+ $enabled = true;
190
  if ( ( is_single() && 'post' === $post->post_type && ! $redux_builder_amp['amp-on-off-for-all-posts'] ) || ( is_page() && ! $redux_builder_amp['amp-on-off-for-all-pages'] ) ){
191
  $enabled = false;
192
  }
306
 
307
 
308
  function ampforwp_update_class($classList, $currentClass){
309
+ if( function_exists('start_non_amp_to_amp_conversion') && start_non_amp_to_amp_conversion()){
310
+ $updateClass = array('AMP_Theme_Support',
311
+ 'AMP_Tag_And_Attribute_Sanitizer',
312
+ 'AMP_Style_Sanitizer',
313
+ 'AMP_Allowed_Tags_Generated',
314
+ );
315
+ }
316
+ else{
317
+ $updateClass = array(
318
+ 'AMP_Theme_Support',
319
  'AMP_Tag_And_Attribute_Sanitizer',
 
320
  'AMP_Allowed_Tags_Generated',
321
+ );
322
+ }
323
  if(!in_array($currentClass, $updateClass)){
324
  return true;
325
  }
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.94
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.95
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
templates/design-manager/design-1/elements/featured-image.php CHANGED
@@ -14,7 +14,7 @@ if($featured_image || ( ampforwp_is_custom_field_featured_image() && ampforwp_cf
14
  $amp_img_width = ampforwp_cf_featured_image_src('width');
15
  $amp_img_height = ampforwp_cf_featured_image_src('height');
16
  if( $amp_img_src ){
17
- $amp_html = "<amp-img data-block-on-consent src='$amp_img_src' width=$amp_img_width height=$amp_img_height layout=responsive ></amp-img>";
18
  }
19
  }
20
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content()) {
14
  $amp_img_width = ampforwp_cf_featured_image_src('width');
15
  $amp_img_height = ampforwp_cf_featured_image_src('height');
16
  if( $amp_img_src ){
17
+ $amp_html = "<amp-img src='$amp_img_src' width=$amp_img_width height=$amp_img_height layout=responsive ></amp-img>";
18
  }
19
  }
20
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content()) {
templates/design-manager/design-1/style.php CHANGED
@@ -208,5 +208,5 @@ if( ( isset($redux_builder_amp['enable-amp-ads-1'] ) && $redux_builder_amp['enab
208
  if ( true == $redux_builder_amp['amp-pagination'] ) { ?>
209
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
210
  <?php }
211
- echo $redux_builder_amp['css_editor'];
212
  //} ?>
208
  if ( true == $redux_builder_amp['amp-pagination'] ) { ?>
209
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
210
  <?php }
211
+
212
  //} ?>
templates/design-manager/design-2/elements/featured-image.php CHANGED
@@ -14,7 +14,7 @@ if( $featured_image || ( ampforwp_is_custom_field_featured_image() && ampforwp_c
14
  $amp_img_width = ampforwp_cf_featured_image_src('width');
15
  $amp_img_height = ampforwp_cf_featured_image_src('height');
16
  if( $amp_img_src ){
17
- $amp_html = "<amp-img data-block-on-consent src='$amp_img_src' width=$amp_img_width height=$amp_img_height layout=responsive ></amp-img>";
18
  }
19
  }
20
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content() ){
14
  $amp_img_width = ampforwp_cf_featured_image_src('width');
15
  $amp_img_height = ampforwp_cf_featured_image_src('height');
16
  if( $amp_img_src ){
17
+ $amp_html = "<amp-img src='$amp_img_src' width=$amp_img_width height=$amp_img_height layout=responsive ></amp-img>";
18
  }
19
  }
20
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content() ){
templates/design-manager/design-2/style.php CHANGED
@@ -349,5 +349,5 @@ if( ( isset($redux_builder_amp['enable-amp-ads-1'] ) && $redux_builder_amp['enab
349
  if ( true == $redux_builder_amp['amp-pagination'] ) { ?>
350
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
351
  <?php }
352
- echo $redux_builder_amp['css_editor'];
353
  //} ?>
349
  if ( true == $redux_builder_amp['amp-pagination'] ) { ?>
350
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
351
  <?php }
352
+
353
  //} ?>
templates/design-manager/design-3/elements/related-posts.php CHANGED
@@ -81,7 +81,7 @@
81
  $thumb_width = ampforwp_get_post_thumbnail('width');
82
  $thumb_height = ampforwp_get_post_thumbnail('height');
83
  if( $thumb_url && true == $redux_builder_amp['ampforwp-single-related-posts-image'] ) { ?>
84
- <amp-img data-block-on-consent src="<?php echo esc_url( $thumb_url ); ?>" width=<?php echo $thumb_width; ?> height=<?php echo $thumb_height; ?> layout="responsive"></amp-img>
85
  <?php }
86
  }?>
87
  </a>
81
  $thumb_width = ampforwp_get_post_thumbnail('width');
82
  $thumb_height = ampforwp_get_post_thumbnail('height');
83
  if( $thumb_url && true == $redux_builder_amp['ampforwp-single-related-posts-image'] ) { ?>
84
+ <amp-img src="<?php echo esc_url( $thumb_url ); ?>" width=<?php echo $thumb_width; ?> height=<?php echo $thumb_height; ?> layout="responsive"></amp-img>
85
  <?php }
86
  }?>
87
  </a>
templates/design-manager/design-3/style.php CHANGED
@@ -474,5 +474,5 @@ if ( (isset($redux_builder_amp['enable-amp-ads-1'] ) && $redux_builder_amp['enab
474
  if ( true == $redux_builder_amp['amp-pagination'] ) { ?>
475
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
476
  <?php }
477
- echo $redux_builder_amp['css_editor'];
478
  //} ?>
474
  if ( true == $redux_builder_amp['amp-pagination'] ) { ?>
475
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
476
  <?php }
477
+
478
  //} ?>
templates/features.php CHANGED
@@ -6881,4 +6881,10 @@ function ampforwp_resave_permalink( $option, $old_value, $value ){
6881
  delete_transient( 'ampforwp_current_version_check' );
6882
  }
6883
  }
 
 
 
 
 
 
6884
  }
6881
  delete_transient( 'ampforwp_current_version_check' );
6882
  }
6883
  }
6884
+ }
6885
+
6886
+ add_action('amp_post_template_css','ampforwp_load_css_editors_custom_css',12);
6887
+ function ampforwp_load_css_editors_custom_css(){
6888
+ global $redux_builder_amp;
6889
+ echo $redux_builder_amp['css_editor'];
6890
  }