AMP for WP – Accelerated Mobile Pages - Version 0.9.2

Version Description

[23th December 2016] = * Proper Details at https://ampforwp.com/mobile-redirection/ * AMP Mobile Redirection Feature added. It can be turned on from Dashboard > General and then Mobile Redirection. [New Feature] * Archive title and description added [Improvement] * Improved the Speed of the AMP version #321 [Improvement] * Anchor link was not closing fixed #328 [Bug Fix] * Typo in Trailingslashit function which resulted in some issues in the Homepage version [Bug Fix]

Download this release

Release Info

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

Code changes from version 0.9.1.2.1 to 0.9.2

README.md CHANGED
@@ -7,7 +7,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
7
  Donate link: https://www.paypal.me/Kaludi/5
8
  Requires at least: 3.0
9
  Tested up to: 4.7
10
- Stable tag: 0.9.1.2.1
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -31,12 +31,13 @@ Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on
31
 
32
  = Features: =
33
 
 
34
  * NEW - DoubleClick Support
35
  * NEW - Custom Post Type Support
36
  * NEW - Star Ratings
37
  * NEW - Drag & Drop Page builder Added
38
- * NEW - 2 Designs Added
39
- * NEW - 100% Yoast SEO support on AMP pages
40
  * AMP WooCommerce Support
41
  * Switch on/off Support for Pages on AMP
42
  * Translation Panel & RTL
@@ -141,6 +142,14 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
141
 
142
  == Changelog ==
143
 
 
 
 
 
 
 
 
 
144
  = 0.9.1.2 [20th December 2016] =
145
  * Proper Details at http://ampforwp.com/new/
146
  * DoubleClick Support
7
  Donate link: https://www.paypal.me/Kaludi/5
8
  Requires at least: 3.0
9
  Tested up to: 4.7
10
+ Stable tag: 0.9.2
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
31
 
32
  = Features: =
33
 
34
+ * NEW - Mobile Redirection - More than 50% of your traffic is from mobile and you aren’t doing anything to improve their user experience, which means you are falling behind on SEO and it can result in lower SERPS. Lightning fast mobile version means faster User experience means more engagement which directly results in the lower bounce rate.
35
  * NEW - DoubleClick Support
36
  * NEW - Custom Post Type Support
37
  * NEW - Star Ratings
38
  * NEW - Drag & Drop Page builder Added
39
+ * 2 Designs Added
40
+ * Yoast SEO support on AMP pages
41
  * AMP WooCommerce Support
42
  * Switch on/off Support for Pages on AMP
43
  * Translation Panel & RTL
142
 
143
  == Changelog ==
144
 
145
+ = 0.9.2 [23th December 2016] =
146
+ * Proper Details at https://ampforwp.com/mobile-redirection/
147
+ * AMP Mobile Redirection Feature added. It can be turned on from Dashboard > General and then Mobile Redirection. [New Feature]
148
+ * Archive title and description added [Improvement]
149
+ * Improved the Speed of the AMP version #321 [Improvement]
150
+ * Anchor link was not closing fixed #328 [Bug Fix]
151
+ * Typo in Trailingslashit function which resulted in some issues in the Homepage version [Bug Fix]
152
+
153
  = 0.9.1.2 [20th December 2016] =
154
  * Proper Details at http://ampforwp.com/new/
155
  * DoubleClick Support
accelerated-moblie-pages.php CHANGED
@@ -3,13 +3,12 @@
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.1.2.1
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/5
10
  License: GPL2
11
  */
12
-
13
  // Exit if accessed directly.
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
@@ -26,7 +25,7 @@ add_action( 'init', 'ampforwp_add_custom_post_support',11);
26
 
27
  define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
28
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
29
- define('AMPFORWP_VERSION','0.9.1.2');
30
 
31
  /*
32
  * Load Files only in the backend
@@ -92,3 +91,24 @@ function ampforwp_plugin_init() {
92
  }
93
  }
94
  add_action('init','ampforwp_plugin_init',9);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/5
10
  License: GPL2
11
  */
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
 
