AMP for WP – Accelerated Mobile Pages - Version 0.9.67

Version Description

(6th November 2017) = * View more details on https://ampforwp.com/one-signal-push-notifications-for-amp/ * OneSignalPush Notifications integrated #807 * Vimeo embed support added * SoundCloud embed support added * Pinterest embed support added * PlayBuzz embed support added * DailyMotion embed support added * Fix: Handle issues with data uri images in CSS#1033 * Fix attribute when adding AMP Mustache lib#1033 * Fix: Output CSS for feature image#1033 * An option added for users who don't want to receiveupdate notifications #1342 * Structured data nav improvement * Sitenavigationelement has been implemented correctly for footer menu. #1345 * Style sanitization for Menu Items #1359 * Polylang flags support for menu #1360 * Mobile Redirection issues fixed#1173 * Jetpack fatal error fixed #1355 * AMP Page Builder requires a button to be clicked, so the scripts are not running on the runtime making it easy on the edit screen page and avoid the possible script conflict. * Needs proper CTA Bar's styling. #1361 * Debug errors on archive pages #1353 * Preview shall only be loaded on click rather than in background #1331 * ampforwp_is_home() function code improved * making sure scripts and styling is properly adding when sanitizing the sidebar #868 * All the backend css and js should be versioned, so it's not cached. #1335

Download this release

Release Info

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

Code changes from version 0.9.66.1 to 0.9.67

Files changed (52) hide show
  1. accelerated-moblie-pages.php +30 -5
  2. components/components-core.php +13 -0
  3. includes/admin-script.js +7 -0
  4. includes/includes.php +2 -2
  5. includes/options/admin-config.php +56 -1
  6. includes/redirect.php +76 -105
  7. includes/vendor/amp/includes/admin/class-amp-customizer.php +1 -1
  8. includes/vendor/amp/includes/amp-helper-functions.php +4 -3
  9. includes/vendor/amp/includes/amp-post-template-actions.php +8 -7
  10. includes/vendor/amp/includes/amp-post-template-functions.php +1 -1
  11. includes/vendor/amp/includes/class-amp-content.php +3 -3
  12. includes/vendor/amp/includes/class-amp-post-template.php +29 -7
  13. includes/vendor/amp/includes/embeds/class-amp-dailymotion-embed.php +103 -0
  14. includes/vendor/amp/includes/embeds/class-amp-gallery-embed.php +1 -1
  15. includes/vendor/amp/includes/embeds/class-amp-instagram-embed.php +1 -1
  16. includes/vendor/amp/includes/embeds/class-amp-pinterest-embed.php +61 -0
  17. includes/vendor/amp/includes/embeds/class-amp-soundcloud-embed.php +95 -0
  18. includes/vendor/amp/includes/embeds/class-amp-vimeo-embed.php +113 -0
  19. includes/vendor/amp/includes/embeds/class-amp-vine-embed.php +1 -1
  20. includes/vendor/amp/includes/embeds/class-amp-youtube-embed.php +2 -2
  21. includes/vendor/amp/includes/sanitizers/class-amp-base-sanitizer.php +2 -2
  22. includes/vendor/amp/includes/sanitizers/class-amp-blacklist-sanitizer.php +5 -5
  23. includes/vendor/amp/includes/sanitizers/class-amp-iframe-sanitizer.php +2 -3
  24. includes/vendor/amp/includes/sanitizers/class-amp-playbuzz-sanitizer.php +104 -0
  25. includes/vendor/amp/includes/sanitizers/class-amp-style-sanitizer.php +6 -3
  26. includes/vendor/amp/includes/settings/class-amp-customizer-design-settings.php +8 -8
  27. includes/vendor/amp/includes/utils/class-amp-dom-utils.php +19 -2
  28. includes/vendor/amp/includes/utils/class-amp-string-utils.php +1 -1
  29. includes/vendor/amp/jetpack-helper.php +8 -5
  30. includes/vendor/amp/readme.md +14 -18
  31. includes/vendor/vendor-changelog.txt +10 -1
  32. pagebuilder/amp-page-builder.php +66 -47
  33. pagebuilder/config/moduleTemplate.php +23 -0
  34. pagebuilder/functions.php +59 -51
  35. pagebuilder/inc/admin-amp-page-builder.css +30 -0
  36. pagebuilder/inc/admin-amp-page-builder.js +65 -14
  37. pagebuilder/inc/js-templates.php +3 -3
  38. readme.txt +33 -6
  39. templates/custom-amp-content.php +5 -0
  40. templates/design-manager/design-1/elements/content.php +2 -1
  41. templates/design-manager/design-1/footer.php +15 -13
  42. templates/design-manager/design-1/header-bar.php +4 -4
  43. templates/design-manager/design-1/style.php +1 -0
  44. templates/design-manager/design-2/elements/content.php +1 -2
  45. templates/design-manager/design-2/footer.php +13 -11
  46. templates/design-manager/design-2/header-bar.php +13 -16
  47. templates/design-manager/design-2/style.php +9 -8
  48. templates/design-manager/design-3/elements/content.php +16 -16
  49. templates/design-manager/design-3/footer.php +5 -3
  50. templates/design-manager/design-3/header-bar.php +3 -4
  51. templates/design-manager/design-3/style.php +8 -8
  52. templates/features.php +409 -202
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.66.1
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
@@ -18,7 +18,7 @@ define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
18
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.php');
19
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
20
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
21
- define('AMPFORWP_VERSION','0.9.66.1');
22
 
23
  // any changes to AMP_QUERY_VAR should be refelected here
24
  function ampforwp_generate_endpoint(){
@@ -520,6 +520,9 @@ if ( ! function_exists('ampforwp_init') ) {
520
  add_filter( 'request', 'amp_force_query_var_value' );
521
  add_action( 'wp', 'amp_maybe_add_actions' );
522
 
 
 
 
523
  if ( class_exists( 'Jetpack' ) && ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
524
  require_once( AMP__DIR__ . '/jetpack-helper.php' );
525
  }
@@ -528,15 +531,18 @@ if ( ! function_exists('ampforwp_init') ) {
528
 
529
 
530
  function AMP_update_db_check() {
 
531
  $ampforWPCurrentVersion = AMPFORWP_VERSION;
532
  if (get_option( 'AMPforwp_db_version' ) != $ampforWPCurrentVersion) {
533
 
534
  if ( isset( $_GET['ampforwp-dismiss'] ) && trim($_GET['ampforwp-dismiss'])=="ampforwp_dismiss_admin_notices" ) {
535
  update_option( 'AMPforwp_db_version', $ampforWPCurrentVersion );
536
- wp_redirect(admin_url('/index.php'), 301);
537
  }
 
538
 
539
- add_action('admin_notices', 'ampforwp_update_notice');
 
540
  }
541
  }
542
  add_action( 'plugins_loaded', 'AMP_update_db_check' );
@@ -604,4 +610,23 @@ require_once( AMP_FRAMEWORK_COMOPNENT_DIR_PATH . '/components-core.php' );
604
  require_once( AMPFORWP_PLUGIN_DIR. 'pagebuilder/amp-page-builder.php' );
605
  require_once( AMPFORWP_PLUGIN_DIR. 'base_remover/base_remover.php' );
606
  require_once( AMPFORWP_PLUGIN_DIR. 'includes/thirdparty-compatibility.php' );
607
- require ( AMPFORWP_PLUGIN_DIR.'/install/index.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
+ Version: 0.9.67
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
18
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.php');
19
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
20
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
21
+ define('AMPFORWP_VERSION','0.9.67');
22
 
23
  // any changes to AMP_QUERY_VAR should be refelected here
24
  function ampforwp_generate_endpoint(){
520
  add_filter( 'request', 'amp_force_query_var_value' );
521
  add_action( 'wp', 'amp_maybe_add_actions' );
522
 
523
+ // Redirect the old url of amp page to the updated url. #1033 (Vendor Update)
524
+ add_filter( 'old_slug_redirect_url', 'ampforwp_redirect_old_slug_to_new_url' );
525
+
526
  if ( class_exists( 'Jetpack' ) && ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
527
  require_once( AMP__DIR__ . '/jetpack-helper.php' );
528
  }
531
 
532
 
533
  function AMP_update_db_check() {
534
+ global $redux_builder_amp;
535
  $ampforWPCurrentVersion = AMPFORWP_VERSION;
536
  if (get_option( 'AMPforwp_db_version' ) != $ampforWPCurrentVersion) {
537
 
538
  if ( isset( $_GET['ampforwp-dismiss'] ) && trim($_GET['ampforwp-dismiss'])=="ampforwp_dismiss_admin_notices" ) {
539
  update_option( 'AMPforwp_db_version', $ampforWPCurrentVersion );
540
+ wp_redirect(remove_query_arg('ampforwp-dismiss'), 301);
541
  }
542
+ if( isset($redux_builder_amp['ampforwp-update-notification-bar'] ) && $redux_builder_amp['ampforwp-update-notification-bar'] && current_user_can( 'manage_options' ) ){
543
 
544
+ add_action('admin_notices', 'ampforwp_update_notice');
545
+ }
546
  }
547
  }
548
  add_action( 'plugins_loaded', 'AMP_update_db_check' );
610
  require_once( AMPFORWP_PLUGIN_DIR. 'pagebuilder/amp-page-builder.php' );
611
  require_once( AMPFORWP_PLUGIN_DIR. 'base_remover/base_remover.php' );
612
  require_once( AMPFORWP_PLUGIN_DIR. 'includes/thirdparty-compatibility.php' );
613
+ require ( AMPFORWP_PLUGIN_DIR.'/install/index.php' );
614
+
615
+ /**
616
+ * Redirects the old AMP URL to the new AMP URL.
617
+ * If post slug is updated the amp page with old post slug will be redirected to the updated url.
618
+ *
619
+ * @param string $link New URL of the post.
620
+ *
621
+ * @return string $link URL to be redirected.
622
+ */
623
+ if( ! function_exists( 'ampforwp_redirect_old_slug_to_new_url' ) ){
624
+ function ampforwp_redirect_old_slug_to_new_url( $link ) {
625
+
626
+ if ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) {
627
+ $link = trailingslashit( trailingslashit( $link ) . AMPFORWP_AMP_QUERY_VAR );
628
+ }
629
+
630
+ return $link;
631
+ }
632
+ }
components/components-core.php CHANGED
@@ -349,6 +349,19 @@ $thisTemplate = new AMP_Post_Template($post_id);
349
  </div>
350
  <?php }
351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  //Load font Compoment
353
  $fontComponent = array();
354
  function amp_post_load_custom_fonts(){
349
  </div>
350
  <?php }
351
 
352
+ function amp_date($args=array()){
353
+ global $redux_builder_amp;
354
+ if(isset($args['format']) && $args['format']=='traditional'){
355
+ $post_date = esc_html( get_the_date() ) . ' '.esc_html( get_the_time());
356
+ }else{
357
+ $post_date = human_time_diff(
358
+ get_the_time('U', get_the_ID() ),
359
+ current_time('timestamp') ) .' '. ampforwp_translation( $redux_builder_amp['amp-translator-ago-date-text'],
360
+ 'ago');
361
+ }
362
+ echo '<div class="loop-date">'.$post_date.'</div>';
363
+ }
364
+
365
  //Load font Compoment
366
  $fontComponent = array();
367
  function amp_post_load_custom_fonts(){
includes/admin-script.js CHANGED
@@ -84,6 +84,13 @@ jQuery(function($) {
84
  return false;
85
  }
86
  });
 
 
 
 
 
 
 
87
 
88
  });
89
  });
84
  return false;
85
  }
86
  });
87
+
88
+ if($(".amp-preview-button").length>0){
89
+ $(".amp-preview-button").click(function(){
90
+ var srcLink = $("#amp-preview-iframe").attr('data-src');
91
+ $("#amp-preview-iframe").html("<iframe src='"+srcLink+"'></iframe>");
92
+ });
93
+ }
94
 
95
  });
96
  });
includes/includes.php CHANGED
@@ -45,11 +45,11 @@
45
  add_action( 'admin_enqueue_scripts', 'ampforwp_add_admin_styling' );
46
  function ampforwp_add_admin_styling(){
47
  // Style file to add or modify css inside admin area
48
- wp_register_style( 'ampforwp_admin_css', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-style.css', false, '1.0.0' );
49
  wp_enqueue_style( 'ampforwp_admin_css' );
50
 
51
  // Admin area scripts file
52
- wp_register_script( 'ampforwp_admin_js', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-script.js', false, '1.0.0' );
53
  wp_enqueue_script( 'ampforwp_admin_js' );
54
 
55
  }
45
  add_action( 'admin_enqueue_scripts', 'ampforwp_add_admin_styling' );
46
  function ampforwp_add_admin_styling(){
47
  // Style file to add or modify css inside admin area
48
+ wp_register_style( 'ampforwp_admin_css', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-style.css', false, AMPFORWP_VERSION );
49
  wp_enqueue_style( 'ampforwp_admin_css' );
50
 
51
  // Admin area scripts file
52
+ wp_register_script( 'ampforwp_admin_js', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-script.js', false, AMPFORWP_VERSION );
53
  wp_enqueue_script( 'ampforwp_admin_js' );
54
 
55
  }
includes/options/admin-config.php CHANGED
@@ -1353,7 +1353,7 @@ Redux::setArgs( "redux_builder_amp", $args );
1353
 
1354
  // Notifications SECTION
1355
  Redux::setSection( $opt_name, array(
1356
- 'title' => __( 'Notifications', 'accelerated-mobile-pages' ),
1357
  'desc' => $cta_desc ,
1358
  'id' => 'amp-notifications',
1359
  'subsection' => true,
@@ -1387,6 +1387,52 @@ Redux::setArgs( "redux_builder_amp", $args );
1387
  ),
1388
 
1389
  ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1390
  // contact form 7
1391
  $forms_support[] = array(
1392
  'id' =>'amp-enable-contactform',
@@ -1764,6 +1810,15 @@ Redux::setSection( $opt_name, array(
1764
  'title' => __('Dev Mode', 'accelerated-mobile-pages'),
1765
  'required' => array('ampforwp-development-mode', '=', 1)
1766
  ),
 
 
 
 
 
 
 
 
 
1767
 
1768
  ),
1769
 
1353
 
1354
  // Notifications SECTION
1355
  Redux::setSection( $opt_name, array(
1356
+ 'title' => __( 'Notice Bar', 'accelerated-mobile-pages' ),
1357
  'desc' => $cta_desc ,
1358
  'id' => 'amp-notifications',
1359
  'subsection' => true,
1387
  ),
1388
 
1389
  ) );
1390
+
1391
+ // Push Notifications section
1392
+ Redux::setSection( $opt_name, array(
1393
+ 'title' => __( 'Push Notifications', 'accelerated-mobile-pages' ),
1394
+ // 'icon' => 'el el-podcast',
1395
+ 'id' => 'ampforwp-push-notifications',
1396
+ 'desc' => " ",
1397
+ 'subsection' => true,
1398
+ 'fields' => array(
1399
+ array(
1400
+ 'id' => 'ampforwp-web-push-onesignal',
1401
+ 'type' => 'switch',
1402
+ 'title' => 'OneSignal Push Notifications',
1403
+ 'true' => 'true',
1404
+ 'false' => 'false',
1405
+ 'default' => 0,
1406
+ ),
1407
+ array(
1408
+ 'id' => 'ampforwp-one-signal-app-id',
1409
+ 'subtitle' => '<a href="https://ampforwp.com/tutorials/one-signal-in-amp/" target="_blank">View Integration Tutorial</a>',
1410
+ 'type' => 'text',
1411
+ 'title' => 'APP ID',
1412
+ 'required' => array('ampforwp-web-push-onesignal', '=' , '1'),
1413
+ ),
1414
+ array(
1415
+ 'id' => 'ampforwp-onesignal-http-site',
1416
+ 'type' => 'switch',
1417
+ 'title' => 'HTTP Site',
1418
+ 'subtitle' => 'For HTTP Sites Only',
1419
+ 'required' => array('ampforwp-web-push-onesignal', '=' , '1'),
1420
+ 'true' => 'true',
1421
+ 'false' => 'false',
1422
+ 'default' => 0
1423
+ ),
1424
+ array(
1425
+ 'id' => 'ampforwp-onesignal-subdomain',
1426
+ 'type' => 'text',
1427
+ 'title' => 'Subdomain',
1428
+ 'desc' => __('Example: ampforwp', 'accelerated-mobile-pages'),
1429
+ 'required' => array(
1430
+ array('ampforwp-web-push-onesignal', '=' , '1'),
1431
+ array('ampforwp-onesignal-http-site', '=','1')),
1432
+ ),
1433
+ )
1434
+ )
1435
+ );
1436
  // contact form 7
1437
  $forms_support[] = array(
1438
  'id' =>'amp-enable-contactform',
1810
  'title' => __('Dev Mode', 'accelerated-mobile-pages'),
1811
  'required' => array('ampforwp-development-mode', '=', 1)
1812
  ),
1813
+ array(
1814
+ 'id' => 'ampforwp-update-notification-bar',
1815
+ 'type' => 'switch',
1816
+ 'title' => __('Plugin Update Notification Bar'),
1817
+ 'subtitle' => __('Enable/Disable the Plugin Update Notification Bar', 'accelerated-mobile-pages'),
1818
+ 'true' => 'true',
1819
+ 'false' => 'false',
1820
+ 'default' => 1,
1821
+ ),
1822
 
1823
  ),
1824
 
includes/redirect.php CHANGED
@@ -15,40 +15,47 @@ function ampforwp_check_amp_page_status() {
15
  wp_safe_redirect( $redirection_location );
16
  exit;
17
  }
18
-
19
  }
20
  }
21
  add_action( 'template_redirect', 'ampforwp_check_amp_page_status', 10 );
22
 
23
 
 
24
  function ampforwp_page_template_redirect() {
25
- global $redux_builder_amp, $post;
26
- $post_type = '';
27
- $supported_types = '';
28
- $supported_amp_post_types = '';
29
- $supported_types = array('post','page');
30
- $supported_types = apply_filters('get_amp_supported_post_types',$supported_types);
31
- $post_type = get_post_type();
32
- $supported_amp_post_types = in_array( $post_type , $supported_types );
 
 
 
 
 
33
  if( isset($redux_builder_amp['amp-mobile-redirection']) && $redux_builder_amp['amp-mobile-redirection']){
34
 
 
35
  if( ampforwp_meta_redirection_status()=='disable' ){
36
  return;
37
  }
38
-
39
- if($supported_amp_post_types == false){
40
  return;
41
  }
42
- if(is_archive() && $redux_builder_amp['ampforwp-archive-support']==0){
43
  return;
44
  }
45
- if ( is_feed() ) {
46
- return;
47
  }
48
  // #1192 Password Protected posts exclusion
49
- if(post_password_required( $post )){
50
- return;
51
- }
 
52
  // Return if some categories are selected as Hide #999
53
  if(is_archive() && $redux_builder_amp['ampforwp-archive-support']){
54
  $selected_cats = array();
@@ -67,71 +74,56 @@ function ampforwp_page_template_redirect() {
67
  }
68
  }
69
  }
 
 
 
 
 
70
  }
71
- if (!session_id()) {
72
- session_start();
73
- }
74
- if( isset($_SESSION['ampforwp_mobile']) && $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_SESSION['ampforwp_mobile']=='exit'){
75
- return;
76
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  if( wp_is_mobile() && $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_GET['nonamp']==1){
78
- // non mobile session variable creation
79
- session_start();
80
- $_SESSION['ampforwp_mobile']='exit';
81
- if ( ampforwp_is_amp_endpoint() ) {
82
- session_destroy();
83
- }
84
  }
85
 
86
- if ( wp_is_mobile() ) {
87
- if ( ampforwp_is_amp_endpoint() ) {
88
- return;
89
- } else {
90
- if(is_page() && $redux_builder_amp['amp-on-off-for-all-pages'] == 0){return;}
91
  if( !isset($_SESSION['ampforwp_amp_mode']) || !isset($_GET['nonamp']) ) {
 
92
  $_SESSION['ampforwp_amp_mode']='mobile-on';
93
- if ( is_home() ) {
94
- if( get_option( 'page_for_posts' ) && get_queried_object_id() ) {
95
- $post_id = get_option('page_for_posts');
96
- $ampforwp_amp_post_on_off_meta = get_post_meta( get_the_ID(),'ampforwp-amp-on-off',true);
97
- if( $ampforwp_amp_post_on_off_meta === 'hide-amp' ) {
98
- //dont Echo anything
99
- } else {
100
- wp_redirect( user_trailingslashit(trailingslashit( esc_url( ( get_permalink( $post_id ) ) ) ) . AMPFORWP_AMP_QUERY_VAR ) , 301 );
101
  exit();
102
- }
103
  }
104
-
105
- if ( $redux_builder_amp['ampforwp-homepage-on-off-support'] == 1 ) {
106
- wp_redirect( user_trailingslashit(trailingslashit( esc_url( home_url() ) ) . AMPFORWP_AMP_QUERY_VAR ) , 301 );
107
- exit();
108
- }
109
- }
110
- elseif ( is_archive() ) {
111
- if ( $redux_builder_amp['ampforwp-archive-support'] == 1 ) {
112
- global $wp;
113
- $current_archive_url = home_url( $wp->request );
114
- wp_redirect( user_trailingslashit(trailingslashit( esc_url( $current_archive_url ) ) . AMPFORWP_AMP_QUERY_VAR ) , 301 );
115
- exit();
116
- }
117
- } else {
118
- $ampforwp_amp_post_on_off_meta = get_post_meta( get_the_ID(),'ampforwp-amp-on-off',true);
119
- if( $ampforwp_amp_post_on_off_meta === 'hide-amp' ) {
120
- //dont Echo anything
121
- }
122
- elseif($redux_builder_amp['ampforwp-homepage-on-off-support'] == 0 &&get_option('page_on_front')){
123
- return;
124
- }
125
- else {
126
- wp_redirect( user_trailingslashit(trailingslashit( esc_url( ( get_permalink( $id ) ) ) ) . AMPFORWP_AMP_QUERY_VAR ) , 301 );
127
- exit();
128
- }
129
- }
130
- }
131
- }
132
- }
133
-
134
- }
135
  }
136
  add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
137
 
@@ -139,35 +131,14 @@ add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
139
  add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
140
  function ampforwp_page_template_redirect_archive() {
141
 
142
- if ( is_404() ) {
143
- if( ampforwp_is_amp_endpoint() ) {
144
- global $wp;
145
- $ampforwp_404_url = add_query_arg( '', '', home_url( $wp->request ) );
146
- $ampforwp_404_url = trailingslashit($ampforwp_404_url );
147
- $ampforwp_404_url = dirname($ampforwp_404_url);
148
- wp_redirect( esc_url( $ampforwp_404_url ) , 301 );
149
- exit();
150
- }
151
- }
152
- }
153
- // Redirection code is not working properly. Need fix
154
- //add_action( 'template_redirect', 'ampforwp_page_template_redirect_non_amp', 10 );
155
- // function ampforwp_page_template_redirect_non_amp() {
156
-
157
- // if ( (is_home() || is_front_page() || is_archive()) && $_GET['nonamp']==1 ){
158
- // global $wp;
159
- // $current_view_nonamp_url = add_query_arg( '', '', home_url( $wp->request ) );
160
- // $current_view_nonamp_url = trailingslashit($current_view_nonamp_url);
161
- // wp_redirect( esc_url( $current_view_nonamp_url ) , 301 );
162
- // exit();
163
- // }
164
-
165
- // elseif ( is_singular() && $_GET['nonamp']==1 ) {
166
-
167
- // global $wp;
168
- // $current_view_nonamp_url = add_query_arg( '', '', get_permalink() );
169
- // $current_view_nonamp_url = trailingslashit($current_view_nonamp_url );
170
- // wp_redirect( esc_url( $current_view_nonamp_url) , 301 );
171
- // exit();
172
- // }
173
- // }
15
  wp_safe_redirect( $redirection_location );
16
  exit;
17
  }
18
+
19
  }
20
  }
21
  add_action( 'template_redirect', 'ampforwp_check_amp_page_status', 10 );
22
 
23
 
24
+ // Redirection code
25
  function ampforwp_page_template_redirect() {
26
+ global $redux_builder_amp, $post, $wp;
27
+ $post_type = '';
28
+ $supported_types = '';
29
+ $supported_amp_post_types = array();
30
+ $url_to_redirect = '';
31
+
32
+ $supported_types = array('post','page');
33
+ $supported_types = apply_filters('get_amp_supported_post_types',$supported_types);
34
+ $post_type = get_post_type();
35
+ $supported_amp_post_types = in_array( $post_type , $supported_types );
36
+ $url_to_redirect = ampforwp_amphtml_generator();
37
+
38
+
39
  if( isset($redux_builder_amp['amp-mobile-redirection']) && $redux_builder_amp['amp-mobile-redirection']){
40
 
41
+ // Return if the set value is not met and do not start redirection
42
  if( ampforwp_meta_redirection_status()=='disable' ){
43
  return;
44
  }
45
+ if( $supported_amp_post_types == false ){
 
46
  return;
47
  }
48
+ if( is_archive() && $redux_builder_amp['ampforwp-archive-support']==0 ){
49
  return;
50
  }
51
+ if ( is_feed() ) {
52
+ return;
53
  }
54
  // #1192 Password Protected posts exclusion
55
+ if( post_password_required( $post )){
56
+ return;
57
+ }
58
+
59
  // Return if some categories are selected as Hide #999
60
  if(is_archive() && $redux_builder_amp['ampforwp-archive-support']){
61
  $selected_cats = array();
74
  }
75
  }
76
  }
77
+ }
78
+
79
+ // If we are in AMP mode then retrun and dont start redirection
80
+ if ( ampforwp_is_amp_endpoint() ) {
81
+ return;
82
  }
