AMP for WP – Accelerated Mobile Pages - Version 0.9.37

Version Description

  • View full details at https://ampforwp.com/category-tags-archive-support-added/
  • Debug issues solved [Bug fix]
  • Remove Extra styling added by other Themes/ Plugins [3rd party themes and plugin Support]
  • Category, Tags & Archive Support with titles added [Enchancement]
  • Archive Title support added [Enchancement]
  • There were some issues with attachments [Bug fix]
  • removed ? from amp url's [Improvement]
  • Mobile redirection for Archives added and 404 redirections removed for archives [Improvement]
  • View non-amp version now properly redirects to the normal version. #415 [Bug fix]
  • Added an option to turn off AMP support for Homepage. [Enchancement]
  • Too many redirects issue on homepage is fixed #435 [Improvement]
  • Spell check and G tags are removed for thrive & Spell check compatibility [Better Validation]
  • If image is not available in gravatar fixed, it was throwing an error #365 #327 [Improvement]
  • Comment anchor link changed for simplecomment button files in both designs [Improvement]
  • Redirection Loop issue fixed [Bug fix]
  • Shortcodes were visible in excerpt, it's fixed now. [Improvement]
  • Defer onload by other plugins was causing issues #431 [Better Validation & 3rd party support]
  • Improved Sessions [Improvement]
  • Advnaced Settings panel was created for better user experience. [Improvement]
  • Spell check tag was causing validation issues. [Better Validation & 3rd party support]
  • RTL issue fixed #454 [Bug fixed]
Download this release

Release Info

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

Code changes from version 0.9.36.1 to 0.9.37

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.36.1
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/5
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
17
  function ampforwp_add_custom_post_support() {
18
  global $redux_builder_amp;
19
  if( $redux_builder_amp['amp-on-off-for-all-pages'] ) {
20
- add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK | EP_PAGES | EP_ROOT );
21
  add_post_type_support( 'page', AMP_QUERY_VAR );
22
  }
23
  }
@@ -25,15 +25,15 @@ add_action( 'init', 'ampforwp_add_custom_post_support',11);
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.36');
29
 
30
- // Redux panel inclusion code
31
  if ( !class_exists( 'ReduxFramework' ) ) {
32
  require_once dirname( __FILE__ ).'/includes/options/redux-core/framework.php';
33
  }
34
  // Register all the main options
35
  require_once dirname( __FILE__ ).'/includes/options/admin-config.php';