25
 
26
  define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
27
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
28
+ define('AMPFORWP_VERSION','0.9.2');
29
 
30
  /*
31
  * Load Files only in the backend
91
  }
92
  }
93
  add_action('init','ampforwp_plugin_init',9);
94
+
95
+ function ampforwp_page_template_redirect() {
96
+ global $redux_builder_amp;
97
+ if($redux_builder_amp['amp-mobile-redirection']){
98
+ if ( wp_is_mobile() ) {
99
+ if ( is_amp_endpoint() ){
100
+ return;
101
+ } else {
102
+ if ( is_home() ) {
103
+ wp_redirect( home_url('/') . AMP_QUERY_VAR . '/', 301 );
104
+ } elseif ( is_archive() ) {
105
+ return;
106
+ } else {
107
+ wp_redirect( get_permalink( $id ) . AMP_QUERY_VAR . '/', 301 );
108
+ }
109
+ }
110
+ exit();
111
+ }
112
+ }
113
+ }
114
+ add_action( 'template_redirect', 'ampforwp_page_template_redirect' );
includes/options/options-init.php CHANGED
@@ -181,7 +181,7 @@
181
  'id' => 'opt-text-subsection',
182
  'subsection' => true,
183
  'fields' => array(
184
- $fields = array(
185
  'id' => 'opt-media',
186
  'type' => 'media',
187
  'url' => true,
@@ -189,6 +189,16 @@
189
  'subtitle' => __('Upload a logo for the AMP version.', 'redux-framework-demo'),
190
  'desc' => __('Recommend logo size is: 190x36', 'redux-framework-demo')
191
  ),
 
 
 
 
 
 
 
 
 
 
192
  array(
193
  'id' => 'amp-analytics-select-option',
194
  'type' => 'select',
@@ -309,6 +319,7 @@
309
  'subtitle' => __('If you want users in header to go to non-AMP website from the Header, then you can enable this option', 'redux-framework-demo'),
310
  'default' => 0,
311
  ),
 
312
  // array(
313
  // 'id' => 'amp-ad-places',
314
  // 'type' => 'select',
@@ -996,7 +1007,7 @@ if(!is_plugin_active( 'amp-incontent-ads/amptoolkit-incontent-ads.php' ) ){
996
 
997
  <a href="http://ampforwp.com/amp-ratings/#utm_source=options-panel&utm_medium=extension-tab_amp-ratings&utm_campaign=AMP%20Plugin" target="_blank"><img class="ampforwp-extension-ad-img-banner" src="'.AMPFORWP_IMAGE_DIR . '/amp-rating-extension.png" width="345" height="500" /></a>
998
 
999
-
1000
  <a href="http://ampforwp.com/extensions/#utm_source=options-panel&utm_medium=extension-tab_coming-soon&utm_campaign=AMP%20Plugin" target="_blank"><img class="ampforwp-extension-ad-img-banner" src="'.AMPFORWP_IMAGE_DIR . '/extension-coming-soon.png" width="345" height="500" /></a>',
1001
  'icon' => 'el el-info-circle',
1002
  ) );
181
  'id' => 'opt-text-subsection',
182
  'subsection' => true,
183
  'fields' => array(
184
+ array(
185
  'id' => 'opt-media',
186
  'type' => 'media',
187
  'url' => true,
189
  'subtitle' => __('Upload a logo for the AMP version.', 'redux-framework-demo'),
190
  'desc' => __('Recommend logo size is: 190x36', 'redux-framework-demo')
191
  ),
192
+ array(
193
+ 'id' => 'amp-mobile-redirection',
194
+ 'type' => 'switch',
195
+ 'title' => __('Mobile Redirection', 'redux-framework-demo'),
196
+ 'subtitle' => __('
197
+ Enable AMP for your mobile users. Give your visitors a Faster mobile User Experience.','ampforwp'),
198
+ 'default' => 0,
199
+
200
+ ),
201
+
202
  array(
203
  'id' => 'amp-analytics-select-option',
204
  'type' => 'select',
319
  'subtitle' => __('If you want users in header to go to non-AMP website from the Header, then you can enable this option', 'redux-framework-demo'),
320
  'default' => 0,
321
  ),
322
+
323
  // array(
324
  // 'id' => 'amp-ad-places',
325
  // 'type' => 'select',
1007
 
1008
  <a href="http://ampforwp.com/amp-ratings/#utm_source=options-panel&utm_medium=extension-tab_amp-ratings&utm_campaign=AMP%20Plugin" target="_blank"><img class="ampforwp-extension-ad-img-banner" src="'.AMPFORWP_IMAGE_DIR . '/amp-rating-extension.png" width="345" height="500" /></a>
1009
 
1010
+
1011
  <a href="http://ampforwp.com/extensions/#utm_source=options-panel&utm_medium=extension-tab_coming-soon&utm_campaign=AMP%20Plugin" target="_blank"><img class="ampforwp-extension-ad-img-banner" src="'.AMPFORWP_IMAGE_DIR . '/extension-coming-soon.png" width="345" height="500" /></a>',
1012
  'icon' => 'el el-info-circle',
1013
  ) );
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/5
5
  Requires at least: 3.0
6
  Tested up to: 4.7
7
- Stable tag: 0.9.1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -28,12 +28,13 @@ Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on
28
 
29
  = Features: =
30
 
 
31
  * NEW - DoubleClick Support
32
  * NEW - Custom Post Type Support
33
  * NEW - Star Ratings
34
  * NEW - Drag & Drop Page builder Added
35
- * NEW - 2 Designs Added
36
- * NEW - 100% Yoast SEO support on AMP pages
37
  * AMP WooCommerce Support
38
  * Switch on/off Support for Pages on AMP
39
  * Translation Panel & RTL
@@ -138,6 +139,14 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
138
 
139
  == Changelog ==
140
 
 
 
 
 
 
 
 
 
141
  = 0.9.1.2 [20th December 2016] =
142
  * Proper Details at http://ampforwp.com/new/
143
  * DoubleClick Support
4
  Donate link: https://www.paypal.me/Kaludi/5
5
  Requires at least: 3.0
6
  Tested up to: 4.7
7
+ Stable tag: 0.9.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
28
 
29
  = Features: =
30
 
31
+ * NEW - Mobile Redirection - More than 50% of your traffic is from mobile and you aren’t doing anything to improve their user experience, which means you are falling behind on SEO and it can result in lower SERPS. Lightning fast mobile version means faster User experience means more engagement which directly results in the lower bounce rate.
32
  * NEW - DoubleClick Support
33
  * NEW - Custom Post Type Support
34
  * NEW - Star Ratings
35
  * NEW - Drag & Drop Page builder Added
36
+ * 2 Designs Added
37
+ * Yoast SEO support on AMP pages
38
  * AMP WooCommerce Support
39
  * Switch on/off Support for Pages on AMP
40
  * Translation Panel & RTL
139
 
140
  == Changelog ==
141
 
142
+ = 0.9.2 [23th December 2016] =
143
+ * Proper Details at https://ampforwp.com/mobile-redirection/
144
+ * AMP Mobile Redirection Feature added. It can be turned on from Dashboard > General and then Mobile Redirection. [New Feature]
145
+ * Archive title and description added [Improvement]
146
+ * Improved the Speed of the AMP version #321 [Improvement]
147
+ * Anchor link was not closing fixed #328 [Bug Fix]
148
+ * Typo in Trailingslashit function which resulted in some issues in the Homepage version [Bug Fix]
149
+
150
  = 0.9.1.2 [20th December 2016] =
151
  * Proper Details at http://ampforwp.com/new/
152
  * DoubleClick Support
templates/design-manager/design-1/elements/related-posts.php CHANGED
@@ -39,13 +39,15 @@
39
  <?php
40
  while( $my_query->have_posts() ) {
41
  $my_query->the_post();?>
42
- <li class="<?php if ( has_post_thumbnail() ) { echo'has_related_thumbnail'; } else { echo 'no_related_thumbnail'; } ?>"><a href="<?php trailingslashit(the_permalink()); ?><?php echo AMP_QUERY_VAR ;?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
 
43
  <?php if ( has_post_thumbnail() ) {
44
  $thumb_id_2 = get_post_thumbnail_id();
45
  $thumb_url_array_2 = wp_get_attachment_image_src($thumb_id_2, 'thumbnail', true);
46
  $thumb_url_2 = $thumb_url_array_2[0];?>
47
  <amp-img src="<?php echo $thumb_url_2 ?>" width="150" height="150" layout="responsive"></amp-img>
48
  <?php } ?>
 
49
  <div class="related_link">
50
  <a href="<?php trailingslashit(the_permalink()); ?><?php echo AMP_QUERY_VAR ;?>"><?php the_title(); ?></a>
51
  <?php
39
  <?php
40
  while( $my_query->have_posts() ) {
41
  $my_query->the_post();?>
42
+ <li class="<?php if ( has_post_thumbnail() ) { echo'has_related_thumbnail'; } else { echo 'no_related_thumbnail'; } ?>">
43
+ <a href="<?php trailingslashit(the_permalink()); ?><?php echo AMP_QUERY_VAR ;?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
44
  <?php if ( has_post_thumbnail() ) {
45
  $thumb_id_2 = get_post_thumbnail_id();
46
  $thumb_url_array_2 = wp_get_attachment_image_src($thumb_id_2, 'thumbnail', true);
47
  $thumb_url_2 = $thumb_url_array_2[0];?>
48
  <amp-img src="<?php echo $thumb_url_2 ?>" width="150" height="150" layout="responsive"></amp-img>
49
  <?php } ?>
50
+ </a>
51
  <div class="related_link">
52
  <a href="<?php trailingslashit(the_permalink()); ?><?php echo AMP_QUERY_VAR ;?>"><?php the_title(); ?></a>
53
  <?php
templates/design-manager/design-2/elements/related-posts.php CHANGED
@@ -42,7 +42,8 @@
42
  $related_post_permalink = trailingslashit($related_post_permalink);
43
  $related_post_permalink = $related_post_permalink . AMP_QUERY_VAR ;;
44
  ?>
45
- <li class="<?php if ( has_post_thumbnail() ) { echo'has_related_thumbnail'; } else { echo 'no_related_thumbnail'; } ?>"><a href="<?php echo esc_url( $related_post_permalink ); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
 
46
  <?php
47
  $thumb_id_2 = get_post_thumbnail_id();
48
  $thumb_url_array_2 = wp_get_attachment_image_src($thumb_id_2, 'thumbnail', true);
@@ -52,6 +53,7 @@
52
  <?php if ( has_post_thumbnail() ) { ?>
53
  <amp-img src="<?php echo esc_url( $thumb_url_2 ); ?>" width="150" height="150" layout="responsive"></amp-img>
54
  <?php } ?>
 
55
  <div class="related_link">
56
  <a href="<?php echo esc_url( $related_post_permalink ); ?>"><?php the_title(); ?></a>
57
  <?php if(has_excerpt()){
42
  $related_post_permalink = trailingslashit($related_post_permalink);
43
  $related_post_permalink = $related_post_permalink . AMP_QUERY_VAR ;;
44
  ?>
45
+ <li class="<?php if ( has_post_thumbnail() ) { echo'has_related_thumbnail'; } else { echo 'no_related_thumbnail'; } ?>">
46
+ <a href="<?php echo esc_url( $related_post_permalink ); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
47
  <?php
48
  $thumb_id_2 = get_post_thumbnail_id();
49
  $thumb_url_array_2 = wp_get_attachment_image_src($thumb_id_2, 'thumbnail', true);
53
  <?php if ( has_post_thumbnail() ) { ?>
54
  <amp-img src="<?php echo esc_url( $thumb_url_2 ); ?>" width="150" height="150" layout="responsive"></amp-img>
55
  <?php } ?>
56
+ </a>
57
  <div class="related_link">
58
  <a href="<?php echo esc_url( $related_post_permalink ); ?>"><?php the_title(); ?></a>
59
  <?php if(has_excerpt()){
templates/design-manager/design-2/index.php CHANGED
@@ -19,6 +19,12 @@
19
 
20
  <main>
21
 
 
 
 
 
 
 
22
  <?php if ( have_posts() ) :
23
  while ( have_posts() ) : the_post();
24
 
19
 
20
  <main>
21
 
22
+
23
+ <?php if ( is_archive() ) {
24
+ the_archive_title( '<h3 class="page-title">', '</h3>' );
25
+ the_archive_description( '<div class="taxonomy-description">', '</div>' );
26
+ } ?>
27
+
28
  <?php if ( have_posts() ) :
29
  while ( have_posts() ) : the_post();
30
 
templates/features.php CHANGED
@@ -72,21 +72,20 @@
72
  if ( is_home() || is_front_page() ){
73
  $amp_url = home_url('/?amp');
74
  }
75
- elseif( is_archive()){
76
- global $wp;
77
- $archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
78
- $amp_url = $archive_current_url . '/?amp';
79
- }
80
- else {
81
- $amp_url = trailingslashit( get_permalink().'amp' );
82
  }
83
-
84
  //checking if the user wants amp page for archives or not
85
- if( is_archive() && $redux_builder_amp['ampforwp-amp-archive-pages-on-off']=='1') {
86
- printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
87
  } else {
88
- // Dont do anything :)
89
  }
 
90
  // end of checking if the user wants amp page for archives or not
91
  }
92
  } //end of ampforwp_home_archive_rel_canonical()
@@ -174,19 +173,18 @@
174
  }
175
 
176
  // 6. Add required Javascripts for extra AMP features
177
- add_action('amp_post_template_head','ampforwp_register_additional_scripts');
178
  function ampforwp_register_additional_scripts() {
179
  global $redux_builder_amp;
180
- ?>
181
- <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
182
- <script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
183
  <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
184
  <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
185
  <script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
186
  <?php } ?>
187
  <?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
188
- <script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
189
- <?php } ?>
190
  <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
191
  <?php }
192
 
72
  if ( is_home() || is_front_page() ){
73
  $amp_url = home_url('/?amp');
74
  }
75
+ elseif ( is_archive() ) {
76
+ global $wp;
77
+ $archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
78
+ $amp_url = $archive_current_url . '/?amp';
79
+ } else {
80
+ $amp_url = trailingslashit( get_permalink().'amp' );
 
81
  }
 
82
  //checking if the user wants amp page for archives or not
83
+ if( is_archive() && $redux_builder_amp['ampforwp-amp-archive-pages-on-off']=='0') {
84
+ return;
85
  } else {
86
+ printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
87
  }
88
+
89
  // end of checking if the user wants amp page for archives or not
90
  }
91
  } //end of ampforwp_home_archive_rel_canonical()
173
  }
174
 
175
  // 6. Add required Javascripts for extra AMP features
176
+ add_action('amp_post_template_head','ampforwp_register_additional_scripts', 20);
177
  function ampforwp_register_additional_scripts() {
178
  global $redux_builder_amp;
179
+ ?><script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
180
+ <?php if( is_page() ) { ?><script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script><?php } ?>
 
181
  <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
182
  <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
183
  <script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
184
  <?php } ?>
185
  <?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
186
+ <?php if( is_single() ) { ?><script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
187
+ <?php } } ?>
188
  <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
189
  <?php }
190