83
+
84
+ if( is_page() && $redux_builder_amp['amp-on-off-for-all-pages'] == 0 ){
85
+ return;
 
 
86
  }
87
+
88
+ if( ampforwp_is_home() &&$redux_builder_amp['ampforwp-homepage-on-off-support'] == 0 ){
89
+ return;
90
+ }
91
+
92
+ if ( ! session_id() ) {
93
+ session_start();
94
+ }
95
+
96
+ if( isset( $_SESSION['ampforwp_mobile'] ) && $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_SESSION['ampforwp_mobile']=='exit'){
97
+ return;
98
+ }
99
+
100
  if( wp_is_mobile() && $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_GET['nonamp']==1){
101
+ // non mobile session variable creation
102
+ session_start();
103
+ $_SESSION['ampforwp_mobile']='exit';
104
+ if ( ampforwp_is_amp_endpoint() ) {
105
+ session_destroy();
106
+ }
107
  }
108
 
109
+ // Check if we are on Mobile phones then start redirection process
110
+ if ( wp_is_mobile() ) {
111
+
 
 
112
  if( !isset($_SESSION['ampforwp_amp_mode']) || !isset($_GET['nonamp']) ) {
113
+
114
  $_SESSION['ampforwp_amp_mode']='mobile-on';
115
+
116
+ if ( $url_to_redirect ) {
117
+ wp_redirect( $url_to_redirect , 301 );
 
 
 
 
 
118
  exit();
 
119
  }
120
+
121
+ // if nothing matches then return back
122
+ return;
123
+ }
124
+ }
125
+
126
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
  add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
129
 
131
  add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