36
-
37
  /*
38
  * Load Files only in the backend
39
  * As we don't need plugin activation code to run everytime the site loads
@@ -85,10 +85,23 @@ if ( is_admin() ) {
85
  }
86
  </style> <?php
87
  }
 
 
88
  }
89
 
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
92
  // Add Settings Button in Plugin backend
93
  if ( ! function_exists( 'ampforwp_plugin_settings_link' ) ) {
94
 
@@ -120,6 +133,11 @@ if ( is_admin() ) {
120
 
121
  } // is_admin() closing
122
 
 
 
 
 
 
123
  if ( ! class_exists( 'Ampforwp_Init', false ) ) {
124
  class Ampforwp_Init {
125
 
@@ -128,6 +146,9 @@ if ( ! class_exists( 'Ampforwp_Init', false ) ) {
128
  // Load Files required for the plugin to run
129
  require AMPFORWP_PLUGIN_DIR .'/includes/includes.php';
130
 
 
 
 
131
  require AMPFORWP_PLUGIN_DIR .'/classes/class-init.php';
132
  new Ampforwp_Loader;
133
 
@@ -143,60 +164,4 @@ function ampforwp_plugin_init() {
143
  new Ampforwp_Init;
144
  }
145
  }
146
- add_action('init','ampforwp_plugin_init',9);
147
-
148
- function ampforwp_page_template_redirect() {
149
- global $redux_builder_amp;
150
- if($redux_builder_amp['amp-mobile-redirection']){
151
- if ( wp_is_mobile() ) {
152
- if ( ampforwp_is_amp_endpoint() ) {
153
- return;
154
- } else {
155
- if ( is_home() ) {
156
- wp_redirect( trailingslashit( esc_url( home_url() ) ) .'?'. AMP_QUERY_VAR , 301 );
157
- exit();
158
- } elseif ( is_archive() ) {
159
- return ;
160
- } else {
161
- wp_redirect( trailingslashit( esc_url( ( get_permalink( $id ) ) ) ) . AMP_QUERY_VAR , 301 );
162
- exit();
163
- }
164
- }
165
- }
166
- }
167
- }
168
-
169
- add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
170
-
171
- add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
172
- function ampforwp_page_template_redirect_archive() {
173
-
174
- if ( is_archive() || is_404() ) {
175
- if( ampforwp_is_amp_endpoint() ) {
176
- global $wp;
177
- $archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
178
- $archive_current_url = trailingslashit($archive_current_url );
179
- if (is_404() ) {
180
- $archive_current_url = dirname($archive_current_url);
181
- }
182
- wp_redirect( esc_url( $archive_current_url ) , 301 );
183
- exit();
184
- }
185
- }
186
- }
187
-
188
- // Add Custom Rewrite Rule to make sure pagination & redirection is working correctly
189
- function ampforwp_add_custom_rewrite_rules() {
190
- add_rewrite_rule(
191
- 'amp/page/([0-9]{1,})/?$',
192
- 'index.php?amp&paged=$matches[1]',
193
- 'top'
194
- );
195
- }
196
- add_action( 'init', 'ampforwp_add_custom_rewrite_rules' );
197
-
198
-
199
- function ampforwp_is_amp_endpoint() {
200
- return false !== get_query_var( 'amp', false );
201
- }
202
-
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.37
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/5
17
  function ampforwp_add_custom_post_support() {
18
  global $redux_builder_amp;
19
  if( $redux_builder_amp['amp-on-off-for-all-pages'] ) {
20
+ add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK | EP_PAGES | EP_ROOT | EP_ALL );
21
  add_post_type_support( 'page', AMP_QUERY_VAR );
22
  }
23
  }
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.37');
29
 
30
+ // Redux panel inclusion code
31
  if ( !class_exists( 'ReduxFramework' ) ) {
32
  require_once dirname( __FILE__ ).'/includes/options/redux-core/framework.php';
33
  }
34
  // Register all the main options
35
  require_once dirname( __FILE__ ).'/includes/options/admin-config.php';
36
+
37
  /*
38
  * Load Files only in the backend
39
  * As we don't need plugin activation code to run everytime the site loads
85
  }
86
  </style> <?php
87
  }
88
+ } else {
89
+ // add_action('admin_notices', 'ampforwp_permalink_update_notice');
90
  }
91
 
92
  }
93
 
94
+ // display custom admin notice
95
+ function ampforwp_permalink_update_notice() { ?>
96
+ <div class="notice notice-warning is-dismissible">
97
+ <p>
98
+ <?php _e( 'Congratulation, your site is fully AMP enabled. Update your permalink setting once and you are done.', 'ampforwp' ); ?>
99
+ <strong> <span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;"><a href="<?php echo admin_url( 'options-permalink.php'); ?>"><?php _e( 'Update Permalink', 'ampforwp' ); ?></a> | <a href="#"><?php _e( 'Dismiss', 'ampforwp' ); ?></a>
100
+ </span> </strong>
101
+ </p>
102
+ </div>
103
+ <?php }
104
+
105
  // Add Settings Button in Plugin backend
106
  if ( ! function_exists( 'ampforwp_plugin_settings_link' ) ) {
107
 
133
 
134
  } // is_admin() closing
135
 
136
+ // AMP endpoint Verifier
137
+ function ampforwp_is_amp_endpoint() {
138
+ return false !== get_query_var( 'amp', false );
139
+ }
140
+
141
  if ( ! class_exists( 'Ampforwp_Init', false ) ) {
142
  class Ampforwp_Init {
143
 
146
  // Load Files required for the plugin to run
147
  require AMPFORWP_PLUGIN_DIR .'/includes/includes.php';
148
 
149
+ // Redirection Code added
150
+ require AMPFORWP_PLUGIN_DIR.'/includes/redirect.php';
151
+
152
  require AMPFORWP_PLUGIN_DIR .'/classes/class-init.php';
153
  new Ampforwp_Loader;
154
 
164
  new Ampforwp_Init;
165
  }
166
  }
167
+ add_action('init','ampforwp_plugin_init',9);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/options/admin-config.php CHANGED
@@ -11,16 +11,16 @@ $opt_name = "redux_builder_amp";
11
  // All the possible arguments for Redux.
12
  //$amp_redux_header = '<span id="name"><span style="color: #4dbefa;">U</span>ltimate <span style="color: #4dbefa;">W</span>idgets</span>';
13
 
14
- $args = array(
15
  // TYPICAL -> Change these values as you need/desire
16
  'opt_name' => 'redux_builder_amp', // This is where your data is stored in the database and also becomes your global variable name.
17
  'display_name' => __( 'Accelerated Mobile Pages Options','ampforwp' ), // Name that appears at the top of your panel
18
  'menu_type' => 'menu', //Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only)
19
  'allow_sub_menu' => true, // Show the sections below the admin menu item or not
20
  'menu_title' => __( 'AMP', 'ampforwp' ),
21
- 'page_title' => 'Accelerated Mobile Pages Options',
22
  'display_version' => AMPFORWP_VERSION,
23
- 'update_notice' => false,
24
  'intro_text' => '<a href="https://wordpress.org/support/plugin/accelerated-mobile-pages" target="_blank">Need Help? Support Forum</a> | <a href="https://wordpress.org/plugins/accelerated-mobile-pages/faq/" target="_blank">FAQ</a> | <a href="https://wordpress.org/plugins/accelerated-mobile-pages/changelog/" target="_blank">Change Log</a> | <a href="https://wordpress.org/support/view/plugin-reviews/accelerated-mobile-pages" target="_blank">Reviews</a>| <a href="https://www.paypal.me/Kaludi/5" target="_blank">Donate</a>',
25
  'global_variable' => '', // Set a different name for your global variable other than the opt_name
26
  'dev_mode' => false, // Show the time the page took to load, etc
@@ -139,6 +139,7 @@ Redux::setArgs( "redux_builder_amp", $args );
139
  'id' => 'opt-text-subsection',
140
  'subsection' => true,
141
  'fields' => array(
 
142
  array(
143
  'id' => 'opt-media',
144
  'type' => 'media',
@@ -148,16 +149,6 @@ Redux::setArgs( "redux_builder_amp", $args );
148
  'desc' => __('Recommend logo size is: 190x36', 'redux-framework-demo')
149
  ),
150
 
151
- array(
152
- 'id' => 'amp-mobile-redirection',
153
- 'type' => 'switch',
154
- 'title' => __('Mobile Redirection', 'redux-framework-demo'),
155
- 'subtitle' => __('
156
- Enable AMP for your mobile users. Give your visitors a Faster mobile User Experience.','ampforwp'),
157
- 'default' => 0,
158
-
159
- ),
160
-
161
  array(
162
  'id' => 'amp-analytics-select-option',
163
  'type' => 'select',
@@ -168,13 +159,13 @@ Redux::setArgs( "redux_builder_amp", $args );
168
  '2' => __('Segment Analytics', 'redux-framework-demo' ),
169
  '3' => __('Piwik Analytics', 'redux-framework-demo' )
170
  ),
171
- 'default' => '1'
172
  ),
173
  array(
174
  'id' => 'ga-feild',
175
  'type' => 'text',
176
  'title' => __( 'Google Analytics', 'redux-framework-demo' ),
177
- 'required' => array('amp-analytics-select-option', '=' , '1'),
178
  'subtitle' => __( 'Enter your Google Analytics ID.', 'redux-framework-demo' ),
179
  'desc' => __('Example: UA-XXXXX-Y', 'redux-framework-demo' ),
180
  'default' => 'UA-XXXXX-Y',
@@ -191,12 +182,11 @@ Redux::setArgs( "redux_builder_amp", $args );
191
  'id' => 'pa-feild',
192
  'type' => 'text',
193
  'title' => __( 'Piwik Analytics', 'redux-framework-demo' ),
194
- 'required' => array('amp-analytics-select-option', '=' , '3'),
195
  'desc' => __( 'Example: https://piwik.example.org/piwik.php?idsite=YOUR_SITE_ID&rec=1&action_name=TITLE&urlref=DOCUMENT_REFERRER&url=CANONICAL_URL&rand=RANDOM', 'redux-framework-demo' ),
196
  'subtitle' => __('Enter your Piwik Analytics URL.', 'redux-framework-demo' ),
197
  'default' => '#',
198
  ),
199
-
200
  array(
201
  'id' =>'amp-frontpage-select-option',
202
  'type' => 'switch',
@@ -248,15 +238,6 @@ Redux::setArgs( "redux_builder_amp", $args );
248
  'default' => 1
249
  ),
250
 
251
- array(
252
- 'id' =>'amp-rtl-select-option',
253
- 'type' => 'switch',
254
- 'title' => __('RTL Support', 'redux-framework-demo'),
255
- 'default' => 0,
256
- 'subtitle' => __('Enable Right to Left language support', 'redux-framework-demo'),
257
- 'true' => 'true',
258
- 'false' => 'false',
259
- ),
260
  // array(
261
  // 'id' => 'amp-navigation-text',
262
  // 'title' => __('Navigation Text', 'redux-framework-demo'),
@@ -274,13 +255,6 @@ Redux::setArgs( "redux_builder_amp", $args );
274
  'default' => 1,
275
  'desc' => __( 'Re-Save permalink if you make changes in this option', 'redux-framework-demo' ),
276
  ),
277
- array(
278
- 'id' =>'amp-on-off-support-for-non-amp-home-page',
279
- 'type' => 'switch',
280
- 'title' => __('Non-AMP HomePage link in Header and Logo', 'redux-framework-demo'),
281
- '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'),
282
- 'default' => 0,
283
- ),
284
 
285
  // array(
286
  // 'id' => 'amp-ad-places',
@@ -302,7 +276,7 @@ Redux::setArgs( "redux_builder_amp", $args );
302
  Redux::setSection( $opt_name, array(
303
  'title' => __( 'Design', 'redux-framework-demo' ),
304
  'desc' => __( '
305
- <br /><a href="' . esc_url(admin_url('customize.php?autofocus[section]=amp_design&customize_amp=1')) .'" target="_blank"><img class="ampforwp-post-builder-img" src="'.AMPFORWP_IMAGE_DIR . '/amp-post-builder.png" width="489" height="72" /></a>
306
  '),
307
  'id' => 'amp-design',
308
  'subsection' => true,
@@ -336,8 +310,6 @@ Redux::setArgs( "redux_builder_amp", $args );
336
 
337
  );
338
 
339
-
340
-
341
  // SEO SECTION
342
  Redux::setSection( $opt_name, array(
343
  'title' => __( 'SEO', 'redux-framework-demo' ),
@@ -588,7 +560,7 @@ Redux::setArgs( "redux_builder_amp", $args );
588
  // Ad 4 ends
589
  ),
590
  ) );
591
-
592
 
593
  // Single Section
594
  Redux::setSection( $opt_name, array(
@@ -751,7 +723,7 @@ Redux::setArgs( "redux_builder_amp", $args );
751
  'type' => 'text',
752
  'placeholder' => '550',
753
  'subtitle' => 'Please don\'t add "PX" in the image size.',
754
- 'default' => ''
755
  ),
756
  array(
757
  'id' => 'amp-structured-data-placeholder-image-height',
@@ -759,7 +731,7 @@ Redux::setArgs( "redux_builder_amp", $args );
759
  'type' => 'text',
760
  'placeholder' => '350',
761
  'subtitle' => 'Please don\'t add "PX" in the image size.',
762
- 'default' => ''
763
  ),
764
  )
765
  ) );
@@ -953,18 +925,59 @@ Redux::setArgs( "redux_builder_amp", $args );
953
  //
954
 
955
 
956
- // // Advance Settings SECTION
957
- // Redux::setSection( $opt_name, array(
958
- // 'title' => __( 'Advance Settings', 'redux-framework-demo' ),
959
- // 'desc' => __( 'This section has Advance settings'),
960
- // 'id' => 'amp-advance',
961
- // 'subsection' => true,
962
- // 'fields' => array(
963
- //
964
- // ),
965
- //
966
- // ) );
967
- //
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
968
 
969
  // Extension Section
970
  Redux::setSection( $opt_name, array(
11
  // All the possible arguments for Redux.
12
  //$amp_redux_header = '<span id="name"><span style="color: #4dbefa;">U</span>ltimate <span style="color: #4dbefa;">W</span>idgets</span>';
13
 
14
+ $args = array(
15
  // TYPICAL -> Change these values as you need/desire
16
  'opt_name' => 'redux_builder_amp', // This is where your data is stored in the database and also becomes your global variable name.
17
  'display_name' => __( 'Accelerated Mobile Pages Options','ampforwp' ), // Name that appears at the top of your panel
18
  'menu_type' => 'menu', //Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only)
19
  'allow_sub_menu' => true, // Show the sections below the admin menu item or not
20
  'menu_title' => __( 'AMP', 'ampforwp' ),
21
+ 'page_title' => 'Accelerated Mobile Pages Options',
22
  'display_version' => AMPFORWP_VERSION,
23
+ 'update_notice' => false,
24
  'intro_text' => '<a href="https://wordpress.org/support/plugin/accelerated-mobile-pages" target="_blank">Need Help? Support Forum</a> | <a href="https://wordpress.org/plugins/accelerated-mobile-pages/faq/" target="_blank">FAQ</a> | <a href="https://wordpress.org/plugins/accelerated-mobile-pages/changelog/" target="_blank">Change Log</a> | <a href="https://wordpress.org/support/view/plugin-reviews/accelerated-mobile-pages" target="_blank">Reviews</a>| <a href="https://www.paypal.me/Kaludi/5" target="_blank">Donate</a>',
25
  'global_variable' => '', // Set a different name for your global variable other than the opt_name
26
  'dev_mode' => false, // Show the time the page took to load, etc
139
  'id' => 'opt-text-subsection',
140
  'subsection' => true,
141
  'fields' => array(
142
+
143
  array(
144
  'id' => 'opt-media',
145
  'type' => 'media',
149
  'desc' => __('Recommend logo size is: 190x36', 'redux-framework-demo')
150
  ),
151
 
 
 
 
 
 
 
 
 
 
 
152
  array(
153
  'id' => 'amp-analytics-select-option',
154
  'type' => 'select',
159
  '2' => __('Segment Analytics', 'redux-framework-demo' ),
160
  '3' => __('Piwik Analytics', 'redux-framework-demo' )
161
  ),
162
+ 'default' => '1',
163
  ),
164
  array(
165
  'id' => 'ga-feild',
166
  'type' => 'text',
167
  'title' => __( 'Google Analytics', 'redux-framework-demo' ),
168
+ 'required' => array('amp-analytics-select-option', '=' , '1'),
169
  'subtitle' => __( 'Enter your Google Analytics ID.', 'redux-framework-demo' ),
170
  'desc' => __('Example: UA-XXXXX-Y', 'redux-framework-demo' ),
171
  'default' => 'UA-XXXXX-Y',
182
  'id' => 'pa-feild',
183
  'type' => 'text',
184
  'title' => __( 'Piwik Analytics', 'redux-framework-demo' ),
185
+ 'required' =>array('amp-analytics-select-option', '=' , '3'),
186
  'desc' => __( 'Example: https://piwik.example.org/piwik.php?idsite=YOUR_SITE_ID&rec=1&action_name=TITLE&urlref=DOCUMENT_REFERRER&url=CANONICAL_URL&rand=RANDOM', 'redux-framework-demo' ),
187
  'subtitle' => __('Enter your Piwik Analytics URL.', 'redux-framework-demo' ),
188
  'default' => '#',
189
  ),
 
190
  array(
191
  'id' =>'amp-frontpage-select-option',
192
  'type' => 'switch',
238
  'default' => 1
239
  ),
240
 
 
 
 
 
 
 
 
 
 
241
  // array(
242
  // 'id' => 'amp-navigation-text',
243
  // 'title' => __('Navigation Text', 'redux-framework-demo'),
255
  'default' => 1,
256
  'desc' => __( 'Re-Save permalink if you make changes in this option', 'redux-framework-demo' ),
257
  ),
 
 
 
 
 
 
 
258
 
259
  // array(
260
  // 'id' => 'amp-ad-places',
276
  Redux::setSection( $opt_name, array(
277
  'title' => __( 'Design', 'redux-framework-demo' ),
278
  'desc' => __( '
279
+ <br /><a href="' . esc_url(admin_url('customize.php?autofocus[section]=amp_design&customize_amp=1')) .'" target="_blank"><img class="ampforwp-post-builder-img" src="'.AMPFORWP_IMAGE_DIR . '/amp-post-builder.png" width="489" height="72" /></a>
280
  '),
281
  'id' => 'amp-design',
282
  'subsection' => true,
310
 
311
  );
312
 
 
 
313
  // SEO SECTION
314
  Redux::setSection( $opt_name, array(
315
  'title' => __( 'SEO', 'redux-framework-demo' ),
560
  // Ad 4 ends
561
  ),
562
  ) );
563
+
564
 
565
  // Single Section
566
  Redux::setSection( $opt_name, array(
723
  'type' => 'text',
724
  'placeholder' => '550',
725
  'subtitle' => 'Please don\'t add "PX" in the image size.',
726
+ 'default' => '700'
727
  ),
728
  array(
729
  'id' => 'amp-structured-data-placeholder-image-height',
731
  'type' => 'text',
732
  'placeholder' => '350',
733
  'subtitle' => 'Please don\'t add "PX" in the image size.',
734
+ 'default' => '550'
735
  ),
736
  )
737
  ) );
925
  //
926
 
927
 
928
+ // Advance Settings SECTION
929
+ Redux::setSection( $opt_name, array(
930
+ 'title' => __( 'Advanced', 'redux-framework-demo' ),
931
+ 'desc' => __( 'This section has Advance settings'),
932
+ 'id' => 'amp-advance',
933
+ 'subsection' => true,
934
+ 'fields' => array(
935
+
936
+ array(
937
+ 'id' => 'ampforwp-homepage-on-off-support',
938
+ 'type' => 'switch',
939
+ 'title' => __('Homepage Support', 'redux-framework-demo'),
940
+ 'subtitle' => __('Enable/Disable Home page using this switch.', 'redux-framework-demo'),
941
+ 'default' => '1'
942
+ ),
943
+ array(
944
+ 'id' => 'ampforwp-archive-support',
945
+ 'type' => 'switch',
946
+ 'title' => __('Archive page Support', 'redux-framework-demo'),
947
+ 'subtitle' => __('Enable/Disable Archive pages using this switch.', 'redux-framework-demo'),
948
+ 'default' => '0'
949
+ ),
950
+
951
+ array(
952
+ 'id' => 'amp-mobile-redirection',
953
+ 'type' => 'switch',
954
+ 'title' => __('Mobile Redirection', 'redux-framework-demo'),
955
+ 'subtitle' => __('
956
+ Enable AMP for your mobile users. Give your visitors a Faster mobile User Experience.','ampforwp'),
957
+ 'default' => 0,
958
+
959
+ ),
960
+ array(
961
+ 'id' =>'amp-on-off-support-for-non-amp-home-page',
962
+ 'type' => 'switch',
963
+ 'title' => __('Non-AMP HomePage link in Header and Logo', 'redux-framework-demo'),
964
+ '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'),
965
+ 'default' => 0,
966
+ ),
967
+ array(
968
+ 'id' =>'amp-rtl-select-option',
969
+ 'type' => 'switch',
970
+ 'title' => __('RTL Support', 'redux-framework-demo'),
971
+ 'default' => 0,
972
+ 'subtitle' => __('Enable Right to Left language support', 'redux-framework-demo'),
973
+ 'true' => 'true',
974
+ 'false' => 'false',
975
+ ),
976
+
977
+ ),
978
+
979
+ ) );
980
+
981
 
982
  // Extension Section
983
  Redux::setSection( $opt_name, array(
includes/redirect.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Redirection for Homepage and Archive Pages when Turned Off from options panel
3
+ function ampforwp_check_amp_page_status() {
4
+ global $redux_builder_amp;
5
+
6
+ if ( ampforwp_is_amp_endpoint() ) {
7
+ if ( is_home() || is_archive() ) {
8
+
9
+ if ( is_home() && $redux_builder_amp['ampforwp-homepage-on-off-support'] == 0 ) {
10
+ $redirection_location = get_home_url();
11
+ wp_safe_redirect( $redirection_location );
12
+ exit;
13
+ }
14
+
15
+ if (is_archive() && $redux_builder_amp['ampforwp-archive-support'] == 0 ) {
16
+ global $wp;
17
+ $redirection_location = add_query_arg( '', '', home_url( $wp->request ) );
18
+ $redirection_location = trailingslashit($redirection_location );
19
+ $redirection_location = dirname($redirection_location);
20
+ wp_safe_redirect( $redirection_location );
21
+ exit;
22
+ }
23
+ }
24
+ }
25
+ }
26
+ add_action( 'template_redirect', 'ampforwp_check_amp_page_status', 10 );
27
+
28
+
29
+ function ampforwp_page_template_redirect() {
30
+ global $redux_builder_amp;
31
+
32
+ if($redux_builder_amp['amp-mobile-redirection']){
33
+
34
+ session_start();
35
+ if( $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_SESSION['ampforwp_mobile']=='exit'){
36
+ return;
37
+ }
38
+ if( wp_is_mobile() && $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_GET['nonamp']==1){
39
+ // non mobile session variable creation
40
+ session_start();
41
+ $_SESSION['ampforwp_mobile']='exit';
42
+ if ( ampforwp_is_amp_endpoint() ) {
43
+ session_destroy();
44
+ }
45
+ }
46
+
47
+ if ( wp_is_mobile() ) {
48
+ if ( ampforwp_is_amp_endpoint() ) {
49
+ return;
50
+ } else {
51
+ if( !isset($_SESSION['ampforwp_amp_mode']) || !isset($_GET['nonamp']) ) {
52
+ $_SESSION['ampforwp_amp_mode']='mobile-on';
53
+ if ( is_home() ) {
54
+ wp_redirect( trailingslashit( esc_url( home_url() ) ) . AMP_QUERY_VAR , 301 );
55
+ exit();
56
+ }
57
+ elseif ( is_archive() ) {
58
+ global $wp;
59
+ $current_archive_url = home_url( $wp->request );
60
+ wp_redirect( trailingslashit( esc_url( $current_archive_url ) ) . AMP_QUERY_VAR , 301 );
61
+ exit();
62
+ } else {
63
+ wp_redirect( trailingslashit( esc_url( ( get_permalink( $id ) ) ) ) . AMP_QUERY_VAR , 301 );
64
+ exit();
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ }
71
+ }
72
+ add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
73
+
74
+
75
+ add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
76
+ function ampforwp_page_template_redirect_archive() {
77
+
78
+ if ( is_404() ) {
79
+ if( ampforwp_is_amp_endpoint() ) {
80
+ global $wp;
81
+ $ampforwp_404_url = add_query_arg( '', '', home_url( $wp->request ) );
82
+ $ampforwp_404_url = trailingslashit($ampforwp_404_url );
83
+ $ampforwp_404_url = dirname($ampforwp_404_url);
84
+ wp_redirect( esc_url( $ampforwp_404_url ) , 301 );
85
+ exit();
86
+ }
87
+ }
88
+ }
89
+
90
+ // Add Custom Rewrite Rule to make sure pagination & redirection is working correctly
91
+ function ampforwp_add_custom_rewrite_rules() {
92
+ // For Homepage
93
+ add_rewrite_rule(
94
+ 'amp/?$',
95
+ 'index.php?amp',
96
+ 'top'
97
+ );
98
+ // For Homepage with Pagination
99
+ add_rewrite_rule(
100
+ 'amp/page/([0-9]{1,})/?$',
101
+ 'index.php?amp&paged=$matches[1]',
102
+ 'top'
103
+ );
104
+ // For category pages
105
+ add_rewrite_rule(
106
+ 'category\/(.+?)\/amp/?$',
107
+ 'index.php?amp&category_name=$matches[1]',
108
+ 'top'
109
+ );
110
+ // For category pages with Pagination
111
+ add_rewrite_rule(
112
+ 'category\/(.+?)\/amp\/page\/?([0-9]{1,})\/?$',
113
+ 'index.php?amp&category_name=$matches[1]&paged=$matches[2]',
114
+ 'top'
115
+ );
116
+ // For tag pages
117
+ add_rewrite_rule(
118
+ 'tag\/(.+?)\/amp/?$',
119
+ 'index.php?amp&tag=$matches[1]',
120
+ 'top'
121
+ );
122
+ // For tag pages with Pagination
123
+ add_rewrite_rule(
124
+ 'tag\/(.+?)\/amp\/page\/?([0-9]{1,})\/?$',
125
+ 'index.php?amp&tag=$matches[1]&paged=$matches[2]',
126
+ 'top'
127
+ );
128
+
129
+ }
130
+ add_action( 'init', 'ampforwp_add_custom_rewrite_rules' );
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.36.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -29,6 +29,7 @@ Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on
29
 
30
  = Features: =
31
 
 
32
  * NEW - Custom AMP Editor - Which allows you to override your Content that you had written in Post or page, so you can add the different content just for AMP.
33
  * 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.
34
  * NEW - Custom Post Type Support
@@ -122,6 +123,29 @@ You can contact me using this url: http://ampforwp.com/contact/
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  = 0.9.36 =
126
  * Full details at https://ampforwp.com/0-9-36-released-stability-update-43rd-update/
127
  * Redux Core Update. Better compatibility with the Salient theme and Themeforest themes & plugins using redux framework in their core, which makes the plugin much stable. [Huge Improvements]
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.37
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
29
 
30
  = Features: =
31
 
32
+ * NEW - Page, Category & Tags Support Added
33
  * NEW - Custom AMP Editor - Which allows you to override your Content that you had written in Post or page, so you can add the different content just for AMP.
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 - Custom Post Type Support
123
 
124
  == Changelog ==
125
 
126
+ = 0.9.37 =
127
+ * View full details at https://ampforwp.com/category-tags-archive-support-added/
128
+ * Debug issues solved [Bug fix]
129
+ * Remove Extra styling added by other Themes/ Plugins [3rd party themes and plugin Support]
130
+ * Category, Tags & Archive Support with titles added [Enchancement]
131
+ * Archive Title support added [Enchancement]
132
+ * There were some issues with attachments [Bug fix]
133
+ * removed ? from amp url's [Improvement]
134
+ * Mobile redirection for Archives added and 404 redirections removed for archives [Improvement]
135
+ * View non-amp version now properly redirects to the normal version. #415 [Bug fix]
136
+ * Added an option to turn off AMP support for Homepage. [Enchancement]
137
+ * Too many redirects issue on homepage is fixed #435 [Improvement]
138
+ * Spell check and G tags are removed for thrive & Spell check compatibility [Better Validation]
139
+ * If image is not available in gravatar fixed, it was throwing an error #365 #327 [Improvement]
140
+ * Comment anchor link changed for simplecomment button files in both designs [Improvement]
141
+ * Redirection Loop issue fixed [Bug fix]
142
+ * Shortcodes were visible in excerpt, it's fixed now. [Improvement]
143
+ * Defer onload by other plugins was causing issues #431 [Better Validation & 3rd party support]
144
+ * Improved Sessions [Improvement]
145
+ * Advnaced Settings panel was created for better user experience. [Improvement]
146
+ * Spell check tag was causing validation issues. [Better Validation & 3rd party support]
147
+ * RTL issue fixed #454 [Bug fixed]
148
+
149
  = 0.9.36 =
150
  * Full details at https://ampforwp.com/0-9-36-released-stability-update-43rd-update/
151
  * Redux Core Update. Better compatibility with the Salient theme and Themeforest themes & plugins using redux framework in their core, which makes the plugin much stable. [Huge Improvements]
templates/custom-amp-content.php CHANGED
@@ -8,9 +8,9 @@ function ampforwp_custom_post_content_sanitizer( $data, $post ) {
8
 
9
  if( is_home() && $redux_builder_amp['amp-frontpage-select-option'] == 0 ){
10
  return $data;
11
- }
12
 
13
-
14
  $amp_custom_post_content_input = get_post_meta($post->ID, 'ampforwp_custom_content_editor', true);
15
  $amp_custom_post_content_check = get_post_meta($post->ID, 'ampforwp_custom_content_editor_checkbox', true);
16
 
@@ -19,7 +19,7 @@ function ampforwp_custom_post_content_sanitizer( $data, $post ) {
19
  return $data;
20
  }
21
 
22
- if ( $amp_custom_post_content_check === 'yes') {
23
 
24
  $amp_custom_content = new AMP_Content( $amp_custom_post_content_input,
25
  apply_filters( 'amp_content_embed_handlers', array(
8
 
9
  if( is_home() && $redux_builder_amp['amp-frontpage-select-option'] == 0 ){
10
  return $data;
11
+ }
12
 
13
+ global $post;
14
  $amp_custom_post_content_input = get_post_meta($post->ID, 'ampforwp_custom_content_editor', true);
15
  $amp_custom_post_content_check = get_post_meta($post->ID, 'ampforwp_custom_content_editor_checkbox', true);
16
 
19
  return $data;
20
  }
21
 
22
+ if ( $amp_custom_post_content_check === 'yes') {
23
 
24
  $amp_custom_content = new AMP_Content( $amp_custom_post_content_input,
25
  apply_filters( 'amp_content_embed_handlers', array(
templates/design-manager/design-1/archive.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php global $redux_builder_amp; ?>
2
+ <!doctype html>
3
+ <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
+ <?php
8
+ global $redux_builder_amp;
9
+ if ( is_home() || is_front_page() || is_archive() ){
10
+ global $wp;
11
+ $current_archive_url = home_url( $wp->request );
12
+ $amp_url = trailingslashit($current_archive_url);
13
+ } ?>
14
+ <link rel="canonical" href="<?php echo $amp_url ?>">
15
+ <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
16
+ <?php do_action( 'amp_post_template_head', $this ); ?>
17
+ <style amp-custom>
18
+ <?php $this->load_parts( array( 'style' ) ); ?>
19
+ <?php do_action( 'amp_post_template_css', $this ); ?>
20
+ </style>
21
+ </head>
22
+
23
+ <body class="<?php echo esc_attr( $this->get( 'body_class' ) ); ?>">
24
+
25
+ <?php $this->load_parts( array( 'header-bar' ) ); ?>
26
+
27
+ <article class="amp-wp-article ampforwp-custom-index amp-wp-home">
28
+
29
+ <?php do_action('ampforwp_post_before_design_elements') ?>
30
+
31
+ <?php if ( is_archive() ) {
32
+ the_archive_title( '<h3 class="page-title">', '</h3>' );
33
+ the_archive_description( '<div class="taxonomy-description">', '</div>' );
34
+ } ?>
35
+
36
+ <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
37
+ <div class="amp-wp-content amp-wp-article-header amp-loop-list">
38
+
39
+ <h1 class="amp-wp-title">
40
+ <?php $ampforwp_post_url = get_permalink(); ?>
41
+ <a href="<?php echo trailingslashit($ampforwp_post_url) . AMP_QUERY_VAR ;?>"><?php the_title() ?></a>
42
+ </h1>
43
+
44
+ <div class="amp-wp-content-loop">
45
+ <div class="amp-wp-meta">
46
+ <?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-author', 'meta-time' ) ) ); ?>
47
+ </div>
48
+
49
+
50
+ <?php if ( has_post_thumbnail() ) { ?>
51
+ <?php
52
+ $thumb_id = get_post_thumbnail_id();
53
+ $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true);
54
+ $thumb_url = $thumb_url_array[0];
55
+ ?>
56
+ <div class="home-post-image">
57
+ <a href="<?php echo trailingslashit($ampforwp_post_url) . AMP_QUERY_VAR ;?>">
58
+ <amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img>
59
+ </a>
60
+ </div>
61
+ <?php }
62
+ if( has_excerpt() ){
63
+ $content = get_the_excerpt();
64
+ }else{
65
+ $content = get_the_content();
66
+ } ?>
67
+ <p><?php echo wp_trim_words( $content , '20'); ?></p>
68
+ </div>
69
+ </div>
70
+ <?php endwhile; ?>
71
+ <div class="amp-wp-content pagination-holder">
72
+
73
+ <div id="pagination">
74
+ <div class="next"><?php next_posts_link( $redux_builder_amp['amp-translator-next-text']. ' &raquo;', 0 ) ?></div>
75
+ <div class="prev"><?php previous_posts_link( '&laquo; '. $redux_builder_amp['amp-translator-previous-text'] ); ?></div>
76
+ <div class="clearfix"></div>
77
+ </div>
78
+
79
+ </div>
80
+ <?php endif; ?>
81
+
82
+ <?php do_action('ampforwp_post_after_design_elements') ?>
83
+
84
+ </article>
85
+
86
+ <?php $this->load_parts( array( 'footer' ) ); ?>
87
+
88
+ <?php do_action( 'amp_post_template_footer', $this ); ?>
89
+
90
+ </body>
91
+ </html>
templates/design-manager/design-1/elements/comments.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  if (!comments_open()) {
3
  return;
4
- }
5
  ?>
6
  <div class="ampforwp-comment-wrapper">
7
  <?php
@@ -65,7 +65,7 @@ if (!comments_open()) {
65
  </ul>
66
  </div>
67
  <div class="comment-button-wrapper">
68
- <a href="<?php echo get_permalink().'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
69
  </div>
70
  <?php } else {
71
  global $redux_builder_amp ;
@@ -73,7 +73,7 @@ if (!comments_open()) {
73
  return;
74
  } ?>
75
  <div class="comment-button-wrapper">
76
- <a href="<?php echo get_permalink().'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
77
  </div>
78
  <?php } ?>
79
  </div>
1
  <?php
2
  if (!comments_open()) {
3
  return;
4
+ }
5
  ?>
6
  <div class="ampforwp-comment-wrapper">
7
  <?php
65
  </ul>
66
  </div>
67
  <div class="comment-button-wrapper">
68
+ <a href="<?php echo get_permalink().'?nonamp=1'.'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
69
  </div>
70
  <?php } else {
71
  global $redux_builder_amp ;
73
  return;
74
  } ?>
75
  <div class="comment-button-wrapper">
76
+ <a href="<?php echo get_permalink().'?nonamp=1'.'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
77
  </div>
78
  <?php } ?>
79
  </div>
templates/design-manager/design-1/elements/meta-info.php CHANGED
@@ -3,16 +3,11 @@
3
  <?php $post_author = $this->get( 'post_author' ); ?>
4
  <?php
5
  if ( $post_author ) : ?>
6
- <?php
7
- $string = get_avatar($post_author->user_email);
8
- $token = strtok($string, " ");
9
- $token = strtok(" ");
10
- $token = strtok(" ");
11
- ?>
12
  <div class="amp-wp-meta amp-wp-byline">
13
- <?php if ( function_exists( 'get_avatar_url' ) ) : ?>
14
- <amp-img <?php echo $token; ?> width="24" height="24" layout="fixed"></amp-img>
15
- <?php endif; ?>
 
16
  <span class="amp-wp-author author vcard"><?php echo esc_html( $post_author->display_name ); ?></span>
17
  </div>
18
  <?php endif; ?>
3
  <?php $post_author = $this->get( 'post_author' ); ?>
4
  <?php
5
  if ( $post_author ) : ?>
 
 
 
 
 
 
6
  <div class="amp-wp-meta amp-wp-byline">
7
+ <?php if ( function_exists( 'get_avatar_url' ) && ( $author_image ) ) { ?>
8
+ <amp-img src="<?php echo esc_url($author_image); ?>" width="24" height="24" layout="fixed"></amp-img>
9
+ <?php }?>
10
+
11
  <span class="amp-wp-author author vcard"><?php echo esc_html( $post_author->display_name ); ?></span>
12
  </div>
13
  <?php endif; ?>
templates/design-manager/design-1/elements/simple-comment-button.php CHANGED
@@ -2,5 +2,5 @@
2
  global $redux_builder_amp ; ?>
3
  <?php if( !comments_open() ) { return; } ?>
4
  <div class="comment-button-wrapper ampforwp-comment-button">
5
- <a href="<?php echo get_permalink().'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
6
  </div>
2
  global $redux_builder_amp ; ?>
3
  <?php if( !comments_open() ) { return; } ?>
4
  <div class="comment-button-wrapper ampforwp-comment-button">
5
+ <a href="<?php echo get_permalink().'?nonamp=1'.'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
6
  </div>
templates/design-manager/design-1/footer.php CHANGED
@@ -4,15 +4,15 @@ global $redux_builder_amp;
4
 
5
  $ampforwp_backto_nonamp = '';
6
  if ( is_home() ) {
7
- $ampforwp_backto_nonamp = home_url();
8
  }
9
  if ( is_single() ){
10
  global $post;
11
- $ampforwp_backto_nonamp = get_permalink( $post->ID );
12
  }
13
  if( is_archive() ) {
14
  global $wp;
15
- $ampforwp_backto_nonamp = esc_url( home_url( $wp->request ) );
16
  }
17
  ?>
18
  <footer class="amp-wp-footer">
4
 
5
  $ampforwp_backto_nonamp = '';
6
  if ( is_home() ) {
7
+ $ampforwp_backto_nonamp = untrailingslashit(home_url()).'?nonamp=1' ;
8
  }
9
  if ( is_single() ){
10
  global $post;
11
+ $ampforwp_backto_nonamp = untrailingslashit(get_permalink( $post->ID )).'?nonamp=1' ;
12
  }
13
  if( is_archive() ) {
14
  global $wp;
15
+ $ampforwp_backto_nonamp = esc_url( untrailingslashit(home_url( $wp->request )).'?nonamp=1' );
16
  }
17
  ?>
18
  <footer class="amp-wp-footer">
templates/design-manager/design-1/header-bar.php CHANGED
@@ -4,11 +4,11 @@
4
  <?php
5
  if($redux_builder_amp['amp-on-off-support-for-non-amp-home-page']){
6
  ?>
7
- <a href="<?php echo esc_url( trailingslashit( $this->get( 'home_url' ) ) ); ?>">
8
  <?php
9
  }else{
10
  ?>
11
- <a href="<?php echo esc_url( trailingslashit( $this->get( 'home_url' ) ) ) . '?' .AMP_QUERY_VAR; ?>">
12
 
13
  <?php }?>
14
 
@@ -24,7 +24,7 @@
24
  ?>
25
  <a href="<?php echo esc_url( $this->get( 'home_url' ) ); ?>">
26
  <?php }else{ ?>
27
- <a href="<?php echo esc_url( trailingslashit( $this->get( 'home_url' ) ) ) . '?' .AMP_QUERY_VAR; ?>">
28
  <?php } ?>
29
  <?php $site_icon_url = $this->get( 'site_icon_url' );
30
  if ( $site_icon_url ) : ?>
@@ -53,5 +53,4 @@
53
  </amp-sidebar>
54
 
55
  <?php
56
-
57
- do_action('ampforwp_design_1_after_header');
4
  <?php
5
  if($redux_builder_amp['amp-on-off-support-for-non-amp-home-page']){
6
  ?>
7
+ <a href="<?php echo esc_url( untrailingslashit( $this->get( 'home_url' ) ).'?nonamp=1'); ?>">
8
  <?php
9
  }else{
10
  ?>
11
+ <a href="<?php echo esc_url( trailingslashit( $this->get( 'home_url' ) ) ) . AMP_QUERY_VAR; ?>">
12
 
13
  <?php }?>
14
 
24
  ?>
25
  <a href="<?php echo esc_url( $this->get( 'home_url' ) ); ?>">
26
  <?php }else{ ?>
27
+ <a href="<?php echo esc_url( trailingslashit( $this->get( 'home_url' ) ) ) . AMP_QUERY_VAR; ?>">
28
  <?php } ?>
29
  <?php $site_icon_url = $this->get( 'site_icon_url' );
30
  if ( $site_icon_url ) : ?>
53
  </amp-sidebar>
54
 
55
  <?php
56
+ do_action('ampforwp_design_1_after_header');
 
templates/design-manager/design-1/index.php CHANGED
@@ -6,7 +6,7 @@
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
8
  global $redux_builder_amp;
9
- if ( is_home() || is_front_page() ){
10
  global $wp;
11
  $current_archive_url = home_url( $wp->request );
12
  $amp_url = trailingslashit($current_archive_url);
@@ -37,12 +37,11 @@ if ( is_home() || is_front_page() ){
37
  $paged = 1;
38
  }
39
 
40
- $exclude_ids = get_option('ampforwp_exclude_post');
41
 
42
  $q = new WP_Query( array(
43
  'post_type' => 'post',
44
- 'orderby' => 'date',
45
- 'offset' => esc_attr($fn_offset),
46
  'ignore_sticky_posts' => 1,
47
  'paged' => esc_attr($paged),
48
  'post__not_in' => $exclude_ids
@@ -72,13 +71,13 @@ if ( is_home() || is_front_page() ){
72
  <amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img>
73
  </a>
74
  </div>
75
- <?php }
76
  if(has_excerpt()){
77
  $content = get_the_excerpt();
78
  }else{
79
  $content = get_the_content();
80
  } ?>
81
- <p><?php echo wp_trim_words( $content , '20'); ?></p>
82
  </div>
83
  </div>
84
  <?php endwhile; ?>
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
8
  global $redux_builder_amp;
9
+ if ( is_home() || is_front_page() || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ){
10
  global $wp;
11
  $current_archive_url = home_url( $wp->request );
12
  $amp_url = trailingslashit($current_archive_url);
37
  $paged = 1;
38
  }
39
 
40
+ $exclude_ids = get_option('ampforwp_exclude_post');
41
 
42
  $q = new WP_Query( array(
43
  'post_type' => 'post',
44
+ 'orderby' => 'date',
 
45
  'ignore_sticky_posts' => 1,
46
  'paged' => esc_attr($paged),
47
  'post__not_in' => $exclude_ids
71
  <amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img>
72
  </a>
73
  </div>
74
+ <?php }
75
  if(has_excerpt()){
76
  $content = get_the_excerpt();
77
  }else{
78
  $content = get_the_content();
79
  } ?>
80
+ <p><?php echo wp_trim_words( strip_shortcodes( $content ) , '20' ); ?></p>
81
  </div>
82
  </div>
83
  <?php endwhile; ?>
templates/design-manager/design-1/style.php CHANGED
@@ -305,6 +305,9 @@ amp-carousel > amp-img > img {
305
  -webkit-transition: background-color 0.2s ease;
306
  transition: background-color 0.2s ease;
307
  }
 
 
 
308
  /* AMP Footer */
