AMP for WP – Accelerated Mobile Pages - Version 0.9.97.33

Version Description

(13th February 2019) = * Fixed: Style sanitizer code updated #2387 * Fixed: UTM Parameters when Mobile Redirection is enabled #2854 * Fixed: ?nonamp=1 is not working properly #1947 & #2537 * Fixed: All media queries load in single media query only #2711 * Fixed: 'Hide AMP option' is not working when AMP take over is enabled #2880 * Fixed: Swift Hover Color Changes #2751 * Fixed: Google Font is not getting saved #2839 * Fixed: Sidebar CSS condition code fixed #2757 * Fixed: Performance improvement for ampforwp_stylesheet_file_insertion #2873

Full changelog available in changelog.txt

Download this release

Release Info

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

Code changes from version 0.9.97.32 to 0.9.97.33

README.md CHANGED
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.0.3
7
- Stable tag: 0.9.97.32
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -184,6 +184,17 @@ You can contact us from [here](https://ampforwp.com/contact/)
184
 
185
  == Changelog ==
186
 
 
 
 
 
 
 
 
 
 
 
 
187
  = 0.9.97.32 (8th February 2019) =
188
  * Added: Rank Math SEO compatibility integrated #2701 & #2736
189
  * Added: New filter "ampforwp_modify_thumb_url_array" to modify the thumbnail #2739
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.0.3
7
+ Stable tag: 0.9.97.33
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
184
 
185
  == Changelog ==
186
 
187
+ = 0.9.97.33 (13th February 2019) =
188
+ * Fixed: Style sanitizer code updated #2387
189
+ * Fixed: UTM Parameters when Mobile Redirection is enabled #2854
190
+ * Fixed: ?nonamp=1 is not working properly #1947 & #2537
191
+ * Fixed: All media queries load in single media query only #2711
192
+ * Fixed: 'Hide AMP option' is not working when AMP take over is enabled #2880
193
+ * Fixed: Swift Hover Color Changes #2751
194
+ * Fixed: Google Font is not getting saved #2839
195
+ * Fixed: Sidebar CSS condition code fixed #2757
196
+ * Fixed: Performance improvement for ampforwp_stylesheet_file_insertion #2873
197
+
198
  = 0.9.97.32 (8th February 2019) =
199
  * Added: Rank Math SEO compatibility integrated #2701 & #2736
200
  * Added: New filter "ampforwp_modify_thumb_url_array" to modify the thumbnail #2739
accelerated-moblie-pages.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
- Version: 0.9.97.32
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
@@ -20,7 +20,7 @@ define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
20
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
21
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
22
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
23
- define('AMPFORWP_VERSION','0.9.97.32');
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
26
  $ampforwp_slug = '';
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
+ Version: 0.9.97.33
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
20
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
21
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
22
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
23
+ define('AMPFORWP_VERSION','0.9.97.33');
24
  // any changes to AMP_QUERY_VAR should be refelected here
25
  function ampforwp_generate_endpoint(){
26
  $ampforwp_slug = '';
changelog.txt CHANGED
@@ -1,5 +1,16 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 0.9.97.32 (8th February 2019) =
4
  * Added: Rank Math SEO compatibility integrated #2701 & #2736
5
  * Added: New filter "ampforwp_modify_thumb_url_array" to modify the thumbnail #2739
1
  == Changelog ==
2
 
3
+ = 0.9.97.33 (13th February 2019) =
4
+ * Fixed: Style sanitizer code updated #2387
5
+ * Fixed: UTM Parameters when Mobile Redirection is enabled #2854
6
+ * Fixed: ?nonamp=1 is not working properly #1947 & #2537
7
+ * Fixed: All media queries load in single media query only #2711
8
+ * Fixed: 'Hide AMP option' is not working when AMP take over is enabled #2880
9
+ * Fixed: Swift Hover Color Changes #2751
10
+ * Fixed: Google Font is not getting saved #2839
11
+ * Fixed: Sidebar CSS condition code fixed #2757
12
+ * Fixed: Performance improvement for ampforwp_stylesheet_file_insertion #2873
13
+
14
  = 0.9.97.32 (8th February 2019) =
15
  * Added: Rank Math SEO compatibility integrated #2701 & #2736
16
  * Added: New filter "ampforwp_modify_thumb_url_array" to modify the thumbnail #2739
components/related-posts/related-posts.php CHANGED
@@ -161,10 +161,12 @@ function ampforwp_get_relatedpost_image( $imagetype ='thumbnail', $data=array()
161
 
162
  function ampforwp_get_relatedpost_content($argsdata=array()){
163
  global $redux_builder_amp;
164
- if ( isset($redux_builder_amp['ampforwp-single-related-posts-link']) && true == $redux_builder_amp['ampforwp-single-related-posts-link'] ) {
 
165
  $related_post_permalink = get_permalink();
166
- } else {
167
- $related_post_permalink = ampforwp_url_controller( get_permalink() );
 
168
  }
169
  ?>
170
  <div class="related_link">
161
 
162
  function ampforwp_get_relatedpost_content($argsdata=array()){
163
  global $redux_builder_amp;
164
+ $related_post_permalink = ampforwp_url_controller( get_permalink() );
165
+ if ( ampforwp_get_setting('ampforwp-single-related-posts-link') ) {
166
  $related_post_permalink = get_permalink();
167
+ if ( ampforwp_get_setting('amp-mobile-redirection') ) {
168
+ $related_post_permalink = add_query_arg('nonamp','1',$related_post_permalink);
169
+ }
170
  }
171
  ?>
172
  <div class="related_link">
includes/admin-script.js CHANGED
@@ -321,10 +321,10 @@ jQuery(function($) {
321
  $('#s2id_amp_font_selector-select .select2-chosen').html(redux_data.amp_font_selector);
322
 
323
  $('#amp_font_selector-select option[value="'+redux_data.amp_font_selector+'"]').attr("selected", "selected");
324
- $('#amp_font_selector-select').select2('val',redux_data.amp_font_selector).trigger("change");
325
 
326
  $('#amp_font_selector_content_single-select option[value="'+redux_data.amp_font_selector+'"]').attr("selected", "selected");
327
- $('#amp_font_selector_content_single-select').select2('val',redux_data.amp_font_selector).trigger("change");
328
 
329
  // Build select data
330
  let fontData = redux_data.google_current_font_data;
321
  $('#s2id_amp_font_selector-select .select2-chosen').html(redux_data.amp_font_selector);
322
 
323
  $('#amp_font_selector-select option[value="'+redux_data.amp_font_selector+'"]').attr("selected", "selected");
324
+ $('#amp_font_selector-select').val(redux_data.amp_font_selector).trigger("change");
325
 
326
  $('#amp_font_selector_content_single-select option[value="'+redux_data.amp_font_selector+'"]').attr("selected", "selected");
327
+ $('#amp_font_selector_content_single-select').val(redux_data.amp_font_selector).trigger("change");
328
 
329
  // Build select data
330
  let fontData = redux_data.google_current_font_data;
includes/options/admin-config.php CHANGED
@@ -4284,25 +4284,37 @@ Redux::setSection( $opt_name, array(
4284
  'img' => AMPFORWP_PLUGIN_DIR_URI.'/images/swift.png',
4285
  ),
4286
  );
4287
- if(count(get_plugins())>0){
4288
- foreach (get_plugins() as $key => $value) {
4289
- $plugin = get_plugin_data(WP_PLUGIN_DIR.'/'.$key);
4290
- if(!empty($plugin['AMP'])){//$plugin['AMP']
4291
- $imageUrl = '';
4292
- if(file_exists(AMPFORWP_MAIN_PLUGIN_DIR.$value['TextDomain'].'/screenshot.png')){
4293
- $imageUrl = plugins_url($value['TextDomain'].'/screenshot.png');
4294
- }
4295
- $themeDesign[] = array(
4296
- 'demo_link' => $plugin['AMP Demo'],
4297
- 'upgrade'=>true,
4298
- 'title'=>$plugin['AMP'],
4299
- 'value'=>$value['TextDomain'],
4300
- 'alt'=>$plugin['AMP'],
4301
- 'img'=>$imageUrl,
4302
- );
 
 
 
 
 
 
4303
  }
 
4304
  }
4305
  }
 
 
 
 
 
4306
  // Themes Section
4307
  Redux::setSection( $opt_name, array(
4308
  'title' => esc_html__( 'Themes', 'accelerated-mobile-pages' ), 'class' => 'ampforwp-new-element',
@@ -4374,6 +4386,18 @@ Redux::setSection( $opt_name, array(
4374
  array('amp-design-selector', '=' , '4')
4375
  )
4376
  ),
 
 
 
 
 
 
 
 
 
 
 
 
4377
  array(
4378
  'id' => 'amp-opt-color-rgba-colorscheme',
4379
  'type' => 'color_rgba',
4284
  'img' => AMPFORWP_PLUGIN_DIR_URI.'/images/swift.png',
4285
  ),
4286
  );
4287
+
4288
+ $pluginsData = array();
4289
+ $pluginsData = get_transient( 'ampforwp_themeframework_active_plugins' );
4290
+ if( empty( $pluginsData )){
4291
+ $activePlugins = get_option( 'active_plugins', array() );
4292
+ if(count( $activePlugins)>0){
4293
+ foreach ( $activePlugins as $key => $value) {
4294
+ $plugin = get_plugin_data(WP_PLUGIN_DIR.'/'.$value);
4295
+ if(!empty($plugin['AMP'])){//$plugin['AMP']
4296
+ $imageUrl = '';
4297
+ if(file_exists(AMPFORWP_MAIN_PLUGIN_DIR.$plugin['TextDomain'].'/screenshot.png')){
4298
+ $imageUrl = plugins_url($plugin['TextDomain'].'/screenshot.png');
4299
+ }
4300
+ $pluginsData[$plugin['TextDomain']] = array(
4301
+ 'demo_link' => esc_html($plugin['AMP Demo']),
4302
+ 'upgrade' => true,
4303
+ 'title' => $plugin['AMP'],
4304
+ 'value' => esc_html($plugin['TextDomain']),
4305
+ 'alt' => esc_attr($plugin['AMP']),
4306
+ 'img' => esc_url($imageUrl),
4307
+ );
4308
+ }
4309
  }
4310
+ set_transient( 'ampforwp_themeframework_active_plugins', $pluginsData );
4311
  }
4312
  }
4313
+ if ( is_array($pluginsData) ) {
4314
+ $themeDesign = array_merge($themeDesign, $pluginsData);
4315
+ }
4316
+ $themeDesign = apply_filters( 'ampforwp_themeframe_available_designs', $themeDesign );
4317
+
4318
  // Themes Section
4319
  Redux::setSection( $opt_name, array(
4320
  'title' => esc_html__( 'Themes', 'accelerated-mobile-pages' ), 'class' => 'ampforwp-new-element',
4386
  array('amp-design-selector', '=' , '4')
4387
  )
4388
  ),
4389
+ array(
4390
+ 'id' => 'swift-hover-color-scheme',
4391
+ 'title' => esc_html__('Hover Color Scheme', 'accelerated-mobile-pages'),
4392
+ 'tooltip-subtitle' => esc_html__('Choose the color when hover for title, anchor links','accelerated-mobile-pages'),
4393
+ 'type' => 'color_rgba',
4394
+ 'default' => array(
4395
+ 'color' => '#005be2',
4396
+ ),
4397
+ 'required' => array(
4398
+ array('amp-design-selector', '=' , '4')
4399
+ )
4400
+ ),
4401
  array(
4402
  'id' => 'amp-opt-color-rgba-colorscheme',
4403
  'type' => 'color_rgba',
includes/options/extensions/demolink_image_select/demolink_image_select/field_demolink_image_select.js CHANGED
@@ -54,10 +54,10 @@
54
  'change', function() {
55
  var preview = $( this ).parents( '.redux-field:first' ).find( '.redux-preview-image' );
56
 
57
- if(typeof $( this ).select2().find(":selected").data("demolink")!="undefined"){
58
- if($( this ).select2().find(":selected").data("demolink")!=""){
59
  preview.next('#theme-selected-demo-link').remove();
60
- var demo = $( this ).select2().find(":selected").data("demolink");
61
  preview.after('<a href="'+demo+'" id="theme-selected-demo-link" target="_blank"> Demo </a>');
62
 
63
  preview.attr('onclick','return window.open(\''+demo+'\')');
@@ -68,16 +68,16 @@
68
  }
69
 
70
  }
71
- if(typeof $( this ).select2().find(":selected").data("image")!="undefined"){
72
- if($( this ).select2().find(":selected").data("image")===""){
73
  preview.fadeOut(
74
  'medium', function() {
75
  preview.attr( 'src', '' );
76
  }
77
  );
78
  }else{
79
- preview.attr( 'src', $( this ).select2().find(":selected").data("image") );
80
- preview.attr( 'alt', $( this ).select2().find(":selected").data("alt") );
81
  preview.fadeIn().css( 'visibility', 'visible' );
82
  }
83
  }else{
54
  'change', function() {
55
  var preview = $( this ).parents( '.redux-field:first' ).find( '.redux-preview-image' );
56
 
57
+ if(typeof $( this ).find(":selected").data("demolink")!="undefined"){
58
+ if($( this ).find(":selected").data("demolink")!=""){
59
  preview.next('#theme-selected-demo-link').remove();
60
+ var demo = $( this ).find(":selected").data("demolink");
61
  preview.after('<a href="'+demo+'" id="theme-selected-demo-link" target="_blank"> Demo </a>');
62
 
63
  preview.attr('onclick','return window.open(\''+demo+'\')');
68
  }
69
 
70
  }
71
+ if(typeof $( this ).find(":selected").data("image")!="undefined"){
72
+ if($( this ).find(":selected").data("image")===""){
73
  preview.fadeOut(
74
  'medium', function() {
75
  preview.attr( 'src', '' );
76
  }
77
  );
78
  }else{
79
+ preview.attr( 'src', $( this ).find(":selected").data("image") );
80
+ preview.attr( 'alt', $( this ).find(":selected").data("alt") );
81
  preview.fadeIn().css( 'visibility', 'visible' );
82
  }
83
  }else{
includes/options/extensions/demolink_image_select/demolink_image_select/field_demolink_image_select.php CHANGED
@@ -101,7 +101,7 @@ if ( ! class_exists( 'ReduxFramework_demolink_image_select' ) ) {
101
  // variable to use later on when we want to extract its associted
102
  // url.
103
  if ( '' != $selected ) {
104
- $arrNum = $x;
105
  }
106
  // No alt? Set it to title. We do this so the alt tag shows
107
  // something. It also makes HTML/SEO purists happy.
@@ -138,7 +138,7 @@ if ( ! class_exists( 'ReduxFramework_demolink_image_select' ) ) {
138
  // variable to use later on when we want to extract its associted
139
  // url.
140
  if ( '' != $selected ) {
141
- $arrNum = $x;
142
  }
143
 
144
  // Add the option tag, with values.
@@ -171,11 +171,11 @@ if ( ! class_exists( 'ReduxFramework_demolink_image_select' ) ) {
171
  echo '<img src="#" class="redux-preview-image" style="visibility:hidden;" id="image_' . $this->field['id'] . '">';
172
  } else {
173
  $demo="#";
174
- if (isset($this->field['options'][ $arrNum - 1 ]['demo_link'])) {
175
- $demo = $this->field['options'][ $arrNum - 1 ]['demo_link'];
176
  }
177
- echo '<img src=' . esc_url($this->field['options'][ $arrNum - 1 ]['img']) . ' class="redux-preview-image" id="image_' . $this->field['id'] . '" onclick="return window.open(\''.$demo.'\')">';
178
- if (isset($this->field['options'][ $arrNum - 1 ]['demo_link'])) {
179
  echo '<a href="'. esc_url($demo) .'" id="theme-selected-demo-link" target="_blank">
180
  Demo
181
  </a>';
101
  // variable to use later on when we want to extract its associted
102
  // url.
103
  if ( '' != $selected ) {
104
+ $arrNum = $k;
105
  }
106
  // No alt? Set it to title. We do this so the alt tag shows
107
  // something. It also makes HTML/SEO purists happy.
138
  // variable to use later on when we want to extract its associted
139
  // url.
140
  if ( '' != $selected ) {
141
+ $arrNum = $k;
142
  }
143
 
144
  // Add the option tag, with values.
171
  echo '<img src="#" class="redux-preview-image" style="visibility:hidden;" id="image_' . $this->field['id'] . '">';
172
  } else {
173
  $demo="#";
174
+ if (isset($this->field['options'][ $arrNum ]['demo_link'])) {
175
+ $demo = $this->field['options'][ $arrNum ]['demo_link'];
176
  }
177
+ echo '<img src="' . esc_url($this->field['options'][ $arrNum ]['img']) . '" class="redux-preview-image" id="image_' . $this->field['id'] . '" onclick="return window.open(\''.$demo.'\')">';
178
+ if (isset($this->field['options'][ $arrNum ]['demo_link'])) {
179
  echo '<a href="'. esc_url($demo) .'" id="theme-selected-demo-link" target="_blank">
180
  Demo
181
  </a>';
includes/redirect.php CHANGED
@@ -260,7 +260,7 @@ function ampforwp_page_template_redirect() {
260
  }
261
  }
262
  }
263
- add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
264
 
265
 
266
  add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
@@ -277,4 +277,35 @@ function ampforwp_page_template_redirect_archive() {
277
  exit();
278
  }
279
  }
280
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  }
261
  }
262
  }
263
+ add_action( 'template_redirect', 'ampforwp_page_template_redirect', 10 );
264
 
265
 
266
  add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
277
  exit();
278
  }
279
  }
280
+ }
281
+ // #1947 when nonamp=1 it should redirect to original link so that google
282
+ function ampforwp_custom_query_var($vars) {
283
+ $vars[] = 'nonamp';
284
+ return $vars;
285
+ }
286
+ add_filter( 'query_vars', 'ampforwp_custom_query_var' );
287
+ add_action( 'template_redirect', 'ampforwp_redirect_to_orginal_url' );
288
+ function ampforwp_redirect_to_orginal_url(){
289
+ $go_to_url = "";
290
+ $url = "";
291
+ $url = ampforwp_amphtml_generator();
292
+ $nonamp_checker = get_query_var( 'nonamp');
293
+ if($url){
294
+ if( $nonamp_checker == 1 ){
295
+ $go_to_url = remove_query_arg('nonamp', $url);
296
+ $go_to_url = explode('/', $go_to_url);
297
+ $go_to_url = array_flip($go_to_url);
298
+ unset($go_to_url['amp']);
299
+ $go_to_url = array_flip($go_to_url);
300
+ $go_to_url = implode('/', $go_to_url);
301
+
302
+ wp_safe_redirect( $go_to_url, 301 );
303
+ exit;
304
+ }
305
+ else{
306
+ return;
307
+ }
308
+ }
309
+ return;
310
+ }
311
+ // #1947 ends here
includes/thirdparty-compatibility.php CHANGED
@@ -541,3 +541,18 @@ function ampforwp_allows_tag_sanitizer($sanitizer_classes){
541
  $sanitizer_classes['AMP_Tag_And_Attribute_Sanitizer'] = array();
542
  return $sanitizer_classes;
543
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  $sanitizer_classes['AMP_Tag_And_Attribute_Sanitizer'] = array();
542
  return $sanitizer_classes;
543
  };
544
+
545
+ add_action( 'activated_plugin', 'ampforwp_active_update_transient' );
546
+ function ampforwp_active_update_transient($plugin){
547
+ delete_transient( 'ampforwp_themeframework_active_plugins' );
548
+ }
549
+ add_action( 'deactivated_plugin', 'ampforwp_deactivate_update_transient' );
550
+ function ampforwp_deactivate_update_transient($plugin){
551
+ delete_transient( 'ampforwp_themeframework_active_plugins' );
552
+ $check_plugin = strpos($plugin, ampforwp_get_setting('amp-design-selector'));
553
+ if ( false !== $check_plugin ) {
554
+ $selectedOption = get_option('redux_builder_amp',true);
555
+ $selectedOption['amp-design-selector'] = 4;
556
+ update_option('redux_builder_amp',$selectedOption);
557
+ }
558
+ }
includes/vendor/amp/includes/sanitizers/class-amp-style-sanitizer.php CHANGED
@@ -1,103 +1,552 @@
1
  <?php
2
-
3
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
 
5
  /**
6
  * Collects inline styles and outputs them in the amp-custom stylesheet.
7
  */
8
  class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
 
 
 
 
 
 
 
 
 
9
  private $styles = array();
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  public function get_styles() {
 
 
 
12
  return $this->styles;
13
  }
14
 
15
- public function sanitize() {
16
- $body = $this->get_body_node();
17
- $this->collect_styles_recursive( $body );
 
 
 
 
 
18
  }
19
 
20
- private function collect_styles_recursive( $node ) {
21
- if ( XML_ELEMENT_NODE !== $node->nodeType ) {
 
 
 
 
 
 
 
 
22
  return;
23
  }
24
 
25
- if ( $node->hasAttributes() && $node instanceof DOMElement ) {
26
- $style = $node->getAttribute( 'style' );
27
- $class = $node->getAttribute( 'class' );
28
- $tagName = $node->tagName;
 
 
 
 
 
 
 
29
 
30
- if ( $style ) {
31
- $style = $this->process_style( $style );
32
- if ( ! empty( $style ) ) {
33
- $class_name = $this->generate_class_name( $style );
34
- $new_class = trim( $class . ' ' . $class_name );
35
- $selector = $tagName.'.' . $class_name;
36
- $node->setAttribute( 'class', $new_class );
37
- $this->styles[ $selector ] = $style;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- $node->removeAttribute( 'style' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
 
42
  }
43
 
44
- $length = $node->childNodes->length;
45
- for ( $i = $length - 1; $i >= 0; $i -- ) {
46
- $child_node = $node->childNodes->item( $i );
47
 
48
- $this->collect_styles_recursive( $child_node );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
  }
51
 
52
- private function process_style( $string ) {
53
- // Filter properties
54
- $string = safecss_filter_attr( esc_html( $string ) );
 
 
 
 
55
 
56
- if ( ! $string ) {
57
- return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
- // safecss returns a string but we want individual rules.
61
- // Using preg_split to break up rules by `;` but only if the semi-colon is not inside parens (like a data-encoded image).
62
- $styles = array_map( 'trim', preg_split( "/;(?![^(]*\))/", $string ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- // Normalize the order of the styles
65
  sort( $styles );
66
 
67
  $processed_styles = array();
68
 
69
- // Normalize whitespace and filter rules
70
  foreach ( $styles as $index => $rule ) {
71
- $arr2 = array_map( 'trim', explode( ':', $rule, 2 ) );
72
- if ( 2 !== count( $arr2 ) ) {
73
  continue;
74
  }
75
 
76
- list( $property, $value ) = $this->filter_style( $arr2[0], $arr2[1] );
77
  if ( empty( $property ) || empty( $value ) ) {
78
  continue;
79
  }
80
 
81
- $processed_styles[ $index ] = $property . ':' . $value;
82
  }
83
 
84
  return $processed_styles;
85
  }
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  private function filter_style( $property, $value ) {
88
- // Handle overflow rule
89
- // https://www.ampproject.org/docs/reference/spec.html#properties
90
- if ( 0 === strpos( $property, 'overflow' )
91
- && ( false !== strpos( $value, 'auto' ) || false !== strpos( $value, 'scroll' ) )
92
- ) {
93
- return false;
 
 
94
  }
95
 
96
  if ( 'width' === $property ) {
97
  $property = 'max-width';
98
  }
99
 
100
- // !important is not allowed
 
 
 
 
101
  if ( false !== strpos( $value, 'important' ) ) {
102
  $value = preg_replace( '/\s*\!\s*important$/', '', $value );
103
  }
@@ -105,8 +554,18 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
105
  return array( $property, $value );
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
108
  private function generate_class_name( $data ) {
109
  $string = maybe_serialize( $data );
110
  return 'amp-wp-inline-' . md5( $string );
111
  }
112
- }
1
  <?php
 
2
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
3
 
4
  /**
5
  * Collects inline styles and outputs them in the amp-custom stylesheet.
6
  */
7
  class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
8
+
9
+ /**
10
+ * Styles.
11
+ *
12
+ * List of CSS styles in HTML content of DOMDocument ($this->dom).
13
+ *
14
+ * @since 0.4
15
+ * @var array[]
16
+ */
17
  private $styles = array();
18
 
19
+ /**
20
+ * Stylesheets.
21
+ *
22
+ * Values are the CSS stylesheets. Keys are MD5 hashes of the stylesheets
23
+ *
24
+ * @since 0.7
25
+ * @var string[]
26
+ */
27
+ private $stylesheets = array();
28
+
29
+ /**
30
+ * Maximum number of bytes allowed for a keyframes style.
31
+ *
32
+ * @since 0.7
33
+ * @var int
34
+ */
35
+ private $keyframes_max_size;
36
+
37
+ /**
38
+ * Maximum number of bytes allowed for a AMP Custom style.
39
+ *
40
+ * @since 0.7
41
+ * @var int
42
+ */
43
+ private $custom_max_size;
44
+
45
+ /**
46
+ * Current CSS size.
47
+ *
48
+ * Sum of CSS located in $styles and $stylesheets.
49
+ *
50
+ * @var int
51
+ */
52
+ private $current_custom_size = 0;
53
+
54
+ /**
55
+ * The style[amp-custom] element.
56
+ *
57
+ * @var DOMElement
58
+ */
59
+ private $amp_custom_style_element;
60
+
61
+ /**
62
+ * Regex for allowed font stylesheet URL.
63
+ *
64
+ * @var string
65
+ */
66
+ private $allowed_font_src_regex;
67
+
68
+ /**
69
+ * Base URL for styles.
70
+ *
71
+ * Full URL with trailing slash.
72
+ *
73
+ * @var string
74
+ */
75
+ private $base_url;
76
+
77
+ /**
78
+ * URL of the content directory.
79
+ *
80
+ * @var string
81
+ */
82
+ private $content_url;
83
+
84
+ /**
85
+ * AMP_Base_Sanitizer constructor.
86
+ *
87
+ * @since 0.7
88
+ *
89
+ * @param DOMDocument $dom Represents the HTML document to sanitize.
90
+ * @param array $args Args.
91
+ */
92
+ public function __construct( DOMDocument $dom, array $args = array() ) {
93
+ parent::__construct( $dom, $args );
94
+
95
+ $spec_name = 'style[amp-keyframes]';
96
+ foreach ( AMP_Allowed_Tags_Generated::get_allowed_tag( 'style' ) as $spec_rule ) {
97
+ if ( isset( $spec_rule[ AMP_Rule_Spec::TAG_SPEC ]['spec_name'] ) && $spec_name === $spec_rule[ AMP_Rule_Spec::TAG_SPEC ]['spec_name'] ) {
98
+ $this->keyframes_max_size = $spec_rule[ AMP_Rule_Spec::CDATA ]['max_bytes'];
99
+ break;
100
+ }
101
+ }
102
+
103
+ $spec_name = 'style amp-custom';
104
+ foreach ( AMP_Allowed_Tags_Generated::get_allowed_tag( 'style' ) as $spec_rule ) {
105
+ if ( isset( $spec_rule[ AMP_Rule_Spec::TAG_SPEC ]['spec_name'] ) && $spec_name === $spec_rule[ AMP_Rule_Spec::TAG_SPEC ]['spec_name'] ) {
106
+ $this->custom_max_size = $spec_rule[ AMP_Rule_Spec::CDATA ]['max_bytes'];
107
+ break;
108
+ }
109
+ }
110
+
111
+ $spec_name = 'link rel=stylesheet for fonts'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
112
+ foreach ( AMP_Allowed_Tags_Generated::get_allowed_tag( 'link' ) as $spec_rule ) {
113
+ if ( isset( $spec_rule[ AMP_Rule_Spec::TAG_SPEC ]['spec_name'] ) && $spec_name === $spec_rule[ AMP_Rule_Spec::TAG_SPEC ]['spec_name'] ) {
114
+ $this->allowed_font_src_regex = '@^(' . $spec_rule[ AMP_Rule_Spec::ATTR_SPEC_LIST ]['href']['value_regex'] . ')$@';
115
+ break;
116
+ }
117
+ }
118
+
119
+ $guessurl = site_url();
120
+ if ( ! $guessurl ) {
121
+ $guessurl = wp_guess_url();
122
+ }
123
+ $this->base_url = $guessurl;
124
+ $this->content_url = WP_CONTENT_URL;
125
+ }
126
+
127
+ /**
128
+ * Get list of CSS styles in HTML content of DOMDocument ($this->dom).
129
+ *
130
+ * @since 0.4
131
+ *
132
+ * @return array[] Mapping CSS selectors to array of properties, or mapping of keys starting with 'stylesheet:' with value being the stylesheet.
133
+ */
134
  public function get_styles() {
135
+ if ( ! $this->did_convert_elements ) {
136
+ return array();
137
+ }
138
  return $this->styles;
139
  }
140
 
141
+ /**
142
+ * Get stylesheets.
143
+ *
144
+ * @since 0.7
145
+ * @returns array Values are the CSS stylesheets. Keys are MD5 hashes of the stylesheets.
146
+ */
147
+ public function get_stylesheets() {
148
+ return array_merge( $this->stylesheets, parent::get_stylesheets() );
149
  }
150
 
151
+ /**
152
+ * Sanitize CSS styles within the HTML contained in this instance's DOMDocument.
153
+ *
154
+ * @since 0.4
155
+ */
156
+ public function sanitize() {
157
+ $elements = array();
158
+
159
+ // Do nothing if inline styles are allowed.
160
+ if ( ! empty( $this->args['allow_dirty_styles'] ) ) {
161
  return;
162
  }
163
 
164
+ /*
165
+ * Note that xpath is used to query the DOM so that the link and style elements will be
166
+ * in document order. DOMNode::compareDocumentPosition() is not yet implemented.
167
+ */
168
+ $xpath = new DOMXPath( $this->dom );
169
+
170
+ $lower_case = 'translate( %s, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz" )'; // In XPath 2.0 this is lower-case().
171
+ $predicates = array(
172
+ sprintf( '( self::style and not( @amp-boilerplate ) and ( not( @type ) or %s = "text/css" ) )', sprintf( $lower_case, '@type' ) ),
173
+ sprintf( '( self::link and @href and %s = "stylesheet" )', sprintf( $lower_case, '@rel' ) ),
174
+ );
175
 
176
+ foreach ( $xpath->query( '//*[ ' . implode( ' or ', $predicates ) . ' ]' ) as $element ) {
177
+ $elements[] = $element;
178
+ }
179
+
180
+ /**
181
+ * Element.
182
+ *
183
+ * @var DOMElement $element
184
+ */
185
+ foreach ( $elements as $element ) {
186
+ $node_name = strtolower( $element->nodeName );
187
+ if ( 'style' === $node_name ) {
188
+ $this->process_style_element( $element );
189
+ } elseif ( 'link' === $node_name ) {
190
+ $this->process_link_element( $element );
191
+ }
192
+ }
193
+
194
+ $elements = array();
195
+ foreach ( $xpath->query( '//*[ @style ]' ) as $element ) {
196
+ $elements[] = $element;
197
+ }
198
+ foreach ( $elements as $element ) {
199
+ $this->collect_inline_styles( $element );
200
+ }
201
+ $this->did_convert_elements = true;
202
+
203
+ // Now make sure the amp-custom style is in the DOM and populated, if we're working with the document element.
204
+ if ( ! empty( $this->args['use_document_element'] ) ) {
205
+ if ( ! $this->amp_custom_style_element ) {
206
+ $this->amp_custom_style_element = $this->dom->createElement( 'style' );
207
+ $this->amp_custom_style_element->setAttribute( 'amp-custom', '' );
208
+ $head = $this->dom->getElementsByTagName( 'head' )->item( 0 );
209
+ if ( ! $head ) {
210
+ $head = $this->dom->createElement( 'head' );
211
+ $this->dom->documentElement->insertBefore( $head, $this->dom->documentElement->firstChild );
212
  }
213
+ $head->appendChild( $this->amp_custom_style_element );
214
+ }
215
+
216
+ $css = implode( '', $this->get_stylesheets() );
217
+
218
+ /*
219
+ * Let the style[amp-custom] be populated with the concatenated CSS.
220
+ * !important: Updating the contents of this style element by setting textContent is not
221
+ * reliable across PHP/libxml versions, so this is why the children are removed and the
222
+ * text node is then explicitly added containing the CSS.
223
+ */
224
+ while ( $this->amp_custom_style_element->firstChild ) {
225
+ $this->amp_custom_style_element->removeChild( $this->amp_custom_style_element->firstChild );
226
+ }
227
+ $this->amp_custom_style_element->appendChild( $this->dom->createTextNode( $css ) );
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Generates an enqueued style's fully-qualified file path.
233
+ *
234
+ * @since 0.7
235
+ * @see WP_Styles::_css_href()
236
+ *
237
+ * @param string $src The source URL of the enqueued style.
238
+ * @return string|WP_Error Style's absolute validated filesystem path, or WP_Error when error.
239
+ */
240
+ public function get_validated_css_file_path( $src ) {
241
+ $needs_base_url = (
242
+ ! is_bool( $src )
243
+ &&
244
+ ! preg_match( '|^(https?:)?//|', $src )
245
+ &&
246
+ ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) )
247
+ );
248
+ if ( $needs_base_url ) {
249
+ $src = $this->base_url . $src;
250
+ }
251
+
252
+ // Strip query and fragment from URL.
253
+ $src = preg_replace( ':[\?#].*$:', '', $src );
254
+
255
+ if ( ! preg_match( '/\.(css|less|scss|sass)$/i', $src ) ) {
256
+ /* translators: %s is stylesheet URL */
257
+ return new WP_Error( 'amp_css_bad_file_extension', sprintf( __( 'Skipped stylesheet which does not have recognized CSS file extension (%s).', 'amp' ), $src ) );
258
+ }
259
+
260
+ $includes_url = includes_url( '/' );
261
+ $content_url = content_url( '/' );
262
+ $admin_url = get_admin_url( null, '/' );
263
+ $css_path = null;
264
+ if ( 0 === strpos( $src, $content_url ) ) {
265
+ $css_path = WP_CONTENT_DIR . substr( $src, strlen( $content_url ) - 1 );
266
+ } elseif ( 0 === strpos( $src, $includes_url ) ) {
267
+ $css_path = ABSPATH . WPINC . substr( $src, strlen( $includes_url ) - 1 );
268
+ } elseif ( 0 === strpos( $src, $admin_url ) ) {
269
+ $css_path = ABSPATH . 'wp-admin' . substr( $src, strlen( $admin_url ) - 1 );
270
+ }
271
 
272
+ if ( ! $css_path || false !== strpos( '../', $css_path ) || 0 !== validate_file( $css_path ) || ! file_exists( $css_path ) ) {
273
+ /* translators: %s is stylesheet URL */
274
+ return new WP_Error( 'amp_css_path_not_found', sprintf( __( 'Unable to locate filesystem path for stylesheet %s.', 'amp' ), $src ) );
275
+ }
276
+
277
+ return $css_path;
278
+ }
279
+
280
+ /**
281
+ * Process style element.
282
+ *
283
+ * @param DOMElement $element Style element.
284
+ */
285
+ private function process_style_element( DOMElement $element ) {
286
+ if ( $element->hasAttribute( 'amp-keyframes' ) ) {
287
+ $validity = $this->validate_amp_keyframe( $element );
288
+ if ( is_wp_error( $validity ) ) {
289
+ $this->remove_invalid_child( $element, array(
290
+ 'message' => $validity->get_error_message(),
291
+ ) );
292
  }
293
+ return;
294
  }
295
 
296
+ $rules = trim( $element->textContent );
297
+ $rules = $this->remove_illegal_css( $rules, $element );
 
298
 
299
+ // Remove if surpasses max size.
300
+ $length = strlen( $rules );
301
+ if ( $this->current_custom_size + $length > $this->custom_max_size ) {
302
+ $this->remove_invalid_child( $element, array(
303
+ 'message' => __( 'Too much CSS enqueued.', 'amp' ),
304
+ ) );
305
+ return;
306
+ }
307
+
308
+ $this->stylesheets[ md5( $rules ) ] = $rules;
309
+ $this->current_custom_size += $length;
310
+
311
+ if ( $element->hasAttribute( 'amp-custom' ) ) {
312
+ if ( ! $this->amp_custom_style_element ) {
313
+ $this->amp_custom_style_element = $element;
314
+ } else {
315
+ $element->parentNode->removeChild( $element ); // There can only be one. #highlander.
316
+ }
317
+ } else {
318
+
319
+ // Remove from DOM since we'll be adding it to amp-custom.
320
+ $element->parentNode->removeChild( $element );
321
  }
322
  }
323
 
324
+ /**
325
+ * Process link element.
326
+ *
327
+ * @param DOMElement $element Link element.
328
+ */
329
+ private function process_link_element( DOMElement $element ) {
330
+ $href = $element->getAttribute( 'href' );
331
 
332
+ // Allow font URLs.
333
+ if ( $this->allowed_font_src_regex && preg_match( $this->allowed_font_src_regex, $href ) ) {
334
+ return;
335
+ }
336
+
337
+ $css_file_path = $this->get_validated_css_file_path( $href );
338
+ if ( is_wp_error( $css_file_path ) ) {
339
+ $this->remove_invalid_child( $element, array(
340
+ 'message' => $css_file_path->get_error_message(),
341
+ ) );
342
+ return;
343
+ }
344
+
345
+ // Load the CSS from the filesystem.
346
+ $rules = "\n/* $href */\n";
347
+ $rules .= file_get_contents( $css_file_path ); // phpcs:ignore -- It's a local filesystem path not a remote request.
348
+
349
+ $rules = $this->remove_illegal_css( $rules, $element );
350
+
351
+ $media = $element->getAttribute( 'media' );
352
+ if ( $media && 'all' !== $media ) {
353
+ $rules = sprintf( '@media %s { %s }', $media, $rules );
354
+ }
355
+
356
+ // Remove if surpasses max size.
357
+ $length = strlen( $rules );
358
+ if ( $this->current_custom_size + $length > $this->custom_max_size ) {
359
+ $this->remove_invalid_child( $element, array(
360
+ 'message' => __( 'Too much CSS enqueued.', 'amp' ),
361
+ ) );
362
+ return;
363
+ }
364
+
365
+ $this->current_custom_size += $length;
366
+ $this->stylesheets[ $href ] = $rules;
367
+
368
+ // Remove now that styles have been processed.
369
+ $element->parentNode->removeChild( $element );
370
+ }
371
+
372
+ /**
373
+ * Remove illegal CSS from the stylesheet.
374
+ *
375
+ * @since 0.7
376
+ *
377
+ * @todo This needs proper CSS parser and to take an alternative approach to removing !important by extracting
378
+ * the rule into a separate style rule with a very specific selector.
379
+ * @param string $stylesheet Stylesheet.
380
+ * @param DOMElement $element Element where the stylesheet came from.
381
+ * @return string Scrubbed stylesheet.
382
+ */
383
+ private function remove_illegal_css( $stylesheet, $element ) {
384
+ $stylesheet = preg_replace( '/\s*!important/', '', $stylesheet, -1, $important_count ); // Note this has to also replace inside comments to be valid.
385
+ if ( $important_count > 0 && ! empty( $this->args['validation_error_callback'] ) ) {
386
+ call_user_func( $this->args['validation_error_callback'], array(
387
+ 'code' => 'css_important_removed',
388
+ 'node' => $element,
389
+ ) );
390
+ }
391
+ $stylesheet = preg_replace( '/overflow(-[xy])?\s*:\s*(auto|scroll)\s*;?\s*/', '', $stylesheet, -1, $overlow_count );
392
+ if ( $overlow_count > 0 && ! empty( $this->args['validation_error_callback'] ) ) {
393
+ call_user_func( $this->args['validation_error_callback'], array(
394
+ 'code' => 'css_overflow_property_removed',
395
+ 'node' => $element,
396
+ ) );
397
+ }
398
+ return $stylesheet;
399
+ }
400
+
401
+ /**
402
+ * Validate amp-keyframe style.
403
+ *
404
+ * @since 0.7
405
+ * @link https://github.com/ampproject/amphtml/blob/b685a0780a7f59313666225478b2b79b463bcd0b/validator/validator-main.protoascii#L1002-L1043
406
+ *
407
+ * @param DOMElement $style Style element.
408
+ * @return true|WP_Error Validity.
409
+ */
410
+ private function validate_amp_keyframe( $style ) {
411
+ if ( 'body' !== $style->parentNode->nodeName ) {
412
+ return new WP_Error( 'mandatory_body_child', __( 'amp-keyframes is not child of body element.', 'amp' ) );
413
  }
414
 
415
+ if ( $this->keyframes_max_size && strlen( $style->textContent ) > $this->keyframes_max_size ) {
416
+ return new WP_Error( 'max_bytes', __( 'amp-keyframes is too large', 'amp' ) );
417
+ }
418
+
419
+ // This logic could be in AMP_Tag_And_Attribute_Sanitizer, but since it only applies to amp-keyframes it seems unnecessary.
420
+ $next_sibling = $style->nextSibling;
421
+ while ( $next_sibling ) {
422
+ if ( $next_sibling instanceof DOMElement ) {
423
+ return new WP_Error( 'mandatory_last_child', __( 'amp-keyframes is not last element in body.', 'amp' ) );
424
+ }
425
+ $next_sibling = $next_sibling->nextSibling;
426
+ }
427
+
428
+ // @todo Also add validation of the CSS spec itself.
429
+ return true;
430
+ }
431
+
432
+ /**
433
+ * Collect and store all CSS style attributes.
434
+ *
435
+ * Collects the CSS styles from within the HTML contained in this instance's DOMDocument.
436
+ *
437
+ * @see Retrieve array of styles using $this->get_styles() after calling this method.
438
+ *
439
+ * @since 0.4
440
+ * @since 0.7 Modified to use element passed by XPath query.
441
+ *
442
+ * @note Uses recursion to traverse down the tree of DOMDocument nodes.
443
+ *
444
+ * @param DOMElement $element Node.
445
+ */
446
+ private function collect_inline_styles( $element ) {
447
+ $value = $element->getAttribute( 'style' );
448
+ if ( ! $value ) {
449
+ return;
450
+ }
451
+ $class = $element->getAttribute( 'class' );
452
+ $tagName = $element->tagName;
453
+ $properties = $this->process_style( $value );
454
+
455
+ if ( ! empty( $properties ) ) {
456
+ $class_name = $this->generate_class_name( $properties );
457
+ $new_class = trim( $class . ' ' . $class_name );
458
+ $selector = $tagName.'.' . $class_name;
459
+ $length = strlen( sprintf( '%s { %s }', $selector, join( '; ', $properties ) . ';' ) );
460
+
461
+ if ( $this->current_custom_size + $length > $this->custom_max_size ) {
462
+ $this->remove_invalid_attribute( $element, 'style', array(
463
+ 'message' => __( 'Too much CSS.', 'amp' ),
464
+ ) );
465
+ return;
466
+ }
467
+
468
+ $element->setAttribute( 'class', $new_class );
469
+ $this->styles[ $selector ] = $properties;
470
+ }
471
+ $element->removeAttribute( 'style' );
472
+ }
473
+
474
+ /**
475
+ * Sanitize and convert individual styles.
476
+ *
477
+ * @since 0.4
478
+ *
479
+ * @param string $css Style string.
480
+ * @return array Style properties.
481
+ */
482
+ private function process_style( $css ) {
483
+
484
+ // Normalize whitespace.
485
+ $css = str_replace( array( "\n", "\r", "\t" ), '', $css );
486
+
487
+ /*
488
+ * Use preg_split to break up rules by `;` but only if the
489
+ * semi-colon is not inside parens (like a data-encoded image).
490
+ */
491
+ $styles = preg_split( '/\s*;\s*(?![^(]*\))/', trim( $css, '; ' ) );
492
+ $styles = array_filter( $styles );
493
 
494
+ // Normalize the order of the styles.
495
  sort( $styles );
496
 
497
  $processed_styles = array();
498
 
499
+ // Normalize whitespace and filter rules.
500
  foreach ( $styles as $index => $rule ) {
501
+ $tuple = preg_split( '/\s*:\s*/', $rule, 2 );
502
+ if ( 2 !== count( $tuple ) ) {
503
  continue;
504
  }
505
 
506
+ list( $property, $value ) = $this->filter_style( $tuple[0], $tuple[1] );
507
  if ( empty( $property ) || empty( $value ) ) {
508
  continue;
509
  }
510
 
511
+ $processed_styles[ $index ] = "{$property}:{$value}";
512
  }
513
 
514
  return $processed_styles;
515
  }
516
 
517
+ /**
518
+ * Filter individual CSS name/value pairs.
519
+ *
520
+ * - Remove overflow if value is `auto` or `scroll`
521
+ * - Change `width` to `max-width`
522
+ * - Remove !important
523
+ *
524
+ * @since 0.4
525
+ *
526
+ * @param string $property Property.
527
+ * @param string $value Value.
528
+ * @return array
529
+ */
530
  private function filter_style( $property, $value ) {
531
+ /*
532
+ * Remove overflow if value is `auto` or `scroll`; not allowed in AMP
533
+ *
534
+ * @todo This removal needs to be reported.
535
+ * @see https://www.ampproject.org/docs/reference/spec.html#properties
536
+ */
537
+ if ( preg_match( '#^overflow(-[xy])?$#i', $property ) && preg_match( '#^(auto|scroll)$#i', $value ) ) {
538
+ return array( false, false );
539
  }
540
 
541
  if ( 'width' === $property ) {
542
  $property = 'max-width';
543
  }
544
 
545
+ /*
546
+ * Remove `!important`; not allowed in AMP
547
+ *
548
+ * @todo This removal needs to be reported.
549
+ */
550
  if ( false !== strpos( $value, 'important' ) ) {
551
  $value = preg_replace( '/\s*\!\s*important$/', '', $value );
552
  }
554
  return array( $property, $value );
555
  }
556
 
557
+ /**
558
+ * Generate a unique class name
559
+ *
560
+ * Use the md5() of the $data parameter
561
+ *
562
+ * @since 0.4
563
+ *
564
+ * @param string $data Data.
565
+ * @return string Class name.
566
+ */
567
  private function generate_class_name( $data ) {
568
  $string = maybe_serialize( $data );
569
  return 'amp-wp-inline-' . md5( $string );
570
  }
571
+ }
pagebuilder/inc/viewShowFrontData.php CHANGED
@@ -499,7 +499,59 @@ function amppb_validateCss($css){
499
  $css = preg_replace('/(([a-z -]*:(\s)*;))/', "", $css);
500
  $css = preg_replace('/((;[\s\n;]*;))/', ";", $css);
501
  $css = preg_replace('/(?:[^\r\n,{}]+)(?:,(?=[^}]*{,)|\s*{[\s]*})/', "", $css);
502
- return $css;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  }
504
 
505
  function amppb_post_content($content){
499
  $css = preg_replace('/(([a-z -]*:(\s)*;))/', "", $css);
500
  $css = preg_replace('/((;[\s\n;]*;))/', ";", $css);
501
  $css = preg_replace('/(?:[^\r\n,{}]+)(?:,(?=[^}]*{,)|\s*{[\s]*})/', "", $css);
502
+ return ampforwp_pb_autoCompileLess($css);
503
+ }
504
+
505
+ function ampforwp_pb_autoCompileLess($css)
506
+ {
507
+ $completeCssMinifies = array();
508
+ preg_match_all("/@media\b[^{]*({((?:[^{}]+|(?1))*)})/si",$css,$matches,PREG_SET_ORDER);//$MatchingString now hold all strings matching $pattern.
509
+ foreach ($matches as $key => $value) {
510
+ preg_match('/@media\s*(.*?)\s*{/', $value[0], $data);
511
+ if(!isset($completeCssMinifies[$data[1]])){ $completeCssMinifies[$data[1]] = ''; }
512
+ $completeCssMinifies[$data[1]] .= trim($value[2]);
513
+ }
514
+ // delete media query of cache
515
+ $css = preg_replace('/@media\b[^{]*({((?:[^{}]+|(?1))*)})/si', '', $css);
516
+
517
+ // add groups of media query at the end of CSS
518
+ $css = $css." \n";
519
+ foreach ($completeCssMinifies as $id => $val)
520
+ {
521
+ $css .= "\n" . '@media' . $id . '{' . $val . '}' . "\n";
522
+ }
523
+ //Remove multiple Spaces
524
+ //padding:\s*?(\d*px)\s*(\d*px)\s*(\d*px)\s*(\d*px)\s*?;
525
+ //"/(margin|padding):\s*?(\d*px)\s*(\d*px)\s*(\d*px)\s*(\d*px)\s*?\s*;/",
526
+ $css = preg_replace_callback(
527
+ "/(margin|padding):\s*?(auto|\d*(|px))\s*(auto|\d*(|px))\s*(auto|\d*(|px))\s*(auto|\d*(|px))\s*?\s*;/",
528
+ function($m) {
529
+ if(count($m)!==0){
530
+ $m[2] = trim($m[2]);
531
+ $m[3] = trim($m[3]);
532
+ $m[4] = trim($m[4]);
533
+ $m[5] = trim($m[5]);
534
+ if( ($m[2]==$m[6]) && ($m[4] == $m[8]) ){
535
+ if ( $m[2] == $m[4] ) {
536
+ return $m[1].":".$m[2].";";
537
+ }
538
+ if(trim($parts[0])==trim($m[1])){
539
+ return $m[1].":".$m[2].";";
540
+ }else{
541
+ return $m[1].":".$m[2]." ".$m[4].";";
542
+ }
543
+ }
544
+ else{
545
+ return $m[0];
546
+ }
547
+ }else{
548
+ return $m[0];
549
+ }
550
+
551
+ },
552
+ $css);
553
+ // save CSS with groups of media query
554
+ return $css;
555
  }
556
 
557
  function amppb_post_content($content){
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.0.3
7
- Stable tag: 0.9.97.32
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -185,14 +185,15 @@ You can contact us from [here](https://ampforwp.com/contact/)
185
 
186
  == Changelog ==
187
 
188
- = 0.9.97.32 (8th February 2019) =
189
- * Added: Rank Math SEO compatibility integrated #2701 & #2736
190
- * Added: New filter "ampforwp_modify_thumb_url_array" to modify the thumbnail #2739
191
- * Fixed: 'Call Button Color' option not working - code updated #2820
192
- * Fixed: Validation error when uploading YouTube video in Comments #2827
193
- * Fixed: When Mobile Redirection option is enabled then, fr (language symbol) is removed from the URL. #2721
194
- * Fixed: Category Module from Page Builder not displaying #2870
195
- * Fixed: The homepage displays the title of the first post in All in one SEO #2865
196
- * Fixed: Title mismatch in some posts with Yoast #2871
 
197
 
198
  Full changelog available in changelog.txt
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 5.0.3
7
+ Stable tag: 0.9.97.33
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
185
 
186
  == Changelog ==
187
 
188
+ = 0.9.97.33 (13th February 2019) =
189
+ * Fixed: Style sanitizer code updated #2387
190
+ * Fixed: UTM Parameters when Mobile Redirection is enabled #2854
191
+ * Fixed: ?nonamp=1 is not working properly #1947 & #2537
192
+ * Fixed: All media queries load in single media query only #2711
193
+ * Fixed: 'Hide AMP option' is not working when AMP take over is enabled #2880
194
+ * Fixed: Swift Hover Color Changes #2751
195
+ * Fixed: Google Font is not getting saved #2839
196
+ * Fixed: Sidebar CSS condition code fixed #2757
197
+ * Fixed: Performance improvement for ampforwp_stylesheet_file_insertion #2873
198
 
199
  Full changelog available in changelog.txt
templates/design-manager.php CHANGED
@@ -72,27 +72,26 @@ if ( is_customize_preview() ) {
72
  // Design Selector
73
  add_action('pre_amp_render_post','ampforwp_design_selector', 11 );
74
  function ampforwp_design_selector() {
75
-
76
  global $redux_builder_amp;
77
- if ( isset($redux_builder_amp['amp-design-selector']) && $redux_builder_amp['amp-design-selector'] ) {
78
- if ( file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'.$redux_builder_amp['amp-design-selector'] . '/style.php') ) {
 
 
 
 
 
 
79
  return $redux_builder_amp['amp-design-selector'];
80
  }
81
- elseif ( 4 == $redux_builder_amp['amp-design-selector'] && file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/swift/style.php') ) {
82
  return $redux_builder_amp['amp-design-selector'];
83
  }
84
  else {
85
- $plugin_data = get_plugins();
86
- if ( count($plugin_data) > 0 ) {
87
- foreach ( $plugin_data as $key => $data ) {
88
- if ( $data['TextDomain'] == $redux_builder_amp['amp-design-selector'] ) {
89
- if ( file_exists(AMPFORWP_MAIN_PLUGIN_DIR."/".$key) ) {
90
- return $redux_builder_amp['amp-design-selector'];
91
- }
92
- break;
93
- }
94
- }
95
- }
96
  }
97
  return 2;
98
  }
@@ -111,20 +110,7 @@ function ampforwp_stylesheet_file_insertion() {
111
  if ( file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $ampforwp_design_selector . '/style.php') && 4 != $ampforwp_design_selector ) {
112
  //require AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $ampforwp_design_selector . '/style.php';
113
  }else {
114
- if ( 4 != $ampforwp_design_selector ) {
115
- $plugin_data = get_plugins();
116
- if ( count($plugin_data) > 0 ) {
117
- foreach ( $plugin_data as $key => $data ) {
118
- if ( $data['TextDomain'] == $ampforwp_design_selector ) {
119
- if ( ! file_exists(AMPFORWP_MAIN_PLUGIN_DIR."/".$key) ) {
120
- echo "plugin theme not exists";
121
- }
122
- break;
123
- }
124
- }
125
- }
126
- }
127
- require AMPFORWP_PLUGIN_DIR."/components/theme-loader.php";
128
  }
129
  }
130
 
72
  // Design Selector
73
  add_action('pre_amp_render_post','ampforwp_design_selector', 11 );
74
  function ampforwp_design_selector() {
 
75
  global $redux_builder_amp;
76
+ $design = '';
77
+ $design = ampforwp_get_setting('amp-design-selector');
78
+ if ( empty( $design )){
79
+ return 4;
80
+ }
81
+
82
+ if ( $design ) {
83
+ if ( file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $design . '/style.php') ) {
84
  return $redux_builder_amp['amp-design-selector'];
85
  }
86
+ elseif ( 4 == $design && file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/swift/style.php') ) {
87
  return $redux_builder_amp['amp-design-selector'];
88
  }
89
  else {
90
+ if ( file_exists( WP_PLUGIN_DIR.'/'.$design.'/functions.php' ) ){
91
+ return $design;
92
+ } else {
93
+ return 4;
94
+ }
 
 
 
 
 
 
95
  }
96
  return 2;
97
  }
110
  if ( file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $ampforwp_design_selector . '/style.php') && 4 != $ampforwp_design_selector ) {
111
  //require AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $ampforwp_design_selector . '/style.php';
112
  }else {
113
+ require AMPFORWP_PLUGIN_DIR."/components/theme-loader.php";
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
  }
116
 
templates/design-manager/design-1/style.php CHANGED
@@ -55,7 +55,7 @@ amp-iframe{ max-width: 100%; margin-bottom : 20px; }
55
  amp-wistia-player {margin:5px 0px;}
56
  .amp-wp-content,.amp-wp-title-bar div {<?php if ( $content_max_width > 0 ) : ?> margin: 0 auto;max-width: <?php echo esc_attr(sprintf( '%dpx', $content_max_width )); ?>; <?php endif; ?> }
57
  html{background: <?php echo sanitize_hex_color( $header_background_color ); ?>;} body{background: <?php echo sanitize_hex_color( $theme_color ); ?>;color: <?php echo sanitize_hex_color( $text_color ); ?>;font-family: 'Merriweather', 'Times New Roman', Times, Serif;font-weight: 300;line-height: 1.75em;}
58
- p,ol,ul,figure {margin: 0 0 1em;padding: 0;} a,a:visited {color:<?php echo $redux_builder_amp['amp-opt-color-rgba-link-design1']['color']; ?>;}a:hover,a:active,a:focus {color: <?php echo sanitize_hex_color( $text_color ); ?>;} .wp-caption amp-img{max-width: 100%}
59
  blockquote {color: <?php echo sanitize_hex_color( $text_color ); ?>;background: rgba(127,127,127,.125);border-left: 2px solid <?php echo sanitize_hex_color( $link_color ); ?>;margin: 8px 0 24px 0;padding: 16px;} blockquote p:last-child {margin-bottom: 0;}
60
  .amp-wp-meta,.amp-wp-header .ampforwp-logo-area,.amp-wp-title,.wp-caption-text,.amp-wp-tax-category,.amp-wp-tax-tag,.amp-wp-comments-link,.amp-wp-footer p,.back-to-top {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif;}
61
  .amp-wp-header {background-color: <?php echo sanitize_hex_color( $header_background_color ); ?>;}
55
  amp-wistia-player {margin:5px 0px;}
56
  .amp-wp-content,.amp-wp-title-bar div {<?php if ( $content_max_width > 0 ) : ?> margin: 0 auto;max-width: <?php echo esc_attr(sprintf( '%dpx', $content_max_width )); ?>; <?php endif; ?> }
57
  html{background: <?php echo sanitize_hex_color( $header_background_color ); ?>;} body{background: <?php echo sanitize_hex_color( $theme_color ); ?>;color: <?php echo sanitize_hex_color( $text_color ); ?>;font-family: 'Merriweather', 'Times New Roman', Times, Serif;font-weight: 300;line-height: 1.75em;}
58
+ p,ol,ul,figure {margin: 0 0 1em;padding: 0;} a,a:visited {color:<?php echo ampforwp_sanitize_color($redux_builder_amp['amp-opt-color-rgba-link-design1']['color']); ?>;}a:hover,a:active,a:focus {color: <?php echo sanitize_hex_color( $text_color ); ?>;} .wp-caption amp-img{max-width: 100%}
59
  blockquote {color: <?php echo sanitize_hex_color( $text_color ); ?>;background: rgba(127,127,127,.125);border-left: 2px solid <?php echo sanitize_hex_color( $link_color ); ?>;margin: 8px 0 24px 0;padding: 16px;} blockquote p:last-child {margin-bottom: 0;}
60
  .amp-wp-meta,.amp-wp-header .ampforwp-logo-area,.amp-wp-title,.wp-caption-text,.amp-wp-tax-category,.amp-wp-tax-tag,.amp-wp-comments-link,.amp-wp-footer p,.back-to-top {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif;}
61
  .amp-wp-header {background-color: <?php echo sanitize_hex_color( $header_background_color ); ?>;}
templates/design-manager/swift/style.php CHANGED
@@ -7,6 +7,9 @@
7
  @font-face {font-family: 'Poppins';font-display: auto;font-style: normal;font-weight: 700;src: local('Poppins Bold'), local('Poppins-Bold'), url('<?php echo plugin_dir_url(__FILE__) ?>fonts/Poppins-Bold.ttf'); }
8
  <?php } ?>
9
  body{<?php $fontFamily = "font-family: 'Poppins', sans-serif;";
 
 
 
10
  if(isset($redux_builder_amp['amp_font_selector']) && $redux_builder_amp['amp_font_selector'] != 1 && !empty($redux_builder_amp['amp_font_selector'])){
11
  $fontFamily = "font-family: '".$redux_builder_amp['amp_font_selector']."';"; }
12
  echo $fontFamily;?>
@@ -19,7 +22,9 @@ font-size: 16px; line-height:1.25; }
19
  ol, ul{ list-style-position: inside }
20
  p, ol, ul, figure{ margin: 0 0 1em; padding: 0; }
21
  a, a:active, a:visited{ text-decoration: none; color: <?php echo ampforwp_sanitize_color($swift_cs_color); ?>;}
22
- a:hover, a:active, a:focus{}
 
 
23
  pre{ white-space: pre-wrap;}
24
  .left{float:left}
25
  .right{float:right}
@@ -55,7 +60,7 @@ header .cntr{
55
  }
56
  <?php if($redux_builder_amp['amp-sticky-header'] == '1'){?>
57
  .h_m{position:fixed;z-index:999;top:0px;width: 100vw;display:inline-block;
58
- <?php if($redux_builder_amp['swift-background-scheme']['rgba']){?>background: <?php echo $redux_builder_amp['swift-background-scheme'] ['rgba'] ?>;<?php }?>
59
  <?php if($redux_builder_amp['swift-border-line-control']){?>border-bottom: <?php echo $redux_builder_amp['swift-border-line-control'] ?>px solid;<?php } ?>
60
  <?php if($redux_builder_amp['swift-border-color-control']['rgba']){?>border-color:<?php echo ampforwp_sanitize_color($redux_builder_amp['swift-border-color-control'] ['rgba']) ?>;<?php } ?>
61
  <?php if($redux_builder_amp['swift-boxshadow-checkbox-control']){?>box-shadow:0px 0px 2px 2px #ccc;<?php }?>
@@ -66,7 +71,7 @@ header .cntr{
66
  <?php } else{ ?>
67
  .h_m{
68
  position: static;
69
- <?php if($redux_builder_amp['swift-background-scheme']['rgba']){?>background: <?php echo $redux_builder_amp['swift-background-scheme'] ['rgba'] ?>;<?php }?>
70
  <?php if($redux_builder_amp['swift-border-line-control']){?>border-bottom: <?php echo $redux_builder_amp['swift-border-line-control'] ?>px solid;<?php } ?>
71
  <?php if($redux_builder_amp['swift-border-color-control']['rgba']){?>border-color:<?php echo ampforwp_sanitize_color($redux_builder_amp['swift-border-color-control'] ['rgba']) ?>;<?php } ?>
72
  <?php if($redux_builder_amp['swift-boxshadow-checkbox-control']){?>box-shadow:0px 0px 2px 2px #ccc;<?php }?>
@@ -127,7 +132,7 @@ if($redux_builder_amp['header-type'] == '3'){?>
127
  <?php //search overlay
128
 
129
  if( true == $redux_builder_amp['amp-swift-search-feature'] ){ ?>
130
- .lb-t {position: fixed;top: -50px;width: 100%;width: 100%;opacity: 0;-webkit-transition: opacity .5s ease-in-out;transition: opacity .5s ease-in-out;overflow: hidden;z-index:9;<?php if($redux_builder_amp['swift-header-overlay']['rgba']){?>background: <?php echo $redux_builder_amp['swift-header-overlay'] ['rgba'] ?>;<?php } ?>}
131
  .lb-t img {margin: auto;position: absolute;top: 0;left:0;right:0;bottom: 0;max-height: 0%;max-width: 0%;border: 3px solid white;box-shadow: 0px 0px 8px rgba(0,0,0,.3);box-sizing: border-box;-webkit-transition: .5s ease-in-out;transition: .5s ease-in-out;}
132
  a.lb-x {display: block;width:50px;height:50px;box-sizing: border-box;background: tranparent;color: black;text-decoration: none;position: absolute;top: -80px;right: 0;-webkit-transition: .5s ease-in-out;transition: .5s ease-in-out;}
133
  a.lb-x:after {content: "\e5cd";font-family: 'icomoon';font-size: 30px;line-height: 0;display: block;text-indent: 1px;
@@ -249,9 +254,9 @@ if( ampforwp_is_home() || is_archive() || is_search() || (function_exists('is_sh
249
  .loop-wrapper{display: flex;flex-wrap: wrap;margin: -15px;}
250
  .loop-category li{display: inline-block;list-style-type: none;margin-right: 10px;font-size: 10px;font-weight: 600;letter-spacing: 1.5px;}
251
  .loop-category li a{color:#555;text-transform: uppercase;}
252
- .loop-category li:hover a{color:#005be2;}
253
  .fbp-cnt p, .fsp-cnt p{color:#444;font-size:13px;line-height:1.5;letter-spacing: 0.10px;word-break: break-word;}
254
- .fbp:hover h2 a, .fsp:hover h2 a{color: <?php echo ampforwp_sanitize_color($swift_cs_color); ?>;}
255
  .fsp h2 a{color:#191919;}
256
  .fsp{margin: 15px;flex-basis: calc(33.33% - 30px);}
257
  .fsp-img {margin-bottom:10px;}
@@ -398,6 +403,7 @@ p.nocomments {padding: 10px;color: #fff;}
398
  .tl-exc{font-size: 16px;color: #444;margin-top: 10px;line-height:20px;}
399
  .amp-category span:nth-child(1) {display: none;}
400
  .amp-category span a, .amp-category span{color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']); ?>;font-size: 12px;font-weight: 500;text-transform: uppercase;}
 
401
  .amp-category span:after{content:"/";display:inline-block;margin:0px 5px 0px 5px;position:relative;top:1px;color:rgba(0, 0, 0, 0.25);}
402
  .amp-category span:last-child:after{display:none;}
403
  .sp{width:100%;margin-top:20px;display:inline-block;}
@@ -417,6 +423,7 @@ p.nocomments {padding: 10px;color: #fff;}
417
  .shr-txt, .athr-tx, .r-pf h3, .amp-tags > span:nth-child(1), .amp-related-posts-title, .post-date, .related-title{text-transform: uppercase;font-size: 12px;color: #666;font-weight: 400;}
418
  .loop-date, .post-edit-link{display:inline-block;}
419
  .post-date .post-edit-link{color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']); ?>;float: right;}
 
420
  .sp-athr, .amp-tags, .post-date{margin-top:20px;}
421
  .sp-athr .author-details a, .sp-athr .author-details, .amp-tags span a, .amp-tag {font-size: 15px;color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']); ?>;font-weight: 400;line-height: 1.5;}
422
  .amp-tags .amp-tag:after{content: "/";display: inline-block;padding: 0px 10px;position: relative;top: -1px;color: #ccc;font-size: 12px;}
@@ -588,7 +595,7 @@ letter-spacing: 0.10px;margin-top: 5px;font-weight: 400;}
588
  .sp-rt .amp-author {padding: 20px 20px;border-radius: 0;background: #f9f9f9;border: 1px solid #ececec;display: inline-block;width: 100%;}
589
  .sp-rt .amp-author-image{float:left;}
590
  .sp-rt .author-details a{color: #222;font-size: 14px;font-weight: 500;}
591
- .sp-rt .author-details a:hover{color:#005be2;text-decoration:underline;}
592
  .amp-author-image amp-img{border-radius: 50%;margin: 0px 12px 5px 0px;display: block; width:50px;}
593
  .author-details p{margin: 0;font-size: 13px;line-height: 20px;color: #666;padding-top: 4px;}
594
  <?php } ?>
@@ -600,7 +607,7 @@ border-bottom: 1px solid #eee;
600
  <?php }?>}
601
  .breadcrumb ul li,.breadcrumbs span{display: inline-block;list-style-type: none;font-size: 10px;text-transform: uppercase;margin-right: 5px;}
602
  .breadcrumb ul li a, .breadcrumbs span a{color: #999;letter-spacing: 1px;}
603
- .breadcrumb ul li a:hover, .breadcrumbs span a:hover{color:#005be2;}
604
  .breadcrumbs li a:after, .breadcrumbs span a:after{content: "\e315";display: inline-block;color: #bdbdbd;font-family: 'icomoon';padding-left: 5px;font-size: 12px;position: relative;top: 1px;}
605
  .breadcrumbs li:last-child a:after {display: none;}
606
  <?php } //Breadcrumbs Ends?>
@@ -610,7 +617,7 @@ border-bottom: 1px solid #eee;
610
  .prev{float: left;width: 45%;position:relative;margin-top:10px;}
611
  .prev span{text-transform: uppercase;font-size: 12px;color: #666;display: block;position: absolute;top: -26px;}
612
  .next span{text-transform: uppercase;font-size: 12px;color: #666;display: block;font-weight: 400;position: absolute;top: -26px;right:0}
613
- .next:hover a, .prev:hover a{color:<?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']) ?>;}
614
  .prev:after{border-left:1px dotted #ccc;content: "";height: calc(100% - -10px);right: -50px;position: absolute;top: 50%;transform: translate(0px, -50%);width: 2px;}
615
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
616
  .ampforwp_post_pagination p{margin: 0;font-size: 18px;color: #444;font-weight: 500;margin-bottom:10px;}
@@ -641,7 +648,7 @@ border-bottom: 1px solid #eee;
641
  .loop-category li a{color:#555;text-transform: uppercase;}
642
  .loop-category li:hover a{color:#005be2;}
643
  .fsp-cnt p{color:#444;font-size:13px;line-height:20px;letter-spacing: 0.10px;word-break: break-word;}
644
- .fsp:hover h2 a{color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']); ?>;}
645
  .fsp h2 a{color:#191919;}
646
  .fsp{margin: 15px;flex-basis: calc(33.33% - 30px);}
647
  .fsp-img {margin-bottom:10px;}
@@ -924,8 +931,7 @@ if (isset($redux_builder_amp['swift-sidebar']) && $redux_builder_amp['swift-side
924
  <?php } // sidebar CSS ends
925
  } // single design 4 ends?>
926
  <?php // Header and Archive Sidebar
927
- if ( (isset($redux_builder_amp['gbl-sidebar']) && $redux_builder_amp['gbl-sidebar'])
928
- && (isset($redux_builder_amp['gnrl-sidebar']) && $redux_builder_amp['gnrl-sidebar']) ) { ?>
929
  .b-w, .arch-dsgn{
930
  display: flex;
931
  }
@@ -978,12 +984,12 @@ if ( (isset($redux_builder_amp['gbl-sidebar']) && $redux_builder_amp['gbl-sideba
978
  }
979
  }
980
  <?php }
981
- if ( (isset($redux_builder_amp['gbl-sidebar']) && $redux_builder_amp['gbl-sidebar'] ) || (isset($redux_builder_amp['swift-sidebar']) && $redux_builder_amp['swift-sidebar'] ) ) { ?>
982
  /*** Sidebar CSS ***/
983
  <?php if ( is_active_sidebar( 'swift-sidebar' ) ) : ?>
984
  .sdbr-right{
985
  <?php if( isset($redux_builder_amp['sidebar-bgcolor']['rgba']) && $redux_builder_amp['sidebar-bgcolor']['rgba'] ) {?>
986
- background:<?php echo $redux_builder_amp['sidebar-bgcolor']['rgba']?>;
987
  <?php } ?>
988
  display:flex;
989
  flex-direction:column;
@@ -1096,7 +1102,7 @@ if ( isset($redux_builder_amp['footer-type']) && '1' == $redux_builder_amp['foot
1096
  .f-menu ul li .sub-menu{display:none;}
1097
  .f-menu ul li{display:inline-block;margin-right:20px;}
1098
  .f-menu ul li a {padding:0;color:#7a7a7a;}
1099
- .f-menu ul > li:hover a{color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']) ?>;}
1100
  .f-menu{font-size:14px;line-height:1.4;margin-bottom:30px;}
1101
  .rr{font-size: 12px;color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-footer-txt-clr']['rgba']) ?>;}
1102
  .rr span{margin:0 10px 0 0px}
@@ -1199,7 +1205,7 @@ if( isset($redux_builder_amp['footer-customize-options']) && true == $redux_bui
1199
  }
1200
  .f-w-f1{
1201
  <?php if( $redux_builder_amp['swift-footer-bg']['rgba'] ) {?>
1202
- background:<?php echo $redux_builder_amp['swift-footer-bg']['rgba']?>;
1203
  <?php } ?>
1204
  font-size: <?php echo $redux_builder_amp['swift-footer1-cntnsize']?>;
1205
  line-height: 1.5;
7
  @font-face {font-family: 'Poppins';font-display: auto;font-style: normal;font-weight: 700;src: local('Poppins Bold'), local('Poppins-Bold'), url('<?php echo plugin_dir_url(__FILE__) ?>fonts/Poppins-Bold.ttf'); }
8
  <?php } ?>
9
  body{<?php $fontFamily = "font-family: 'Poppins', sans-serif;";
10
+ $hovercolor = '';
11
+ $hovercolor = ampforwp_get_setting('swift-hover-color-scheme');
12
+ $hovercolor = $hovercolor['color'];
13
  if(isset($redux_builder_amp['amp_font_selector']) && $redux_builder_amp['amp_font_selector'] != 1 && !empty($redux_builder_amp['amp_font_selector'])){
14
  $fontFamily = "font-family: '".$redux_builder_amp['amp_font_selector']."';"; }
15
  echo $fontFamily;?>
22
  ol, ul{ list-style-position: inside }
23
  p, ol, ul, figure{ margin: 0 0 1em; padding: 0; }
24
  a, a:active, a:visited{ text-decoration: none; color: <?php echo ampforwp_sanitize_color($swift_cs_color); ?>;}
25
+ body a:hover{
26
+ color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;
27
+ }
28
  pre{ white-space: pre-wrap;}
29
  .left{float:left}
30
  .right{float:right}
60
  }
61
  <?php if($redux_builder_amp['amp-sticky-header'] == '1'){?>
62
  .h_m{position:fixed;z-index:999;top:0px;width: 100vw;display:inline-block;
63
+ <?php if($redux_builder_amp['swift-background-scheme']['rgba']){?>background: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-background-scheme'] ['rgba']) ?>;<?php }?>
64
  <?php if($redux_builder_amp['swift-border-line-control']){?>border-bottom: <?php echo $redux_builder_amp['swift-border-line-control'] ?>px solid;<?php } ?>
65
  <?php if($redux_builder_amp['swift-border-color-control']['rgba']){?>border-color:<?php echo ampforwp_sanitize_color($redux_builder_amp['swift-border-color-control'] ['rgba']) ?>;<?php } ?>
66
  <?php if($redux_builder_amp['swift-boxshadow-checkbox-control']){?>box-shadow:0px 0px 2px 2px #ccc;<?php }?>
71
  <?php } else{ ?>
72
  .h_m{
73
  position: static;
74
+ <?php if($redux_builder_amp['swift-background-scheme']['rgba']){?>background: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-background-scheme'] ['rgba']) ?>;<?php }?>
75
  <?php if($redux_builder_amp['swift-border-line-control']){?>border-bottom: <?php echo $redux_builder_amp['swift-border-line-control'] ?>px solid;<?php } ?>
76
  <?php if($redux_builder_amp['swift-border-color-control']['rgba']){?>border-color:<?php echo ampforwp_sanitize_color($redux_builder_amp['swift-border-color-control'] ['rgba']) ?>;<?php } ?>
77
  <?php if($redux_builder_amp['swift-boxshadow-checkbox-control']){?>box-shadow:0px 0px 2px 2px #ccc;<?php }?>
132
  <?php //search overlay
133
 
134
  if( true == $redux_builder_amp['amp-swift-search-feature'] ){ ?>
135
+ .lb-t {position: fixed;top: -50px;width: 100%;width: 100%;opacity: 0;-webkit-transition: opacity .5s ease-in-out;transition: opacity .5s ease-in-out;overflow: hidden;z-index:9;<?php if($redux_builder_amp['swift-header-overlay']['rgba']){?>background: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-header-overlay'] ['rgba']) ?>;<?php } ?>}
136
  .lb-t img {margin: auto;position: absolute;top: 0;left:0;right:0;bottom: 0;max-height: 0%;max-width: 0%;border: 3px solid white;box-shadow: 0px 0px 8px rgba(0,0,0,.3);box-sizing: border-box;-webkit-transition: .5s ease-in-out;transition: .5s ease-in-out;}
137
  a.lb-x {display: block;width:50px;height:50px;box-sizing: border-box;background: tranparent;color: black;text-decoration: none;position: absolute;top: -80px;right: 0;-webkit-transition: .5s ease-in-out;transition: .5s ease-in-out;}
138
  a.lb-x:after {content: "\e5cd";font-family: 'icomoon';font-size: 30px;line-height: 0;display: block;text-indent: 1px;
254
  .loop-wrapper{display: flex;flex-wrap: wrap;margin: -15px;}
255
  .loop-category li{display: inline-block;list-style-type: none;margin-right: 10px;font-size: 10px;font-weight: 600;letter-spacing: 1.5px;}
256
  .loop-category li a{color:#555;text-transform: uppercase;}
257
+ .loop-category li:hover a{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
258
  .fbp-cnt p, .fsp-cnt p{color:#444;font-size:13px;line-height:1.5;letter-spacing: 0.10px;word-break: break-word;}
259
+ .fbp:hover h2 a, .fsp:hover h2 a{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
260
  .fsp h2 a{color:#191919;}
261
  .fsp{margin: 15px;flex-basis: calc(33.33% - 30px);}
262
  .fsp-img {margin-bottom:10px;}
403
  .tl-exc{font-size: 16px;color: #444;margin-top: 10px;line-height:20px;}
404
  .amp-category span:nth-child(1) {display: none;}
405
  .amp-category span a, .amp-category span{color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']); ?>;font-size: 12px;font-weight: 500;text-transform: uppercase;}
406
+ .amp-category span a:hover {color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
407
  .amp-category span:after{content:"/";display:inline-block;margin:0px 5px 0px 5px;position:relative;top:1px;color:rgba(0, 0, 0, 0.25);}
408
  .amp-category span:last-child:after{display:none;}
409
  .sp{width:100%;margin-top:20px;display:inline-block;}
423
  .shr-txt, .athr-tx, .r-pf h3, .amp-tags > span:nth-child(1), .amp-related-posts-title, .post-date, .related-title{text-transform: uppercase;font-size: 12px;color: #666;font-weight: 400;}
424
  .loop-date, .post-edit-link{display:inline-block;}
425
  .post-date .post-edit-link{color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']); ?>;float: right;}
426
+ .post-date .post-edit-link:hover{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
427
  .sp-athr, .amp-tags, .post-date{margin-top:20px;}
428
  .sp-athr .author-details a, .sp-athr .author-details, .amp-tags span a, .amp-tag {font-size: 15px;color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-color-scheme']['color']); ?>;font-weight: 400;line-height: 1.5;}
429
  .amp-tags .amp-tag:after{content: "/";display: inline-block;padding: 0px 10px;position: relative;top: -1px;color: #ccc;font-size: 12px;}
595
  .sp-rt .amp-author {padding: 20px 20px;border-radius: 0;background: #f9f9f9;border: 1px solid #ececec;display: inline-block;width: 100%;}
596
  .sp-rt .amp-author-image{float:left;}
597
  .sp-rt .author-details a{color: #222;font-size: 14px;font-weight: 500;}
598
+ .sp-rt .author-details a:hover{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;text-decoration:underline;}
599
  .amp-author-image amp-img{border-radius: 50%;margin: 0px 12px 5px 0px;display: block; width:50px;}
600
  .author-details p{margin: 0;font-size: 13px;line-height: 20px;color: #666;padding-top: 4px;}
601
  <?php } ?>
607
  <?php }?>}
608
  .breadcrumb ul li,.breadcrumbs span{display: inline-block;list-style-type: none;font-size: 10px;text-transform: uppercase;margin-right: 5px;}
609
  .breadcrumb ul li a, .breadcrumbs span a{color: #999;letter-spacing: 1px;}
610
+ .breadcrumb ul li a:hover, .breadcrumbs span a:hover{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
611
  .breadcrumbs li a:after, .breadcrumbs span a:after{content: "\e315";display: inline-block;color: #bdbdbd;font-family: 'icomoon';padding-left: 5px;font-size: 12px;position: relative;top: 1px;}
612
  .breadcrumbs li:last-child a:after {display: none;}
613
  <?php } //Breadcrumbs Ends?>
617
  .prev{float: left;width: 45%;position:relative;margin-top:10px;}
618
  .prev span{text-transform: uppercase;font-size: 12px;color: #666;display: block;position: absolute;top: -26px;}
619
  .next span{text-transform: uppercase;font-size: 12px;color: #666;display: block;font-weight: 400;position: absolute;top: -26px;right:0}
620
+ .next:hover a, .prev:hover a{color:<?php echo ampforwp_sanitize_color($hovercolor); ?>;}
621
  .prev:after{border-left:1px dotted #ccc;content: "";height: calc(100% - -10px);right: -50px;position: absolute;top: 50%;transform: translate(0px, -50%);width: 2px;}
622
  .ampforwp_post_pagination{width:100%;text-align:center;display:inline-block;}
623
  .ampforwp_post_pagination p{margin: 0;font-size: 18px;color: #444;font-weight: 500;margin-bottom:10px;}
648
  .loop-category li a{color:#555;text-transform: uppercase;}
649
  .loop-category li:hover a{color:#005be2;}
650
  .fsp-cnt p{color:#444;font-size:13px;line-height:20px;letter-spacing: 0.10px;word-break: break-word;}
651
+ .fsp:hover h2 a{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
652
  .fsp h2 a{color:#191919;}
653
  .fsp{margin: 15px;flex-basis: calc(33.33% - 30px);}
654
  .fsp-img {margin-bottom:10px;}
931
  <?php } // sidebar CSS ends
932
  } // single design 4 ends?>
933
  <?php // Header and Archive Sidebar
934
+ if ( ampforwp_get_setting('gbl-sidebar') && ampforwp_get_setting('gnrl-sidebar') && is_active_sidebar( 'swift-sidebar' ) ) { ?>
 
935
  .b-w, .arch-dsgn{
936
  display: flex;
937
  }
984
  }
985
  }
986
  <?php }
987
+ if ( ( true == ampforwp_get_setting('gbl-sidebar') && (ampforwp_is_front_page() || ampforwp_is_home()) ) || ( true == ampforwp_get_setting('swift-sidebar') && is_single() ) ) { ?>
988
  /*** Sidebar CSS ***/
989
  <?php if ( is_active_sidebar( 'swift-sidebar' ) ) : ?>
990
  .sdbr-right{
991
  <?php if( isset($redux_builder_amp['sidebar-bgcolor']['rgba']) && $redux_builder_amp['sidebar-bgcolor']['rgba'] ) {?>
992
+ background:<?php echo ampforwp_sanitize_color($redux_builder_amp['sidebar-bgcolor']['rgba'])?>;
993
  <?php } ?>
994
  display:flex;
995
  flex-direction:column;
1102
  .f-menu ul li .sub-menu{display:none;}
1103
  .f-menu ul li{display:inline-block;margin-right:20px;}
1104
  .f-menu ul li a {padding:0;color:#7a7a7a;}
1105
+ .f-menu ul > li:hover a{color: <?php echo ampforwp_sanitize_color($hovercolor); ?>;}
1106
  .f-menu{font-size:14px;line-height:1.4;margin-bottom:30px;}
1107
  .rr{font-size: 12px;color: <?php echo ampforwp_sanitize_color($redux_builder_amp['swift-footer-txt-clr']['rgba']) ?>;}
1108
  .rr span{margin:0 10px 0 0px}
1205
  }
1206
  .f-w-f1{
1207
  <?php if( $redux_builder_amp['swift-footer-bg']['rgba'] ) {?>
1208
+ background:<?php echo ampforwp_sanitize_color($redux_builder_amp['swift-footer-bg']['rgba'])?>;
1209
  <?php } ?>
1210
  font-size: <?php echo $redux_builder_amp['swift-footer1-cntnsize']?>;
1211
  line-height: 1.5;
templates/features.php CHANGED
@@ -366,7 +366,6 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
366
  $amp_url = untrailingslashit($current_search_url);
367
  }
368
 
369
- $amp_url = ampforwp_url_purifier($amp_url);
370
 
371
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
372
  if( get_option('permalink_structure') && is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' )){
@@ -445,6 +444,8 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
445
  }
446
  }
447
  }
 
 
448
 
449
  $amp_url = apply_filters('ampforwp_modify_rel_canonical',$amp_url);
450
 
@@ -2532,7 +2533,7 @@ function ampforwp_replace_title_tags() {
2532
  }
2533
  }
2534
  // All in One SEO #2816
2535
- if ( class_exists('All_in_One_SEO_Pack') && ( ampforwp_is_front_page() )) {
2536
  $aiseop_title = $post = '';
2537
  $aiseop_title = get_post_meta( $post_id, '_aioseop_title', true );
2538
  if ( !empty($aiseop_title) ) {
@@ -2547,7 +2548,8 @@ function ampforwp_replace_title_tags() {
2547
  }
2548
  if ( !empty($aiseop_title) ) {
2549
  $site_title = $aiseop_title;
2550
- }
 
2551
  }
2552
  // Custom Front Page Title From Rank Math SEO #2701
2553
  if ( defined( 'RANK_MATH_FILE' ) && 'rank_math' == ampforwp_get_setting('ampforwp-seo-selection') ) {
@@ -6120,9 +6122,7 @@ function ampforwp_url_purifier($url){
6120
  $get_permalink_structure = get_option('permalink_structure');
6121
  $checker = $redux_builder_amp['amp-core-end-point'];
6122
  $endpointq = '?' . $endpoint;
6123
-
6124
  if ( empty( $get_permalink_structure ) ) {
6125
-
6126
  if ( is_home() || is_archive() || is_front_page() ) {
6127
  $url = add_query_arg(AMPFORWP_AMP_QUERY_VAR,'1', $url);
6128
  if ( is_home() && get_query_var('page_id') == ampforwp_get_blog_details('id') ) {
@@ -6136,7 +6136,6 @@ function ampforwp_url_purifier($url){
6136
  }
6137
  }
6138
  if ( is_archive() ) {
6139
-
6140
  if ( is_archive() ) {
6141
  $queried_var = 'm';
6142
  }
@@ -6151,41 +6150,43 @@ function ampforwp_url_purifier($url){
6151
  }
6152
  $quried_value = get_query_var($queried_var);
6153
  $url = add_query_arg($queried_var,$quried_value, $url);
6154
- //$url = $url .'&'. $queried_var .'='. $quried_value;
6155
  }
6156
  } else {
6157
  if ( is_singular() && true == $checker ) {
6158
  $url = untrailingslashit($url);
6159
  }
6160
  if ( is_home() || is_archive() || is_front_page() ) {
6161
- if ( is_archive() && get_query_var('paged') > 1 || is_home() && get_query_var('paged') > 1 ) {
6162
  if ( true == $checker )
6163
  $url = trailingslashit($url).$endpointq;
6164
  else
6165
  $url = user_trailingslashit( trailingslashit($url) );
6166
  } else {
6167
- if ( true == $checker )
6168
  $url = trailingslashit($url) . $endpointq;
6169
- else
6170
- $url = user_trailingslashit( trailingslashit($url) . $endpoint );
 
 
6171
  }
6172
  }
6173
  }
6174
- if ( is_singular() && !empty( $_SERVER['QUERY_STRING'] ) ) {
6175
  $query_arg = wp_parse_args($_SERVER['QUERY_STRING']);
6176
  $query_name = '';
6177
- if( is_single() ){
6178
- $query_name = $wp_query->query['name'];
6179
- } else {
6180
- $query_name = $wp_query->query['pagename'];
 
6181
  }
6182
- if( ampforwp_is_query_post_same( $_SERVER['QUERY_STRING'],$query_name) && isset( $query_arg['q'] ) ){
6183
- unset($query_arg['q']);
6184
  }
6185
  else if ( $query_name && isset( $query_arg['q'] ) ){
6186
  unset($query_arg['q']);
6187
- }
6188
- $url = add_query_arg( $query_arg, $url);
6189
  }
6190
  return apply_filters( 'ampforwp_url_purifier', $url );
6191
  }
@@ -6887,8 +6888,11 @@ add_action( 'init', 'swifttheme_footer_widgets_init' );
6887
  function ampforwp_is_non_amp( $type="" ) {
6888
  global $redux_builder_amp;
6889
  $non_amp = false;
6890
- $amp_metas = array();
6891
- $ampforwp_amp_post_on_off_meta = '';
 
 
 
6892
  if ( false !== get_query_var( 'amp', false ) ) {
6893
  return false;
6894
  }
@@ -6954,8 +6958,7 @@ function ampforwp_is_non_amp( $type="" ) {
6954
  if ( is_page() && false == $redux_builder_amp['amp-on-off-for-all-pages'] ) {
6955
  return;
6956
  }
6957
- $amp_metas = json_decode(get_post_meta( get_the_ID(),'ampforwp-post-metas',true), true );
6958
- $ampforwp_amp_post_on_off_meta = $amp_metas['ampforwp-amp-on-off'];
6959
  if($ampforwp_amp_post_on_off_meta == 'hide-amp'){
6960
  return false;
6961
  }
366
  $amp_url = untrailingslashit($current_search_url);
367
  }
368
 
 
369
 
370
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
371
  if( get_option('permalink_structure') && is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' )){
444
  }
445
  }
446
  }
447
+ // URL Purifier
448
+ $amp_url = ampforwp_url_purifier($amp_url);
449
 
450
  $amp_url = apply_filters('ampforwp_modify_rel_canonical',$amp_url);
451
 
2533
  }
2534
  }
2535
  // All in One SEO #2816
2536
+ if ( class_exists('All_in_One_SEO_Pack') && ampforwp_is_front_page()){
2537
  $aiseop_title = $post = '';
2538
  $aiseop_title = get_post_meta( $post_id, '_aioseop_title', true );
2539
  if ( !empty($aiseop_title) ) {
2548
  }
2549
  if ( !empty($aiseop_title) ) {
2550
  $site_title = $aiseop_title;
2551
+ }
2552
+ add_filter('aioseop_title', '__return_false');
2553
  }
2554
  // Custom Front Page Title From Rank Math SEO #2701
2555
  if ( defined( 'RANK_MATH_FILE' ) && 'rank_math' == ampforwp_get_setting('ampforwp-seo-selection') ) {
6122
  $get_permalink_structure = get_option('permalink_structure');
6123
  $checker = $redux_builder_amp['amp-core-end-point'];
6124
  $endpointq = '?' . $endpoint;
 
6125
  if ( empty( $get_permalink_structure ) ) {
 
6126
  if ( is_home() || is_archive() || is_front_page() ) {
6127
  $url = add_query_arg(AMPFORWP_AMP_QUERY_VAR,'1', $url);
6128
  if ( is_home() && get_query_var('page_id') == ampforwp_get_blog_details('id') ) {
6136
  }
6137
  }
6138
  if ( is_archive() ) {
 
6139
  if ( is_archive() ) {
6140
  $queried_var = 'm';
6141
  }
6150
  }
6151
  $quried_value = get_query_var($queried_var);
6152
  $url = add_query_arg($queried_var,$quried_value, $url);
 
6153
  }
6154
  } else {
6155
  if ( is_singular() && true == $checker ) {
6156
  $url = untrailingslashit($url);
6157
  }
6158
  if ( is_home() || is_archive() || is_front_page() ) {
6159
+ if ( ( is_archive() || is_home() ) && get_query_var('paged') > 1 ) {
6160
  if ( true == $checker )
6161
  $url = trailingslashit($url).$endpointq;
6162
  else
6163
  $url = user_trailingslashit( trailingslashit($url) );
6164
  } else {
6165
+ if ( true == $checker && false == strpos($url, $endpointq) )
6166
  $url = trailingslashit($url) . $endpointq;
6167
+ else {
6168
+ if ( false == strpos($url, $endpoint) )
6169
+ $url = user_trailingslashit( trailingslashit($url) . $endpoint );
6170
+ }
6171
  }
6172
  }
6173
  }
6174
+ if ( is_singular() && !empty($_SERVER['QUERY_STRING']) ) {
6175
  $query_arg = wp_parse_args($_SERVER['QUERY_STRING']);
6176
  $query_name = '';
6177
+ if(is_single()){
6178
+ $query_name = isset($wp_query->query['name'])?$wp_query->query['name']:'';
6179
+ }
6180
+ else{
6181
+ $query_name = isset($wp_query->query['pagename'])?$wp_query->query['pagename']:'';
6182
  }
6183
+ if( ampforwp_is_query_post_same( $_SERVER['QUERY_STRING'],$query_name) && isset( $query_arg['q'] ) ){
6184
+ unset($query_arg['q']);
6185
  }
6186
  else if ( $query_name && isset( $query_arg['q'] ) ){
6187
  unset($query_arg['q']);
6188
+ }
6189
+ $url = add_query_arg( $query_arg, $url);
6190
  }
6191
  return apply_filters( 'ampforwp_url_purifier', $url );
6192
  }
6888
  function ampforwp_is_non_amp( $type="" ) {
6889
  global $redux_builder_amp;
6890
  $non_amp = false;
6891
+ $ampforwp_amp_post_on_off_meta = $post_id = '';
6892
+ $post_id = get_the_ID();
6893
+ if ( ampforwp_is_front_page() ) {
6894
+ $post_id = ampforwp_get_frontpage_id();
6895
+ }
6896
  if ( false !== get_query_var( 'amp', false ) ) {
6897
  return false;
6898
  }
6958
  if ( is_page() && false == $redux_builder_amp['amp-on-off-for-all-pages'] ) {
6959
  return;
6960
  }
6961
+ $ampforwp_amp_post_on_off_meta = get_post_meta( $post_id,'ampforwp-amp-on-off',true);
 
6962
  if($ampforwp_amp_post_on_off_meta == 'hide-amp'){
6963
  return false;
6964
  }