132
  function ampforwp_page_template_redirect_archive() {
133
 
134
+ if ( is_404() ) {
135
+ if( ampforwp_is_amp_endpoint() ) {
136
+ global $wp;
137
+ $ampforwp_404_url = add_query_arg( '', '', home_url( $wp->request ) );
138
+ $ampforwp_404_url = trailingslashit($ampforwp_404_url );
139
+ $ampforwp_404_url = dirname($ampforwp_404_url);
140
+ wp_redirect( esc_url( $ampforwp_404_url ) , 301 );
141
+ exit();
142
+ }
143
+ }
144
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/vendor/amp/includes/admin/class-amp-customizer.php CHANGED
@@ -156,7 +156,7 @@ class AMP_Template_Customizer {
156
  }
157
 
158
  public function force_mobile_preview( $devices ) {
159
- if ( isset( $devices[ 'mobile' ] ) ) {
160
  $devices['mobile']['default'] = true;
161
  unset( $devices['desktop']['default'] );
162
  }
156
  }
157
 
158
  public function force_mobile_preview( $devices ) {
159
+ if ( isset( $devices['mobile'] ) ) {
160
  $devices['mobile']['default'] = true;
161
  unset( $devices['desktop']['default'] );
162
  }
includes/vendor/amp/includes/amp-helper-functions.php CHANGED
@@ -7,10 +7,11 @@ function amp_get_permalink( $post_id ) {
7
  return $pre_url;
8
  }
9
 
10
- if ( '' != get_option( 'permalink_structure' ) ) {
11
- $amp_url = trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( AMP_QUERY_VAR, 'single_amp' );
12
- } else {
13
  $amp_url = add_query_arg( AMP_QUERY_VAR, 1, get_permalink( $post_id ) );
 
 
14
  }
15
 
16
  return apply_filters( 'amp_get_permalink', $amp_url, $post_id );
7
  return $pre_url;
8
  }
9
 
10
+ $structure = get_option( 'permalink_structure' );
11
+ if ( empty( $structure ) ) {
 
12
  $amp_url = add_query_arg( AMP_QUERY_VAR, 1, get_permalink( $post_id ) );
13
+ } else {
14
+ $amp_url = trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( AMP_QUERY_VAR, 'single_amp' );
15
  }
16
 
17
  return apply_filters( 'amp_get_permalink', $amp_url, $post_id );
includes/vendor/amp/includes/amp-post-template-actions.php CHANGED
@@ -18,8 +18,9 @@ function amp_post_template_add_canonical( $amp_template ) {
18
  add_action( 'amp_post_template_head', 'amp_post_template_add_scripts' );
19
  function amp_post_template_add_scripts( $amp_template ) {
20
  $scripts = $amp_template->get( 'amp_component_scripts', array() );
21
- foreach ( $scripts as $element => $script ) : ?>
22
- <script custom-element="<?php echo esc_attr( $element ); ?>" src="<?php echo esc_url( $script ); ?>" async></script>
 
23
  <?php endforeach; ?>
24
  <script src="<?php echo esc_url( $amp_template->get( 'amp_runtime_script' ) ); ?>" async></script>
25
  <?php
@@ -28,7 +29,7 @@ function amp_post_template_add_scripts( $amp_template ) {
28
  add_action( 'amp_post_template_head', 'amp_post_template_add_fonts' );
29
  function amp_post_template_add_fonts( $amp_template ) {
30
  $font_urls = $amp_template->get( 'font_urls', array() );
31
- foreach( $font_urls as $slug => $url ) : ?>
32
  <link rel="stylesheet" href="<?php echo esc_url( $url ); ?>">
33
  <?php endforeach;
34
  }
@@ -47,7 +48,7 @@ function amp_post_template_add_schemaorg_metadata( $amp_template ) {
47
  return;
48
  }
49
  ?>
50
- <script type="application/ld+json"><?php echo json_encode( $metadata ); ?></script>
51
  <?php
52
  }
53
 
@@ -57,7 +58,7 @@ function amp_post_template_add_styles( $amp_template ) {
57
  if ( ! empty( $styles ) ) {
58
  echo '/* Inline styles */' . PHP_EOL;
59
  foreach ( $styles as $selector => $declarations ) {
60
- $declarations = implode( ";", $declarations ) . ";";
61
  printf( '%1$s{%2$s}', $selector, $declarations );
62
  }
63
  }
@@ -80,13 +81,13 @@ function amp_post_template_add_analytics_data( $amp_template ) {
80
 
81
  foreach ( $analytics_entries as $id => $analytics_entry ) {
82
  if ( ! isset( $analytics_entry['type'], $analytics_entry['attributes'], $analytics_entry['config_data'] ) ) {
83
- _doing_it_wrong( __FUNCTION__, sprintf( __( 'Analytics entry for %s is missing one of the following keys: `type`, `attributes`, or `config_data` (array keys: %s)', 'amp' ), esc_html( $id ), esc_html( implode( ', ', array_keys( $analytics_entry ) ) ) ), '0.3.2' );
84
  continue;
85
  }
86
 
87
  $script_element = AMP_HTML_Utils::build_tag( 'script', array(
88
  'type' => 'application/json',
89
- ), json_encode( $analytics_entry['config_data'] ) );
90
 
91
  $amp_analytics_attr = array_merge( array(
92
  'id' => $id,
18
  add_action( 'amp_post_template_head', 'amp_post_template_add_scripts' );
19
  function amp_post_template_add_scripts( $amp_template ) {
20
  $scripts = $amp_template->get( 'amp_component_scripts', array() );
21
+ foreach ( $scripts as $element => $script ) :
22
+ $custom_type = ($element == 'amp-mustache') ? 'template' : 'element'; ?>
23
+ <script custom-<?php echo esc_attr( $custom_type ); ?>="<?php echo esc_attr( $element ); ?>" src="<?php echo esc_url( $script ); ?>" async></script>
24
  <?php endforeach; ?>
25
  <script src="<?php echo esc_url( $amp_template->get( 'amp_runtime_script' ) ); ?>" async></script>
26
  <?php
29
  add_action( 'amp_post_template_head', 'amp_post_template_add_fonts' );
30
  function amp_post_template_add_fonts( $amp_template ) {
31
  $font_urls = $amp_template->get( 'font_urls', array() );
32
+ foreach ( $font_urls as $slug => $url ) : ?>
33
  <link rel="stylesheet" href="<?php echo esc_url( $url ); ?>">
34
  <?php endforeach;
35
  }
48
  return;
49
  }
50
  ?>
51
+ <script type="application/ld+json"><?php echo wp_json_encode( $metadata ); ?></script>
52
  <?php
53
  }
54
 
58
  if ( ! empty( $styles ) ) {
59
  echo '/* Inline styles */' . PHP_EOL;
60
  foreach ( $styles as $selector => $declarations ) {
61
+ $declarations = implode( ';', $declarations ) . ';';
62
  printf( '%1$s{%2$s}', $selector, $declarations );
63
  }
64
  }
81
 
82
  foreach ( $analytics_entries as $id => $analytics_entry ) {
83
  if ( ! isset( $analytics_entry['type'], $analytics_entry['attributes'], $analytics_entry['config_data'] ) ) {
84
+ _doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'Analytics entry for %s is missing one of the following keys: `type`, `attributes`, or `config_data` (array keys: %s)', 'amp' ), esc_html( $id ), esc_html( implode( ', ', array_keys( $analytics_entry ) ) ) ), '0.3.2' );
85
  continue;
86
  }
87
 
88
  $script_element = AMP_HTML_Utils::build_tag( 'script', array(
89
  'type' => 'application/json',
90
+ ), wp_json_encode( $analytics_entry['config_data'] ) );
91
 
92
  $amp_analytics_attr = array_merge( array(
93
  'id' => $id,
includes/vendor/amp/includes/amp-post-template-functions.php CHANGED
@@ -8,7 +8,7 @@ if ( ! function_exists( 'sanitize_hex_color' ) ) {
8
  }
9
 
10
  // 3 or 6 hex digits, or the empty string.
11
- if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
12
  return $color;
13
  }
14
  }
8
  }
9
 
10
  // 3 or 6 hex digits, or the empty string.
11
+ if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
12
  return $color;
13
  }
14
  }
includes/vendor/amp/includes/class-amp-content.php CHANGED
@@ -63,7 +63,7 @@ class AMP_Content {
63
  $embed_handler = new $embed_handler_class( array_merge( $this->args, $args ) );
64
 
65
  if ( ! is_subclass_of( $embed_handler, 'AMP_Base_Embed_Handler' ) ) {
66
- _doing_it_wrong( __METHOD__, sprintf( __( 'Embed Handler (%s) must extend `AMP_Embed_Handler`', 'amp' ), $embed_handler_class ), '0.1' );
67
  continue;
68
  }
69
 
@@ -99,14 +99,14 @@ class AMP_Content_Sanitizer {
99
 
100
  foreach ( $sanitizer_classes as $sanitizer_class => $args ) {
101
  if ( ! class_exists( $sanitizer_class ) ) {
102
- _doing_it_wrong( __METHOD__, sprintf( __( 'Sanitizer (%s) class does not exist', 'amp' ), esc_html( $sanitizer_class ) ), '0.4.1' );
103
  continue;
104
  }
105
 
106
  $sanitizer = new $sanitizer_class( $dom, array_merge( $global_args, $args ) );
107
 
108
  if ( ! is_subclass_of( $sanitizer, 'AMP_Base_Sanitizer' ) ) {
109
- _doing_it_wrong( __METHOD__, sprintf( __( 'Sanitizer (%s) must extend `AMP_Base_Sanitizer`', 'amp' ), esc_html( $sanitizer_class ) ), '0.1' );
110
  continue;
111
  }
112
 
63
  $embed_handler = new $embed_handler_class( array_merge( $this->args, $args ) );
64
 
65
  if ( ! is_subclass_of( $embed_handler, 'AMP_Base_Embed_Handler' ) ) {
66
+ _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Embed Handler (%s) must extend `AMP_Embed_Handler`', 'amp' ), $embed_handler_class ), '0.1' );
67
  continue;
68
  }
69
 
99
 
100
  foreach ( $sanitizer_classes as $sanitizer_class => $args ) {
101
  if ( ! class_exists( $sanitizer_class ) ) {
102
+ _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Sanitizer (%s) class does not exist', 'amp' ), esc_html( $sanitizer_class ) ), '0.4.1' );
103
  continue;
104
  }
105
 
106
  $sanitizer = new $sanitizer_class( $dom, array_merge( $global_args, $args ) );
107
 
108
  if ( ! is_subclass_of( $sanitizer, 'AMP_Base_Sanitizer' ) ) {
109
+ _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Sanitizer (%s) must extend `AMP_Base_Sanitizer`', 'amp' ), esc_html( $sanitizer_class ) ), '0.1' );
110
  continue;
111
  }
112
 
includes/vendor/amp/includes/class-amp-post-template.php CHANGED
@@ -3,6 +3,7 @@
3
  require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php' );
4
  require_once( AMP__DIR__ . '/includes/utils/class-amp-html-utils.php' );
5
  require_once( AMP__DIR__ . '/includes/utils/class-amp-string-utils.php' );
 
6
 
7
  require_once( AMP__DIR__ . '/includes/class-amp-content.php' );
8
 
@@ -12,13 +13,18 @@ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-img-sanitizer.php' );
12
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-video-sanitizer.php' );
13
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-iframe-sanitizer.php' );
14
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-audio-sanitizer.php' );
15
- require_once(AMP__DIR__ . '/includes/utils/class-amp-wp-utils.php' );
 
16
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-twitter-embed.php' );
17
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-youtube-embed.php' );
 
18
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-gallery-embed.php' );
19
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-instagram-embed.php' );
20
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-vine-embed.php' );
21
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-facebook-embed.php' );
 
 
 
22
 
23
  class AMP_Post_Template {
24
  const SITE_ICON_SIZE = 32;
@@ -70,6 +76,8 @@ class AMP_Post_Template {
70
  'merriweather' => 'https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic',
71
  ),
72
 
 
 
73
  /**
74
  * Add amp-analytics tags.
75
  *
@@ -81,7 +89,7 @@ class AMP_Post_Template {
81
  * @param object $post The current post.
82
  */
83
  'amp_analytics' => apply_filters( 'amp_post_template_analytics', array(), $this->post ),
84
- );
85
 
86
  $this->build_post_content();
87
  $this->build_post_data();
@@ -95,11 +103,20 @@ class AMP_Post_Template {
95
  if ( isset( $this->data[ $property ] ) ) {
96
  return $this->data[ $property ];
97
  } else {
98
- _doing_it_wrong( __METHOD__, sprintf( __( 'Called for non-existant key ("%s").', 'amp' ), esc_html( $property ) ), '0.1' );
99
  }
100
 
101
  return $default;
102
  }
 
 
 
 
 
 
 
 
 
103
 
104
  public function get_customizer_setting( $name, $default = null ) {
105
  $settings = $this->get( 'customizer_settings' );
@@ -233,9 +250,13 @@ class AMP_Post_Template {
233
  apply_filters( 'amp_content_embed_handlers', array(
234
  'AMP_Twitter_Embed_Handler' => array(),
235
  'AMP_YouTube_Embed_Handler' => array(),
 
 
 
236
  'AMP_Instagram_Embed_Handler' => array(),
237
  'AMP_Vine_Embed_Handler' => array(),
238
  'AMP_Facebook_Embed_Handler' => array(),
 
239
  'AMP_Gallery_Embed_Handler' => array(),
240
  ), $this->post ),
241
  apply_filters( 'amp_content_sanitizers', array(
@@ -244,6 +265,7 @@ class AMP_Post_Template {
244
  'AMP_Img_Sanitizer' => array(),
245
  'AMP_Video_Sanitizer' => array(),
246
  'AMP_Audio_Sanitizer' => array(),
 
247
  'AMP_Iframe_Sanitizer' => array(
248
  'add_placeholder' => true,
249
  ),
@@ -255,7 +277,7 @@ class AMP_Post_Template {
255
 
256
  $this->add_data_by_key( 'post_amp_content', $amp_content->get_amp_content() );
257
  $this->merge_data_for_key( 'amp_component_scripts', $amp_content->get_amp_scripts() );
258
- $this->add_data_by_key( 'post_amp_styles', $amp_content->get_amp_styles() );
259
  }else{
260
  $this->add_data_by_key( 'post_amp_content', '' );
261
  $this->merge_data_for_key( 'amp_component_scripts', array() );
@@ -296,7 +318,7 @@ class AMP_Post_Template {
296
  $featured_html,
297
  array( 'AMP_Img_Sanitizer' => array() ),
298
  array(
299
- 'content_max_width' => $this->get( 'content_max_width' )
300
  )
301
  );
302
 
@@ -310,7 +332,7 @@ class AMP_Post_Template {
310
  }
311
 
312
  if ( $featured_styles ) {
313
- $this->add_data_by_key( 'post_amp_styles', $featured_styles );
314
  }
315
  }
316
 
@@ -403,7 +425,7 @@ class AMP_Post_Template {
403
 
404
  $file = apply_filters( 'amp_post_template_file', $file, $template_type, $this->post );
405
  if ( ! $this->is_valid_template( $file ) ) {
406
- _doing_it_wrong( __METHOD__, sprintf( __( 'Path validation for template (%s) failed. Path cannot traverse and must be located in `%s`.', 'amp' ), esc_html( $file ), 'WP_CONTENT_DIR' ), '0.1' );
407
  return;
408
  }
409
 
3
  require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php' );
4
  require_once( AMP__DIR__ . '/includes/utils/class-amp-html-utils.php' );
5
  require_once( AMP__DIR__ . '/includes/utils/class-amp-string-utils.php' );
6
+ require_once( AMP__DIR__ . '/includes/utils/class-amp-wp-utils.php' );
7
 
8
  require_once( AMP__DIR__ . '/includes/class-amp-content.php' );
9
 
13
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-video-sanitizer.php' );
14
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-iframe-sanitizer.php' );
15
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-audio-sanitizer.php' );
16
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-playbuzz-sanitizer.php' );
17
+
18
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-twitter-embed.php' );
19
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-youtube-embed.php' );
20
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-dailymotion-embed.php' );
21
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-gallery-embed.php' );
22
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-instagram-embed.php' );
23
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-vine-embed.php' );
24
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-facebook-embed.php' );
25
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-vimeo-embed.php' );
26
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-soundcloud-embed.php' );
27
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-pinterest-embed.php' );
28
 
29
  class AMP_Post_Template {
30
  const SITE_ICON_SIZE = 32;
76
  'merriweather' => 'https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic',
77
  ),
78
 
79
+ 'post_amp_styles' => array(),
80
+
81
  /**
82
  * Add amp-analytics tags.
83
  *
89
  * @param object $post The current post.
90
  */
91
  'amp_analytics' => apply_filters( 'amp_post_template_analytics', array(), $this->post ),
92
+ );
93
 
94
  $this->build_post_content();
95
  $this->build_post_data();
103
  if ( isset( $this->data[ $property ] ) ) {
104
  return $this->data[ $property ];
105
  } else {
106
+ _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Called for non-existant key ("%s").', 'amp' ), esc_html( $property ) ), '0.1' );
107
  }
108
 
109
  return $default;
110
  }
111
+ public function set( $property, $value = '' ) {
112
+ if ( isset( $this->data[ $property ] ) ) {
113
+ return $this->data[ $property ] = $value ;
114
+ } else {
115
+ _doing_it_wrong( __METHOD__, sprintf( __( 'Called for non-existant key ("%s").', 'amp' ), esc_html( $property ) ), '0.1' );
116
+ }
117
+
118
+ return $value;
119
+ }
120
 
121
  public function get_customizer_setting( $name, $default = null ) {
122
  $settings = $this->get( 'customizer_settings' );
250
  apply_filters( 'amp_content_embed_handlers', array(
251
  'AMP_Twitter_Embed_Handler' => array(),
252
  'AMP_YouTube_Embed_Handler' => array(),
253
+ 'AMP_DailyMotion_Embed_Handler' => array(),
254
+ 'AMP_Vimeo_Embed_Handler' => array(),
255
+ 'AMP_SoundCloud_Embed_Handler' => array(),
256
  'AMP_Instagram_Embed_Handler' => array(),
257
  'AMP_Vine_Embed_Handler' => array(),
258
  'AMP_Facebook_Embed_Handler' => array(),
259
+ 'AMP_Pinterest_Embed_Handler' => array(),
260
  'AMP_Gallery_Embed_Handler' => array(),
261
  ), $this->post ),
262
  apply_filters( 'amp_content_sanitizers', array(
265
  'AMP_Img_Sanitizer' => array(),
266
  'AMP_Video_Sanitizer' => array(),
267
  'AMP_Audio_Sanitizer' => array(),
268
+ 'AMP_Playbuzz_Sanitizer' => array(),
269
  'AMP_Iframe_Sanitizer' => array(
270
  'add_placeholder' => true,
271
  ),
277
 
278
  $this->add_data_by_key( 'post_amp_content', $amp_content->get_amp_content() );
279
  $this->merge_data_for_key( 'amp_component_scripts', $amp_content->get_amp_scripts() );
280
+ $this->merge_data_for_key( 'post_amp_styles', $amp_content->get_amp_styles() );
281
  }else{
282
  $this->add_data_by_key( 'post_amp_content', '' );
283
  $this->merge_data_for_key( 'amp_component_scripts', array() );
318
  $featured_html,
319
  array( 'AMP_Img_Sanitizer' => array() ),
320
  array(
321
+ 'content_max_width' => $this->get( 'content_max_width' ),
322
  )
323
  );
324
 
332
  }
333
 
334
  if ( $featured_styles ) {
335
+ $this->merge_data_for_key( 'post_amp_styles', $featured_styles );
336
  }
337
  }
338
 
425
 
426
  $file = apply_filters( 'amp_post_template_file', $file, $template_type, $this->post );
427
  if ( ! $this->is_valid_template( $file ) ) {
428
+ _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Path validation for template (%s) failed. Path cannot traverse and must be located in `%s`.', 'amp' ), esc_html( $file ), 'WP_CONTENT_DIR' ), '0.1' );
429
  return;
430
  }
431
 
includes/vendor/amp/includes/embeds/class-amp-dailymotion-embed.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ // Much of this class is borrowed from Jetpack embeds
6
+ class AMP_DailyMotion_Embed_Handler extends AMP_Base_Embed_Handler {
7
+
8
+ const URL_PATTERN = '#https?:\/\/(www\.)?dailymotion\.com\/video\/.*#i';
9
+ const RATIO = 0.5625;
10
+
11
+ protected $DEFAULT_WIDTH = 600;
12
+ protected $DEFAULT_HEIGHT = 338;
13
+
14
+ private static $script_slug = 'amp-dailymotion';
15
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-dailymotion-0.1.js';
16
+
17
+ function __construct( $args = array() ) {
18
+ parent::__construct( $args );
19
+
20
+ if ( isset( $this->args['content_max_width'] ) ) {
21
+ $max_width = $this->args['content_max_width'];
22
+ $this->args['width'] = $max_width;
23
+ $this->args['height'] = round( $max_width * self::RATIO );
24
+ }
25
+ }
26
+
27
+ function register_embed() {
28
+ wp_embed_register_handler( 'amp-dailymotion', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
29
+ add_shortcode( 'dailymotion', array( $this, 'shortcode' ) );
30
+ }
31
+
32
+ public function unregister_embed() {
33
+ wp_embed_unregister_handler( 'amp-dailymotion', -1 );
34
+ remove_shortcode( 'dailymotion' );
35
+ }
36
+
37
+ public function get_scripts() {
38
+ if ( ! $this->did_convert_elements ) {
39
+ return array();
40
+ }
41
+
42
+ return array( self::$script_slug => self::$script_src );
43
+ }
44
+
45
+ public function shortcode( $attr ) {
46
+ $video_id = false;
47
+
48
+ if ( isset( $attr['id'] ) ) {
49
+ $video_id = $attr['id'];
50
+ } elseif ( isset( $attr[0] ) ) {
51
+ $video_id = $attr[0];
52
+ } elseif ( function_exists( 'shortcode_new_to_old_params' ) ) {
53
+ $video_id = shortcode_new_to_old_params( $attr );
54
+ }
55
+
56
+ if ( empty( $video_id ) ) {
57
+ return '';
58
+ }
59
+
60
+ return $this->render( array(
61
+ 'video_id' => $video_id,
62
+ ) );
63
+ }
64
+
65
+ public function oembed( $matches, $attr, $url, $rawattr ) {
66
+ $video_id = $this->get_video_id_from_url( $url );
67
+ return $this->render( array(
68
+ 'video_id' => $video_id,
69
+ ) );
70
+ }
71
+
72
+ public function render( $args ) {
73
+ $args = wp_parse_args( $args, array(
74
+ 'video_id' => false,
75
+ ) );
76
+
77
+ if ( empty( $args['video_id'] ) ) {
78
+ return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
79
+ }
80
+
81
+ $this->did_convert_elements = true;
82
+
83
+ return AMP_HTML_Utils::build_tag(
84
+ 'amp-dailymotion',
85
+ array(
86
+ 'data-videoid' => $args['video_id'],
87
+ 'layout' => 'responsive',
88
+ 'width' => $this->args['width'],
89
+ 'height' => $this->args['height'],
90
+ )
91
+ );
92
+ }
93
+
94
+ private function get_video_id_from_url( $url ) {
95
+ $parsed_url = AMP_WP_Utils::parse_url( $url );
96
+ parse_str( $parsed_url['path'], $path );
97
+ $tok = explode( '/', $parsed_url['path'] );
98
+ $tok = explode( '_', $tok[2] );
99
+ $video_id = $tok[0];
100
+
101
+ return $video_id;
102
+ }
103
+ }
includes/vendor/amp/includes/embeds/class-amp-gallery-embed.php CHANGED
@@ -39,7 +39,7 @@ class AMP_Gallery_Embed_Handler extends AMP_Base_Embed_Handler {
39
  'id' => $post ? $post->ID : 0,
40
  'include' => '',
41
  'exclude' => '',
42
- 'size' => array( $this->args['width'], $this->args['height'] )
43
  ), $attr, 'gallery' );
44
 
45
  $id = intval( $atts['id'] );
39
  'id' => $post ? $post->ID : 0,
40
  'include' => '',
41
  'exclude' => '',
42
+ 'size' => array( $this->args['width'], $this->args['height'] ),
43
  ), $attr, 'gallery' );
44
 
45
  $id = intval( $atts['id'] );
includes/vendor/amp/includes/embeds/class-amp-instagram-embed.php CHANGED
@@ -52,7 +52,7 @@ class AMP_Instagram_Embed_Handler extends AMP_Base_Embed_Handler {
52
  }
53
 
54
  public function oembed( $matches, $attr, $url, $rawattr ) {
55
- return $this->render( array( 'url' => $url, 'instagram_id' => end( $matches ) ) );
56
  }
57
 
58
  public function render( $args ) {
52
  }
53
 
54
  public function oembed( $matches, $attr, $url, $rawattr ) {
55
+ return $this->render( array( 'url' => $url, 'instagram_id' => end( $matches ) ) );
56
  }
57
 
58
  public function render( $args ) {
includes/vendor/amp/includes/embeds/class-amp-pinterest-embed.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php');
4
+
5
+ class AMP_Pinterest_Embed_Handler extends AMP_Base_Embed_Handler {
6
+
7
+ const URL_PATTERN = '#https?://(www\.)?pinterest\.com/pin/.*#i';
8
+
9
+ protected $DEFAULT_WIDTH = 450;
10
+ protected $DEFAULT_HEIGHT = 750;
11
+
12
+ private static $script_slug = 'amp-pinterest';
13
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-pinterest-0.1.js';
14
+
15
+ public function register_embed() {
16
+ wp_embed_register_handler(
17
+ 'amp-pinterest',
18
+ self::URL_PATTERN,
19
+ array($this, 'oembed'),
20
+ -1);
21
+ }
22
+
23
+ public function unregister_embed() {
24
+ wp_embed_unregister_handler('amp-pinterest', -1);
25
+ }
26
+
27
+ public function get_scripts() {
28
+ if ( ! $this->did_convert_elements) {
29
+ return array();
30
+ }
31
+
32
+ return array( self::$script_slug => self::$script_src);
33
+ }
34
+
35
+ public function oembed( $matches, $attr, $url, $rawattr ) {
36
+ return $this->render( array( 'url' => $url ) );
37
+ }
38
+
39
+ public function render( $args ) {
40
+ $args = wp_parse_args( $args, array(
41
+ 'url' => false,
42
+ ) );
43
+
44
+ if ( empty( $args['url'] ) ) {
45
+ return '';
46
+ }
47
+
48
+ $this->did_convert_elements = true;
49
+
50
+ return AMP_HTML_Utils::build_tag(
51
+ 'amp-pinterest',
52
+ array(
53
+ 'width' => $this->args['width'],
54
+ 'height' => $this->args['height'],
55
+ 'data-do' => "embedPin",
56
+ 'data-url' => $args['url'],
57
+ 'layout' => 'responsive',
58
+ )
59
+ );
60
+ }
61
+ }
includes/vendor/amp/includes/embeds/class-amp-soundcloud-embed.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ class AMP_SoundCloud_Embed_Handler extends AMP_Base_Embed_Handler {
6
+ const URL_PATTERN = '#https?://api\.soundcloud\.com/tracks/.*#i';
7
+ protected $DEFAULT_HEIGHT = 200;
8
+
9
+ private static $script_slug = 'amp-soundcloud';
10
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-soundcloud-0.1.js';
11
+
12
+ public function register_embed() {
13
+ wp_embed_register_handler( 'amp-soundcloud', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
14
+ add_shortcode( 'soundcloud', array( $this, 'shortcode' ) );
15
+ }
16
+
17
+ public function unregister_embed() {
18
+ wp_embed_unregister_handler( 'amp-soundcloud', -1 );
19
+ remove_shortcode( 'soundcloud' );
20
+ }
21
+
22
+ public function get_scripts() {
23
+ if ( ! $this->did_convert_elements ) {
24
+ return array();
25
+ }
26
+
27
+ return array( self::$script_slug => self::$script_src );
28
+ }
29
+
30
+ public function oembed( $matches, $attr, $url, $rawattr ) {
31
+ $track_id = $this->get_track_id_from_url( $url );
32
+ return $this->render( array(
33
+ 'track_id' => $track_id,
34
+ ) );
35
+ }
36
+
37
+ public function shortcode( $attr ) {
38
+
39
+ $track_id = false;
40
+
41
+ if ( isset( $attr['id'] ) ) {
42
+ $track_id = $attr['id'];
43
+ } else {
44
+ $url = false;
45
+ if ( isset( $attr['url'] ) ) {
46
+ $url = $attr['url'];
47
+ } elseif ( isset( $attr[0] ) ) {
48
+ $url = $attr[0];
49
+ } elseif ( function_exists( 'shortcode_new_to_old_params' ) ) {
50
+ $url = shortcode_new_to_old_params( $attr );
51
+ }
52
+
53
+ if ( ! empty( $url ) ) {
54
+ $track_id = $this->get_track_id_from_url( $url );
55
+ }
56
+ }
57
+
58
+ if ( empty( $track_id ) ) {
59
+ return '';
60
+ }
61
+
62
+ return $this->render( array(
63
+ 'track_id' => $track_id,
64
+ ) );
65
+ }
66
+
67
+ public function render( $args ) {
68
+ $args = wp_parse_args( $args, array(
69
+ 'track_id' => false,
70
+ ) );
71
+
72
+ if ( empty( $args['track_id'] ) ) {
73
+ return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
74
+ }
75
+
76
+ $this->did_convert_elements = true;
77
+
78
+ return AMP_HTML_Utils::build_tag(
79
+ 'amp-soundcloud',
80
+ array(
81
+ 'data-trackid' => $args['track_id'],
82
+ 'layout' => 'fixed-height',
83
+ 'height' => $this->args['height'],
84
+ )
85
+ );
86
+ }
87
+
88
+ private function get_track_id_from_url( $url ) {
89
+ $parsed_url = AMP_WP_Utils::parse_url( $url );
90
+ $tok = explode( '/', $parsed_url['path'] );
91
+ $track_id = $tok[2];
92
+
93
+ return $track_id;
94
+ }
95
+ }
includes/vendor/amp/includes/embeds/class-amp-vimeo-embed.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ class AMP_Vimeo_Embed_Handler extends AMP_Base_Embed_Handler {
6
+
7
+ const URL_PATTERN = '#https?:\/\/(www\.)?vimeo\.com\/.*#i';
8
+
9
+ const RATIO = 0.5625;
10
+
11
+ protected $DEFAULT_WIDTH = 600;
12
+ protected $DEFAULT_HEIGHT = 338;
13
+
14
+ private static $script_slug = 'amp-vimeo';
15
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-vimeo-0.1.js';
16
+
17
+ function __construct( $args = array() ) {
18
+ parent::__construct( $args );
19
+
20
+ if ( isset( $this->args['content_max_width'] ) ) {
21
+ $max_width = $this->args['content_max_width'];
22
+ $this->args['width'] = $max_width;
23
+ $this->args['height'] = round( $max_width * self::RATIO );
24
+ }
25
+ }
26
+
27
+ function register_embed() {
28
+ wp_embed_register_handler( 'amp-vimeo', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
29
+ add_shortcode( 'vimeo', array( $this, 'shortcode' ) );
30
+ }
31
+
32
+ public function unregister_embed() {
33
+ wp_embed_unregister_handler( 'amp-vimeo', -1 );
34
+ remove_shortcode( 'vimeo' );
35
+ }
36
+
37
+ public function get_scripts() {
38
+ if ( ! $this->did_convert_elements ) {
39
+ return array();
40
+ }
41
+
42
+ return array( self::$script_slug => self::$script_src );
43
+ }
44
+
45
+ public function shortcode( $attr ) {
46
+ $video_id = false;
47
+
48
+ if ( isset( $attr['id'] ) ) {
49
+ $video_id = $attr['id'];
50
+ } elseif ( isset( $attr['url'] ) ) {
51
+ $video_id = $this->get_video_id_from_url($attr['url']);
52
+ }elseif ( isset( $attr[0] ) ) {
53
+ $video_id = $this->get_video_id_from_url($attr[0]);
54
+ } elseif ( function_exists( 'shortcode_new_to_old_params' ) ) {
55
+ $video_id = shortcode_new_to_old_params( $attr );
56
+ }
57
+
58
+ if ( empty( $video_id ) ) {
59
+ return '';
60
+ }
61
+
62
+ return $this->render( array(
63
+ 'video_id' => $video_id,
64
+ ) );
65
+ }
66
+
67
+ public function oembed( $matches, $attr, $url, $rawattr ) {
68
+ $video_id = $this->get_video_id_from_url( $url );
69
+
70
+ return $this->render( array(
71
+ 'url' => $url,
72
+ 'video_id' => $video_id,
73
+ ) );
74
+ }
75
+
76
+ public function render( $args ) {
77
+ $args = wp_parse_args( $args, array(
78
+ 'video_id' => false,
79
+ ) );
80
+
81
+ if ( empty( $args['video_id'] ) ) {
82
+ return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
83
+ }
84
+
85
+ $this->did_convert_elements = true;
86
+
87
+ return AMP_HTML_Utils::build_tag(
88
+ 'amp-vimeo',
89
+ array(
90
+ 'data-videoid' => $args['video_id'],
91
+ 'layout' => 'responsive',
92
+ 'width' => $this->args['width'],
93
+ 'height' => $this->args['height'],
94
+ )
95
+ );
96
+ }
97
+
98
+ // get_video_id_from_url()
99
+ // Takes the last component of a Vimeo URL
100
+ // and returns it as the associated video id
101
+ private function get_video_id_from_url( $url ) {
102
+ $parsed_url = parse_url( $url );
103
+ parse_str( $parsed_url['path'], $path );
104
+
105
+ $video_id = "";
106
+ if ( $path ) {
107
+ $tok = explode( '/', $parsed_url['path'] );
108
+ $video_id = end($tok);
109
+ }
110
+
111
+ return $video_id;
112
+ }
113
+ }
includes/vendor/amp/includes/embeds/class-amp-vine-embed.php CHANGED
@@ -28,7 +28,7 @@ class AMP_Vine_Embed_Handler extends AMP_Base_Embed_Handler {
28
  }
29
 
30
  public function oembed( $matches, $attr, $url, $rawattr ) {
31
- return $this->render( array( 'url' => $url, 'vine_id' => end( $matches ) ) );
32
  }
33
 
34
  public function render( $args ) {
28
  }
29
 
30
  public function oembed( $matches, $attr, $url, $rawattr ) {
31
+ return $this->render( array( 'url' => $url, 'vine_id' => end( $matches ) ) );
32
  }
33
 
34
  public function render( $args ) {
includes/vendor/amp/includes/embeds/class-amp-youtube-embed.php CHANGED
@@ -48,7 +48,7 @@ class AMP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
48
  $video_id = false;
49
  if ( isset( $attr[0] ) ) {
50
  $url = ltrim( $attr[0] , '=' );
51
- } elseif ( function_exists ( 'shortcode_new_to_old_params' ) ) {
52
  $url = shortcode_new_to_old_params( $attr );
53
  }
54
 
@@ -113,7 +113,7 @@ class AMP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
113
  // /(v|e|embed)/{id}
114
  $parts = explode( '/', $parsed_url['path'] );
115
 
116
- if ( in_array( $parts[1], array( 'v', 'e', 'embed' ) ) ) {
117
  $video_id = $parts[2];
118
  }
119
  }
48
  $video_id = false;
49
  if ( isset( $attr[0] ) ) {
50
  $url = ltrim( $attr[0] , '=' );
51
+ } elseif ( function_exists( 'shortcode_new_to_old_params' ) ) {
52
  $url = shortcode_new_to_old_params( $attr );
53
  }
54
 
113
  // /(v|e|embed)/{id}
114
  $parts = explode( '/', $parsed_url['path'] );
115
 
116
+ if ( in_array( $parts[1], array( 'v', 'e', 'embed' ), true ) ) {
117
  $video_id = $parts[2];
118
  }
119
  }
includes/vendor/amp/includes/sanitizers/class-amp-base-sanitizer.php CHANGED
@@ -42,9 +42,9 @@ abstract class AMP_Base_Sanitizer {
42
  }
43
 
44
  if ( AMP_String_Utils::endswith( $value, '%' ) ) {
45
- if ( 'width' === $dimension && isset( $this->args[ 'content_max_width'] ) ) {
46
  $percentage = absint( $value ) / 100;
47
- return round( $percentage * $this->args[ 'content_max_width'] );
48
  }
49
  }
50
 
42
  }
43
 
44
  if ( AMP_String_Utils::endswith( $value, '%' ) ) {
45
+ if ( 'width' === $dimension && isset( $this->args['content_max_width'] ) ) {
46
  $percentage = absint( $value ) / 100;
47
+ return round( $percentage * $this->args['content_max_width'] );
48
  }
49
  }
50
 
includes/vendor/amp/includes/sanitizers/class-amp-blacklist-sanitizer.php CHANGED
@@ -28,7 +28,7 @@ class AMP_Blacklist_Sanitizer extends AMP_Base_Sanitizer {
28
  }
29
 
30
  private function strip_attributes_recursive( $node, $bad_attributes, $bad_protocols ) {
31
- if ( $node->nodeType !== XML_ELEMENT_NODE ) {
32
  return;
33
  }
34
 
@@ -49,13 +49,13 @@ class AMP_Blacklist_Sanitizer extends AMP_Base_Sanitizer {
49
  for ( $i = $length - 1; $i >= 0; $i-- ) {
50
  $attribute = $node->attributes->item( $i );
51
  $attribute_name = strtolower( $attribute->name );
52
- if ( in_array( $attribute_name, $bad_attributes ) ) {
53
  $node->removeAttribute( $attribute_name );
54
  continue;
55
  }
56
 
57
  // on* attributes (like onclick) are a special case
58
- if ( 0 === stripos( $attribute_name, 'on' ) && $attribute_name != 'on' ) {
59
  $node->removeAttribute( $attribute_name );
60
  continue;
61
  } elseif ( 'a' === $node_name ) {
@@ -150,11 +150,11 @@ class AMP_Blacklist_Sanitizer extends AMP_Base_Sanitizer {
150
  $protocol = strtok( $href, ':' );
151
 
152
  if ( false === filter_var( $href, FILTER_VALIDATE_URL )
153
- && ! in_array( $protocol, $special_protocols ) ) {
154
  return false;
155
  }
156
 
157
- if ( ! in_array( $protocol, $valid_protocols ) ) {
158
  return false;
159
  }
160
 
28
  }
29
 
30
  private function strip_attributes_recursive( $node, $bad_attributes, $bad_protocols ) {
31
+ if ( XML_ELEMENT_NODE !== $node->nodeType ) {
32
  return;
33
  }
34
 
49
  for ( $i = $length - 1; $i >= 0; $i-- ) {
50
  $attribute = $node->attributes->item( $i );
51
  $attribute_name = strtolower( $attribute->name );
52
+ if ( in_array( $attribute_name, $bad_attributes, true ) ) {
53
  $node->removeAttribute( $attribute_name );
54
  continue;
55
  }
56
 
57
  // on* attributes (like onclick) are a special case
58
+ if ( 0 === stripos( $attribute_name, 'on' ) && 'on' !== $attribute_name ) {
59
  $node->removeAttribute( $attribute_name );
60
  continue;
61
  } elseif ( 'a' === $node_name ) {
150
  $protocol = strtok( $href, ':' );
151
 
152
  if ( false === filter_var( $href, FILTER_VALIDATE_URL )
153
+ && ! in_array( $protocol, $special_protocols, true ) ) {
154
  return false;
155
  }
156
 
157
+ if ( ! in_array( $protocol, $valid_protocols, true ) ) {
158
  return false;
159
  }
160
 
includes/vendor/amp/includes/sanitizers/class-amp-iframe-sanitizer.php CHANGED
@@ -97,7 +97,6 @@ class AMP_Iframe_Sanitizer extends AMP_Base_Sanitizer {
97
  $out[ $name ] = $this->sanitize_dimension( $value, $name );
98
  break;
99
 
100
-
101
  case 'frameborder':
102
  if ( '0' !== $value && '1' !== $value ) {
103
  $value = '0';
@@ -117,8 +116,8 @@ class AMP_Iframe_Sanitizer extends AMP_Base_Sanitizer {
117
  }
118
  }
119
 
120
- if ( ! isset( $out[ 'sandbox' ] ) ) {
121
- $out[ 'sandbox' ] = self::SANDBOX_DEFAULTS;
122
  }
123
 
124
  return $out;
97
  $out[ $name ] = $this->sanitize_dimension( $value, $name );
98
  break;
99
 
 
100
  case 'frameborder':
101
  if ( '0' !== $value && '1' !== $value ) {
102
  $value = '0';
116
  }
117
  }
118
 
119
+ if ( ! isset( $out['sandbox'] ) ) {
120
+ $out['sandbox'] = self::SANDBOX_DEFAULTS;
121
  }
122
 
123
  return $out;
includes/vendor/amp/includes/sanitizers/class-amp-playbuzz-sanitizer.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php';
4
+
5
+ /**
6
+ * Converts Playbuzz embed to <amp-playbuzz>
7
+ */
8
+ class AMP_Playbuzz_Sanitizer extends AMP_Base_Sanitizer {
9
+
10
+
11
+ public static $tag = 'div';
12
+ public static $pb_class = 'pb_feed';
13
+ private static $script_slug = 'amp-playbuzz';
14
+ private static $height = '500';
15
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-playbuzz-0.1.js';
16
+
17
+
18
+
19
+ public function get_scripts() {
20
+ if ( ! $this->did_convert_elements ) {
21
+ return array();
22
+ }
23
+ return array(
24
+ self::$script_slug => self::$script_src,
25
+ );
26
+ }
27
+
28
+
29
+ public function sanitize() {
30
+
31
+ $nodes = $this->dom->getElementsByTagName( self::$tag );
32
+ $num_nodes = $nodes->length;
33
+
34
+ if ( 0 === $num_nodes ) {
35
+
36
+ return;
37
+
38
+ }
39
+
40
+ for ( $i = $num_nodes - 1; $i >= 0; $i-- ) {
41
+ $node = $nodes->item( $i );
42
+
43
+ if ( self::$pb_class !== $node -> getAttribute( 'class' ) ) {
44
+ continue;
45
+ }
46
+
47
+ $old_attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $node );
48
+
49
+ $new_attributes = $this->filter_attributes( $old_attributes );
50
+
51
+ if ( ! isset( $new_attributes['data-item'] ) && ! isset( $new_attributes['src'] ) ) {
52
+ continue;
53
+ }
54
+
55
+ $new_node = AMP_DOM_Utils::create_node( $this->dom, self::$script_slug, $new_attributes );
56
+
57
+ $node->parentNode->replaceChild( $new_node, $node );
58
+
59
+ $this->did_convert_elements = true;
60
+
61
+ }
62
+
63
+ }
64
+
65
+
66
+ private function filter_attributes( $attributes ) {
67
+ $out = array();
68
+
69
+ foreach ( $attributes as $name => $value ) {
70
+ switch ( $name ) {
71
+ case 'data-item':
72
+ if ( ! empty( $value ) ) {
73
+ $out['data-item'] = $value;
74
+ }
75
+ break;
76
+
77
+ case 'data-game':
78
+ if ( ! empty( $value ) ) {
79
+ $out['src'] = $value;
80
+ }
81
+ break;
82
+
83
+ case 'data-game-info':
84
+ $out['data-item-info'] = $value;
85
+ break;
86
+
87
+ case 'data-shares':
88
+ $out['data-share-buttons'] = $value;
89
+ break;
90
+
91
+ case 'data-comments':
92
+ $out['data-comments'] = $value;
93
+ break;
94
+
95
+ default;
96
+ break;
97
+ }
98
+ }
99
+
100
+ $out['height'] = self::$height;
101
+
102
+ return $out;
103
+ }
104
+ }
includes/vendor/amp/includes/sanitizers/class-amp-style-sanitizer.php CHANGED
@@ -18,7 +18,7 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
18
  }
19
 
20
  private function collect_styles_recursive( $node ) {
21
- if ( $node->nodeType !== XML_ELEMENT_NODE ) {
22
  return;
23
  }
24
 
@@ -56,8 +56,11 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
56
  return array();
57
  }
58
 
59
- // Normalize order
60
- $styles = array_map( 'trim', explode( ';', $string ) );
 
 
 
61
  sort( $styles );
62
 
63
  $processed_styles = array();
18
  }
19
 
20
  private function collect_styles_recursive( $node ) {
21
+ if ( XML_ELEMENT_NODE !== $node->nodeType ) {
22
  return;
23
  }
24
 
56
  return array();
57
  }
58
 
59
+ // safecss returns a string but we want individual rules.
60
+ // Using preg_split to break up rules by `;` but only if the semi-colon is not inside parens (like a data-encoded image).
61
+ $styles = array_map( 'trim', preg_split( "/;(?![^(]*\))/", $string ) );
62
+
63
+ // Normalize the order of the styles
64
  sort( $styles );
65
 
66
  $processed_styles = array();
includes/vendor/amp/includes/settings/class-amp-customizer-design-settings.php CHANGED
@@ -23,7 +23,7 @@ class AMP_Customizer_Design_Settings {
23
  'type' => 'option',
24
  'default' => self::DEFAULT_HEADER_COLOR,
25
  'sanitize_callback' => 'sanitize_hex_color',
26
- 'transport' => 'postMessage'
27
  ) );
28
 
29
  // Header background color
@@ -31,7 +31,7 @@ class AMP_Customizer_Design_Settings {
31
  'type' => 'option',
32
  'default' => self::DEFAULT_HEADER_BACKGROUND_COLOR,
33
  'sanitize_callback' => 'sanitize_hex_color',
34
- 'transport' => 'postMessage'
35
  ) );
36
 
37
  // Background color scheme
@@ -39,7 +39,7 @@ class AMP_Customizer_Design_Settings {
39
  'type' => 'option',
40
  'default' => self::DEFAULT_COLOR_SCHEME,
41
  'sanitize_callback' => array( __CLASS__ , 'sanitize_color_scheme' ),
42
- 'transport' => 'postMessage'
43
  ) );
44
  }
45
 
@@ -55,7 +55,7 @@ class AMP_Customizer_Design_Settings {
55
  'settings' => 'amp_customizer[header_color]',
56
  'label' => __( 'Header Text Color', 'amp' ),
57
  'section' => 'amp_design',
58
- 'priority' => 10
59
  ) )
60
  );
61
 
@@ -65,7 +65,7 @@ class AMP_Customizer_Design_Settings {
65
  'settings' => 'amp_customizer[header_background_color]',
66
  'label' => __( 'Header Background & Link Color', 'amp' ),
67
  'section' => 'amp_design',
68
- 'priority' => 20
69
  ) )
70
  );
71
 
@@ -109,7 +109,7 @@ class AMP_Customizer_Design_Settings {
109
 
110
  protected static function get_color_scheme_names() {
111
  return array(
112
- 'light' => __( 'Light', 'amp'),
113
  'dark' => __( 'Dark', 'amp' ),
114
  );
115
  }
@@ -129,7 +129,7 @@ class AMP_Customizer_Design_Settings {
129
  'text_color' => '#dedede',
130
  'muted_text_color' => '#b1b1b1',
131
  'border_color' => '#707070',
132
- )
133
  );
134
  }
135
 
@@ -147,7 +147,7 @@ class AMP_Customizer_Design_Settings {
147
  $schemes = self::get_color_scheme_names();
148
  $scheme_slugs = array_keys( $schemes );
149
 
150
- if ( ! in_array( $value, $scheme_slugs ) ) {
151
  $value = self::DEFAULT_COLOR_SCHEME;
152
  }
153
 
23
  'type' => 'option',
24
  'default' => self::DEFAULT_HEADER_COLOR,
25
  'sanitize_callback' => 'sanitize_hex_color',
26
+ 'transport' => 'postMessage',
27
  ) );
28
 
29
  // Header background color
31
  'type' => 'option',
32
  'default' => self::DEFAULT_HEADER_BACKGROUND_COLOR,
33
  'sanitize_callback' => 'sanitize_hex_color',
34
+ 'transport' => 'postMessage',
35
  ) );
36
 
37
  // Background color scheme
39
  'type' => 'option',
40
  'default' => self::DEFAULT_COLOR_SCHEME,
41
  'sanitize_callback' => array( __CLASS__ , 'sanitize_color_scheme' ),
42
+ 'transport' => 'postMessage',
43
  ) );
44
  }
45
 
55
  'settings' => 'amp_customizer[header_color]',
56
  'label' => __( 'Header Text Color', 'amp' ),
57
  'section' => 'amp_design',
58
+ 'priority' => 10,
59
  ) )
60
  );
61
 
65
  'settings' => 'amp_customizer[header_background_color]',
66
  'label' => __( 'Header Background & Link Color', 'amp' ),
67
  'section' => 'amp_design',
68
+ 'priority' => 20,
69
  ) )
70
  );
71
 
109
 
110
  protected static function get_color_scheme_names() {
111
  return array(
112
+ 'light' => __( 'Light', 'amp' ),
113
  'dark' => __( 'Dark', 'amp' ),
114
  );
115
  }
129
  'text_color' => '#dedede',
130
  'muted_text_color' => '#b1b1b1',
131
  'border_color' => '#707070',
132
+ ),
133
  );
134
  }
135
 
147
  $schemes = self::get_color_scheme_names();
148
  $scheme_slugs = array_keys( $schemes );
149
 
150
+ if ( ! in_array( $value, $scheme_slugs, true ) ) {
151
  $value = self::DEFAULT_COLOR_SCHEME;
152
  }
153
 