309
  .amp-wp-footer {
310
  border-top: 1px solid <?php echo sanitize_hex_color( $border_color ); ?>;
305
  -webkit-transition: background-color 0.2s ease;
306
  transition: background-color 0.2s ease;
307
  }
308
+ .page-title {
309
+ margin: 0 15px;
310
+ }
311
  /* AMP Footer */
312
  .amp-wp-footer {
313
  border-top: 1px solid <?php echo sanitize_hex_color( $border_color ); ?>;
templates/design-manager/design-2/archive.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php global $redux_builder_amp; ?>
2
+ <!doctype html>
3
+ <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
+ <?php
8
+ global $redux_builder_amp;
9
+ if ( is_home() || is_front_page() || is_archive() ){
10
+ global $wp;
11
+ $current_archive_url = home_url( $wp->request );
12
+ $amp_url = trailingslashit($current_archive_url);
13
+ } ?>
14
+ <link rel="canonical" href="<?php echo $amp_url ?>">
15
+ <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
16
+ <?php do_action( 'amp_post_template_head', $this ); ?>
17
+
18
+ <style amp-custom>
19
+ <?php $this->load_parts( array( 'style' ) ); ?>
20
+ <?php do_action( 'amp_post_template_css', $this ); ?>
21
+ </style>
22
+ </head>
23
+ <body class="amp_home_body">
24
+ <?php $this->load_parts( array( 'header-bar' ) ); ?>
25
+
26
+ <?php do_action( 'ampforwp_after_header', $this ); ?>
27
+
28
+ <main>
29
+
30
+ <?php if ( is_archive() ) { ?>
31
+ <div class="amp-wp-content amp-archive-heading">
32
+ <?php
33
+ the_archive_title( '<h3 class="page-title">', '</h3>' );
34
+ the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?>
35
+ </div>
36
+ <?php
37
+ } ?>
38
+
39
+ <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
40
+ $ampforwp_amp_post_url = trailingslashit( get_permalink() ) . AMP_QUERY_VAR ; ?>
41
+
42
+ <div class="amp-wp-content amp-loop-list">
43
+ <?php if ( has_post_thumbnail() ) { ?>
44
+ <?php
45
+ $thumb_id = get_post_thumbnail_id();
46
+ $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true);
47
+ $thumb_url = $thumb_url_array[0];
48
+ ?>
49
+ <div class="home-post_image"><a href="<?php echo esc_url( $ampforwp_amp_post_url ); ?>"><amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img></a></div>
50
+ <?php } ?>
51
+
52
+ <div class="amp-wp-post-content">
53
+
54
+ <h2 class="amp-wp-title"> <a href="<?php echo esc_url( $ampforwp_amp_post_url ); ?>"> <?php the_title(); ?></a></h2>
55
+
56
+ <?php
57
+ if(has_excerpt()){
58
+ $content = get_the_excerpt();
59
+ }else{
60
+ $content = get_the_content();
61
+ }
62
+ ?>
63
+ <p><?php echo wp_trim_words( $content , '15' ); ?></p>
64
+
65
+ </div>
66
+ <div class="cb"></div>
67
+ </div>
68
+
69
+ <?php endwhile; ?>
70
+
71
+ <div class="amp-wp-content pagination-holder">
72
+
73
+ <div id="pagination">
74
+ <div class="next"><?php next_posts_link( $redux_builder_amp['amp-translator-next-text'] . ' &raquo;', 0 ) ?></div>
75
+ <div class="prev"><?php previous_posts_link( '&laquo; '. $redux_builder_amp['amp-translator-previous-text'] ); ?></div>
76
+
77
+ <div class="clearfix"></div>
78
+ </div>
79
+ </div>
80
+
81
+ <?php endif; ?>
82
+ </main>
83
+ <?php $this->load_parts( array( 'footer' ) ); ?>
84
+ <?php do_action( 'amp_post_template_footer', $this ); ?>
85
+ </body>
86
+
87
+ </html>
templates/design-manager/design-2/elements/comments.php CHANGED
@@ -65,7 +65,7 @@ if (!comments_open()) {
65
  </ul>
66
  </div>
67
  <div class="comment-button-wrapper">
68
- <a href="<?php echo get_permalink().'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
69
  </div><?php
70
  } else {
71
  global $redux_builder_amp ;
@@ -73,7 +73,7 @@ if (!comments_open()) {
73
  return;
74
  } ?>
75
  <div class="comment-button-wrapper">
76
- <a href="<?php echo get_permalink().'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
77
  </div>
78
  <?php } ?>
79
  </div>
65
  </ul>
66
  </div>
67
  <div class="comment-button-wrapper">
68
+ <a href="<?php echo get_permalink().'?nonamp=1'.'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
69
  </div><?php
70
  } else {
71
  global $redux_builder_amp ;
73
  return;
74
  } ?>
75
  <div class="comment-button-wrapper">
76
+ <a href="<?php echo get_permalink().'?nonamp=1'.'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
77
  </div>
78
  <?php } ?>
79
  </div>
templates/design-manager/design-2/elements/simple-comment-button.php CHANGED
@@ -2,5 +2,5 @@
2
  global $redux_builder_amp ; ?>
3
  <?php if( !comments_open() ) { return; } ?>
4
  <div class="comment-button-wrapper ampforwp-comment-button">
5
- <a href="<?php echo get_permalink().'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
6
  </div>
2
  global $redux_builder_amp ; ?>
3
  <?php if( !comments_open() ) { return; } ?>
4
  <div class="comment-button-wrapper ampforwp-comment-button">
5
+ <a href="<?php echo get_permalink().'?nonamp=1'.'#commentform' ?>"><?php esc_html_e( $redux_builder_amp['amp-translator-leave-a-comment-text'] ); ?></a>
6
  </div>
templates/design-manager/design-2/footer.php CHANGED
@@ -3,28 +3,28 @@
3
 