includes/vendor/amp/includes/utils/class-amp-dom-utils.php CHANGED
@@ -95,10 +95,27 @@ class AMP_DOM_Utils {
95
  // https://www.w3.org/TR/html5/syntax.html#serializing-html-fragments
96
  // Not all are valid AMP, but we include them for completeness.
97
  $self_closing_tags = array(
98
- 'area', 'base', 'basefont', 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  );
100
  }
101
 
102
- return in_array( $tag, $self_closing_tags );
103
  }
104
  }
95
  // https://www.w3.org/TR/html5/syntax.html#serializing-html-fragments
96
  // Not all are valid AMP, but we include them for completeness.
97
  $self_closing_tags = array(
98
+ 'area',
99
+ 'base',
100
+ 'basefont',
101
+ 'bgsound',
102
+ 'br',
103
+ 'col',
104
+ 'embed',
105
+ 'frame',
106
+ 'hr',
107
+ 'img',
108
+ 'input',
109
+ 'keygen',
110
+ 'link',
111
+ 'meta',
112
+ 'param',
113
+ 'source',
114
+ 'track',
115
+ 'wbr',
116
  );
117
  }
118
 
119
+ return in_array( $tag, $self_closing_tags, true );
120
  }
121
  }
includes/vendor/amp/includes/utils/class-amp-string-utils.php CHANGED
@@ -4,6 +4,6 @@ class AMP_String_Utils {
4
  public static function endswith( $haystack, $needle ) {
5
  return '' !== $haystack
6
  && '' !== $needle
7
- && $needle === substr( $haystack, -strlen( $needle ) );
8
  }
9
  }
4
  public static function endswith( $haystack, $needle ) {
5
  return '' !== $haystack
6
  && '' !== $needle
7
+ && substr( $haystack, -strlen( $needle ) ) === $needle;
8
  }
9
  }
includes/vendor/amp/jetpack-helper.php CHANGED
@@ -9,13 +9,16 @@ add_action( 'pre_amp_render_post', 'amp_jetpack_mods' );
9
  *
10
  **/
11
  function amp_jetpack_mods() {
12
- if ( Jetpack::is_module_active( 'stats' ) ) {
13
- add_action( 'amp_post_template_footer', 'jetpack_amp_add_stats_pixel' );
 
 
 
 
14
  }
15
- amp_jetpack_disable_sharing();
16
- amp_jetpack_disable_related_posts();
17
  }
18
 
 
19
  function amp_jetpack_disable_sharing() {
20
  add_filter( 'sharing_show', '__return_false', 100 );
21
  }
@@ -63,7 +66,7 @@ function jetpack_amp_build_stats_pixel_url() {
63
  $data = compact( 'v', 'j', 'blog', 'post', 'tz', 'srv' );
64
  }
65
 
66
- $data['host'] = rawurlencode( $_SERVER['HTTP_HOST'] );
67
  $data['rand'] = 'RANDOM'; // amp placeholder
68
  $data['ref'] = 'DOCUMENT_REFERRER'; // amp placeholder
69
  $data = array_map( 'rawurlencode' , $data );
9
  *
10
  **/
11
  function amp_jetpack_mods() {
12
+ if ( class_exists('Jetpack') ) {
13
+ if ( Jetpack::is_module_active( 'stats' ) ) {
14
+ add_action( 'amp_post_template_footer', 'jetpack_amp_add_stats_pixel' );
15
+ }
16
+ amp_jetpack_disable_sharing();
17
+ amp_jetpack_disable_related_posts();
18
  }
 
 
19
  }
20
 
21
+
22
  function amp_jetpack_disable_sharing() {
23
  add_filter( 'sharing_show', '__return_false', 100 );
24
  }
66
  $data = compact( 'v', 'j', 'blog', 'post', 'tz', 'srv' );
67
  }
68
 
69
+ $data['host'] = isset( $_SERVER['HTTP_HOST'] ) ? rawurlencode( $_SERVER['HTTP_HOST'] ) : '';
70
  $data['rand'] = 'RANDOM'; // amp placeholder
71
  $data['ref'] = 'DOCUMENT_REFERRER'; // amp placeholder
72
  $data = array_map( 'rawurlencode' , $data );