4
  $ampforwp_backto_nonamp = " ";
5
  if ( is_home() ) {
6
- $ampforwp_backto_nonamp = home_url();
7
  }
8
  if ( is_single() ){
9
  global $post;
10
- $ampforwp_backto_nonamp = get_permalink( $post->ID );
11
  }
12
  if ( is_page() ){
13
  global $post;
14
- $ampforwp_backto_nonamp = get_permalink( $post->ID );
15
  }
16
  if( is_archive() ) {
17
  global $wp;
18
- $ampforwp_backto_nonamp = esc_url( home_url( $wp->request ) );
19
  }
20
  ?>
21
  <footer class="container">
22
  <div id="footer">
23
  <p><a href="#header"> <?php echo esc_html( $redux_builder_amp['amp-translator-top-text'] ); ?></a> <?php
24
  //24. Added an options button for switching on/off link to non amp page
25
- if($redux_builder_amp['amp-footer-link-non-amp-page']=='1'){ if ( $ampforwp_backto_nonamp ) { ?>
26
- |
27
- <a href="<?php echo $ampforwp_backto_nonamp; ?>"><?php echo esc_html( $redux_builder_amp['amp-translator-non-amp-page-text'] ) ;?> </a> <?php } }?>
28
  </p>
29
  <p>
30
  <?php
3
 
4
  $ampforwp_backto_nonamp = " ";
5
  if ( is_home() ) {
6
+ $ampforwp_backto_nonamp = untrailingslashit(home_url()).'?nonamp=1';
7
  }
8
  if ( is_single() ){
9
  global $post;
10
+ $ampforwp_backto_nonamp = untrailingslashit(get_permalink( $post->ID )).'?nonamp=1';
11
  }
12
  if ( is_page() ){
13
  global $post;
14
+ $ampforwp_backto_nonamp = untrailingslashit(get_permalink( $post->ID )).'?nonamp=1';
15
  }
16
  if( is_archive() ) {
17
  global $wp;
18
+ $ampforwp_backto_nonamp = esc_url( untrailingslashit(home_url( $wp->request )).'?nonamp=1' );
19
  }
20
  ?>
21
  <footer class="container">
22
  <div id="footer">
23
  <p><a href="#header"> <?php echo esc_html( $redux_builder_amp['amp-translator-top-text'] ); ?></a> <?php
24
  //24. Added an options button for switching on/off link to non amp page
25
+ if($redux_builder_amp['amp-footer-link-non-amp-page']=='1') {
26
+ if ( $ampforwp_backto_nonamp ) { ?> | <a href="<?php echo $ampforwp_backto_nonamp; ?>"><?php echo esc_html( $redux_builder_amp['amp-translator-non-amp-page-text'] ) ;?> </a> <?php }
27
+ } ?>
28
  </p>
29
  <p>
30
  <?php
templates/design-manager/design-2/header-bar.php CHANGED
@@ -5,9 +5,9 @@
5
  <?php global $redux_builder_amp;
6
 
7
  if ($redux_builder_amp['amp-on-off-support-for-non-amp-home-page']) {
8
- $ampforwp_home_url = trailingslashit( get_bloginfo('url') );
9
  }else{
10
- $ampforwp_home_url = trailingslashit( get_bloginfo('url') ) . '?' . AMP_QUERY_VAR;
11
  }
12
  ?>
13
 
5
  <?php global $redux_builder_amp;
6
 
7
  if ($redux_builder_amp['amp-on-off-support-for-non-amp-home-page']) {
8
+ $ampforwp_home_url = untrailingslashit( get_bloginfo('url') ).'?nonamp=1';
9
  }else{
10
+ $ampforwp_home_url = trailingslashit( get_bloginfo('url') ) . AMP_QUERY_VAR;
11
  }
12
  ?>
13
 