includes/vendor/amp/readme.md CHANGED
@@ -55,7 +55,7 @@ function xyz_amp_set_site_icon_url( $data ) {
55
 
56
  If you want to hide the site text and just show a logo, use the `amp_post_template_css` action. The following colors the title bar black, hides the site title, and replaces it with a centered logo:
57
 
58
- ```
59
  add_action( 'amp_post_template_css', 'xyz_amp_additional_css_styles' );
60
 
61
  function xyz_amp_additional_css_styles( $amp_template ) {
@@ -90,18 +90,11 @@ You can tweak various parts of the template via code.
90
  The default template does not display the featured image currently. There are many ways to add it, such as the snippet below:
91
 
92
  ```php
93
- add_action( 'pre_amp_render_post', 'xyz_amp_add_custom_actions' );
94
- function xyz_amp_add_custom_actions() {
95
- add_filter( 'the_content', 'xyz_amp_add_featured_image' );
96
- }
97
 
98
- function xyz_amp_add_featured_image( $content ) {
99
- if ( has_post_thumbnail() ) {
100
- // Just add the raw <img /> tag; our sanitizer will take care of it later.
101
- $image = sprintf( '<p class="xyz-featured-image">%s</p>', get_the_post_thumbnail() );
102
- $content = $image . $content;
103
- }
104
- return $content;
105
  }
106
  ```
107
 
@@ -136,7 +129,7 @@ Note: The path must pass the default criteria set out by [`validate_file`](https
136
 
137
  The plugin adds some default metadata to enable ["Rich Snippet" support](https://developers.google.com/structured-data/rich-snippets/articles). You can modify this using the `amp_post_template_metadata` filter. The following changes the type annotation to `NewsArticle` (from the default `BlogPosting`) and overrides the default Publisher Logo.
138
 
139
- ```
140
  add_filter( 'amp_post_template_metadata', 'xyz_amp_modify_json_metadata', 10, 2 );
141
 
142
  function xyz_amp_modify_json_metadata( $metadata, $post ) {
@@ -314,13 +307,13 @@ Note: there are some requirements for a custom template:
314
 
315
  * You must trigger the `amp_post_template_head` action in the `<head>` section:
316
 
317
- ```
318
  do_action( 'amp_post_template_head', $this );
319
  ```
320
 
321
  * You must trigger the `amp_post_template_footer` action right before the `</body>` tag:
322
 
323
- ```
324
  do_action( 'amp_post_template_footer', $this );
325
  ```
326
 
@@ -395,7 +388,10 @@ class XYZ_AMP_Related_Posts_Embed extends AMP_Base_Embed_Handler {
395
  }
396
 
397
  public function get_scripts() {
398
- return array( 'amp-mustache' => 'https://cdn.ampproject.org/v0/amp-mustache-0.1.js' );
 
 
 
399
  }
400
 
401
  public function add_related_posts( $content ) {
@@ -557,7 +553,7 @@ pairs in the single argument as per the example above.**
557
 
558
  To output proper analytics tags, you can use the `amp_post_template_analytics` filter:
559
 
560
- ```
561
  add_filter( 'amp_post_template_analytics', 'xyz_amp_add_custom_analytics' );
562
  function xyz_amp_add_custom_analytics( $analytics ) {
563
  if ( ! is_array( $analytics ) ) {
@@ -619,7 +615,7 @@ You'll need to flush your rewrite rules after this.
619
 
620
  If you want a custom template for your post type:
621
 
622
- ```
623
  add_filter( 'amp_post_template_file', 'xyz_amp_set_review_template', 10, 3 );
624
 
625
  function xyz_amp_set_review_template( $file, $type, $post ) {
55
 
56
  If you want to hide the site text and just show a logo, use the `amp_post_template_css` action. The following colors the title bar black, hides the site title, and replaces it with a centered logo:
57
 
58
+ ```php
59
  add_action( 'amp_post_template_css', 'xyz_amp_additional_css_styles' );
60
 
61
  function xyz_amp_additional_css_styles( $amp_template ) {
90
  The default template does not display the featured image currently. There are many ways to add it, such as the snippet below:
91
 
92
  ```php
93
+ add_filter( 'amp_post_template_data', 'xyz_amp_remove_featured_image' );
 
 
 
94
 
95
+ function xyz_amp_remove_featured_image( $data ) {
96
+ $data['featured_image'] = false;
97
+ return $data;
 
 
 
 
98
  }
99
  ```
100
 
129
 
130
  The plugin adds some default metadata to enable ["Rich Snippet" support](https://developers.google.com/structured-data/rich-snippets/articles). You can modify this using the `amp_post_template_metadata` filter. The following changes the type annotation to `NewsArticle` (from the default `BlogPosting`) and overrides the default Publisher Logo.
131
 
132
+ ```php
133
  add_filter( 'amp_post_template_metadata', 'xyz_amp_modify_json_metadata', 10, 2 );
134
 
135
  function xyz_amp_modify_json_metadata( $metadata, $post ) {
307
 
308
  * You must trigger the `amp_post_template_head` action in the `<head>` section:
309
 
310
+ ```php
311
  do_action( 'amp_post_template_head', $this );
312
  ```
313
 
314
  * You must trigger the `amp_post_template_footer` action right before the `</body>` tag:
315
 
316
+ ```php
317
  do_action( 'amp_post_template_footer', $this );
318
  ```
319
 
388
  }
389
 
390
  public function get_scripts() {
391
+ return array(
392
+ 'amp-mustache' => 'https://cdn.ampproject.org/v0/amp-mustache-0.1.js'
393
+ 'amp-list' => 'https://cdn.ampproject.org/v0/amp-list-0.1.js',
394
+ );
395
  }
396
 
397
  public function add_related_posts( $content ) {
553
 
554
  To output proper analytics tags, you can use the `amp_post_template_analytics` filter:
555
 
556
+ ```php
557
  add_filter( 'amp_post_template_analytics', 'xyz_amp_add_custom_analytics' );
558
  function xyz_amp_add_custom_analytics( $analytics ) {
559
  if ( ! is_array( $analytics ) ) {
615
 
616
  If you want a custom template for your post type:
617
 
618
+ ```php
619
  add_filter( 'amp_post_template_file', 'xyz_amp_set_review_template', 10, 3 );
620
 
621
  function xyz_amp_set_review_template( $file, $type, $post ) {
includes/vendor/vendor-changelog.txt CHANGED
@@ -23,4 +23,13 @@ Reference: #1130 #966
23
 
24
  9 Changed placeholder image path from assets folder to image folder
25
  amp\includes\class-amp-post-template.php, line no: 58, Issue no: 1310
26
- 'placeholder_image_url' => AMPFORWP_IMAGE_DIR. '/placeholder-icon.png' ,
 
 
 
 
 
 
 
 
 
23
 
24
  9 Changed placeholder image path from assets folder to image folder
25
  amp\includes\class-amp-post-template.php, line no: 58, Issue no: 1310
26
+ 'placeholder_image_url' => AMPFORWP_IMAGE_DIR. '/placeholder-icon.png'
27
+
28
+ 10. Embed Handlers: Added support for Vimeo, SoundCloud, Pinterest, Dailymotion and PlayBuzz
29
+ 11.Fixes: Old slug redirect for AMP URLs
30
+ Handle issues with data uri images in CSS
31
+ Output CSS for feature image
32
+ Fix attribute when adding AMP Mustache
33
+ Various documentation updates
34
+ Coding Standards
35
+ Check #1033 for more details on 10 and 11
pagebuilder/amp-page-builder.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
  echo "Silence is golden";
4
  }
5
 
@@ -7,58 +7,96 @@ if ( ! defined( 'ABSPATH' ) ) {
7
  define( 'AMP_PAGE_BUILDER', plugin_dir_path(__FILE__) );
8
  define( 'AMP_PAGE_BUILDER_URL', plugin_dir_url(__FILE__) );
9
 
10
- add_action('add_meta_boxes','ampforwp_pagebuilder_content_meta_register');
 
11
  function ampforwp_pagebuilder_content_meta_register($post_type){
12
  global $redux_builder_amp;
13
-
14
  // Page builder for posts
15
  if( $redux_builder_amp['amp-on-off-for-all-posts'] && $post_type == 'post' ) {
16
- add_meta_box( 'pagebilder_content', __( 'AMP Page Builder', 'amp-page-builder' ), 'amp_content_pagebuilder_title_callback', $post_type , 'normal', 'default' );
17
- }
18
-
19
  // Page builder for pages
20
  if ( $redux_builder_amp['amp-on-off-for-all-pages'] && $post_type == 'page' ) {
21
- add_meta_box( 'pagebilder_content', __( 'AMP Page Builder', 'amp-page-builder' ), 'amp_content_pagebuilder_title_callback', $post_type , 'normal', 'default' );
22
  }
23
-
24
  }
25
 
26
  function amp_content_pagebuilder_title_callback( $post ){
27
  global $post;
28
  $amp_current_post_id = $post->ID;
29
- wp_nonce_field( basename( __FILE__) , 'amp_content_editor_nonce' );
30
-
31
  $content = get_post_meta ( $amp_current_post_id, 'ampforwp_custom_content_editor', true );
32
  $editor_id = 'ampforwp_custom_content_editor';
33
  //wp_editor( $content, $editor_id );
34
- if(empty($content)){
35
- echo "<div class='amppb_welcome'>
36
- <a class='amppb_helper_btn beta_btn' href='https://ampforwp.com/tutorials/article/page-builder-is-in-beta/' target='_blank'><span>Beta Feature</span></a>
37
- <a class='amppb_helper_btn video_btn' href='https://ampforwp.com/tutorials/article/amp-page-builder-installation/' target='_blank'><span>Video Tutorial</span></a>
38
-
39
- <a class='amppb_helper_btn leave_review' href='https://wordpress.org/support/view/plugin-reviews/accelerated-mobile-pages?rate=5#new-post' target='_blank'><span>Rate</span></a>
40
- </div>";
41
- }
42
  //echo "<textarea style='display:none' id='amp-content-preview'>$content</textarea>";
43
  /*echo "<div class='rander_amp_html'>";
44
  echo html_entity_decode($content);
45
  echo "</div>";*/
46
- wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
47
- wp_enqueue_style( 'wp-jquery-ui-dialog' );
48
- call_page_builder();
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
 
 
51
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  /* Add page builder form after editor */
54
  function call_page_builder(){
55
  global $post;
56
  global $moduleTemplate;
 
 
 
 
 
 
57
  add_thickbox();
58
- $previousData = get_post_meta($post->ID,'amp-page-builder');
59
- $ampforwp_pagebuilder_enable = get_post_meta($post->ID,'ampforwp_page_builder_enable', true);
 
 
 
 
60
  $previousData = isset($previousData[0])? $previousData[0]: null;
61
- //$previousData = wp_slash($previousData);
62
  $previousData = (str_replace("'", "", $previousData));
63
 
64
  $totalRows = 1;
@@ -77,6 +115,7 @@ function call_page_builder(){
77
  $previousData = json_encode($jsonData);
78
  }
79
  }
 
80
  ?>
81
  <div class="enable_ampforwp_page_builder">
82
  <label><input type="checkbox" name="ampforwp_page_builder_enable" value="yes" <?php if($ampforwp_pagebuilder_enable=='yes'){echo 'checked'; } ?> >Enable Builder</label>
@@ -88,22 +127,15 @@ function call_page_builder(){
88
 
89
  <div id="sorted_rows" class="amppb-rows droppable">
90
  <p class="dummy amppb-rows-message">Welcome to AMP Page Builder.</p>
91
-
92
  </div><!-- .amppb-rows -->
93
-
94
-
95
  <?php /* This is where our action buttons to add rows
96
  Modules
97
  */ ?>
98
  <div class="amppb-actions" id="amppb-actions-container" data-containerid="<?php echo $totalRows; ?>">
99
  <span id="action-col-1" class="amppb-add-row button-primary button-large draggable module-col-1" data-template="col-1">1 Column</span>
100
  <span id="action-col-2" class="amppb-add-row button-primary button-large draggable module-col-2" data-template="col-2">2 Columns</span>
101
-
102
  </div><!-- .amppb-actions -->
103
 
104
-
105
-
106
-
107
  <div class="amppb-module-actions" id="amppb-module-actions-container" data-recentid="<?php echo $totalmodules; ?>">
108
  <?php
109
  foreach ($moduleTemplate as $key => $module) {
@@ -114,7 +146,6 @@ function call_page_builder(){
114
 
115
 
116
  </div>
117
- <?php add_thickbox(); ?>
118
  <div id="my-amppb-dialog" class="hidden" style="max-width:800px">
119
 
120
  <div class="amp-pb-module-content">
@@ -144,22 +175,11 @@ function call_page_builder(){
144
  </div>
145
  </div>
146
  </div>
147
- <!-- <div id="my-image-dialog" class="hidden" style="max-width:800px">
148
- <input type="button" class="button" value="Select image" id="selectImage">
149
- <img id="ampforwp-preview-image" src="http://via.placeholder.com/350x150" />
150
- <input type="hidden" name="ampforwp_image_id" id="ampforwp_image_id" value="" class="regular-text" />
151
- <div class="amppb-tc-footer">
152
- <div class="amppb-status"></div>
153
- <div class="buttons-groups">
154
- <input type="button" class="button" data-current-container="" data-current-module="" id="amppb-rowData-content-image" data-type="image" value="Submit">
155
- </div>
156
- </div>
157
- </div> -->
158
  <?php
159
  }
160
 
161
  // Ajax action to refresh the user image
162
- add_action( 'wp_ajax_ampforwp_get_image', 'ampforwp_get_image' );
163
  function ampforwp_get_image() {
164
  if(isset($_GET['id']) ){
165
  if(strpos($_GET['id'],",") !== false){
@@ -188,5 +208,4 @@ function ampforwp_get_image() {
188
  }
189
  }
190
 
191
- require_once AMP_PAGE_BUILDER.'functions.php';
192
-
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
  echo "Silence is golden";
4
  }
5
 
7
  define( 'AMP_PAGE_BUILDER', plugin_dir_path(__FILE__) );
8
  define( 'AMP_PAGE_BUILDER_URL', plugin_dir_url(__FILE__) );
9
 
10
+ //Set Metabox
11
+ add_action('add_meta_boxes','ampforwp_pagebuilder_content_meta_register', 10 ,1);
12
  function ampforwp_pagebuilder_content_meta_register($post_type){
13
  global $redux_builder_amp;
 
14
  // Page builder for posts
15
  if( $redux_builder_amp['amp-on-off-for-all-posts'] && $post_type == 'post' ) {
16
+ add_meta_box( 'pagebilder_content', __( 'AMP Page Builder', 'amp-page-builder' ), 'amp_content_pagebuilder_title_callback', 'post' , 'normal', 'default' );
17
+ }
 
18
  // Page builder for pages
19
  if ( $redux_builder_amp['amp-on-off-for-all-pages'] && $post_type == 'page' ) {
20
+ add_meta_box( 'pagebilder_content', __( 'AMP Page Builder', 'amp-page-builder' ), 'amp_content_pagebuilder_title_callback', 'page' , 'normal', 'default' );
21
  }
 
22
  }
23
 
24
  function amp_content_pagebuilder_title_callback( $post ){
25
  global $post;
26
  $amp_current_post_id = $post->ID;
 
 
27
  $content = get_post_meta ( $amp_current_post_id, 'ampforwp_custom_content_editor', true );
28
  $editor_id = 'ampforwp_custom_content_editor';
29
  //wp_editor( $content, $editor_id );
30
+
 
 
 
 
 
 
 
31
  //echo "<textarea style='display:none' id='amp-content-preview'>$content</textarea>";
32
  /*echo "<div class='rander_amp_html'>";
33
  echo html_entity_decode($content);
34
  echo "</div>";*/
35
+
36
+
37
+
38
+ //previous data stored compatible
39
+ //echo get_post_meta( $amp_current_post_id, 'amp-page-builder', true );
40
+ if(get_post_meta($amp_current_post_id ,'use_ampforwp_page_builder',true)==null &&
41
+ get_post_meta( $amp_current_post_id, 'amp-page-builder', true ) != ''){
42
+ update_post_meta($amp_current_post_id, 'use_ampforwp_page_builder','yes');
43
+ }
44
+ //Disable page builder
45
+ if(isset($_GET['ramppb']) && $_GET['ramppb']=='1'){
46
+ delete_post_meta($amp_current_post_id, 'use_ampforwp_page_builder','yes');
47
+ delete_post_meta($amp_current_post_id, 'ampforwp_page_builder_enable','yes');
48
+ }
49
+ //Enable page builder
50
+ if(isset($_GET['use_amp_pagebuilder']) && $_GET['use_amp_pagebuilder']=='1'){
51
+ update_post_meta($amp_current_post_id, 'use_ampforwp_page_builder','yes');
52
+ }
53
+ if(get_post_meta($amp_current_post_id ,'use_ampforwp_page_builder',true)=='yes'){
54
+ $url = remove_query_arg('use_amp_pagebuilder');
55
+
56
+ if(empty($content)){
57
+ echo "<div class='amppb_welcome'>
58
+ <a class='amppb_helper_btn beta_btn' href='https://ampforwp.com/tutorials/article/page-builder-is-in-beta/' target='_blank'><span>Beta Feature</span></a>
59
+ <a class='amppb_helper_btn video_btn' href='https://ampforwp.com/tutorials/article/amp-page-builder-installation/' target='_blank'><span>Video Tutorial</span></a>
60
+
61
+ <a class='amppb_helper_btn leave_review' href='https://wordpress.org/support/view/plugin-reviews/accelerated-mobile-pages?rate=5#new-post' target='_blank'><span>Rate</span></a>
62
+ </div>";
63
+ }
64
 
65
+ wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
66
+ wp_enqueue_style( 'wp-jquery-ui-dialog' );
67
 
68
+ // echo "<div class='amppb_welcome'>
69
+ // <a class='amppb_helper_btn' href='".add_query_arg('ramppb','1',$url)."' style='margin-right:285px;'><span>Remove</span></a>
70
+ // </div>";
71
+
72
+ call_page_builder();
73
+ }else{
74
+ $url = remove_query_arg('ramppb');
75
+ echo '<div href="'.add_query_arg('use_amp_pagebuilder','1',$url).'" id="start_amp_pb_post" class="start_amp_pb" data-postId="'.get_the_ID().'" onclick="">Start the AMP Page Builder</div>';
76
+ }
77
+ }
78
+
79
+ add_action("wp_ajax_call_page_builder", "call_page_builder");
80
 
81
  /* Add page builder form after editor */
82
  function call_page_builder(){
83
  global $post;
84
  global $moduleTemplate;
85
+ if($post!=null){
86
+ $postId = $post->ID;
87
+ }
88
+ if(isset($_GET['post_id'])){
89
+ $postId = $_GET['post_id'];
90
+ }
91
  add_thickbox();
92
+ if(isset($postId) && get_post_meta($postId,'use_ampforwp_page_builder')!='yes'){
93
+ update_post_meta($postId, 'use_ampforwp_page_builder','yes');
94
+ }
95
+
96
+ $previousData = get_post_meta($postId,'amp-page-builder');
97
+ $ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true);
98
  $previousData = isset($previousData[0])? $previousData[0]: null;
99
+
100
  $previousData = (str_replace("'", "", $previousData));
101
 
102
  $totalRows = 1;
115
  $previousData = json_encode($jsonData);
116
  }
117
  }
118
+ wp_nonce_field( basename( __FILE__) , 'amp_content_editor_nonce' );
119
  ?>
120
  <div class="enable_ampforwp_page_builder">
121
  <label><input type="checkbox" name="ampforwp_page_builder_enable" value="yes" <?php if($ampforwp_pagebuilder_enable=='yes'){echo 'checked'; } ?> >Enable Builder</label>
127
 
128
  <div id="sorted_rows" class="amppb-rows droppable">
129
  <p class="dummy amppb-rows-message">Welcome to AMP Page Builder.</p>
 
130
  </div><!-- .amppb-rows -->
 
 
131
  <?php /* This is where our action buttons to add rows
132
  Modules
133
  */ ?>
134
  <div class="amppb-actions" id="amppb-actions-container" data-containerid="<?php echo $totalRows; ?>">
135
  <span id="action-col-1" class="amppb-add-row button-primary button-large draggable module-col-1" data-template="col-1">1 Column</span>
136
  <span id="action-col-2" class="amppb-add-row button-primary button-large draggable module-col-2" data-template="col-2">2 Columns</span>
 
137
  </div><!-- .amppb-actions -->
138
 
 
 
 
139
  <div class="amppb-module-actions" id="amppb-module-actions-container" data-recentid="<?php echo $totalmodules; ?>">
140
  <?php
141
  foreach ($moduleTemplate as $key => $module) {
146
 
147
 
148
  </div>
 
149
  <div id="my-amppb-dialog" class="hidden" style="max-width:800px">
150
 
151
  <div class="amp-pb-module-content">
175
  </div>
176
  </div>
177
  </div>
 
 
 
 
 
 
 
 
 
 
 
178
  <?php
179
  }
180
 
181
  // Ajax action to refresh the user image
182
+ add_action( 'wp_ajax_ampforwp_get_image', 'ampforwp_get_image');
183
  function ampforwp_get_image() {
184
  if(isset($_GET['id']) ){
185
  if(strpos($_GET['id'],",") !== false){
208
  }
209
  }
210
 
211
+ require_once AMP_PAGE_BUILDER.'functions.php';
 
pagebuilder/config/moduleTemplate.php CHANGED
@@ -13,3 +13,26 @@ if (is_dir($dir)) {
13
  $moduleTemplate = array_filter($moduleTemplate);
14
  }
15
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  $moduleTemplate = array_filter($moduleTemplate);
14
  }
15
  }
16
+
17
+ //Row Contents
18
+ $output = '<div class="amp_pb_module {{row_class}}">';
19
+ $outputEnd = '<div class="cb"></div> </div>';
20
+ $containerCommonSettings = array(
21
+ 'fields' => array(
22
+ array(
23
+ 'type' =>'text',
24
+ 'name' =>"row_label",
25
+ 'label' =>'Row label',
26
+ 'default' =>'',
27
+ ),
28
+
29
+ array(
30
+ 'type' =>'text',
31
+ 'name' =>"row_class",
32
+ 'label' =>'Row class',
33
+ 'default' =>'',
34
+ )
35
+ ),
36
+ 'front_template_start'=>$output,
37
+ 'front_template_end'=>$outputEnd
38
+ );
pagebuilder/functions.php CHANGED
@@ -1,28 +1,6 @@
1
  <?php
2
 
3
- require_once("config/moduleTemplate.php");
4
-
5
- $output = '<div class="amp_pb_module {{row_class}}">';
6
- $outputEnd = '</div>';
7
- $containerCommonSettings = array(
8
- 'fields' => array(
9
- array(
10
- 'type' =>'text',
11
- 'name' =>"row_label",
12
- 'label' =>'Row label',
13
- 'default' =>'',
14
- ),
15
-
16
- array(
17
- 'type' =>'text',
18
- 'name' =>"row_class",
19
- 'label' =>'Row class',
20
- 'default' =>'',
21
- )
22
- ),
23
- 'front_template_start'=>$output,
24
- 'front_template_end'=>$outputEnd
25
- );
26
 
27
 
28
  /* Admin Script */
@@ -38,24 +16,27 @@ function amppbbase_admin_scripts( $hook_suffix ){
38
  //if( 'page' == $post_type && in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ){
39
  if($post_type=='post' || $post_type=='page'){
40
  /* Enqueue CSS & JS For Page Builder */
41
- wp_enqueue_style( 'amppb-admin', AMP_PAGE_BUILDER_URL. 'inc/admin-amp-page-builder.css', array(), '0.0.1' );
42
  wp_enqueue_media();
43
- if(function_exists('wp_enqueue_editor')){
44
- wp_enqueue_editor();
45
- }
46
- wp_enqueue_script( 'text-widgets' );
47
- wp_enqueue_script( 'amppb-admin', AMP_PAGE_BUILDER_URL. 'inc/admin-amp-page-builder.js', array(
48
- 'jquery',
49
- 'jquery-ui-resizable',
50
- 'jquery-ui-sortable',
51
- 'jquery-ui-draggable',
52
- 'jquery-ui-droppable',
53
- 'underscore',
54
- 'backbone',
55
- 'plupload',
56
- 'plupload-all',
57
- ), '0.0.1', true );
58
- add_action( 'admin_footer', 'js_templates');
 
 
 
59
  }
60
  }
61
 
@@ -117,15 +98,21 @@ function amppb_save_post( $post_id, $post ){
117
 
118
 
119
 
120
- add_action("pre_amp_render_post",'amp_pagebuilder_content');
121
- function amp_pagebuilder_content(){
122
- add_filter( 'the_content', 'amppb_post_content', 1 ); // Run
123
  }
124
 
125
- $ampPagebuilderModuleCss = array();
 
 
 
 
 
 
 
126
  add_action('amp_post_template_css','amp_pagebuilder_content_styles',100);
127
  function amp_pagebuilder_content_styles(){
128
- global $ampPagebuilderModuleCss;
129
  ?>.amp_pb{display: inline-block;width: 100%;}
130
  .row{display: inline-flex;width: 100%;}
131
  .col-2{width:50%;float:left;}
@@ -134,7 +121,31 @@ function amp_pagebuilder_content_styles(){
134
  .amp_btn{text-align:center}
135
  .amp_btn a{background: #f92c8b;color: #fff;padding: 9px 20px;border-radius: 3px;display: inline-block;box-shadow: 1px 1px 4px #ccc;}
136
  <?php
137
- echo implode(" ", $ampPagebuilderModuleCss);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
 
140
 
@@ -201,11 +212,12 @@ function amppb_post_content($content){
201
  $content = $html;
202
  }
203
  }
 
204
  return $content;
205
  }
206
 
207
  function rowData($container,$col){
208
- global $moduleTemplate, $ampPagebuilderModuleCss;
209
  $ampforwp_show_excerpt = true;
210
  $html = '';
211
  if(count($container)>0){
@@ -215,10 +227,6 @@ function rowData($container,$col){
215
  if(count($container)>0){
216
  foreach($container as $contentArray){
217
  $moduleFrontHtml = $moduleTemplate[$contentArray['type']]['front_template'];
218
- if(isset($moduleTemplate[$contentArray['type']]['front_css'])){
219
- $ampPagebuilderModuleCss[$contentArray['type']] = $moduleTemplate[$contentArray['type']]['front_css'];
220
-
221
- }
222
  $moduleName = $moduleTemplate[$contentArray['type']]['name'];
223
  switch($moduleName){
224
  case 'gallery_image':
1
  <?php
2
 
3
+ require_once(AMP_PAGE_BUILDER."config/moduleTemplate.php");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
 
6
  /* Admin Script */
16
  //if( 'page' == $post_type && in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ){
17
  if($post_type=='post' || $post_type=='page'){
18
  /* Enqueue CSS & JS For Page Builder */
19
+ wp_enqueue_style( 'amppb-admin', AMP_PAGE_BUILDER_URL. 'inc/admin-amp-page-builder.css', array(), AMPFORWP_VERSION );
20
  wp_enqueue_media();
21
+ $amp_current_post_id = get_the_ID();
22
+ if(function_exists('wp_enqueue_editor')){
23
+ wp_enqueue_editor();
24
+ }
25
+ wp_enqueue_script( 'text-widgets' );
26
+ wp_enqueue_script( 'amppb-admin', AMP_PAGE_BUILDER_URL. 'inc/admin-amp-page-builder.js', array(
27
+ 'jquery',
28
+ 'jquery-ui-resizable',
29
+ 'jquery-ui-sortable',
30
+ 'jquery-ui-draggable',
31
+ 'jquery-ui-droppable',
32
+ 'underscore',
33
+ 'backbone',
34
+ 'plupload',
35
+ 'plupload-all',
36
+ ),AMPFORWP_VERSION, true );
37
+ add_action( 'admin_footer', 'js_templates');
38
+
39
+
40
  }
41
  }
42
 
98
 
99
 
100
 
101
+ add_action('pre_amp_render_post','amp_pagebuilder_content');
102
+ function amp_pagebuilder_content(){
103
+ add_filter( 'the_content', 'ampforwp_insert_pb_content' ); // Run
104
  }
105
 
106
+ function ampforwp_insert_pb_content( $content ){
107
+ $new_content = "";
108
+ $new_content = amppb_post_content($content);
109
+ $content = $new_content;
110
+ return $content;
111
+ }
112
+
113
+
114
  add_action('amp_post_template_css','amp_pagebuilder_content_styles',100);
115
  function amp_pagebuilder_content_styles(){
 
116
  ?>.amp_pb{display: inline-block;width: 100%;}
117
  .row{display: inline-flex;width: 100%;}
118
  .col-2{width:50%;float:left;}
121
  .amp_btn{text-align:center}
122
  .amp_btn a{background: #f92c8b;color: #fff;padding: 9px 20px;border-radius: 3px;display: inline-block;box-shadow: 1px 1px 4px #ccc;}
123
  <?php
124
+ //To load css of modules which are in use
125
+ global $redux_builder_amp, $moduleTemplate, $post;
126
+ $postId = $post->ID;
127
+ if(is_home() && $redux_builder_amp['ampforwp-homepage-on-off-support']==1 && ampforwp_get_blog_details() == false){
128
+ $postId = $redux_builder_amp['amp-frontpage-select-option-pages'];
129
+ }
130
+ $previousData = get_post_meta($postId,'amp-page-builder');
131
+ $previousData = isset($previousData[0])? $previousData[0]: null;
132
+ $ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true);
133
+ if($previousData!="" && $ampforwp_pagebuilder_enable=='yes'){
134
+ $previousData = (str_replace("'", "", $previousData));
135
+ $previousData = json_decode($previousData,true);
136
+ if(count($previousData['rows'])>0){
137
+
138
+ foreach ($previousData['rows'] as $key => $rowsData) {
139
+ $container = $rowsData['cell_data'];
140
+ if(count($container)>0){
141
+ foreach($container as $contentArray){
142
+ echo $moduleTemplate[$contentArray['type']]['front_css'];
143
+ }//foreach content closed
144
+ }//ic container check closed
145
+
146
+ }//foreach closed
147
+ }//if closed count($previousData['rows'])>0
148
+ }//If Closed $previousData!="" && $ampforwp_pagebuilder_enable=='yes'
149
  }
150
 
151
 
212
  $content = $html;
213
  }
214
  }
215
+
216
  return $content;
217
  }
218
 
219
  function rowData($container,$col){
220
+ global $moduleTemplate;
221
  $ampforwp_show_excerpt = true;
222
  $html = '';
223
  if(count($container)>0){
227
  if(count($container)>0){
228
  foreach($container as $contentArray){
229
  $moduleFrontHtml = $moduleTemplate[$contentArray['type']]['front_template'];
 
 
 
 
230
  $moduleName = $moduleTemplate[$contentArray['type']]['name'];
231
  switch($moduleName){
232
  case 'gallery_image':
pagebuilder/inc/admin-amp-page-builder.css CHANGED
@@ -604,4 +604,34 @@ Form Styles
604
  width: 100%;
605
  clear: both;
606
  margin: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  }
604
  width: 100%;
605
  clear: both;
606
  margin: 0;
607
+ }
608
+ .start_amp_pb{
609
+ font-size: 15px;
610
+ height: 40px;
611
+ line-height: 2.55;
612
+ padding: 0px 20px 0px 5px;
613
+ font-weight: 300;
614
+ background: #ed1c25;
615
+ border: 0;
616
+ color: #fff;
617
+ cursor: pointer;
618
+ text-shadow: none;
619
+ position: relative;
620
+ top: 3px;
621
+ width: fit-content;
622
+ margin: 0 auto;
623
+ display: block;
624
+ border-radius: 3px;
625
+ }
626
+ .start_amp_pb:before {
627
+ content: "";
628
+ background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjMxNHB4IiBoZWlnaHQ9IjMxNXB4IiB2aWV3Qm94PSIwIDAgMzE0IDMxNSIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggNDEgKDM1MzI2KSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5TaGFwZTwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPjwvZGVmcz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSIyNjA3MSIgZmlsbD0iI2ZmZiI+CiAgICAgICAgICAgIDxnIGlkPSJDYXBhXzEiPgogICAgICAgICAgICAgICAgPGcgaWQ9Il94MzJfNDAuX1Bvd2VyIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTU3LjAwNywwIEM3MC4yOTIsMCAwLDcwLjI5MiAwLDE1Ny4wMDcgQzAsMjQzLjcxNSA3MC4yOTIsMzE0LjAxNCAxNTcuMDA3LDMxNC4wMTQgQzI0My43MTYsMzE0LjAxNCAzMTQuMDE0LDI0My43MTUgMzE0LjAxNCwxNTcuMDA3IEMzMTQuMDE0LDcwLjI5MiAyNDMuNzE2LDAgMTU3LjAwNywwIFogTTE1Ny4wMDcsMjgyLjYxMiBDODcuNjM0LDI4Mi42MTIgMzEuNDAyLDIyNi4zNzIgMzEuNDAyLDE1Ny4wMDcgQzMxLjQwMiw4Ny42MzQgODcuNjM0LDMxLjQwMiAxNTcuMDA3LDMxLjQwMiBDMjI2LjM3MSwzMS40MDIgMjgyLjYxMSw4Ny42MzQgMjgyLjYxMSwxNTcuMDA3IEMyODIuNjEyLDIyNi4zNzIgMjI2LjM3MiwyODIuNjEyIDE1Ny4wMDcsMjgyLjYxMiBaIE0yMDQuMTExLDE0MS4zNjggTDE2My40NzksMTQxLjUzMyBDMTU5LjEzOSwxNDEuNTUzIDE1Ny41NDQsMTM4LjYyMyAxNTkuOTA1LDEzNC45NzkgTDIwMy4zOTcsNjguMTA5IEMyMDguMTI2LDYwLjg0MSAyMDYuOTg0LDU5LjkyMiAyMDAuODYxLDY2LjA1MyBMMTA1LjMwNSwxNjEuNiBDOTkuMTcyLDE2Ny43MzIgMTAxLjIzMiwxNzIuNjc2IDEwOS45MDYsMTcyLjY0MSBMMTQyLjY3OSwxNzIuNTA4IEMxNTEuMzQ3LDE3Mi40NzIgMTU0LjU1MiwxNzguMzM1IDE0OS44MjQsMTg1LjYwNSBMMTA2LjMzNCwyNTIuNDc3IEMxMDMuOTcyLDI1Ni4xMTIgMTA0LjU0MiwyNTYuNTgxIDEwNy42MiwyNTMuNTI3IEwxNzUuOTE1LDE4NS43MTcgQzE3OC45ODgsMTgyLjY1OSAxODMuOTUsMTc3LjY4NiAxODYuOTgzLDE3NC41OTYgTDIwOC43ODgsMTUyLjQ4NSBDMjE0Ljg3NSwxNDYuMzE3IDIxMi43NzUsMTQxLjMzIDIwNC4xMTEsMTQxLjM2OCBaIiBpZD0iU2hhcGUiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+") !important;
629
+ background-size: 18px;
630
+ background-repeat: no-repeat;
631
+ padding-left: 26px;
632
+ background-position: 0px 0px;
633
+ position: relative;
634
+ top: 1px;
635
+ left: 10px;
636
+ margin-right: 10px;
637
  }
pagebuilder/inc/admin-amp-page-builder.js CHANGED
@@ -1,4 +1,40 @@
 
1
  jQuery( document ).ready( function( $ ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  $( "#sorted_rows" ).sortable({
3
  placeholder: "ui-state-highlight",
4
  handle : '.amppb-handle',
@@ -181,7 +217,7 @@ jQuery( document ).ready( function( $ ){
181
  //Save data of row settings
182
  $( document.body ).on('click', "#amppb-rowsetting", function(e){
183
  e.preventDefault();
184
- console.log("Save button #amppb-rowsetting has clicked");
185
  var containerId = $(this).attr('data-current-container');
186
 
187
  var popupContents = $(this).attr('data-template');
@@ -226,7 +262,11 @@ jQuery( document ).ready( function( $ ){
226
  $.each(moduleJson.fields, function(fieldtype,modData){
227
  var fieldIdentifier = modData.name+'-'+containerdetails[0]+'-'+containerdetails[1];
228
  if(modData.type=='text-editor'){
229
- modData.default = encodeURI(tinymce.get(fieldIdentifier).getContent().replace("'","\'"));
 
 
 
 
230
  }if(modData.type=='select'){
231
  modData.default = encodeURI($('#'+fieldIdentifier).val());
232
  }else{
@@ -234,7 +274,7 @@ jQuery( document ).ready( function( $ ){
234
  }
235
 
236
  });
237
- console.log(JSON.stringify(moduleJson));
238
  $('#module-'+containerdetails[1]).find('#selectedModule').val(JSON.stringify(moduleJson))
239
 
240
  /*var fieldValue = [];
@@ -254,7 +294,12 @@ jQuery( document ).ready( function( $ ){
254
  $.each(moduledetails.fields, function(fieldtype,modData){
255
  var fieldIdentifier = modData.name+'-'+containerdetails[0]+'-'+containerdetails[1];
256
  if(modData.type=='text-editor'){
257
- cells[modData.name] = encodeURI(tinymce.get(fieldIdentifier).getContent().replace("'","\'"));
 
 
 
 
 
258
  }else{
259
  cells[modData.name] = encodeURI($('#'+fieldIdentifier).val().replace("'","\'"));
260
  }
@@ -291,6 +336,9 @@ jQuery( document ).ready( function( $ ){
291
  $.each(popupContents.fields, function(fieldsName,fieldReplace){
292
  var id = fieldReplace.name+"-"+conatinerId+'-' +moduleId;
293
  var htmlFields = $('.amppb-fields-templates').find("#"+fieldReplace.type).html();
 
 
 
294
  fieldReplace.default_images = '';
295
  switch(fieldReplace.type){
296
  case 'select':
@@ -572,7 +620,7 @@ jQuery( document ).ready( function( $ ){
572
  return false;
573
  }
574
  });
575
- console.log(previousValue);
576
  }
577
  });
578
  $.each(ploatedStructure.rows,function(k,rowVal){
@@ -597,7 +645,7 @@ jQuery( document ).ready( function( $ ){
597
  var moduleJson = JSON.parse($(this).find('div.amppb-module:last').find("#selectedModule").val());
598
  //Store module inside the array
599
  $.each(ploatedStructure.rows,function(k,columnVal){
600
- console.log(columnVal.id+' '+containerId);
601
  if(columnVal.id==containerId){
602
 
603
  var moduleIndex = $(currentDropZone).find('div.amppb-module').length;
@@ -621,7 +669,7 @@ jQuery( document ).ready( function( $ ){
621
  });
622
  ploatedStructure['totalmodules'] = $moduleId+1;
623
  storeJsonDataInput(ploatedStructure);
624
- console.log(ploatedStructure);
625
 
626
  }
627
  loadAfterModule();
@@ -669,7 +717,7 @@ jQuery( document ).ready( function( $ ){
669
  var ploatedStructure = JSON.parse($('#amp-page-builder-data').val());
670
  var indexOfRow = $(this).parents('.amppb-row').attr('id').replace("conatiner-","");
671
  $(this).find('div.amppb-module').each(function(indexKey,val){
672
- console.log(indexKey);
673
  var indexOfModule = $(this).attr('id').replace('module-','');
674
  $.each(ploatedStructure.rows,function(k,columnVal){
675
  if(columnVal.id==indexOfRow){
@@ -761,7 +809,7 @@ jQuery( document ).ready( function( $ ){
761
  ***************/
762
  $(document.body).on('click', "input.selectImage", function(e){
763
  e.preventDefault();
764
- console.log("selectImage click event called");
765
  var currentSelectfield = $(this);
766
  var selectorType = currentSelectfield.attr("data-imageselactor");
767
  var multiple = false;
@@ -813,14 +861,14 @@ jQuery( document ).ready( function( $ ){
813
 
814
  function loadEditor(id){
815
  id = id;//.replace("-","_").replace("-","_");
816
- console.log("loadEditor function called "+ id);
817
 
818
 
819
 
820
  }
821
 
822
  function callToRemoveHasModule(){
823
- console.log("called Function");
824
  $(".modules-drop").each(function(index, container){
825
  if($(this).find('.amppb-module').length==0){
826
  $(this).removeClass("has-module");
@@ -829,8 +877,11 @@ jQuery( document ).ready( function( $ ){
829
  }
830
 
831
 
 
 
 
 
832
  });
833
-
834
  /**
835
  *
836
  *
@@ -849,12 +900,12 @@ function Refresh_Image(the_id,currentSelectfield){
849
  jQuery.get(ajaxurl, data, function(response) {
850
 
851
  if(response.success === true) {
852
- console.log(response.data)
853
  if(currentSelectfield.attr("data-imageselactor")=='multiple'){
854
  currentSelectfield.parents('.form-control').find('.sample-gallery-template').html("");
855
  var imageSrc = '';
856
  jQuery.each(response.data, function(keys,imageValue){
857
- console.log(imageValue.image);
858
  currentSelectfield.parents('.form-control').find('.sample-gallery-template').append(imageValue.image);
859
  currentSelectfield.parents('.form-control').find('.sample-gallery-template').find('img:last').attr("width",100).attr("height",100);
860
  imageSrc += imageValue.detail[0]+",";
1
+
2
  jQuery( document ).ready( function( $ ){
3
+
4
+
5
+ $('#start_amp_pb_post').click(function(){
6
+ var ampPbLoader = document.getElementById('start_amp_pb_post');
7
+ if(ampPbLoader!=null){
8
+ $(this).html('Loading...<span class="dashicons dashicons-update spinner"></span>');
9
+ var postId = ampPbLoader.getAttribute("data-postId");
10
+ var data = {
11
+ 'action': 'call_page_builder',
12
+ 'post_id': postId,
13
+ };
14
+ $.ajax({
15
+ url:ajaxurl,
16
+ type:'get',
17
+ data:data,
18
+ beforeSend: function(){
19
+ $(this).html('Loading...<span class="dashicons dashicons-update"></span>');
20
+ },
21
+ success: function(response){
22
+ //alert(response)
23
+ $('#pagebilder_content').find('.inside').html(response);
24
+ pageBuilderStarter();
25
+ },
26
+ error: function(){
27
+ alert('Error occurred, not getting response');
28
+ $(this).html("Start the AMP Page Builder");
29
+ }
30
+ });
31
+
32
+ }
33
+ });
34
+
35
+ //Page builder starter
36
+ var pageBuilderStarter = function(){
37
+
38
  $( "#sorted_rows" ).sortable({
39
  placeholder: "ui-state-highlight",
40
  handle : '.amppb-handle',
217
  //Save data of row settings
218
  $( document.body ).on('click', "#amppb-rowsetting", function(e){
219
  e.preventDefault();
220
+ //console.log("Save button #amppb-rowsetting has clicked");
221
  var containerId = $(this).attr('data-current-container');
222
 
223
  var popupContents = $(this).attr('data-template');
262
  $.each(moduleJson.fields, function(fieldtype,modData){
263
  var fieldIdentifier = modData.name+'-'+containerdetails[0]+'-'+containerdetails[1];
264
  if(modData.type=='text-editor'){
265
+ if(tinymce.get(fieldIdentifier)){
266
+ modData.default = encodeURI(tinymce.get(fieldIdentifier).getContent().replace("'","\'"));
267
+ }else{
268
+ modData.default = encodeURI($("#"+fieldIdentifier).val().replace("'","\'"));
269
+ }
270
  }if(modData.type=='select'){
271
  modData.default = encodeURI($('#'+fieldIdentifier).val());
272
  }else{
274
  }
275
 
276
  });
277
+ //console.log(JSON.stringify(moduleJson));
278
  $('#module-'+containerdetails[1]).find('#selectedModule').val(JSON.stringify(moduleJson))
279
 
280
  /*var fieldValue = [];
294
  $.each(moduledetails.fields, function(fieldtype,modData){
295
  var fieldIdentifier = modData.name+'-'+containerdetails[0]+'-'+containerdetails[1];
296
  if(modData.type=='text-editor'){
297
+ if(tinymce.get(fieldIdentifier)){
298
+ cells[modData.name] = encodeURI(tinymce.get(fieldIdentifier).getContent().replace("'","\'"));
299
+ }else{
300
+ modData.default = encodeURI($("#"+fieldIdentifier).val().replace("'","\'"));
301
+ }
302
+
303
  }else{
304
  cells[modData.name] = encodeURI($('#'+fieldIdentifier).val().replace("'","\'"));
305
  }
336
  $.each(popupContents.fields, function(fieldsName,fieldReplace){
337
  var id = fieldReplace.name+"-"+conatinerId+'-' +moduleId;
338
  var htmlFields = $('.amppb-fields-templates').find("#"+fieldReplace.type).html();
339
+ if(fieldReplace.type=='upload'){
340
+ htmlFields = htmlFields.replace(/src="#"/g, 'src="{default_value}"');
341
+ }
342
  fieldReplace.default_images = '';
343
  switch(fieldReplace.type){
344
  case 'select':
620
  return false;
621
  }
622
  });
623
+ //console.log(previousValue);
624
  }
625
  });
626
  $.each(ploatedStructure.rows,function(k,rowVal){
645
  var moduleJson = JSON.parse($(this).find('div.amppb-module:last').find("#selectedModule").val());
646
  //Store module inside the array
647
  $.each(ploatedStructure.rows,function(k,columnVal){
648
+ //console.log(columnVal.id+' '+containerId);
649
  if(columnVal.id==containerId){
650
 
651
  var moduleIndex = $(currentDropZone).find('div.amppb-module').length;
669
  });
670
  ploatedStructure['totalmodules'] = $moduleId+1;
671
  storeJsonDataInput(ploatedStructure);
672
+ //console.log(ploatedStructure);
673
 
674
  }
675
  loadAfterModule();
717
  var ploatedStructure = JSON.parse($('#amp-page-builder-data').val());
718
  var indexOfRow = $(this).parents('.amppb-row').attr('id').replace("conatiner-","");
719
  $(this).find('div.amppb-module').each(function(indexKey,val){
720
+ //console.log(indexKey);
721
  var indexOfModule = $(this).attr('id').replace('module-','');
722
  $.each(ploatedStructure.rows,function(k,columnVal){
723
  if(columnVal.id==indexOfRow){
809
  ***************/
810
  $(document.body).on('click', "input.selectImage", function(e){
811
  e.preventDefault();
812
+ //console.log("selectImage click event called");
813
  var currentSelectfield = $(this);
814
  var selectorType = currentSelectfield.attr("data-imageselactor");
815
  var multiple = false;
861
 
862
  function loadEditor(id){
863
  id = id;//.replace("-","_").replace("-","_");
864
+ //console.log("loadEditor function called "+ id);
865
 
866
 
867
 
868
  }
869
 
870
  function callToRemoveHasModule(){
871
+ //console.log("called Function");
872
  $(".modules-drop").each(function(index, container){
873
  if($(this).find('.amppb-module').length==0){
874
  $(this).removeClass("has-module");
877
  }
878
 
879
 
880
+ }
881
+ if($("#amp-page-builder").length>0){
882
+ pageBuilderStarter();
883
+ }
884
  });
 
885
  /**
886
  *
887
  *
900
  jQuery.get(ajaxurl, data, function(response) {
901
 
902
  if(response.success === true) {
903
+ //console.log(response.data)
904
  if(currentSelectfield.attr("data-imageselactor")=='multiple'){
905
  currentSelectfield.parents('.form-control').find('.sample-gallery-template').html("");
906
  var imageSrc = '';
907
  jQuery.each(response.data, function(keys,imageValue){
908
+ //console.log(imageValue.image);
909
  currentSelectfield.parents('.form-control').find('.sample-gallery-template').append(imageValue.image);
910
  currentSelectfield.parents('.form-control').find('.sample-gallery-template').find('img:last').attr("width",100).attr("height",100);
911
  imageSrc += imageValue.detail[0]+",";
pagebuilder/inc/js-templates.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php /* Rows template (Going to be hidden) */ ?>
2
- <div class="amppb-templates">
3
  <?php /* == This is the 1 column row template == */ ?>
4
  <div class="amppb-row amppb-col-1" id="conatiner-{id}">
5
  <input type="hidden" name="column-data" value="">
@@ -73,7 +73,7 @@ global $moduleTemplate;
73
  }
74
  ?>
75
  </div>
76
- <div class="amppb-fields-templates hidden">
77
  <div id="textarea">
78
  <p class="form-control">
79
  <label for="{id}">{label}</label>
@@ -97,7 +97,7 @@ global $moduleTemplate;
97
  <p class="form-control">
98
  <label for="{id}">{label}</label>
99
  <input type="button" class="button selectImage" value="Select image" id="" data-imageselactor="single">
100
- <img id="ampforwp-preview-image" src="{default_value}" />
101
  <input type="hidden" name="ampforwp_image_id" id="{id}" class="regular-text" value="{default_value}"/>
102
  </p>
103
  </div>
1
  <?php /* Rows template (Going to be hidden) */ ?>
2
+ <div class="amppb-templates" data-type="text/html">
3
  <?php /* == This is the 1 column row template == */ ?>
4
  <div class="amppb-row amppb-col-1" id="conatiner-{id}">
5
  <input type="hidden" name="column-data" value="">
73
  }
74
  ?>
75
  </div>
76
+ <div class="amppb-fields-templates hidden" data-type="text/html">
77
  <div id="textarea">
78
  <p class="form-control">
79
  <label for="{id}">{label}</label>
97
  <p class="form-control">
98
  <label for="{id}">{label}</label>
99
  <input type="button" class="button selectImage" value="Select image" id="" data-imageselactor="single">
100
+ <img id="ampforwp-preview-image" src="#" />
101
  <input type="hidden" name="ampforwp_image_id" id="{id}" class="regular-text" value="{default_value}"/>
102
  </p>
103
  </div>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
3
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google, plugin, SEO
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
- Tested up to: 4.8.2
7
- Stable tag: 0.9.66.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -31,12 +31,13 @@ Bug reports for AMP for WP are [welcomed on GitHub](https://github.com/ahmedkalu
31
 
32
  = Features: =
33
 
34
- * NEW - Structured Data Options (New & Improved)
 
35
  * NEW - Page Builder 2.0 for AMP! [Learn More & Video](https://ampforwp.com/tutorials/article/amp-page-builder-installation/)
36
  * NEW - Advanced WooCommerce Support [More Info](https://ampforwp.com/woocommerce/)
37
  * NEW - Gravity Forms Support [More Info](https://ampforwp.com/gravity-forms/)
38
- * NEW - AMP Plugins Manager - Which allows you to disable a specific plugin functionality only in the AMP version
39
- * NEW - Page Break / NextPage (Pagination) Support
40
  * Contact Form 7 Support [More Info](https://ampforwp.com/contact-form-7/)
41
  * Facebook Comments Support
42
  * Github Gist Support
@@ -149,12 +150,38 @@ You can contact me using this url: http://ampforwp.com/contact/
149
 
150
  == Changelog ==
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  = 0.9.66.1 (30th October 2017) =
153
  * Fatal error if has version less than WP 4.8 fixed
154
  * More Minor Validation errors fixed
155
  * Odnoklassniki sharing button is not working #1337
156
 
157
- = 0.9.66 (29th October 2017) =
158
  * View more details on https://ampforwp.com/0-9-66-released-bug-squashing-oct-2017-72nd-update/
159
  * Design 3 & Design 1 are optimised with 90+ Google PageSpeed Score on Mobile and 95+ in desktop performance #1273
160
  * Featured Image from the content for blog and homepage #1295
3
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google, plugin, SEO
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
+ Tested up to: 4.8.3
7
+ Stable tag: 0.9.67
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
31
 
32
  = Features: =
33
 
34
+ * NEW - OneSignal Push Notifications integration
35
+ * NEW - Structured Data Options
36
  * NEW - Page Builder 2.0 for AMP! [Learn More & Video](https://ampforwp.com/tutorials/article/amp-page-builder-installation/)
37
  * NEW - Advanced WooCommerce Support [More Info](https://ampforwp.com/woocommerce/)
38
  * NEW - Gravity Forms Support [More Info](https://ampforwp.com/gravity-forms/)
39
+ * AMP Plugins Manager - Which allows you to disable a specific plugin functionality only in the AMP version
40
+ * Page Break / NextPage (Pagination) Support
41
  * Contact Form 7 Support [More Info](https://ampforwp.com/contact-form-7/)
42
  * Facebook Comments Support
43
  * Github Gist Support
150
 
151
  == Changelog ==
152
 
153
+ = 0.9.67 (6th November 2017) =
154
+ * View more details on https://ampforwp.com/one-signal-push-notifications-for-amp/
155
+ * OneSignal Push Notifications integrated #807
156
+ * Vimeo embed support added
157
+ * SoundCloud embed support added
158
+ * Pinterest embed support added
159
+ * PlayBuzz embed support added
160
+ * DailyMotion embed support added
161
+ * Fix: Handle issues with data uri images in CSS #1033
162
+ * Fix attribute when adding AMP Mustache lib #1033
163
+ * Fix: Output CSS for feature image #1033
164
+ * An option added for users who don't want to receive update notifications #1342
165
+ * Structured data nav improvement
166
+ * Sitenavigationelement has been implemented correctly for footer menu. #1345
167
+ * Style sanitization for Menu Items #1359
168
+ * Polylang flags support for menu  #1360
169
+ * Mobile Redirection issues fixed #1173
170
+ * Jetpack fatal error fixed #1355
171
+ * AMP Page Builder requires a button to be clicked, so the scripts are not running on the runtime making it easy on the edit screen page and avoid the possible script conflict.
172
+ * Needs proper CTA Bar's styling. #1361
173
+ * Debug errors on archive pages #1353
174
+ * Preview shall only be loaded on click rather than in background #1331
175
+ * ampforwp_is_home() function code improved
176
+ * making sure scripts and styling is properly adding when sanitizing the sidebar #868
177
+ * All the backend css and js should be versioned, so it's not cached. #1335
178
+
179
  = 0.9.66.1 (30th October 2017) =
180
  * Fatal error if has version less than WP 4.8 fixed
181
  * More Minor Validation errors fixed
182
  * Odnoklassniki sharing button is not working #1337
183
 
184
+ = 0.9.66.0 (29th October 2017) =
185
  * View more details on https://ampforwp.com/0-9-66-released-bug-squashing-oct-2017-72nd-update/
186
  * Design 3 & Design 1 are optimised with 90+ Google PageSpeed Score on Mobile and 95+ in desktop performance #1273
187
  * Featured Image from the content for blog and homepage #1295
templates/custom-amp-content.php CHANGED
@@ -35,9 +35,13 @@ function ampforwp_custom_post_content_sanitizer( $data, $post ) {
35
  apply_filters( 'amp_content_embed_handlers', array(
36
  'AMP_Twitter_Embed_Handler' => array(),
37
  'AMP_YouTube_Embed_Handler' => array(),
 
 
 
38
  'AMP_Instagram_Embed_Handler' => array(),
39
  'AMP_Vine_Embed_Handler' => array(),
40
  'AMP_Facebook_Embed_Handler' => array(),
 
41
  'AMP_Gallery_Embed_Handler' => array(),
42
  ) ),
43
  apply_filters( 'amp_content_sanitizers', array(
@@ -46,6 +50,7 @@ function ampforwp_custom_post_content_sanitizer( $data, $post ) {
46
  'AMP_Img_Sanitizer' => array(),
47
  'AMP_Video_Sanitizer' => array(),
48
  'AMP_Audio_Sanitizer' => array(),
 
49
  'AMP_Iframe_Sanitizer' => array(
50
  'add_placeholder' => true,
51
  ),
35
  apply_filters( 'amp_content_embed_handlers', array(
36
  'AMP_Twitter_Embed_Handler' => array(),
37
  'AMP_YouTube_Embed_Handler' => array(),
38
+ 'AMP_DailyMotion_Embed_Handler' => array(),
39
+ 'AMP_Vimeo_Embed_Handler' => array(),
40
+ 'AMP_SoundCloud_Embed_Handler' => array(),
41
  'AMP_Instagram_Embed_Handler' => array(),
42
  'AMP_Vine_Embed_Handler' => array(),
43
  'AMP_Facebook_Embed_Handler' => array(),
44
+ 'AMP_Pinterest_Embed_Handler' => array(),
45
  'AMP_Gallery_Embed_Handler' => array(),
46
  ) ),
47
  apply_filters( 'amp_content_sanitizers', array(
50
  'AMP_Img_Sanitizer' => array(),
51
  'AMP_Video_Sanitizer' => array(),
52
  'AMP_Audio_Sanitizer' => array(),
53
+ 'AMP_Playbuzz_Sanitizer' => array(),
54
  'AMP_Iframe_Sanitizer' => array(
55
  'add_placeholder' => true,
56
  ),
templates/design-manager/design-1/elements/content.php CHANGED
@@ -23,7 +23,8 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
23
  // Custom/Alternative AMP content added through post meta
24
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
25
  }
26
-
 
27
  if($redux_builder_amp['amp-pagination']) {
28
  $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
29
  $queried_var = get_query_var('page');
23
  // Custom/Alternative AMP content added through post meta
24
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
25
  }
26
+ //Filter to modify the Content
27
+ $ampforwp_the_content = apply_filters('ampforwp_modify_the_content', $ampforwp_the_content);
28
  if($redux_builder_amp['amp-pagination']) {
29
  $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
30
  $queried_var = get_query_var('page');
templates/design-manager/design-1/footer.php CHANGED
@@ -4,20 +4,22 @@ wp_reset_postdata(); ?>
4
  <footer class="amp-wp-footer">
5
  <div id="footer">
6
  <?php if ( has_nav_menu( 'amp-footer-menu' ) ) { ?>
7
- <div class="footer_menu">
8
  <?php // schema.org/SiteNavigationElement missing from menus #1229 ?>
9
- <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
10
- <?php
11
- $menu = wp_nav_menu( array(
12
- 'theme_location' => 'amp-footer-menu',
13
- 'link_before' => '<span itemprop="name">',
14
- 'link_after' => '</span>',
15
- 'echo' => false
16
- ) );
17
- echo strip_tags( $menu , '<ul><li><a>'); ?>
18
- </div>
19
- </nav>
20
- <?php } ?>
 
 
21
  <h2><?php echo esc_html( $this->get( 'blog_name' ) ); ?></h2>
22
  <p class="copyright_txt">
23
  <?php
4
  <footer class="amp-wp-footer">
5
  <div id="footer">
6
  <?php if ( has_nav_menu( 'amp-footer-menu' ) ) { ?>
7
+ <div class="footer_menu">
8
  <?php // schema.org/SiteNavigationElement missing from menus #1229 ?>
9
+ <nav itemscope="" itemtype="https://schema.org/SiteNavigationElement">
10
+ <?php
11
+ $menu = wp_nav_menu( array(
12
+ 'theme_location' => 'amp-footer-menu',
13
+ 'link_before' => '<span itemprop="name">',
14
+ 'link_after' => '</span>',
15
+ 'echo' => false
16
+ ) );
17
+ $sanitizer_obj = new AMPFORWP_Content( $menu, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array(), 'AMP_Style_Sanitizer' => array(), ) ) );
18
+ $sanitized_menu = $sanitizer_obj->get_amp_content();
19
+ echo $sanitized_menu; ?>
20
+ </nav>
21
+ </div>
22
+ <?php } ?>
23
  <h2><?php echo esc_html( $this->get( 'blog_name' ) ); ?></h2>
24
  <p class="copyright_txt">
25
  <?php
templates/design-manager/design-1/header-bar.php CHANGED
@@ -98,12 +98,12 @@
98
  'echo' => false,
99
  'menu_class' => 'menu amp-menu'
100
  ) );
101
- $sanitizer_obj = new AMPFORWP_Content( $menu_html_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
102
- $sanitized_comment_content = $sanitizer_obj->get_amp_content();
103
- echo make_clickable( $sanitized_comment_content );
104
  ?>
 
105
  </div>
106
- </nav>
107
  </amp-sidebar>
108
  <?php }
109
  do_action('ampforwp_design_1_after_header');
98
  'echo' => false,
99
  'menu_class' => 'menu amp-menu'
100
  ) );
101
+ $sanitizer_obj = new AMPFORWP_Content( $menu_html_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array(), 'AMP_Style_Sanitizer' => array(), ) ) );
102
+ $sanitized_menu = $sanitizer_obj->get_amp_content();
103
+ echo $sanitized_menu;
104
  ?>
105
+ </nav>
106
  </div>
 
107
  </amp-sidebar>
108
  <?php }
109
  do_action('ampforwp_design_1_after_header');
templates/design-manager/design-1/style.php CHANGED
@@ -185,4 +185,5 @@ if( !is_home() && $redux_builder_amp['ampforwp-bread-crumb'] == 1 ) { ?>
185
  .amp_widget_above_the_footer {margin:0 10px;}
186
  .widget-wrapper li { list-style-position: inside; }
187
  .amp-menu > li > a > amp-img, .sub-menu > li > a > amp-img { display: inline-block; margin-right: 4px; }
 
188
  <?php echo $redux_builder_amp['css_editor']; } ?>
185
  .amp_widget_above_the_footer {margin:0 10px;}
186
  .widget-wrapper li { list-style-position: inside; }
187
  .amp-menu > li > a > amp-img, .sub-menu > li > a > amp-img { display: inline-block; margin-right: 4px; }
188
+ .menu-item amp-img {width: 16px; height: 11px; display: inline-block; margin-right: 5px;}
189
  <?php echo $redux_builder_amp['css_editor']; } ?>
templates/design-manager/design-2/elements/content.php CHANGED
@@ -24,8 +24,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
24
  // Custom/Alternative AMP content added through post meta
25
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
26
  }
27
- // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
28
-
29
  if($redux_builder_amp['amp-pagination']) {
30
  $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
31
  $queried_var = get_query_var('page');
24
  // Custom/Alternative AMP content added through post meta
25
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
26
  }
27
+ //Filter to modify the Content
 
28
  if($redux_builder_amp['amp-pagination']) {
29
  $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
30
  $queried_var = get_query_var('page');
templates/design-manager/design-2/footer.php CHANGED
@@ -4,18 +4,20 @@
4
  <div id="footer">
5
  <?php if ( has_nav_menu( 'amp-footer-menu' ) ) { ?>
6
  <div class="footer_menu">
7
- <?php // schema.org/SiteNavigationElement missing from menus #1229 ?>
8
- <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
9
- <?php
10
- $menu = wp_nav_menu( array(
11
- 'theme_location' => 'amp-footer-menu',
12
- 'link_before' => '<span itemprop="name">',
13
- 'link_after' => '</span>',
14
- 'echo' => false
15
- ) );
16
- echo strip_tags( $menu , '<ul><li><a>'); ?>
 
 
 
17
  </div>
18
- </nav>
19
  <?php } ?>
20
 
21
  <p> <?php if($redux_builder_amp['ampforwp-footer-top']=='1') { ?>
4
  <div id="footer">
5
  <?php if ( has_nav_menu( 'amp-footer-menu' ) ) { ?>
6
  <div class="footer_menu">
7
+ <?php // #1229 ?>
8
+ <nav itemscope="" itemtype="https://schema.org/SiteNavigationElement">
9
+ <?php
10
+ $menu = wp_nav_menu( array(
11
+ 'theme_location' => 'amp-footer-menu',
12
+ 'link_before' => '<span itemprop="name">',
13
+ 'link_after' => '</span>',
14
+ 'echo' => false
15
+ ) );
16
+ $sanitizer_obj = new AMPFORWP_Content( $menu, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array(), 'AMP_Style_Sanitizer' => array(), ) ) );
17
+ $sanitized_menu = $sanitizer_obj->get_amp_content();
18
+ echo $sanitized_menu; ?>
19
+ </nav>
20
  </div>
 
21
  <?php } ?>
22
 
23
  <p> <?php if($redux_builder_amp['ampforwp-footer-top']=='1') { ?>
templates/design-manager/design-2/header-bar.php CHANGED
@@ -69,23 +69,20 @@
69
  side="right">
70
  <div class="toggle-navigationv2">
71
  <div role="button" tabindex="0" on='tap:sidebar.close' class="close-nav">X</div>
72
- <?php // schema.org/SiteNavigationElement missing from menus #1229 ?>
73
- <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
74
- <?php
75
- $menu_html_content = wp_nav_menu( array(
76
- 'theme_location' => 'amp-menu' ,
77
- 'link_before' => '<span itemprop="name">',
78
- 'link_after' => '</span>',
79
- 'echo' => false,
80
- 'menu_class' => 'menu amp-menu'
81
- ) );
82
- $sanitizer_obj = new AMPFORWP_Content( $menu_html_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
83
- $sanitized_comment_content = $sanitizer_obj->get_amp_content();
84
- echo make_clickable( $sanitized_comment_content );
85
-
86
- ?>
87
  </nav>
88
-
89
  </div>
90
  </amp-sidebar>
91
  <?php } ?>
69
  side="right">
70
  <div class="toggle-navigationv2">
71
  <div role="button" tabindex="0" on='tap:sidebar.close' class="close-nav">X</div>
72
+ <?php // #1229 ?>
73
+ <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
74
+ <?php
75
+ $menu_html_content = wp_nav_menu( array(
76
+ 'theme_location' => 'amp-menu' ,
77
+ 'link_before' => '<span itemprop="name">',
78
+ 'link_after' => '</span>',
79
+ 'echo' => false,
80
+ 'menu_class' => 'menu amp-menu'
81
+ ) );
82
+ $sanitizer_obj = new AMPFORWP_Content( $menu_html_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array(), 'AMP_Style_Sanitizer' => array(), ) ) );
83
+ $sanitized_menu = $sanitizer_obj->get_amp_content();
84
+ echo $sanitized_menu; ?>
 
 
85
  </nav>
 
86
  </div>
87
  </amp-sidebar>
88
  <?php } ?>
templates/design-manager/design-2/style.php CHANGED
@@ -192,7 +192,7 @@ main .amp-wp-content.relatedpost{ background: none; box-shadow: none; max-width:
192
  .no_related_thumbnail{ padding: 15px 18px; }
193
  .no_related_thumbnail .related_link{ margin: 16px 18px 20px 19px; }
194
  <?php }
195
- if($redux_builder_amp['wordpress-comments-support'] ==1) { ?>
196
  /* Comments */
197
  .page-numbers{padding: 9px 10px;background: #fff;font-size: 14px}
198
  .ampforwp-comment-wrapper{margin:1.8em 0px 1.5em 0px}
@@ -217,13 +217,6 @@ main .amp-wp-content.comments_list {background: none;box-shadow: none;max-width:
217
  .single-post .amp_ad_1{ margin-top: 10px; margin-bottom: -20px; }
218
  html .single-post .ampforwp-incontent-ad-1 { margin-bottom: 10px; }
219
  .amp-ad-4{ margin-top:10px; }
220
- <?php if($redux_builder_amp['amp-enable-notifications']==1){ ?>
221
- /* Notifications */
222
- #amp-user-notification1 p { display: inline-block; }
223
- amp-user-notification { padding: 5px; text-align: center; background: #fff; border-top: 1px solid; }
224
- amp-user-notification button { padding: 8px 10px; background: #000; color: #fff; margin-left: 5px; border: 0; }
225
- amp-user-notification button:hover { cursor: pointer }
226
- <?php } ?>
227
  .amp-wp-content blockquote { background-color: #fff; border-left: 3px solid; margin: 0; padding: 15px 20px 8px 24px; background: #f3f3f3; }
228
  pre { white-space: pre-wrap; }
229
  /* Tables */
@@ -247,6 +240,13 @@ table tr:last-child td:last-child { -moz-border-radius-bottomright: 3px; -webkit
247
  table tr:hover td { background: #f2f2f2; background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0)); background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0); }
248
  .hide-meta-info{ display: none; }
249
  <?php }?>
 
 
 
 
 
 
 
250
  /* Responsive */
251
  @media screen and (min-width: 650px) { table {display: inline-table;} }
252
  @media screen and (max-width: 800px) { .single-post main{ padding: 12px 10px 10px 10px } }
@@ -326,4 +326,5 @@ amp-user-notification button { background-color: <?php echo sanitize_hex_color(
326
  .breadcrumb ul li:last-child a::after{display:none;}
327
  <?php } ?>
328
  .amp-menu > li > a > amp-img, .sub-menu > li > a > amp-img { display: inline-block; margin-right: 4px; }
 
329
  <?php echo $redux_builder_amp['css_editor']; } ?>
192
  .no_related_thumbnail{ padding: 15px 18px; }
193
  .no_related_thumbnail .related_link{ margin: 16px 18px 20px 19px; }
194
  <?php }
195
+ if(isset($redux_builder_amp['wordpress-comments-support']) && $redux_builder_amp['wordpress-comments-support'] ==1 ) { ?>
196
  /* Comments */
197
  .page-numbers{padding: 9px 10px;background: #fff;font-size: 14px}
198
  .ampforwp-comment-wrapper{margin:1.8em 0px 1.5em 0px}
217
  .single-post .amp_ad_1{ margin-top: 10px; margin-bottom: -20px; }
218
  html .single-post .ampforwp-incontent-ad-1 { margin-bottom: 10px; }
219
  .amp-ad-4{ margin-top:10px; }
 
 
 
 
 
 
 
220
  .amp-wp-content blockquote { background-color: #fff; border-left: 3px solid; margin: 0; padding: 15px 20px 8px 24px; background: #f3f3f3; }
221
  pre { white-space: pre-wrap; }
222
  /* Tables */
240
  table tr:hover td { background: #f2f2f2; background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0)); background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0); }
241
  .hide-meta-info{ display: none; }
242
  <?php }?>
243
+ <?php if( $redux_builder_amp['amp-enable-notifications'] == 1 || $redux_builder_amp['ampforwp-cta-subsection-notification-sticky'] == 1 ){ ?>
244
+ /* Notifications */
245
+ #amp-user-notification1 p { display: inline-block; }
246
+ amp-user-notification { padding: 5px; text-align: center; background: #fff; border-top: 1px solid; }
247
+ amp-user-notification button { padding: 8px 10px; background: #000; color: #fff; margin-left: 5px; border: 0; }
248
+ amp-user-notification button:hover { cursor: pointer }
249
+ <?php } ?>
250
  /* Responsive */
251
  @media screen and (min-width: 650px) { table {display: inline-table;} }
252
  @media screen and (max-width: 800px) { .single-post main{ padding: 12px 10px 10px 10px } }
326
  .breadcrumb ul li:last-child a::after{display:none;}
327
  <?php } ?>
328
  .amp-menu > li > a > amp-img, .sub-menu > li > a > amp-img { display: inline-block; margin-right: 4px; }
329
+ .menu-item amp-img {width: 16px; height: 11px; display: inline-block; margin-right: 5px;}
330
  <?php echo $redux_builder_amp['css_editor']; } ?>
templates/design-manager/design-3/elements/content.php CHANGED
@@ -24,22 +24,22 @@
24
  // Custom/Alternative AMP content added through post meta
25
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
26
  }
27
-
28
- // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
29
- if($redux_builder_amp['amp-pagination']) {
30
- $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
31
- $queried_var = get_query_var('page');
32
- if ( $queried_var > 1 ) {
33
- $queried_var = $queried_var -1 ;
34
- }
35
- else{
36
- $queried_var = 0;
37
- }
38
- echo $ampforwp_new_content[$queried_var];
39
- } else{
40
- echo $ampforwp_the_content;
41
- }//#1015 pegazee
42
- do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
43
  </div>
44
  <!--Post Content Ends here-->
45
 
24
  // Custom/Alternative AMP content added through post meta
25
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
26
  }
27
+ //Filter to modify the Content
28
+ $ampforwp_the_content = apply_filters('ampforwp_modify_the_content', $ampforwp_the_content);
29
+ if($redux_builder_amp['amp-pagination']) {
30
+ $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
31
+ $queried_var = get_query_var('page');
32
+ if ( $queried_var > 1 ) {
33
+ $queried_var = $queried_var -1 ;
34
+ }
35
+ else{
36
+ $queried_var = 0;
37
+ }
38
+ echo $ampforwp_new_content[$queried_var];
39
+ } else{
40
+ echo $ampforwp_the_content;
41
+ }//#1015 pegazee
42
+ do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
43
  </div>
44
  <!--Post Content Ends here-->
45
 
templates/design-manager/design-3/footer.php CHANGED
@@ -6,7 +6,7 @@
6
  <?php if ( has_nav_menu( 'amp-footer-menu' ) ) { ?>
7
  <?php // schema.org/SiteNavigationElement missing from menus #1229 ?>
8
  <div class="footer_menu">
9
- <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
10
  <?php
11
  $menu = wp_nav_menu( array(
12
  'theme_location' => 'amp-footer-menu',
@@ -14,9 +14,11 @@
14
  'link_after' => '</span>',
15
  'echo' => false
16
  ) );
17
- echo strip_tags( $menu , '<ul><li><a>'); ?>
 
 
 
18
  </div>
19
- </nav>
20
  <?php } ?>
21
 
22
  <?php if( ampforwp_checking_any_social_profiles() ) { ?>
6
  <?php if ( has_nav_menu( 'amp-footer-menu' ) ) { ?>
7
  <?php // schema.org/SiteNavigationElement missing from menus #1229 ?>
8
  <div class="footer_menu">
9
+ <nav itemscope="" itemtype="https://schema.org/SiteNavigationElement">
10
  <?php
11
  $menu = wp_nav_menu( array(
12
  'theme_location' => 'amp-footer-menu',
14
  'link_after' => '</span>',
15
  'echo' => false
16
  ) );
17
+ $sanitizer_obj = new AMPFORWP_Content( $menu, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array(), 'AMP_Style_Sanitizer' => array(), ) ) );
18
+ $sanitized_menu = $sanitizer_obj->get_amp_content();
19
+ echo $sanitized_menu; ?>
20
+ </nav>
21
  </div>
 
22
  <?php } ?>
23
 
24
  <?php if( ampforwp_checking_any_social_profiles() ) { ?>
templates/design-manager/design-3/header-bar.php CHANGED
@@ -13,7 +13,6 @@ if(isset($redux_builder_amp['ampforwp-amp-menu']) && $redux_builder_amp['ampforw
13
  <?php // Grand child support AND amp-accordion non critical error in Design 3 due to nav #1152
14
  // schema.org/SiteNavigationElement missing from menus #1229 ?>
15
  <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
16
- <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
17
  <?php
18
  $menu_html_content = wp_nav_menu( array(
19
  'theme_location' => 'amp-menu',
@@ -23,9 +22,9 @@ if(isset($redux_builder_amp['ampforwp-amp-menu']) && $redux_builder_amp['ampforw
23
  'menu_class'=>'amp-menu',
24
  'echo'=>false
25
  ) );
26
- $sanitizer_obj = new AMPFORWP_Content( $menu_html_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
27
- $sanitized_comment_content = $sanitizer_obj->get_amp_content();
28
- echo make_clickable( $sanitized_comment_content );
29
  }
30
  ?>
31
 
13
  <?php // Grand child support AND amp-accordion non critical error in Design 3 due to nav #1152
14
  // schema.org/SiteNavigationElement missing from menus #1229 ?>
15
  <nav id ="primary-amp-menu" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
 
16
  <?php
17
  $menu_html_content = wp_nav_menu( array(
18
  'theme_location' => 'amp-menu',
22
  'menu_class'=>'amp-menu',
23
  'echo'=>false
24
  ) );
25
+ $sanitizer_obj = new AMPFORWP_Content( $menu_html_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array(), 'AMP_Style_Sanitizer' => array(), ) ) );
26
+ $sanitized_menu = $sanitizer_obj->get_amp_content();
27
+ echo $sanitized_menu;
28
  }
29
  ?>
30
 
templates/design-manager/design-3/style.php CHANGED
@@ -217,13 +217,6 @@ main .amp-wp-content.comments_list{ background: none; box-shadow: none; padding:
217
  html .single-post .ampforwp-incontent-ad-1 { margin-bottom: 10px; }
218
  .amp-ad-3{ margin-bottom:10px; }
219
  .amp-ad-4{ margin-top:2px; }
220
- <?php if($redux_builder_amp['amp-enable-notifications']==1){ ?>
221
- /* Notifications */
222
- #amp-user-notification1 p{ display: inline-block; }
223
- amp-user-notification{ padding: 5px; text-align: center; background: #fff; border-top: 1px solid; }
224
- amp-user-notification button{ padding: 8px 10px; background: #000; color: #fff; margin-left: 5px; border: 0; }
225
- amp-user-notification button:hover{ cursor: pointer }
226
- <?php } ?>
227
  .amp-wp-content blockquote{ background-color: #fff; border-left: 3px solid; margin: 0; padding: 15px 20px; background: #f3f3f3; }
228
  .amp-wp-content blockquote p{ margin-bottom:0 }
229
  pre{ white-space: pre-wrap; }
@@ -321,7 +314,13 @@ table tr:last-child td:first-child { -moz-border-radius-bottomleft: 3px; -webkit
321
  table tr:last-child td:last-child { -moz-border-radius-bottomright: 3px; -webkit-border-bottom-right-radius: 3px; border-bottom-right-radius: 3px; }
322
  table tr:hover td { background: #f2f2f2; background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0)); background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0); }
323
  <?php } ?>
324
-
 
 
 
 
 
 
325
  /* Responsive */
326
  @media screen and (min-width: 650px) { table {display: inline-table;} }
327
 
@@ -440,4 +439,5 @@ if( !is_home() && $redux_builder_amp['ampforwp-bread-crumb'] == 1 ) { ?>
440
  .breadcrumb ul li:last-child a::after{display:none;}
441
  <?php } ?>
442
  .amp-menu > li > a > amp-img, .sub-menu > li > a > amp-img { display: inline-block; margin-right: 4px; }
 
443
  <?php echo $redux_builder_amp['css_editor']; } ?>
217
  html .single-post .ampforwp-incontent-ad-1 { margin-bottom: 10px; }
218
  .amp-ad-3{ margin-bottom:10px; }
219
  .amp-ad-4{ margin-top:2px; }
 
 
 
 
 
 
 
220
  .amp-wp-content blockquote{ background-color: #fff; border-left: 3px solid; margin: 0; padding: 15px 20px; background: #f3f3f3; }
221
  .amp-wp-content blockquote p{ margin-bottom:0 }
222
  pre{ white-space: pre-wrap; }
314
  table tr:last-child td:last-child { -moz-border-radius-bottomright: 3px; -webkit-border-bottom-right-radius: 3px; border-bottom-right-radius: 3px; }
315
  table tr:hover td { background: #f2f2f2; background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0)); background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0); }
316
  <?php } ?>
317
+ <?php if( $redux_builder_amp['amp-enable-notifications'] == 1 || $redux_builder_amp['ampforwp-cta-subsection-notification-sticky'] == 1 ){?>
318
+ /* Notifications */
319
+ #amp-user-notification1 p{ display: inline-block; }
320
+ amp-user-notification{ padding: 5px; text-align: center; background: #fff; border-top: 1px solid; }
321
+ amp-user-notification button{ padding: 8px 10px; background: #000; color: #fff; margin-left: 5px; border: 0; }
322
+ amp-user-notification button:hover{ cursor: pointer }
323
+ <?php } ?>
324
  /* Responsive */
325
  @media screen and (min-width: 650px) { table {display: inline-table;} }
326
 
439
  .breadcrumb ul li:last-child a::after{display:none;}
440
  <?php } ?>
441
  .amp-menu > li > a > amp-img, .sub-menu > li > a > amp-img { display: inline-block; margin-right: 4px; }
442
+ .menu-item amp-img {width: 16px; height: 11px; display: inline-block; margin-right: 5px; }
443
  <?php echo $redux_builder_amp['css_editor']; } ?>
templates/features.php CHANGED
@@ -101,6 +101,9 @@
101
  91. Comment Author Gravatar URL
102
  92. View AMP in Admin Bar
103
  93. added AMP url purifire for amphtml
 
 
 
104
  */
105
  // Adding AMP-related things to the main theme
106
  global $redux_builder_amp;
@@ -176,7 +179,7 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
176
  endif;
177
  }
178
 
179
- function ampforwp_home_archive_rel_canonical() {
180
  global $redux_builder_amp;
181
  global $wp, $post;
182
  if( is_attachment() ) {
@@ -199,20 +202,22 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
199
  if(is_archive() && $redux_builder_amp['ampforwp-archive-support']){
200
  $selected_cats = array();
201
  $categories = get_the_category();
202
- $category_id = $categories[0]->cat_ID;
203
- $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
204
- // Check if $get_categories_from_checkbox has some cats then only show
205
- if ( $get_categories_from_checkbox ) {
206
- $get_selected_cats = array_filter($get_categories_from_checkbox);
207
- foreach ($get_selected_cats as $key => $value) {
208
- $selected_cats[] = $key;
209
- }
210
- if($selected_cats && $category_id){
211
- if(in_array($category_id, $selected_cats)){
212
- return;
 
 
213
  }
214
- }
215
- }
216
  }
217
  if( is_page() && !$redux_builder_amp['amp-on-off-for-all-pages'] ) {
218
  return;
@@ -235,64 +240,76 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
235
  $amp_url = amp_get_permalink( get_queried_object_id() );
236
  }
237
 
238
- global $post;
239
- $ampforwp_amp_post_on_off_meta = get_post_meta( get_the_ID(),'ampforwp-amp-on-off',true);
240
- if( is_singular() && $ampforwp_amp_post_on_off_meta === 'hide-amp' ) {
241
- //dont Echo anything
242
- } else {
243
- $supported_types = array('post','page');
244
-
245
- $supported_types = apply_filters('get_amp_supported_post_types',$supported_types);
246
 
247
- $type = get_post_type();
248
- $supported_amp_post_types = in_array( $type , $supported_types );
249
 
250
- $query_arg_array = $wp->query_vars;
251
- if( array_key_exists( 'paged' , $query_arg_array ) ) {
252
- if ( (is_home() || is_archive()) && $wp->query_vars['paged'] >= '2' ) {
253
- $new_url = home_url('/');
254
- $category_path = $wp->request;
255
- $explode_path = explode("/",$category_path);
256
- $inserted = array(AMPFORWP_AMP_QUERY_VAR);
257
- array_splice( $explode_path, -2, 0, $inserted );
258
- $impode_url = implode('/', $explode_path);
259
 
260
- $amp_url = $new_url . $impode_url ;
261
- }
262
- if( is_search() && $wp->query_vars['paged'] >= '2' ) {
263
- $current_search_url =trailingslashit(get_home_url()) . $wp->request .'/'."?amp=1&s=".get_search_query();
264
- }
 
 
 
 
 
 
 
 
 
265
  }
 
266
 
267
- $amp_url = user_trailingslashit($amp_url);
268
 
269
- if( is_search() ) {
270
- $current_search_url =trailingslashit(get_home_url())."?amp=1&s=".get_search_query();
271
- $amp_url = untrailingslashit($current_search_url);
272
- }
273
 
274
- // WPML AMPHTML #1285
275
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
276
- if(is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' )){
277
- Global $sitepress_settings;
278
- if($sitepress_settings[ 'language_negotiation_type' ] == 3){
279
- $wpml_url =get_permalink( get_queried_object_id() );
280
- $explode_url = explode('/', $wpml_url);
281
- $append_amp = 'amp';
282
- array_splice( $explode_url, 5, 0, $append_amp );
283
- $impode_url = implode('/', $explode_url);
284
- $amp_url = untrailingslashit($impode_url);
285
- }
286
- }
287
-
288
- $amp_url = ampforwp_url_purifier($amp_url);
289
- $amp_url = apply_filters('ampforwp_modify_rel_canonical',$amp_url);
290
 
291
- if( $supported_amp_post_types) {
292
- printf('<link rel="amphtml" href="%s" />', esc_url($amp_url));
293
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
- }
296
  } //end of ampforwp_home_archive_rel_canonical()
297
 
298
 
@@ -971,6 +988,8 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
971
 
972
  //Convert the Twitter embed into url for better sanitization #1010
973
  $content = preg_replace('/<blockquote.+?(?=class="twitter-.*?")class="twitter-.*?".+?(https:\/\/twitter\.com\/\w+\/\w+\/.*?)".+?(?=<\/blockquote>)<\/blockquote>/s', "$1", $content);
 
 
974
 
975
  // for readability attibute in div tag
976
  $content = preg_replace('/readability=[^>]*/', '', $content);
@@ -978,6 +997,11 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
978
  $content = preg_replace('/<span(.*?)(color=".*?")(.*?)>/', '<span$1$3>', $content);
979
  // removing sl-processed form anchor tag
980
  $content = preg_replace('/<a (href=".*?")(.*?)(target=".*?")(.*?)(sl-processed=".*?")>/', '<a $1$3>', $content);
 
 
 
 
 
981
  // removing text-align:center from p tag
982
  $content = preg_replace('/<p(.*?)(text-align:=".*?")(.*?)(center=".*?")(.*?)>/', '<p$1$5>', $content);
983
  // removing paraid, paraeid from p tag
@@ -1237,7 +1261,7 @@ function ampforwp_title_callback( $post ) {
1237
  if($post->post_status == 'publish') {
1238
  add_thickbox(); ?>
1239
  <div class="ampforwp-preview-button-container">
1240
- <input alt="#TB_inline?height=1135&amp;width=718&amp;inlineId=ampforwp_preview" title="AMP Mobile Preview" class="thickbox ampforwp-preview-button preview button" type="button" value="Preview AMP" />
1241
  </div>
1242
  <?php } ?>
1243
  </div>
@@ -1247,10 +1271,9 @@ function ampforwp_title_callback( $post ) {
1247
  <div id="ampforwp-preview-format">
1248
  <div class="row">
1249
  <div class="col-sm-12 margin-top-bottom text-center">
1250
- <div class="ampforwp-preview-phone-frame-wrapper">
1251
  <div class="ampforwp-preview-phone-frame">
1252
- <div class="ampforwp-preview-container">
1253
- <iframe src="<?php echo $preview_link; ?>"></iframe>
1254
  </div>
1255
  </div>
1256
  </div>
@@ -2403,160 +2426,184 @@ function ampforwp_add_widget_support() {
2403
  add_action( 'ampforwp_home_above_loop' , 'ampforwp_output_widget_content_above_loop' );
2404
  add_action( 'ampforwp_frontpage_above_loop' , 'ampforwp_output_widget_content_above_loop' );
2405
  function ampforwp_output_widget_content_above_loop() {
2406
- $sanitized_sidebar = "";
2407
- $non_sanitized_sidebar = "";
2408
- $sidebar_output = "";
2409
-
2410
- ob_start();
2411
- dynamic_sidebar( 'ampforwp-above-loop' );
2412
- $non_sanitized_sidebar = ob_get_contents();
2413
- ob_end_clean();
2414
-
2415
- $sanitized_sidebar = new AMPFORWP_Content( $non_sanitized_sidebar,
2416
- apply_filters( 'amp_content_embed_handlers', array(
2417
- 'AMP_Twitter_Embed_Handler' => array(),
2418
- 'AMP_YouTube_Embed_Handler' => array(),
2419
- 'AMP_Instagram_Embed_Handler' => array(),
2420
- 'AMP_Vine_Embed_Handler' => array(),
2421
- 'AMP_Facebook_Embed_Handler' => array(),
2422
- 'AMP_Gallery_Embed_Handler' => array(),
2423
- ) ),
2424
- apply_filters( 'amp_content_sanitizers', array(
2425
- 'AMP_Style_Sanitizer' => array(),
2426
- 'AMP_Blacklist_Sanitizer' => array(),
2427
- 'AMP_Img_Sanitizer' => array(),
2428
- 'AMP_Video_Sanitizer' => array(),
2429
- 'AMP_Audio_Sanitizer' => array(),
2430
- 'AMP_Iframe_Sanitizer' => array(
2431
- 'add_placeholder' => true,
2432
- ),
2433
- ) )
2434
- );
2435
-
2436
- $sidebar_output = $sanitized_sidebar->get_amp_content();
2437
- echo $sidebar_output;
2438
-
2439
  }
2440
 
2441
  add_action( 'ampforwp_home_below_loop' , 'ampforwp_output_widget_content_below_loop' );
2442
  add_action( 'ampforwp_frontpage_below_loop' , 'ampforwp_output_widget_content_below_loop' );
2443
  function ampforwp_output_widget_content_below_loop() {
2444
- $sanitized_sidebar = "";
2445
- $non_sanitized_sidebar = "";
2446
- $sidebar_output = "";
2447
-
2448
- ob_start();
2449
- dynamic_sidebar( 'ampforwp-below-loop' );
2450
- $non_sanitized_sidebar = ob_get_contents();
2451
- ob_end_clean();
2452
-
2453
- $sanitized_sidebar = new AMPFORWP_Content( $non_sanitized_sidebar,
2454
- apply_filters( 'amp_content_embed_handlers', array(
2455
- 'AMP_Twitter_Embed_Handler' => array(),
2456
- 'AMP_YouTube_Embed_Handler' => array(),
2457
- 'AMP_Instagram_Embed_Handler' => array(),
2458
- 'AMP_Vine_Embed_Handler' => array(),
2459
- 'AMP_Facebook_Embed_Handler' => array(),
2460
- 'AMP_Gallery_Embed_Handler' => array(),
2461
- ) ),
2462
- apply_filters( 'amp_content_sanitizers', array(
2463
- 'AMP_Style_Sanitizer' => array(),
2464
- 'AMP_Blacklist_Sanitizer' => array(),
2465
- 'AMP_Img_Sanitizer' => array(),
2466
- 'AMP_Video_Sanitizer' => array(),
2467
- 'AMP_Audio_Sanitizer' => array(),
2468
- 'AMP_Iframe_Sanitizer' => array(
2469
- 'add_placeholder' => true,
2470
- ),
2471
- ) )
2472
- );
2473
-
2474
- $sidebar_output = $sanitized_sidebar->get_amp_content();
2475
- echo $sidebar_output;
2476
  }
2477
 
2478
  add_action( 'ampforwp_after_header' , 'ampforwp_output_widget_content_below_the_header' );
2479
  add_action('below_the_header_design_1','ampforwp_output_widget_content_below_the_header');
2480
  function ampforwp_output_widget_content_below_the_header() {
2481
  $sanitized_sidebar = "";
2482
- $non_sanitized_sidebar = "";
2483
  $sidebar_output = "";
2484
-
2485
- ob_start();
2486
- dynamic_sidebar( 'ampforwp-below-header' );
2487
- $non_sanitized_sidebar = ob_get_contents();
2488
- ob_end_clean();
2489
-
2490
- $sanitized_sidebar = new AMPFORWP_Content( $non_sanitized_sidebar,
2491
- apply_filters( 'amp_content_embed_handlers', array(
2492
- 'AMP_Twitter_Embed_Handler' => array(),
2493
- 'AMP_YouTube_Embed_Handler' => array(),
2494
- 'AMP_Instagram_Embed_Handler' => array(),
2495
- 'AMP_Vine_Embed_Handler' => array(),
2496
- 'AMP_Facebook_Embed_Handler' => array(),
2497
- 'AMP_Gallery_Embed_Handler' => array(),
2498
- ) ),
2499
- apply_filters( 'amp_content_sanitizers', array(
2500
- 'AMP_Style_Sanitizer' => array(),
2501
- 'AMP_Blacklist_Sanitizer' => array(),
2502
- 'AMP_Img_Sanitizer' => array(),
2503
- 'AMP_Video_Sanitizer' => array(),
2504
- 'AMP_Audio_Sanitizer' => array(),
2505
- 'AMP_Iframe_Sanitizer' => array(
2506
- 'add_placeholder' => true,
2507
- ),
2508
- ) )
2509
- );
2510
-
2511
- $sidebar_output = $sanitized_sidebar->get_amp_content(); ?>
2512
-
2513
  <div class="amp-wp-content widget-wrapper">
2514
  <div class="amp_widget_below_the_header">
2515
- <?php echo $sidebar_output; ?> </div>
2516
  </div>
2517
 
2518
  <?php }
2519
 
2520
  add_action( 'amp_post_template_above_footer' , 'ampforwp_output_widget_content_above_the_footer' );
2521
  function ampforwp_output_widget_content_above_the_footer() {
2522
- $sanitized_sidebar = "";
2523
- $non_sanitized_sidebar = "";
2524
- $sidebar_output = "";
2525
-
2526
- ob_start();
2527
- dynamic_sidebar( 'ampforwp-above-footer' );
2528
- $non_sanitized_sidebar = ob_get_contents();
2529
- ob_end_clean();
2530
-
2531
- $sanitized_sidebar = new AMPFORWP_Content( $non_sanitized_sidebar,
2532
- apply_filters( 'amp_content_embed_handlers', array(
2533
- 'AMP_Twitter_Embed_Handler' => array(),
2534
- 'AMP_YouTube_Embed_Handler' => array(),
2535
- 'AMP_Instagram_Embed_Handler' => array(),
2536
- 'AMP_Vine_Embed_Handler' => array(),
2537
- 'AMP_Facebook_Embed_Handler' => array(),
2538
- 'AMP_Gallery_Embed_Handler' => array(),
2539
- ) ),
2540
- apply_filters( 'amp_content_sanitizers', array(
2541
- 'AMP_Style_Sanitizer' => array(),
2542
- 'AMP_Blacklist_Sanitizer' => array(),
2543
- 'AMP_Img_Sanitizer' => array(),
2544
- 'AMP_Video_Sanitizer' => array(),
2545
- 'AMP_Audio_Sanitizer' => array(),
2546
- 'AMP_Iframe_Sanitizer' => array(
2547
- 'add_placeholder' => true,
2548
- ),
2549
- ) )
2550
- );
2551
-
2552
- $sidebar_output = $sanitized_sidebar->get_amp_content(); ?>
2553
  <div class="amp-wp-content widget-wrapper">
2554
  <div class="amp_widget_above_the_footer">
2555
- <?php echo $sidebar_output; ?> </div>
2556
  </div>
2557
 
2558
  <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2559
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2560
  // 44. auto adding /amp for the menu
2561
  add_action('amp_init','ampforwp_auto_add_amp_menu_link_insert');
2562
  function ampforwp_auto_add_amp_menu_link_insert() {
@@ -3820,9 +3867,10 @@ global $redux_builder_amp;
3820
  function is_category_amp_disabled(){
3821
  global $redux_builder_amp;
3822
 
3823
- if(is_archive() && $redux_builder_amp['ampforwp-archive-support']==1){
3824
- $categories = get_the_category();
3825
- $selected_cats = array();
 
3826
  $category_id = $categories[0]->cat_ID;
3827
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
3828
  // Check if $get_categories_from_checkbox has some cats then only show
@@ -3839,6 +3887,7 @@ if(is_archive() && $redux_builder_amp['ampforwp-archive-support']==1){
3839
  return false;
3840
  }
3841
  }
 
3842
  }
3843
  }
3844
 
@@ -4625,10 +4674,168 @@ function ampforwp_url_purifier($url){
4625
  $url = $url .'&'. $queried_var .'='. $quried_value;
4626
  }
4627
  } else {
4628
- if ( is_home() || is_archive() ) {
4629
- $url = user_trailingslashit( trailingslashit($url) . $endpoint );
4630
- }
 
 
 
 
4631
  }
4632
- //var_dump($url); die;
4633
  return $url;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4634
  }
101
  91. Comment Author Gravatar URL
102
  92. View AMP in Admin Bar
103
  93. added AMP url purifire for amphtml
104
+ 94. OneSignal Push Notifications
105
+ 95. Modify menu link attributes for SiteNavigationElement Schema Markup #1229 #1345
106
+ 96. ampforwp_is_front_page() ampforwp_is_home() and ampforwp_is_blog is created
107
  */
108
  // Adding AMP-related things to the main theme
109
  global $redux_builder_amp;
179
  endif;
180
  }
181
 
182
+ function ampforwp_amphtml_generator(){
183
  global $redux_builder_amp;
184
  global $wp, $post;
185
  if( is_attachment() ) {
202
  if(is_archive() && $redux_builder_amp['ampforwp-archive-support']){
203
  $selected_cats = array();
204
  $categories = get_the_category();
205
+ if ( $categories ) {
206
+ $category_id = $categories[0]->cat_ID;
207
+ $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
208
+ // Check if $get_categories_from_checkbox has some cats then only show
209
+ if ( $get_categories_from_checkbox ) {
210
+ $get_selected_cats = array_filter($get_categories_from_checkbox);
211
+ foreach ($get_selected_cats as $key => $value) {
212
+ $selected_cats[] = $key;
213
+ }
214
+ if($selected_cats && $category_id){
215
+ if(in_array($category_id, $selected_cats)){
216
+ return;
217
+ }
218
  }
219
+ }
220
+ }
221
  }
222
  if( is_page() && !$redux_builder_amp['amp-on-off-for-all-pages'] ) {
223
  return;
240
  $amp_url = amp_get_permalink( get_queried_object_id() );
241
  }
242
 
243
+ global $post;
244
+ $ampforwp_amp_post_on_off_meta = get_post_meta( get_the_ID(),'ampforwp-amp-on-off',true);
245
+ if( is_singular() && $ampforwp_amp_post_on_off_meta === 'hide-amp' ) {
246
+ //dont Echo anything
247
+ } else {
248
+ $supported_types = array('post','page');
 
 
249
 
250
+ $supported_types = apply_filters('get_amp_supported_post_types',$supported_types);
 
251
 
252
+ $type = get_post_type();
253
+ $supported_amp_post_types = in_array( $type , $supported_types );
 
 
 
 
 
 
 
254
 
255
+ $query_arg_array = $wp->query_vars;
256
+ if( array_key_exists( 'paged' , $query_arg_array ) ) {
257
+ if ( (is_home() || is_archive()) && $wp->query_vars['paged'] >= '2' ) {
258
+ $new_url = home_url('/');
259
+ $category_path = $wp->request;
260
+ $explode_path = explode("/",$category_path);
261
+ $inserted = array(AMPFORWP_AMP_QUERY_VAR);
262
+ array_splice( $explode_path, -2, 0, $inserted );
263
+ $impode_url = implode('/', $explode_path);
264
+
265
+ $amp_url = $new_url . $impode_url ;
266
+ }
267
+ if( is_search() && $wp->query_vars['paged'] >= '2' ) {
268
+ $current_search_url =trailingslashit(get_home_url()) . $wp->request .'/'."?amp=1&s=".get_search_query();
269
  }
270
+ }
271
 
272
+ $amp_url = user_trailingslashit($amp_url);
273
 
274
+ if( is_search() ) {
275
+ $current_search_url =trailingslashit(get_home_url())."?amp=1&s=".get_search_query();
276
+ $amp_url = untrailingslashit($current_search_url);
277
+ }
278
 
279
+ // WPML AMPHTML #1285
280
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
281
+ if(is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' )){
282
+ Global $sitepress_settings;
283
+ if($sitepress_settings[ 'language_negotiation_type' ] == 3){
284
+ $wpml_url =get_permalink( get_queried_object_id() );
285
+ $explode_url = explode('/', $wpml_url);
286
+ $append_amp = 'amp';
287
+ array_splice( $explode_url, 5, 0, $append_amp );
288
+ $impode_url = implode('/', $explode_url);
289
+ $amp_url = untrailingslashit($impode_url);
290
+ }
291
+ }
292
+
293
+ $amp_url = ampforwp_url_purifier($amp_url);
294
+ $amp_url = apply_filters('ampforwp_modify_rel_canonical',$amp_url);
295
 
296
+ if( $supported_amp_post_types) {
297
+ return $amp_url;
298
+ }
299
+ }
300
+ return;
301
+ }
302
+
303
+ function ampforwp_home_archive_rel_canonical() {
304
+
305
+ $amp_url = "";
306
+
307
+ $amp_url = ampforwp_amphtml_generator();
308
+
309
+ if ( $amp_url ) {
310
+ printf('<link rel="amphtml" href="%s" />', esc_url($amp_url));
311
+ }
312
 
 
313
  } //end of ampforwp_home_archive_rel_canonical()
314
 
315
 
988
 
989
  //Convert the Twitter embed into url for better sanitization #1010
990
  $content = preg_replace('/<blockquote.+?(?=class="twitter-.*?")class="twitter-.*?".+?(https:\/\/twitter\.com\/\w+\/\w+\/.*?)".+?(?=<\/blockquote>)<\/blockquote>/s', "$1", $content);
991
+ // Convert the Soundcloud embed into URL to build amp-soundcloud
992
+ $content = preg_replace('/<iframe .*(https?).*(\/\/api\.soundcloud\.com\/tracks\/)([0-9]+)(.*)<\/iframe>/', "$1:$2$3", $content);
993
 
994
  // for readability attibute in div tag
995
  $content = preg_replace('/readability=[^>]*/', '', $content);
997
  $content = preg_replace('/<span(.*?)(color=".*?")(.*?)>/', '<span$1$3>', $content);
998
  // removing sl-processed form anchor tag
999
  $content = preg_replace('/<a (href=".*?")(.*?)(target=".*?")(.*?)(sl-processed=".*?")>/', '<a $1$3>', $content);
1000
+ $content = preg_replace('/<a (href=".*?")(.*?)(rel=".*?")(.*?)(sl-processed=".*?")>/', '<a $1$3>', $content);
1001
+ // Removing text-align, center, font-size from the a tag
1002
+ $content = preg_replace('/<a (href=".*?")(.*?)(rel=".*?").*?(text-align:=".*?").*?(center=".*?").*?(font-size:=".*?")>/', '<a $1 $3>', $content);
1003
+ // Removing _blank="" from the a tag
1004
+ $content = preg_replace('/<a (href=".*?")(.*?)(_blank=".*?")>/', '<a $1 $2>', $content);
1005
  // removing text-align:center from p tag
1006
  $content = preg_replace('/<p(.*?)(text-align:=".*?")(.*?)(center=".*?")(.*?)>/', '<p$1$5>', $content);
1007
  // removing paraid, paraeid from p tag
1261
  if($post->post_status == 'publish') {
1262
  add_thickbox(); ?>
1263
  <div class="ampforwp-preview-button-container">
1264
+ <input alt="#TB_inline?height=1135&amp;width=718&amp;inlineId=ampforwp_preview" title="AMP Mobile Preview" class="thickbox ampforwp-preview-button preview button amp-preview-button" type="button" value="Preview AMP" />
1265
  </div>
1266
  <?php } ?>
1267
  </div>
1271
  <div id="ampforwp-preview-format">
1272
  <div class="row">
1273
  <div class="col-sm-12 margin-top-bottom text-center">
1274
+ <div class="ampforwp-preview-phone-frame-wrapper">
1275
  <div class="ampforwp-preview-phone-frame">
1276
+ <div class="ampforwp-preview-container" id="amp-preview-iframe" data-src="<?php echo $preview_link; ?>">
 
1277
  </div>
1278
  </div>
1279
  </div>
2426
  add_action( 'ampforwp_home_above_loop' , 'ampforwp_output_widget_content_above_loop' );
2427
  add_action( 'ampforwp_frontpage_above_loop' , 'ampforwp_output_widget_content_above_loop' );
2428
  function ampforwp_output_widget_content_above_loop() {
2429
+ $sanitized_sidebar = "";
2430
+ $sidebar_output = "";
2431
+ $sanitized_sidebar = ampforwp_sidebar_content_sanitizer('ampforwp-above-loop');
2432
+ if ( $sanitized_sidebar) {
2433
+ $sidebar_output = $sanitized_sidebar->get_amp_content();
2434
+ }
2435
+ if ( $sidebar_output) { echo $sidebar_output ; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2436
  }
2437
 
2438
  add_action( 'ampforwp_home_below_loop' , 'ampforwp_output_widget_content_below_loop' );
2439
  add_action( 'ampforwp_frontpage_below_loop' , 'ampforwp_output_widget_content_below_loop' );
2440
  function ampforwp_output_widget_content_below_loop() {
2441
+ $sanitized_sidebar = "";
2442
+ $sidebar_output = "";
2443
+ $sanitized_sidebar = ampforwp_sidebar_content_sanitizer('ampforwp-below-loop');
2444
+ if ( $sanitized_sidebar) {
2445
+ $sidebar_output = $sanitized_sidebar->get_amp_content();
2446
+ }
2447
+ if ( $sidebar_output) : echo $sidebar_output; endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2448
  }
2449
 
2450
  add_action( 'ampforwp_after_header' , 'ampforwp_output_widget_content_below_the_header' );
2451
  add_action('below_the_header_design_1','ampforwp_output_widget_content_below_the_header');
2452
  function ampforwp_output_widget_content_below_the_header() {
2453
  $sanitized_sidebar = "";
 
2454
  $sidebar_output = "";
2455
+ $sanitized_sidebar = ampforwp_sidebar_content_sanitizer('ampforwp-below-header');
2456
+ if ( $sanitized_sidebar) {
2457
+ $sidebar_output = $sanitized_sidebar->get_amp_content();
2458
+ }?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2459
  <div class="amp-wp-content widget-wrapper">
2460
  <div class="amp_widget_below_the_header">
2461
+ <?php if ( $sidebar_output) : echo $sidebar_output; endif; ?> </div>
2462
  </div>
2463
 
2464
  <?php }
2465
 
2466
  add_action( 'amp_post_template_above_footer' , 'ampforwp_output_widget_content_above_the_footer' );
2467
  function ampforwp_output_widget_content_above_the_footer() {
2468
+ $sanitized_sidebar = "";
2469
+ $sidebar_output = "";
2470
+ $sanitized_sidebar = ampforwp_sidebar_content_sanitizer('ampforwp-above-footer');
2471
+ if ( $sanitized_sidebar) {
2472
+ $sidebar_output = $sanitized_sidebar->get_amp_content();
2473
+ }?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2474
  <div class="amp-wp-content widget-wrapper">
2475
  <div class="amp_widget_above_the_footer">
2476
+ <?php if ( $sidebar_output) : echo $sidebar_output; endif; ?> </div>
2477
  </div>
2478
 
2479
  <?php }
2480
+ // Sidebar Content Sanitizer
2481
+ function ampforwp_sidebar_content_sanitizer($sidebar){
2482
+ $sanitized_sidebar = "";
2483
+ $non_sanitized_sidebar = "";
2484
+ $sidebar_data = array();
2485
+
2486
+ ob_start();
2487
+ dynamic_sidebar( $sidebar );
2488
+ $non_sanitized_sidebar = ob_get_contents();
2489
+ ob_end_clean();
2490
+ if ( $non_sanitized_sidebar ) {
2491
+ $sanitized_sidebar = new AMP_Content( $non_sanitized_sidebar,
2492
+ apply_filters( 'amp_content_embed_handlers', array(
2493
+ 'AMP_Twitter_Embed_Handler' => array(),
2494
+ 'AMP_YouTube_Embed_Handler' => array(),
2495
+ 'AMP_DailyMotion_Embed_Handler' => array(),
2496
+ 'AMP_Vimeo_Embed_Handler' => array(),
2497
+ 'AMP_SoundCloud_Embed_Handler' => array(),
2498
+ 'AMP_Instagram_Embed_Handler' => array(),
2499
+ 'AMP_Vine_Embed_Handler' => array(),
2500
+ 'AMP_Facebook_Embed_Handler' => array(),
2501
+ 'AMP_Pinterest_Embed_Handler' => array(),
2502
+ 'AMP_Gallery_Embed_Handler' => array(),
2503
+ ) ),
2504
+ apply_filters( 'amp_content_sanitizers', array(
2505
+ 'AMP_Style_Sanitizer' => array(),
2506
+ 'AMP_Blacklist_Sanitizer' => array(),
2507
+ 'AMP_Img_Sanitizer' => array(),
2508
+ 'AMP_Video_Sanitizer' => array(),
2509
+ 'AMP_Audio_Sanitizer' => array(),
2510
+ 'AMP_Playbuzz_Sanitizer' => array(),
2511
+ 'AMP_Iframe_Sanitizer' => array(
2512
+ 'add_placeholder' => true,
2513
+ ),
2514
+ ) )
2515
+ );
2516
+ }
2517
 
2518
+ return $sanitized_sidebar;
2519
+ }
2520
+ // Sidebar Scripts
2521
+ add_filter( 'amp_post_template_data', 'ampforwp_add_sidebar_data' );
2522
+ function ampforwp_add_sidebar_data( $data ) {
2523
+ $sanitized_data_above_loop = '';
2524
+ $sanitized_data_below_loop = '';
2525
+ $sanitized_data_below_header = '';
2526
+ $sanitized_data_above_footer = '';
2527
+ // Get the Data
2528
+ $sanitized_data_above_loop = ampforwp_sidebar_content_sanitizer('ampforwp-above-loop');
2529
+ $sanitized_data_below_loop = ampforwp_sidebar_content_sanitizer('ampforwp-below-loop');
2530
+ $sanitized_data_below_header = ampforwp_sidebar_content_sanitizer('ampforwp-below-header');
2531
+ $sanitized_data_above_footer = ampforwp_sidebar_content_sanitizer('ampforwp-above-footer');
2532
+
2533
+ if ( $sanitized_data_above_loop ) {
2534
+ // Add Scripts
2535
+ if ( $sanitized_data_above_loop->get_amp_scripts() ) {
2536
+ foreach ($sanitized_data_above_loop->get_amp_scripts() as $key => $value ) {
2537
+ if( empty( $data['amp_component_scripts'][$key] ) ){
2538
+ $data['amp_component_scripts'][$key] = $value;
2539
+ }
2540
+ }
2541
+ }
2542
+ // Add Styles
2543
+ if ( $sanitized_data_above_loop->get_amp_styles() ) {
2544
+ foreach ($sanitized_data_above_loop->get_amp_styles() as $key => $value ) {
2545
+ if( empty( $data['post_amp_styles'][$key] ) ){
2546
+ $data['post_amp_styles'][$key] = $value;
2547
+ }
2548
+ }
2549
+ }
2550
+ }
2551
+ if ( $sanitized_data_below_loop ) {
2552
+ // Add Scripts
2553
+ if ( $sanitized_data_below_loop->get_amp_scripts() ) {
2554
+ foreach ($sanitized_data_below_loop->get_amp_scripts() as $key => $value ) {
2555
+ if( empty( $data['amp_component_scripts'][$key] ) ){
2556
+ $data['amp_component_scripts'][$key] = $value;
2557
+ }
2558
+ }
2559
+ }
2560
+ // Add Styles
2561
+ if ( $sanitized_data_below_loop->get_amp_styles() ) {
2562
+ foreach ($sanitized_data_below_loop->get_amp_styles() as $key => $value ) {
2563
+ if( empty( $data['post_amp_styles'][$key] ) ){
2564
+ $data['post_amp_styles'][$key] = $value;
2565
+ }
2566
+ }
2567
+ }
2568
+ }
2569
+ if ( $sanitized_data_below_header ) {
2570
+ // Add Scripts
2571
+ if ( $sanitized_data_below_header->get_amp_scripts() ) {
2572
+ foreach ($sanitized_data_below_header->get_amp_scripts() as $key => $value ) {
2573
+ if( empty( $data['amp_component_scripts'][$key] ) ){
2574
+ $data['amp_component_scripts'][$key] = $value;
2575
+ }
2576
+ }
2577
+ }
2578
+ // Add Styles
2579
+ if ( $sanitized_data_below_header->get_amp_styles() ) {
2580
+ foreach ($sanitized_data_below_header->get_amp_styles() as $key => $value ) {
2581
+ if( empty( $data['post_amp_styles'][$key] ) ){
2582
+ $data['post_amp_styles'][$key] = $value;
2583
+ }
2584
+ }
2585
+ }
2586
+ }
2587
+ if ( $sanitized_data_above_footer ) {
2588
+ // Add Scripts
2589
+ if ( $sanitized_data_above_footer->get_amp_scripts() ) {
2590
+ foreach ($sanitized_data_above_footer->get_amp_scripts() as $key => $value ) {
2591
+ if( empty( $data['amp_component_scripts'][$key] ) ){
2592
+ $data['amp_component_scripts'][$key] = $value;
2593
+ }
2594
+ }
2595
+ }
2596
+ // Add Styles
2597
+ if ( $sanitized_data_above_footer->get_amp_styles() ) {
2598
+ foreach ($sanitized_data_above_footer->get_amp_styles() as $key => $value ) {
2599
+ if( empty( $data['post_amp_styles'][$key] ) ){
2600
+ $data['post_amp_styles'][$key] = $value;
2601
+ }
2602
+ }
2603
+ }
2604
+ }
2605
+ return $data;
2606
+ }
2607
  // 44. auto adding /amp for the menu
2608
  add_action('amp_init','ampforwp_auto_add_amp_menu_link_insert');
2609
  function ampforwp_auto_add_amp_menu_link_insert() {
3867
  function is_category_amp_disabled(){
3868
  global $redux_builder_amp;
3869
 
3870
+ if(is_archive() && $redux_builder_amp['ampforwp-archive-support']==1){
3871
+ $categories = get_the_category();
3872
+ $selected_cats = array();
3873
+ if ( $categories) {
3874
  $category_id = $categories[0]->cat_ID;
3875
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
3876
  // Check if $get_categories_from_checkbox has some cats then only show
3887
  return false;
3888
  }
3889
  }
3890
+ }
3891
  }
3892
  }
3893
 
4674
  $url = $url .'&'. $queried_var .'='. $quried_value;
4675
  }
4676
  } else {
4677
+ if ( is_home() || is_archive() || is_front_page() ) {
4678
+ if ( is_archive() && get_query_var('paged') > 1 || is_home() && get_query_var('paged') > 1 ) {
4679
+ $url = user_trailingslashit( trailingslashit($url) );
4680
+ } else {
4681
+ $url = user_trailingslashit( trailingslashit($url) . $endpoint );
4682
+ }
4683
+ }
4684
  }
 
4685
  return $url;
4686
+ }
4687
+
4688
+ // 94. OneSignal Push Notifications
4689
+ add_action( 'ampforwp_body_beginning' , 'ampforwp_onesignal_notifications' , 11 );
4690
+ if( ! function_exists( ' ampforwp_onesignal_notifications ' ) ){
4691
+ function ampforwp_onesignal_notifications(){
4692
+ global $redux_builder_amp;
4693
+ if(isset($redux_builder_amp['ampforwp-web-push-onesignal']) && $redux_builder_amp['ampforwp-web-push-onesignal'] ){
4694
+ $onesignal_domain = '';
4695
+ $onesignal_subdomain = '';
4696
+ $onesignal_app_id = '';
4697
+ $helper_iframe_url = '';
4698
+ $permission_dialog_url = '';
4699
+ $service_worker_url = '';
4700
+ // HTTPS sites
4701
+ $onesignal_domain = trailingslashit( esc_url( home_url() ) ) ;
4702
+ $onesignal_app_id = $redux_builder_amp['ampforwp-one-signal-app-id'];
4703
+ $helper_iframe_url = $onesignal_domain .'amphtml-helper-frame.html?appId=' . $onesignal_app_id;
4704
+
4705
+ $permission_dialog_url = $onesignal_domain .'amp-permission-dialog.html?appId=' . $onesignal_app_id;
4706
+
4707
+ $service_worker_url = $onesignal_domain .'OneSignalSDKWorker.js?appId=' . $onesignal_app_id;
4708
+ // HTTP sites
4709
+ if(isset($redux_builder_amp['ampforwp-onesignal-http-site'] ) && $redux_builder_amp['ampforwp-onesignal-http-site'] ){
4710
+ $onesignal_subdomain = $redux_builder_amp['ampforwp-onesignal-subdomain'];
4711
+ $helper_iframe_url = 'https://' . $onesignal_subdomain . '.os.tc/amp/helper_frame?appId=' . $onesignal_app_id . '';
4712
+ $permission_dialog_url = 'https://' . $onesignal_subdomain . '.os.tc/amp/permission_dialog?appId=' . $onesignal_app_id . '';
4713
+ $service_worker_url = 'https://' . $onesignal_subdomain . '.os.tc/OneSignalSDKWorker.js?appId=' . $onesignal_app_id . '';
4714
+ } ?>
4715
+ <amp-web-push
4716
+ id="amp-web-push"
4717
+ layout="nodisplay"
4718
+ helper-iframe-url="<?php echo esc_url($helper_iframe_url); ?>"
4719
+ permission-dialog-url="<?php echo esc_url($permission_dialog_url); ?>"
4720
+ service-worker-url="<?php echo esc_url($service_worker_url); ?>">
4721
+ </amp-web-push>
4722
+ <?php
4723
+ }
4724
+ }
4725
+ }
4726
+ // OneSignal Push Notifications Widget
4727
+ add_action('ampforwp_after_post_content', 'ampforwp_onesignal_notifications_widget');
4728
+ if( ! function_exists(' ampforwp_onesignal_notifications_widget') ){
4729
+ function ampforwp_onesignal_notifications_widget(){
4730
+ global $redux_builder_amp;
4731
+ if(isset($redux_builder_amp['ampforwp-web-push-onesignal']) && $redux_builder_amp['ampforwp-web-push-onesignal'] ){ ?>
4732
+ <!-- A subscription widget -->
4733
+ <amp-web-push-widget visibility="unsubscribed" layout="fixed" width="245" height="45">
4734
+ <button class="subscribe" on="tap:amp-web-push.subscribe">
4735
+ <amp-img
4736
+ class="subscribe-icon"
4737
+ width="24"
4738
+ height="24"
4739
+ layout="fixed"
4740
+ src="data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Vic2NyaWJlLWljb24iIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xMS44NCAxOS44ODdIMS4yMnMtLjk0Ny0uMDk0LS45NDctLjk5NWMwLS45LjgwNi0uOTQ4LjgwNi0uOTQ4czMuMTctMS41MTcgMy4xNy0yLjYwOGMwLTEuMDktLjUyLTEuODUtLjUyLTYuMzA1czIuODUtNy44NyA2LjI2LTcuODdjMCAwIC40NzMtMS4xMzQgMS44NS0xLjEzNCAxLjMyNSAwIDEuOCAxLjEzNyAxLjggMS4xMzcgMy40MTMgMCA2LjI2IDMuNDE4IDYuMjYgNy44NyAwIDQuNDYtLjQ3NyA1LjIyLS40NzcgNi4zMSAwIDEuMDkgMy4xNzYgMi42MDcgMy4xNzYgMi42MDdzLjgxLjA0Ni44MS45NDdjMCAuODUzLS45OTYuOTk1LS45OTYuOTk1SDExLjg0ek04IDIwLjk3N2g3LjExcy0uNDkgMi45ODctMy41MyAyLjk4N1M4IDIwLjk3OCA4IDIwLjk3OHoiIGZpbGw9IiNGRkYiLz48L3N2Zz4=">
4741
+ </amp-img>
4742
+ Subscribe to updates
4743
+ </button>
4744
+ </amp-web-push-widget>
4745
+ <!-- An unsubscription widget -->
4746
+ <amp-web-push-widget visibility="subscribed" layout="fixed" width="230" height="45">
4747
+ <button class="unsubscribe" on="tap:amp-web-push.unsubscribe">Unsubscribe from updates</button>
4748
+ </amp-web-push-widget>
4749
+ <?php }
4750
+ }
4751
+ }
4752
+ //OneSignal Push Notifications Script
4753
+ add_filter('amp_post_template_data', 'ampforwp_onesignal_notifications_script');
4754
+ if(!function_exists('ampforwp_onesignal_notifications_script')){
4755
+ function ampforwp_onesignal_notifications_script( $data ){
4756
+ global $redux_builder_amp;
4757
+ if(isset($redux_builder_amp['ampforwp-web-push-onesignal']) && $redux_builder_amp['ampforwp-web-push-onesignal'] ){
4758
+ if ( empty( $data['amp_component_scripts']['amp-web-push'] ) ) {
4759
+ $data['amp_component_scripts']['amp-web-push'] = 'https://cdn.ampproject.org/v0/amp-web-push-0.1.js';
4760
+ }
4761
+ }
4762
+ return $data;
4763
+ }
4764
+ }
4765
+ // OneSignal Push Notifications Styling
4766
+ add_action('amp_post_template_css' , 'ampforwp_onesignal_notifications_styling' , 99);
4767
+ if(!function_exists('ampforwp_onesignal_notifications_styling')){
4768
+ function ampforwp_onesignal_notifications_styling(){
4769
+ global $redux_builder_amp;
4770
+ if(isset($redux_builder_amp['ampforwp-web-push-onesignal']) && $redux_builder_amp['ampforwp-web-push-onesignal'] ){ ?>
4771
+ amp-web-push-widget button.subscribe { display: inline-flex; align-items: center; border-radius: 2px; border: 0; box-sizing: border-box; margin: 0; padding: 10px 15px; cursor: pointer; outline: none; font-size: 15px; font-weight: 400; background: #4A90E2; color: white; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.5); -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}
4772
+ amp-web-push-widget button.subscribe .subscribe-icon {margin-right: 10px;}
4773
+ amp-web-push-widget button.subscribe:active {transform: scale(0.99);}
4774
+ amp-web-push-widget button.unsubscribe {display: inline-flex; align-items: center; justify-content: center; height: 45px; border: 0; margin: 0; cursor: pointer; outline: none; font-size: 15px; font-weight: 400; background: #4a90e2; color: #fff; -webkit-tap-highlight-color: rgba(0,0,0,0); box-sizing: border-box; padding: 10px 15px;}
4775
+ amp-web-push-widget.amp-invisible{ display:none;}
4776
+ <?php }
4777
+ }
4778
+ }
4779
+ // 95. Modify menu link attributes for SiteNavigationElement Schema Markup #1229 #1345
4780
+ add_filter( 'nav_menu_link_attributes', 'ampforwp_nav_menu_link_attributes', 10, 3 );
4781
+ if( ! function_exists( 'ampforwp_nav_menu_link_attributes' ) ) {
4782
+ function ampforwp_nav_menu_link_attributes( $atts, $item, $args ) {
4783
+ // Manipulate link attributes
4784
+ $atts['itemprop'] = "url";
4785
+ return $atts;
4786
+ }
4787
+ }
4788
+
4789
+ // 96. ampforwp_is_front_page() ampforwp_is_home() and ampforwp_is_blog is created
4790
+ function ampforwp_is_front_page(){
4791
+ global $redux_builder_amp;
4792
+
4793
+ // Reading settings me frontpage set
4794
+ $get_front_page_reading_settings = get_option('page_on_front');
4795
+
4796
+ // Homepage support on
4797
+ $get_amp_homepage_settings = $redux_builder_amp['ampforwp-homepage-on-off-support'];
4798
+
4799
+ // AMP Custom front page from AMP panel
4800
+ $get_custom_frontpage_settings = $redux_builder_amp['amp-frontpage-select-option'];
4801
+
4802
+ // Frontpage id should be assigned
4803
+ $get_amp_custom_frontpage_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
4804
+
4805
+ // TRUE: When we have "Your latest posts" in reading settings and custom frontpage in amp
4806
+ if ( 'posts' == get_option( 'show_on_front') && is_home() && $get_amp_homepage_settings && $get_custom_frontpage_settings)
4807
+ return true;
4808
+
4809
+ // TRUE: When we have " A static page" in reading settings and custom frontpage in amp
4810
+ if ( 'page' == get_option( 'show_on_front') && is_home() && $get_front_page_reading_settings && $get_amp_homepage_settings && $get_custom_frontpage_settings && $get_amp_custom_frontpage_id) {
4811
+
4812
+ $current_page = get_queried_object();
4813
+ if ( $current_page ) {
4814
+ $current_page = $current_page->ID;
4815
+ }
4816
+ if ( get_option( 'page_for_posts') == $current_page ) {
4817
+ return false ;
4818
+ }
4819
+ return true;
4820
+ }
4821
+
4822
+ return false ;
4823
+
4824
+ }
4825
+
4826
+ function ampforwp_is_home(){
4827
+ global $redux_builder_amp;
4828
+
4829
+ $output = false;
4830
+ if ( ampforwp_is_front_page() == false && ampforwp_is_blog () == false && is_home() ) {
4831
+ $output = true;
4832
+ }
4833
+ return $output;
4834
+ }
4835
+
4836
+ function ampforwp_is_blog(){
4837
+ $get_blog_details = "";
4838
+ $get_blog_details = ampforwp_get_blog_details();
4839
+
4840
+ return $get_blog_details ;
4841
  }