templates/design-manager/design-2/index.php CHANGED
@@ -6,7 +6,7 @@
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
8
  global $redux_builder_amp;
9
- if ( is_home() || is_front_page() ){
10
  global $wp;
11
  $current_archive_url = home_url( $wp->request );
12
  $amp_url = trailingslashit($current_archive_url);
@@ -41,7 +41,6 @@
41
  $q = new WP_Query( array(
42
  'post_type' => 'post',
43
  'orderby' => 'date',
44
- 'offset' => esc_attr($fn_offset),
45
  'ignore_sticky_posts' => 1,
46
  'paged' => esc_attr($paged),
47
  'post__not_in' => $exclude_ids
@@ -76,7 +75,7 @@
76
  $content = get_the_content();
77
  }
78
  ?>
79
- <p><?php echo wp_trim_words( $content , '15' ); ?></p>
80
 
81
  </div>
82
  <div class="cb"></div>
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
8
  global $redux_builder_amp;
9
+ if ( is_home() || is_front_page() || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ){
10
  global $wp;
11
  $current_archive_url = home_url( $wp->request );
12
  $amp_url = trailingslashit($current_archive_url);
41
  $q = new WP_Query( array(
42
  'post_type' => 'post',
43
  'orderby' => 'date',
 
44
  'ignore_sticky_posts' => 1,
45
  'paged' => esc_attr($paged),
46
  'post__not_in' => $exclude_ids
75
  $content = get_the_content();
76
  }
77
  ?>
78
+ <p><?php echo wp_trim_words( strip_shortcodes( $content ) , '15' ); ?></p>
79
 
80
  </div>
81
  <div class="cb"></div>
templates/design-manager/design-2/style.php CHANGED
@@ -270,6 +270,11 @@ h2.amp-wp-title , .amp-wp-post-content p{
270
  line-height: 20px;
271
  margin: 3px 0 0 5px;
272
  }
 
 
 
 
 
273
  /* Footer */
274
  #footer{
275
  background : #fff;
@@ -489,7 +494,7 @@ main .amp-wp-content.comments_list {
489
  padding:0
490
  }
491
  .comments_list ul.children{
492
- padding-bottom:10px;
493
  margin-left: 4%;
494
  width: 96%;
495
  }
@@ -710,6 +715,7 @@ pre {
710
  }
711
  <?php if($redux_builder_amp['amp-rtl-select-option'] == true) { ?>
712
  /* RTL Start */
 
713
  .nav_container, .toggle-navigationv2, .amp-loop-list, #pagination, #footer, .amp-wp-meta, .amp-wp-title, .single-post .the_content, .amp-wp-tax-tag, .sticky_social{
714
  direction:rtl
715
  }
270
  line-height: 20px;
271
  margin: 3px 0 0 5px;
272
  }
273
+ main .amp-archive-heading {
274
+ background : none;
275
+ box-shadow: none;
276
+ padding: 5px;
277
+ }
278
  /* Footer */
279
  #footer{
280
  background : #fff;
494
  padding:0
495
  }
496
  .comments_list ul.children{
497
+ padding-bottom:10px;
498
  margin-left: 4%;
499
  width: 96%;
500
  }
715
  }
716
  <?php if($redux_builder_amp['amp-rtl-select-option'] == true) { ?>
717
  /* RTL Start */
718
+ .amp-wp-meta{ padding-right: 0; }
719
  .nav_container, .toggle-navigationv2, .amp-loop-list, #pagination, #footer, .amp-wp-meta, .amp-wp-title, .single-post .the_content, .amp-wp-tax-tag, .sticky_social{
720
  direction:rtl
721
  }
templates/features.php CHANGED
@@ -40,6 +40,7 @@
40
  30. TagDiv menu issue removed
41
  31. removing scripts added by cleantalk
42
  32. removing bj loading for amp
 
43
  */
44
  // Adding AMP-related things to the main theme
45
  global $redux_builder_amp;
@@ -78,30 +79,44 @@
78
 
79
  function ampforwp_home_archive_rel_canonical() {
80
  global $redux_builder_amp;
81
- if( is_archive() || is_attachment() ) {
82
- return;
83
- }
84
- if( is_page() ) {
85
- if( !$redux_builder_amp['amp-on-off-for-all-pages'] ) {
86
- return;
87
- }
88
- }
89
- if ( is_home() || is_front_page() ){
90
- global $wp;
91
- $current_archive_url = home_url( $wp->request );
92
- $amp_url = trailingslashit($current_archive_url).'?amp';
93
- }
94
- else {
95
- $amp_url = amp_get_permalink( get_queried_object_id() );
96
- }
97
-
98
- global $post;
99
- $ampforwp_amp_post_on_off_meta = get_post_meta( $post->ID );
100
- if( $ampforwp_amp_post_on_off_meta['ampforwp-amp-on-off'][0] === 'hide-amp' ) {
101
- //dont Echo anything
102
- } else {
103
- printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  } //end of ampforwp_home_archive_rel_canonical()
106
 
107
 
@@ -121,10 +136,15 @@
121
  // Custom Homepage and Archive file
122
 
123
  global $redux_builder_amp;
 
124
  if($redux_builder_amp['amp-frontpage-select-option'] == 0) {
125
- if ( is_home() || is_archive() ) {
126
  if ( 'single' === $type ) {
 
 
 
127
  $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php';
 
128
  }
129
  }
130
  } elseif ($redux_builder_amp['amp-frontpage-select-option'] == 1) {
@@ -133,19 +153,14 @@
133
  $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php';
134
  }
135
  }
136
- if ( is_archive() ) {
137
- if ( 'single' === $type ) {
138
- $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php';
139
- }
140
- }
141
 
142
  }
143
  // Custom Single file
144
  if ( is_single() || is_page() ) {
145
 
146
- if('single' === $type && !('product' === $post->post_type )) {
147
- $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/single.php';
148
- }
149
  }
150
  return $file;
151
  }
@@ -156,41 +171,42 @@
156
  if ( 'style' === $type ) {
157
  $file = '';
158
  }
159
- return $file;
160
  }
161
 
162
- //3.5
163
- add_filter( 'amp_post_template_file', 'ampforwp_empty_filter', 10, 3 );
164
- function ampforwp_empty_filter( $file, $type, $post ) {
165
  if ( 'empty-filter' === $type ) {
166
  $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
167
  }
168
  return $file;
169
- }
 
170
  // 4. Custom Header files
171
  add_filter( 'amp_post_template_file', 'ampforwp_custom_header', 10, 3 );
172
  function ampforwp_custom_header( $file, $type, $post ) {
173
- if ( 'header-bar' === $type ) {
174
- $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/header-bar.php';
175
- }
176
- return $file;
177
  }
178
 
179
  // 4.1 Custom Meta-Author files
180
  add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_author', 10, 3 );
181
  function ampforwp_set_custom_meta_author( $file, $type, $post ) {
182
- if ( 'meta-author' === $type ) {
183
- $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
184
- }
185
- return $file;
186
  }
187
  // 4.2 Custom Meta-Taxonomy files
188
  add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_taxonomy', 10, 3 );
189
  function ampforwp_set_custom_meta_taxonomy( $file, $type, $post ) {
190
- if ( 'meta-taxonomy' === $type ) {
191
- $file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/empty-filter.php';
192
- }
193
- return $file;
194
  }
195
 
196
  // 4.5 Added hook to add more layout.
@@ -200,32 +216,32 @@ function ampforwp_empty_filter( $file, $type, $post ) {
200
  // 5. Customize with Width of the site
201
  add_filter( 'amp_content_max_width', 'ampforwp_change_content_width' );
202
  function ampforwp_change_content_width( $content_max_width ) {
203
- return 1000;
204
  }
205
 
206
- // 6. Add required Javascripts for extra AMP features
207
- add_action('amp_post_template_head','ampforwp_register_additional_scripts', 20);
208
- function ampforwp_register_additional_scripts() {
209
- global $redux_builder_amp;
210
- if( is_page() ) { ?>
211
- <script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
212
- <?php } ?>
213
- <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
214
- <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
215
- <script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
216
- <?php } ?>
217
- <?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
218
- <?php if( is_singular() ) { ?>
 
 
 
 
 
219
  <script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
220
- <?php }
221
- } ?>
222
- <?php if($redux_builder_amp['amp-frontpage-select-option'] == 1) { ?>
223
- <?php if( is_home() ) { ?>
224
- <script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
225
- <?php }
226
- } ?>
227
- <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script><?php
228
- }
229
  // 6.1 Adding Analytics Scripts
230
  add_action('amp_post_template_head','ampforwp_register_analytics_script', 20);
231
  function ampforwp_register_analytics_script(){ ?>
@@ -234,7 +250,7 @@ function ampforwp_register_additional_scripts() {
234
 
235
  }
236
 
237
- // 7. Footer for AMP Pages
238
  add_filter( 'amp_post_template_file', 'ampforwp_custom_footer', 10, 3 );
239
  function ampforwp_custom_footer( $file, $type, $post ) {
240
  if ( 'footer' === $type ) {
@@ -602,6 +618,7 @@ function ampforwp_register_additional_scripts() {
602
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 );
603
  function ampforwp_update_metadata_featured_image( $metadata, $post ) {
604
  global $redux_builder_amp;
 
605
  $post_id = $post->ID;
606
  $post_image_id = get_post_thumbnail_id( $post_id );
607
  $structured_data_image = wp_get_attachment_image_src( $post_image_id, 'full' );
@@ -954,6 +971,12 @@ function ampforwp_remove_title_tags(){
954
  $title = $post->post_title;
955
  echo $title . ' | ' . get_option( 'blogname' ) ;
956
  }
 
 
 
 
 
 
957
  $site_title = get_bloginfo('name') . ' | ' . get_option( 'blogdescription' ) ;
958
  if ( is_home() ) {
959
  if ( $redux_builder_amp['amp-frontpage-select-option']== 1) {
@@ -972,9 +995,18 @@ function ampforwp_remove_title_tags(){
972
  function ampforwp_the_content_filter_full( $content_buffer ) {
973
  $ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
974
  if ( $ampforwp_is_amp_endpoint ) {
975
- $content_buffer = preg_replace("/' defer='defer/", "", $content_buffer);
976
- $content_buffer = preg_replace("/onclick=[^>]*/", "", $content_buffer);
977
- $content_buffer = preg_replace("/<\\/?thrive_headline(.|\\s)*?>/",'',$content_buffer);
 
 
 
 
 
 
 
 
 
978
  }
979
  return $content_buffer;
980
  }
@@ -1033,4 +1065,4 @@ function ampforwp_remove_bj_load() {
1033
  add_filter( 'bjll/enabled', '__return_false' );
1034
  }
1035
  }
1036
- add_action( 'bjll/compat', 'ampforwp_remove_bj_load' );
40
  30. TagDiv menu issue removed
41
  31. removing scripts added by cleantalk
42
  32. removing bj loading for amp
43
+
44
  */
45
  // Adding AMP-related things to the main theme
46
  global $redux_builder_amp;
79
 
80
  function ampforwp_home_archive_rel_canonical() {
81
  global $redux_builder_amp;
82
+ if( is_attachment() ) {
83
+ return;
84
+ }
85
+ if( is_page() ) {
86
+ if( !$redux_builder_amp['amp-on-off-for-all-pages'] ) {
87
+ return;
88
+ }
89
+ }
90
+ if( is_archive() ) {
91
+ if( ! $redux_builder_amp['ampforwp-archive-support'] ) {
92
+ //dont do anything
93
+ return;
94
+ }
95
+ }
96
+
97
+ if( is_home() ) {
98
+ if( ! $redux_builder_amp['ampforwp-homepage-on-off-support'] ) {
99
+ //dont do anything
100
+ return;
101
+ }
102
+ }
103
+
104
+ if ( is_home() || is_front_page() || is_archive() ){
105
+ global $wp;
106
+ $current_archive_url = home_url( $wp->request );
107
+ $amp_url = trailingslashit($current_archive_url).'amp';
108
+
109
+ } else {
110
+ $amp_url = amp_get_permalink( get_queried_object_id() );
111
+ }
112
+
113
+ global $post;
114
+ $ampforwp_amp_post_on_off_meta = get_post_meta( get_the_ID(),'ampforwp-amp-on-off',true);
115
+ if( $ampforwp_amp_post_on_off_meta === 'hide-amp' ) {
116
+ //dont Echo anything
117
+ } else {
118
+ printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
119
+ }
120
  } //end of ampforwp_home_archive_rel_canonical()
121
 
122
 
136
  // Custom Homepage and Archive file
137
 
138
  global $redux_builder_amp;
139
+
140
  if($redux_builder_amp['amp-frontpage-select-option'] == 0) {
141
+ if ( is_home() || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ) {
142
  if ( 'single' === $type ) {
143
+ if(is_archive()){
144
+ $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/archive.php';
145
+ }else {
146
  $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php';
147
+ }
148
  }
149
  }
150
  } elseif ($redux_builder_amp['amp-frontpage-select-option'] == 1) {
153
  $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php';
154
  }
155
  }
 
 
 
 
 
156
 
157
  }
158
  // Custom Single file
159
  if ( is_single() || is_page() ) {
160
 
161
+ if('single' === $type && !('product' === $post->post_type )) {
162
+ $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/single.php';
163
+ }
164
  }
165
  return $file;
166
  }
171
  if ( 'style' === $type ) {
172
  $file = '';
173
  }
174
+ return $file;
175
  }
176
 
177
+ //3.5
178
+ add_filter( 'amp_post_template_file', 'ampforwp_empty_filter', 10, 3 );
179
+ function ampforwp_empty_filter( $file, $type, $post ) {
180
  if ( 'empty-filter' === $type ) {
181
  $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
182
  }
183
  return $file;
184
+ }
185
+
186
  // 4. Custom Header files
187
  add_filter( 'amp_post_template_file', 'ampforwp_custom_header', 10, 3 );
188
  function ampforwp_custom_header( $file, $type, $post ) {
189
+ if ( 'header-bar' === $type ) {
190
+ $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/header-bar.php';
191
+ }
192
+ return $file;
193
  }
194
 
195
  // 4.1 Custom Meta-Author files
196
  add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_author', 10, 3 );
197
  function ampforwp_set_custom_meta_author( $file, $type, $post ) {
198
+ if ( 'meta-author' === $type ) {
199
+ $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
200
+ }
201
+ return $file;
202
  }
203
  // 4.2 Custom Meta-Taxonomy files
204
  add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_taxonomy', 10, 3 );
205
  function ampforwp_set_custom_meta_taxonomy( $file, $type, $post ) {
206
+ if ( 'meta-taxonomy' === $type ) {
207
+ $file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/empty-filter.php';
208
+ }
209
+ return $file;
210
  }
211
 
212
  // 4.5 Added hook to add more layout.
216
  // 5. Customize with Width of the site
217
  add_filter( 'amp_content_max_width', 'ampforwp_change_content_width' );
218
  function ampforwp_change_content_width( $content_max_width ) {
219
+ return 1000;
220
  }
221
 
222
+ // 6. Add required Javascripts for extra AMP features
223
+ add_action('amp_post_template_head','ampforwp_register_additional_scripts', 20);
224
+ function ampforwp_register_additional_scripts() {
225
+ global $redux_builder_amp;
226
+ if( is_page() ) { ?>
227
+ <script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
228
+ <?php } ?>
229
+ <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
230
+ <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
231
+ <script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
232
+ <?php } ?>
233
+ <?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
234
+ <?php if( is_singular() ) { ?>
235
+ <script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
236
+ <?php }
237
+ } ?>
238
+ <?php if($redux_builder_amp['amp-frontpage-select-option'] == 1) { ?>
239
+ <?php if( is_home() ) { ?>
240
  <script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
241
+ <?php }
242
+ } ?>
243
+ <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script><?php
244
+ }
 
 
 
 
 
245
  // 6.1 Adding Analytics Scripts
246
  add_action('amp_post_template_head','ampforwp_register_analytics_script', 20);
247
  function ampforwp_register_analytics_script(){ ?>
250
 
251
  }
252
 
253
+ // 7. Footer for AMP Pages
254
  add_filter( 'amp_post_template_file', 'ampforwp_custom_footer', 10, 3 );
255
  function ampforwp_custom_footer( $file, $type, $post ) {
256
  if ( 'footer' === $type ) {
618
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 );
619
  function ampforwp_update_metadata_featured_image( $metadata, $post ) {
620
  global $redux_builder_amp;
621
+ global $post;
622
  $post_id = $post->ID;
623
  $post_image_id = get_post_thumbnail_id( $post_id );
624
  $structured_data_image = wp_get_attachment_image_src( $post_image_id, 'full' );
971
  $title = $post->post_title;
972
  echo $title . ' | ' . get_option( 'blogname' ) ;
973
  }
974
+ // title for archive pages
975
+ if ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) {
976
+ the_archive_title( '' );
977
+ the_archive_description( '' );
978
+ }
979
+
980
  $site_title = get_bloginfo('name') . ' | ' . get_option( 'blogdescription' ) ;
981
  if ( is_home() ) {
982
  if ( $redux_builder_amp['amp-frontpage-select-option']== 1) {
995
  function ampforwp_the_content_filter_full( $content_buffer ) {
996
  $ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
997
  if ( $ampforwp_is_amp_endpoint ) {
998
+ $content_buffer = preg_replace("/' defer='defer/", "", $content_buffer);
999
+ $content_buffer = preg_replace("/onclick=[^>]*/", "", $content_buffer);
1000
+ $content_buffer = preg_replace("/<\\/?thrive_headline(.|\\s)*?>/",'',$content_buffer);
1001
+ // Remove Extra styling added by other Themes/ Plugins
1002
+ $content_buffer = preg_replace('/(<style(.*?)>(.*?)<\/style>)<!doctype html>/','<!doctype html>',$content_buffer);
1003
+ $content_buffer = preg_replace('/(<style(.*?)>(.*?)<\/style>)(\/\*)/','$4',$content_buffer);
1004
+ $content_buffer = preg_replace("/<\\/?g(.|\\s)*?>/",'',$content_buffer);
1005
+ $content_buffer = preg_replace('/(<[^>]+) spellcheck="false"/', '$1', $content_buffer);
1006
+ $content_buffer = preg_replace('/(<[^>]+) spellcheck="true"/', '$1', $content_buffer);
1007
+ $content_buffer = preg_replace('/ defer onload=\'/', '', $content_buffer);
1008
+ //$content_buffer = preg_replace('/<style type=(.*?)>|\[.*?\]\s\{(.*)\}|<\/style>(?!(<\/noscript>)|(\n<\/head>)|(<noscript>))/','',$content_buffer);
1009
+
1010
  }
1011
  return $content_buffer;
1012
  }
1065
  add_filter( 'bjll/enabled', '__return_false' );
1066
  }
1067
  }
1068
+ add_action( 'bjll/compat', 'ampforwp_remove_bj_load' );