AMP for WP – Accelerated Mobile Pages - Version 0.9.56

Version Description

(31st July 2017) = * View more details on https://ampforwp.com/page-break-in-amp/ * Page Break / NextPage (Pagination) Support Added #834 #857 (Improvement) * Show/Hide AMP for Categories of Posts or All posts #872 (Improvement) * Adding analytics capabilities to Instant Articles #978 * JetPack Plugin Conflict Solved #971 * Social sharing code improved. amp-social-share js is getting added for line and WhatsApp social share #981 * Code improvement for rel canonicals(home and archive) * Perfect SEO URL + Yoast SEO Compatibility #982 * Some styling for tags to show up properly * Undefined index notices #960 * Non-amp category pages should redirect to non-amp pages if turned off from Hiding AMP #999 * Page builder text and button module issues #972 * Documentation links updated in the Options panel

Download this release

Release Info

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

Code changes from version 0.9.55 to 0.9.56

README.md CHANGED
@@ -1,10 +1,10 @@
1
  === AMP for WP - Accelerated Mobile Pages ===
2
  Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
3
- Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google, plugin, SEO, Instant Articles
4
  Donate link: https://www.paypal.me/Kaludi/5
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
- Stable tag: 0.9.54
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -29,11 +29,12 @@ Bug reports for AMP for WP are [welcomed on GitHub](https://github.com/ahmedkalu
29
 
30
  = Features: =
31
 
 
32
  * NEW - Contact Form 7 Support [More Info](https://ampforwp.com/contact-form-7/)
33
  * NEW - Page Builder for AMP! [Watch the Demo](http://ampforwp.com/demo/#pagebuilder) | [How to](https://ampforwp.com/tutorials/page-builder/)
34
- * NEW - Github Gist Support
35
  * NEW - Facebook Comments Support
36
- * NEW - Email Opt-in Subscription form support in AMP added
 
37
  * Call to Action boxes and notification bars
38
  * 9 Advertisement sizes - 2 More AD slots added recently
39
  * Comments Forms in AMP.
@@ -136,6 +137,40 @@ You can contact me using this url: http://ampforwp.com/contact/
136
 
137
  == Changelog ==
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  = 0.9.54 (4th July 2017) =
140
  * View more details on https://ampforwp.com/new/
141
  * Facebook Instant Articles Support #862
1
  === AMP for WP - Accelerated Mobile Pages ===
2
  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/5
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
+ Stable tag: 0.9.56
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
29
 
30
  = Features: =
31
 
32
+ * NEW - Page Break / NextPage (Pagination) Support
33
  * NEW - Contact Form 7 Support [More Info](https://ampforwp.com/contact-form-7/)
34
  * NEW - Page Builder for AMP! [Watch the Demo](http://ampforwp.com/demo/#pagebuilder) | [How to](https://ampforwp.com/tutorials/page-builder/)
 
35
  * NEW - Facebook Comments Support
36
+ * Github Gist Support
37
+ * Email Opt-in Subscription form support in AMP added
38
  * Call to Action boxes and notification bars
39
  * 9 Advertisement sizes - 2 More AD slots added recently
40
  * Comments Forms in AMP.
137
 
138
  == Changelog ==
139
 
140
+ = 0.9.56 (31st July 2017) =
141
+ * View more details on https://ampforwp.com/page-break-in-amp/
142
+ * Page Break / NextPage (Pagination) Support Added #834 #857 (Improvement)
143
+ * Show/Hide AMP for Categories of Posts or All posts #872 (Improvement)
144
+ * JetPack Plugin Conflict Solved #971
145
+ * Social sharing code improved. amp-social-share js is getting added for line and WhatsApp social share #981
146
+ * Code improvement for rel canonicals(home and archive)
147
+ * Perfect SEO URL + Yoast SEO Compatibility #982
148
+ * Some styling for tags to show up properly
149
+ * Undefined index notices #960
150
+ * Non-amp category pages should redirect to non-amp pages if turned off from Hiding AMP #999
151
+ * Page builder text and button module issues #972
152
+ * Documentation links updated in the Options panel
153
+
154
+ = 0.9.55 (13th July 2017) =
155
+ * View more details on https://ampforwp.com/0-9-55-released-improvement-update-61st-update/
156
+ * Disqus Comments show up even when disabled per post #931
157
+ * Unnecessary: Adding the Markup for AMP Woocommerce latest Products #929
158
+ * H3 inside OL in Related-Posts.php #930
159
+ * Advertisement Options in Instant Articles #943
160
+ * Incompatible with bootstrap plugin #525
161
+ * Error in tag and category links #934
162
+ * Pagebuilder Button module link had issues #951
163
+ * Unnecessary: Adding the Markup for AMP Woocommerce latest Products #929
164
+ * WPtouch Pro Compatibility Issues #927
165
+ * Better scripts compatibility in Single of post types #757
166
+ * Instant Articles Error: "The HTML element does not contain any text" #949
167
+ * added a filter in all the dates so a user can change the date format and modify #962
168
+ * Design3 Menu Arrows are clickable along with the links #952
169
+
170
+
171
+ = 0.9.54.2 (4th July 2017) =
172
+ * Minor bug post 0.9.54 bug fixed
173
+
174
  = 0.9.54 (4th July 2017) =
175
  * View more details on https://ampforwp.com/new/
176
  * Facebook Instant Articles Support #862
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.55
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
@@ -17,7 +17,7 @@ define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
17
  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_VERSION','0.9.55');
21
  // any changes to AMP_QUERY_VAR should be refelected here
22
  define('AMPFORWP_AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
23
 
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.56
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
17
  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_VERSION','0.9.56');
21
  // any changes to AMP_QUERY_VAR should be refelected here
22
  define('AMPFORWP_AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
23
 
classes/class-ampforwp-youtube-embed.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php #971
2
+ require_once AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' ;
3
+
4
+ // Much of this class is borrowed from Jetpack embeds
5
+ class AMPforWP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
6
+ const SHORT_URL_HOST = 'youtu.be';
7
+ // Only handling single videos. Playlists are handled elsewhere.
8
+ const URL_PATTERN = '#https?://(?:www\.)?(?:youtube.com/(?:v/|e/|embed/|watch[/\#?])|youtu\.be/).*#i';
9
+ const RATIO = 0.5625;
10
+
11
+ protected $DEFAULT_WIDTH = 600;
12
+ protected $DEFAULT_HEIGHT = 338;
13
+
14
+ private static $script_slug = 'amp-youtube';
15
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-youtube-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-youtube', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
29
+ add_shortcode( 'youtube', array( $this, 'shortcode' ) );
30
+ }
31
+
32
+ public function unregister_embed() {
33
+ wp_embed_unregister_handler( 'amp-youtube', -1 );
34
+ remove_shortcode( 'youtube' );
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
+ $url = false;
47
+ $video_id = false;
48
+ if ( isset( $attr[0] ) ) {
49
+ $url = ltrim( $attr[0] , '=' );
50
+ } elseif ( function_exists ( 'ampforwp_youtube_shortcode' ) ) {
51
+ $url = ampforwp_youtube_shortcode( $attr );
52
+ }
53
+
54
+ if ( empty( $url ) ) {
55
+ return '';
56
+ }
57
+
58
+ $video_id = $this->get_video_id_from_url( $url );
59
+
60
+ return $this->render( array(
61
+ 'url' => $url,
62
+ 'video_id' => $video_id,
63
+ ) );
64
+ }
65
+
66
+
67
+ public function oembed( $matches, $attr, $url, $rawattr ) {
68
+ return $this->shortcode( array( $url ) );
69
+ }
70
+
71
+ public function render( $args ) {
72
+ $args = wp_parse_args( $args, array(
73
+ 'video_id' => false,
74
+ ) );
75
+
76
+ if ( empty( $args['video_id'] ) ) {
77
+ return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
78
+ }
79
+
80
+ $this->did_convert_elements = true;
81
+
82
+ return AMP_HTML_Utils::build_tag(
83
+ 'amp-youtube',
84
+ array(
85
+ 'data-videoid' => $args['video_id'],
86
+ 'layout' => 'responsive',
87
+ 'width' => $this->args['width'],
88
+ 'height' => $this->args['height'],
89
+ )
90
+ );
91
+ }
92
+
93
+ private function get_video_id_from_url( $url ) {
94
+ $video_id = false;
95
+ $parsed_url = parse_url( $url );
96
+
97
+ if ( self::SHORT_URL_HOST === substr( $parsed_url['host'], -strlen( self::SHORT_URL_HOST ) ) ) {
98
+ // youtu.be/{id}
99
+ $parts = explode( '/', $parsed_url['path'] );
100
+ if ( ! empty( $parts ) ) {
101
+ $video_id = $parts[1];
102
+ }
103
+ } else {
104
+ // ?v={id} or ?list={id}
105
+ parse_str( $parsed_url['query'], $query_args );
106
+
107
+ if ( isset( $query_args['v'] ) ) {
108
+ $video_id = $this->sanitize_v_arg( $query_args['v'] );
109
+ }
110
+ }
111
+
112
+ if ( empty( $video_id ) ) {
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
+ }
120
+
121
+ return $video_id;
122
+ }
123
+
124
+ private function sanitize_v_arg( $value ) {
125
+ // Deal with broken params like `?v=123?rel=0`
126
+ if ( false !== strpos( $value, '?' ) ) {
127
+ $value = strtok( $value, '?' );
128
+ }
129
+
130
+ return $value;
131
+ }
132
+ }
includes/admin-style.css CHANGED
@@ -21,7 +21,7 @@ body #toplevel_page_amp_options .wp-menu-image{
21
  background-size: 20px auto;
22
  }
23
  .amp_content_builder .redux-group-tab-link-a span:after {
24
- content: "NEW";
25
  color: #fff;
26
  font-size: 10px;
27
  background: #4452a7;
21
  background-size: 20px auto;
22
  }
23
  .amp_content_builder .redux-group-tab-link-a span:after {
24
+ /* content: "NEW";*/
25
  color: #fff;
26
  font-size: 10px;
27
  background: #4452a7;
includes/includes.php CHANGED
@@ -20,20 +20,20 @@
20
  add_action( 'init', 'ampforwp_menu' );
21
  }
22
 
23
- // 1.2 Footer Menu
24
- global $redux_builder_amp;
25
- if ( $redux_builder_amp['amp-design-selector'] == 1 ||
26
- $redux_builder_amp['amp-design-selector'] == 2 ||
27
- $redux_builder_amp['amp-design-selector'] == 3) {
28
- add_action( 'init', 'ampforwp_footermenu' );
29
- }
30
  if (! function_exists( 'ampforwp_footermenu') ) {
31
  function ampforwp_footermenu() {
32
- register_nav_menus(
33
- array(
34
- 'amp-footer-menu' => __( 'AMP Footer Menu','accelerated-mobile-pages' ),
35
- )
36
- );
 
 
 
 
 
37
  }
38
  }
39
 
20
  add_action( 'init', 'ampforwp_menu' );
21
  }
22
 
23
+ // 1.2 Footer Menu
24
+ add_action( 'init', 'ampforwp_footermenu' );
 
 
 
 
 
25
  if (! function_exists( 'ampforwp_footermenu') ) {
26
  function ampforwp_footermenu() {
27
+ global $redux_builder_amp;
28
+ if ( $redux_builder_amp['amp-design-selector'] == 1 ||
29
+ $redux_builder_amp['amp-design-selector'] == 2 ||
30
+ $redux_builder_amp['amp-design-selector'] == 3 ) {
31
+ register_nav_menus(
32
+ array(
33
+ 'amp-footer-menu' => __( 'AMP Footer Menu','accelerated-mobile-pages' ),
34
+ )
35
+ );
36
+ }
37
  }
38
  }
39
 
includes/modules/ampforwp-button.php CHANGED
@@ -74,8 +74,8 @@ class AMPFORWP_Button_Widget extends WP_Widget {
74
  } elseif( $feature['size'] == '3' ){
75
  $size = "l_btn";
76
  }
77
- //Corrected the URL in button module #951
78
- $output .= '<a href=" '. $feature['url'] .'" class="' . $size . '" target="' . $target . '" >'. $feature['title'] .'</a>';
79
  }
80
  $output .= '</div>';
81
 
74
  } elseif( $feature['size'] == '3' ){
75
  $size = "l_btn";
76
  }
77
+ //Corrected the URL in button module and breaking of desing and link issue #951 & #972
78
+ $output .= '<a href="'.esc_url($feature['url']).'" class="' . $size . '" target="' . $target . '" >'. $feature['title'] .'</a>';
79
  }
80
  $output .= '</div>';
81
 
includes/options/admin-config.php CHANGED
@@ -256,7 +256,7 @@ $args = array(
256
  'page_title' => __('Accelerated Mobile Pages Options','accelerated-mobile-pages'),
257
  'display_version' => AMPFORWP_VERSION,
258
  'update_notice' => false,
259
- 'intro_text' => '<a href="https://ampforwp.com/help/#utm_source=options-panel&utm_medium=help_link&utm_campaign=AMP%20Plugin" target="_blank">'.__('Help','accelerated-mobile-pages').'</a> | <a href="http://ampforwp.com/tutorials/#utm_source=options-panel&utm_medium=tuts_link_btn&utm_campaign=AMP%20Plugin" target="_blank">'.__('Tutorials','accelerated-mobile-pages').'</a> <a class="premium_features_btn" href="http://ampforwp.com/extensions/#utm_source=options-panel&utm_medium=view_premium_features_btn&utm_campaign=AMP%20Plugin">VIEW PREMIUM FEATURES</a> ',
260
  'global_variable' => '', // Set a different name for your global variable other than the opt_name
261
  'dev_mode' => false, // Show the time the page took to load, etc
262
  'customizer' => false, // Enable basic customizer support,
@@ -380,7 +380,7 @@ Redux::setArgs( "redux_builder_amp", $args );
380
  . '<p><strong>' . __( '1. <a href="http://ampforwp.com/help/" target="_blank">User Documentation</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'The AMP for WP plugin is easy to setup but we have some tutorials and guides prepared for you which will help you dive deep with the plugin.' ) . '</p>'
381
  . '<p><strong>' . __( '2. <a href="https://ampforwp.com/tutorials/" target="_blank">Tutorials</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We’re bunch of passionate people that are dedicated towards helping our users. We have prepared bunch of tutorials for you' ) . '</p>'
382
  . '<p><strong>' . __( '3. <a href="https://ampforwp.com/help/#extend" target="_blank">Developer Docs</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We have created special documentations for developers and semi technical users who are willing to modify the plugin according to their own needs.' ) . '</p>'
383
- . '<p><strong>' . __( '4. <a href="admin.php?page=amp_options&tab=14" target="_blank">Fixing AMP Validation Errors</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We will personally take care that your website’s AMP version is perfectly validated. We will make sure that your AMP version gets approved and indexed by Google Webmaster Tools properly and we will even keep an eye on AMP updates from Google and implement them into your website.' ) . '</p>'
384
  . '<p><strong>' . __( '5. <a href="https://ampforwp.com/help/#support-forum" target="_blank">Community Support Forum</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We have a special community support forum where you can ask us questions and get help about your AMP related questions. Delivering a good user experience means alot to us and so we try our best to reply each and every question that gets asked.' ) . '</p>'
385
  . '<p><strong>' . __( '6. <a href="https://ampforwp.com/help/#contact" target="_blank">Hire Us / Other queries</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We try to answer each and every email, so remember to give us some time. For any other queries, please use the contact form. Please be descriptive as possible.' ) . '</p>'
386
  . '<p><strong>' . __( '7. <a href="http://ampforwp.com/new/" target="_blank"> What\'s New in this Version?</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'If you want to know whats new in the latest version of the plugin, then please use this link. ') . '</p>'
@@ -439,19 +439,6 @@ Redux::setArgs( "redux_builder_amp", $args );
439
  'default' => 1,
440
  'desc' => __( 'Re-Save permalink if you make changes in this option, please have a look <a href="https://ampforwp.com/flush-rewrite-urls/">here</a> on how to do it', 'accelerated-mobile-pages' ),
441
  ),
442
- array(
443
- 'id' => 'amp-pages-meta-default',
444
- 'type' => 'select',
445
- 'title' => __( 'Individual AMP Page (Bulk Edit)', 'accelerated-mobile-pages' ),
446
- 'subtitle' => __( 'Allows you to Show or Hide AMP from All pages, so it can be changed individually later. This option will change the Default value of AMP metabox in Pages', 'accelerated-mobile-pages' ),
447
- 'desc' => __( 'NOTE: Changes will overwrite the previous settings.', 'accelerated-mobile-pages' ),
448
- 'options' => array(
449
- 'show' => __('Show by Default', 'accelerated-mobile-pages' ),
450
- 'hide' => __('Hide by default', 'accelerated-mobile-pages' ),
451
- ),
452
- 'default' => 'show',
453
- 'required'=>array('amp-on-off-for-all-pages','=','1'),
454
- ),
455
 
456
 
457
  // array(
@@ -2361,30 +2348,104 @@ Redux::setArgs( "redux_builder_amp", $args );
2361
  )
2362
  ) );
2363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2364
 
2365
- // // CSS
2366
- // Redux::setSection( $opt_name, array(
2367
- // 'title' => __( 'Custom CSS Editor', 'accelerated-mobile-pages' ),
2368
- // // 'desc' => __( 'For full documentation on this field, visit: ', 'accelerated-mobile-pages' ) . '<a href="http://docs.reduxframework.com/core/fields/textarea/" target="_blank">http://docs.reduxframework.com/core/fields/textarea/</a>',
2369
- // 'id' => 'opt-css-editor',
2370
- // 'subsection' => true,
2371
- // 'fields' => array(
2372
- // array(
2373
- // 'id' => 'css_editor',
2374
- // 'type' => 'ace_editor',
2375
- // 'title' => __('Custom CSS', 'accelerated-mobile-pages'),
2376
- // 'subtitle' => __('You can customize the Stylesheet of the AMP version by using this option.', 'accelerated-mobile-pages'),
2377
- // 'mode' => 'css',
2378
- // 'theme' => 'monokai',
2379
- // 'desc' => '',
2380
- // 'default' => "/******* Paste your Custom CSS in this Editor *******/"
2381
- // ),
2382
- // )
2383
- // ) );
2384
- //
2385
-
2386
-
2387
-
 
2388
 
2389
  // Advance Settings SECTION
2390
  Redux::setSection( $opt_name, array(
@@ -2456,60 +2517,7 @@ Redux::setSection( $opt_name, array(
2456
 
2457
  ),
2458
 
2459
- ) );
2460
-
2461
- function fb_instant_article(){
2462
- $feedname = '';
2463
- $fb_instant_article_feed = '';
2464
- $feedname = 'instant_articles';
2465
- $fb_instant_article_feed = trailingslashit( site_url() ).$feedname ;
2466
- return esc_url( $fb_instant_article_feed );
2467
- }
2468
- // Facebook Instant Articles
2469
- Redux::setSection( $opt_name, array(
2470
- 'title' => __( 'Facebook Instant Articles', 'accelerated-mobile-pages' ),
2471
- 'id' => 'fb-instant-article',
2472
- 'subsection' => true,
2473
- 'fields' => array(
2474
- array(
2475
- 'id' =>'fb-instant-article-switch',
2476
- 'type' => 'switch',
2477
- 'title' => __('Facebook Instant Articles Support', 'accelerated-mobile-pages'),
2478
- 'default' => 0,
2479
- 'true' => 'true',
2480
- 'false' => 'false',
2481
- 'desc' => __('Re-Save permalink when you enable this option, please have a look <a href="https://ampforwp.com/flush-rewrite-urls/">here</a> on how to do it', 'accelerated-mobile-pages'),
2482
- ),
2483
- array(
2484
- 'id' => 'fb-instant-article-feed-url',
2485
- 'type' => 'info',
2486
- 'style' => 'critical',
2487
- 'desc' => fb_instant_article(),
2488
- 'title' => __('Facebook Instant Articles Feed URL', 'accelerated-mobile-pages'),
2489
- 'required' => array('fb-instant-article-switch', '=', 1)
2490
- ),
2491
- array(
2492
- 'id' => 'fb-instant-article-ads',
2493
- 'type' => 'switch',
2494
- 'title' => __('Advertisement', 'accelerated-mobile-pages'),
2495
- 'default' => 0,
2496
- 'true' => 'true',
2497
- 'false' => 'false',
2498
- 'desc' => __('Switch this on to enable advertising on Instant Article pages.', 'accelerated-mobile-pages'),
2499
- 'required' => array('fb-instant-article-switch', '=', 1)
2500
- ),
2501
- array(
2502
- 'id' => 'fb-instant-article-ad-id',
2503
- 'type' => 'text',
2504
- 'title' => __('Enter your Audience Network Placement ID', 'accelerated-mobile-pages'),
2505
- 'subtitle' => __('You can find out more about this <a href="https://developers.facebook.com/docs/instant-articles/monetization/audience-network">here</a>. ', 'accelerated-mobile-pages'),
2506
- 'required' => array('fb-instant-article-ads', '=', 1)
2507
- ),
2508
- ),
2509
- )
2510
- );
2511
-
2512
-
2513
  // Extension Section
2514
  Redux::setSection( $opt_name, array(
2515
  'title' => __( 'Extensions', 'accelerated-mobile-pages' ),
256
  'page_title' => __('Accelerated Mobile Pages Options','accelerated-mobile-pages'),
257
  'display_version' => AMPFORWP_VERSION,
258
  'update_notice' => false,
259
+ 'intro_text' => '<a href="http://ampforwp.com/tutorials/#utm_source=options-panel&utm_medium=tuts_link_btn&utm_campaign=AMP%20Plugin" target="_blank">'.__('View Documentation','accelerated-mobile-pages').'</a> | <a href="http://ampforwp.com/support/#utm_source=options-panel&utm_medium=contact_link_btn&utm_campaign=AMP%20Plugin" target="_blank">'.__('Contact','accelerated-mobile-pages').'</a> <a class="premium_features_btn" href="http://ampforwp.com/extensions/#utm_source=options-panel&utm_medium=view_premium_features_btn&utm_campaign=AMP%20Plugin">VIEW PREMIUM FEATURES</a> ',
260
  'global_variable' => '', // Set a different name for your global variable other than the opt_name
261
  'dev_mode' => false, // Show the time the page took to load, etc
262
  'customizer' => false, // Enable basic customizer support,
380
  . '<p><strong>' . __( '1. <a href="http://ampforwp.com/help/" target="_blank">User Documentation</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'The AMP for WP plugin is easy to setup but we have some tutorials and guides prepared for you which will help you dive deep with the plugin.' ) . '</p>'
381
  . '<p><strong>' . __( '2. <a href="https://ampforwp.com/tutorials/" target="_blank">Tutorials</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We’re bunch of passionate people that are dedicated towards helping our users. We have prepared bunch of tutorials for you' ) . '</p>'
382
  . '<p><strong>' . __( '3. <a href="https://ampforwp.com/help/#extend" target="_blank">Developer Docs</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We have created special documentations for developers and semi technical users who are willing to modify the plugin according to their own needs.' ) . '</p>'
383
+ . '<p><strong>' . __( '4. <a href="https://ampforwp.com/priority-support/" target="_blank">Fixing AMP Validation Errors</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We will personally take care that your website’s AMP version is perfectly validated. We will make sure that your AMP version gets approved and indexed by Google Webmaster Tools properly and we will even keep an eye on AMP updates from Google and implement them into your website.' ) . '</p>'
384
  . '<p><strong>' . __( '5. <a href="https://ampforwp.com/help/#support-forum" target="_blank">Community Support Forum</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We have a special community support forum where you can ask us questions and get help about your AMP related questions. Delivering a good user experience means alot to us and so we try our best to reply each and every question that gets asked.' ) . '</p>'
385
  . '<p><strong>' . __( '6. <a href="https://ampforwp.com/help/#contact" target="_blank">Hire Us / Other queries</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'We try to answer each and every email, so remember to give us some time. For any other queries, please use the contact form. Please be descriptive as possible.' ) . '</p>'
386
  . '<p><strong>' . __( '7. <a href="http://ampforwp.com/new/" target="_blank"> What\'s New in this Version?</a>: ', 'accelerated-mobile-pages' ) . '</strong>' . __( 'If you want to know whats new in the latest version of the plugin, then please use this link. ') . '</p>'
439
  'default' => 1,
440
  'desc' => __( 'Re-Save permalink if you make changes in this option, please have a look <a href="https://ampforwp.com/flush-rewrite-urls/">here</a> on how to do it', 'accelerated-mobile-pages' ),
441
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
442
 
443
 
444
  // array(
2348
  )
2349
  ) );
2350
 
2351
+ function fb_instant_article(){
2352
+ $feedname = '';
2353
+ $fb_instant_article_feed = '';
2354
+ $feedname = 'instant_articles';
2355
+ $fb_instant_article_feed = trailingslashit( site_url() ).$feedname ;
2356
+ return esc_url( $fb_instant_article_feed );
2357
+ }
2358
+ // Facebook Instant Articles
2359
+ Redux::setSection( $opt_name, array(
2360
+ 'title' => __( 'Facebook Instant Articles', 'accelerated-mobile-pages' ),
2361
+ 'id' => 'fb-instant-article',
2362
+ 'subsection' => true,
2363
+ 'fields' => array(
2364
+ array(
2365
+ 'id' =>'fb-instant-article-switch',
2366
+ 'type' => 'switch',
2367
+ 'title' => __('Facebook Instant Articles Support', 'accelerated-mobile-pages'),
2368
+ 'default' => 0,
2369
+ 'true' => 'true',
2370
+ 'false' => 'false',
2371
+ 'desc' => __('Re-Save permalink when you enable this option, please have a look <a href="https://ampforwp.com/flush-rewrite-urls/">here</a> on how to do it', 'accelerated-mobile-pages'),
2372
+ ),
2373
+ array(
2374
+ 'id' => 'fb-instant-article-feed-url',
2375
+ 'type' => 'info',
2376
+ 'style' => 'critical',
2377
+ 'desc' => fb_instant_article(),
2378
+ 'title' => __('Facebook Instant Articles Feed URL', 'accelerated-mobile-pages'),
2379
+ 'required' => array('fb-instant-article-switch', '=', 1)
2380
+ ),
2381
+ array(
2382
+ 'id' => 'fb-instant-article-ads',
2383
+ 'type' => 'switch',
2384
+ 'title' => __('Advertisement', 'accelerated-mobile-pages'),
2385
+ 'default' => 0,
2386
+ 'true' => 'true',
2387
+ 'false' => 'false',
2388
+ 'desc' => __('Switch this on to enable advertising on Instant Article pages.', 'accelerated-mobile-pages'),
2389
+ 'required' => array('fb-instant-article-switch', '=', 1)
2390
+ ),
2391
+ array(
2392
+ 'id' => 'fb-instant-article-ad-id',
2393
+ 'type' => 'text',
2394
+ 'title' => __('Enter your Audience Network Placement ID', 'accelerated-mobile-pages'),
2395
+ 'subtitle' => __('You can find out more about this <a href="https://developers.facebook.com/docs/instant-articles/monetization/audience-network">here</a>. ', 'accelerated-mobile-pages'),
2396
+ 'required' => array('fb-instant-article-ads', '=', 1)
2397
+ ),
2398
+ array(
2399
+ 'id' => 'fb-instant-article-analytics',
2400
+ 'type' => 'switch',
2401
+ 'title' => __('Analytics', 'accelerated-mobile-pages'),
2402
+ 'default' => 0,
2403
+ 'true' => 'true',
2404
+ 'false' => 'false',
2405
+ 'desc' => __('Switch this on to enable analytics on Instant Article pages.', 'accelerated-mobile-pages'),
2406
+ 'required' => array('fb-instant-article-switch', '=', 1)
2407
+ ),
2408
+ array(
2409
+ 'id' => 'fb-instant-article-analytics-code',
2410
+ 'type' => 'textarea',
2411
+ 'title' => __('Enter your Analytics script code', 'accelerated-mobile-pages'),
2412
+ 'subtitle' => __('Do not enter iframe tag. Find out more about support <a href="https://developers.facebook.com/docs/instant-articles/analytics">here</a> ', 'accelerated-mobile-pages'),
2413
+ 'required' => array('fb-instant-article-analytics', '=', 1)
2414
+ ),
2415
+ ),
2416
+ )
2417
+ );
2418
+ Redux::setSection( $opt_name, array(
2419
+ 'title' => __( 'Hide AMP Bulk Tools', 'accelerated-mobile-pages' ),
2420
+ 'id' => 'hide-amp-section',
2421
+ 'subsection' => true,
2422
+ 'desc' => 'Here are some Advanced options to help you exclude AMP from your prefered pages',
2423
+ 'fields' => array(
2424
 
2425
+ array(
2426
+ 'id' => 'amp-pages-meta-default',
2427
+ 'type' => 'select',
2428
+ 'title' => __( 'Individual AMP Page (Bulk Edit)', 'accelerated-mobile-pages' ),
2429
+ 'subtitle' => __( 'Allows you to Show or Hide AMP from All pages, so it can be changed individually later. This option will change the Default value of AMP metabox in Pages', 'accelerated-mobile-pages' ),
2430
+ 'desc' => __( 'NOTE: Changes will overwrite the previous settings.', 'accelerated-mobile-pages' ),
2431
+ 'options' => array(
2432
+ 'show' => __('Show by Default', 'accelerated-mobile-pages' ),
2433
+ 'hide' => __('Hide by default', 'accelerated-mobile-pages' ),
2434
+ ),
2435
+ 'default' => 'show',
2436
+ 'required'=>array('amp-on-off-for-all-pages','=','1'),
2437
+ ),
2438
+ array(
2439
+ 'id' =>'hide-amp-categories',
2440
+ 'type' => 'checkbox',
2441
+ 'title' => __('Select Categories to Hide AMP'),
2442
+ 'subtitle' => __( 'Hide AMP from all the posts of a selected category.', 'accelerated-mobile-pages' ),
2443
+ 'default' => 0,
2444
+ 'data' => 'categories',
2445
+ ),
2446
+ )
2447
+ )
2448
+ );
2449
 
2450
  // Advance Settings SECTION
2451
  Redux::setSection( $opt_name, array(
2517
 
2518
  ),
2519
 
2520
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2521
  // Extension Section
2522
  Redux::setSection( $opt_name, array(
2523
  'title' => __( 'Extensions', 'accelerated-mobile-pages' ),
includes/redirect.php CHANGED
@@ -29,6 +29,24 @@ function ampforwp_page_template_redirect() {
29
  if($post_type == 'forum'){
30
  return;
31
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  session_start();
33
  if( $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_SESSION['ampforwp_mobile']=='exit'){
34
  return;
29
  if($post_type == 'forum'){
30
  return;
31
  }
32
+ // Return if some categories are selected as Hide #999
33
+ if(is_archive() && $redux_builder_amp['ampforwp-archive-support']){
34
+ $categories = get_the_category();
35
+ $category_id = $categories[0]->cat_ID;
36
+ $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
37
+ // Check if $get_categories_from_checkbox has some cats then only show
38
+ if ( $get_categories_from_checkbox ) {
39
+ $get_selected_cats = array_filter($get_categories_from_checkbox);
40
+ foreach ($get_selected_cats as $key => $value) {
41
+ $selected_cats[] = $key;
42
+ }
43
+ if($selected_cats && $category_id){
44
+ if(in_array($category_id, $selected_cats)){
45
+ return;
46
+ }
47
+ }
48
+ }
49
+ }
50
  session_start();
51
  if( $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_SESSION['ampforwp_mobile']=='exit'){
52
  return;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
4
  Donate link: https://www.paypal.me/Kaludi/5
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
- Stable tag: 0.9.55
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -29,11 +29,12 @@ Bug reports for AMP for WP are [welcomed on GitHub](https://github.com/ahmedkalu
29
 
30
  = Features: =
31
 
 
32
  * NEW - Contact Form 7 Support [More Info](https://ampforwp.com/contact-form-7/)
33
  * NEW - Page Builder for AMP! [Watch the Demo](http://ampforwp.com/demo/#pagebuilder) | [How to](https://ampforwp.com/tutorials/page-builder/)
34
- * NEW - Github Gist Support
35
  * NEW - Facebook Comments Support
36
- * NEW - Email Opt-in Subscription form support in AMP added
 
37
  * Call to Action boxes and notification bars
38
  * 9 Advertisement sizes - 2 More AD slots added recently
39
  * Comments Forms in AMP.
@@ -136,6 +137,21 @@ You can contact me using this url: http://ampforwp.com/contact/
136
 
137
  == Changelog ==
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  = 0.9.55 (13th July 2017) =
140
  * View more details on https://ampforwp.com/0-9-55-released-improvement-update-61st-update/
141
  * Disqus Comments show up even when disabled per post #931
4
  Donate link: https://www.paypal.me/Kaludi/5
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
+ Stable tag: 0.9.56
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
29
 
30
  = Features: =
31
 
32
+ * NEW - Page Break / NextPage (Pagination) Support
33
  * NEW - Contact Form 7 Support [More Info](https://ampforwp.com/contact-form-7/)
34
  * NEW - Page Builder for AMP! [Watch the Demo](http://ampforwp.com/demo/#pagebuilder) | [How to](https://ampforwp.com/tutorials/page-builder/)
 
35
  * NEW - Facebook Comments Support
36
+ * Github Gist Support
37
+ * Email Opt-in Subscription form support in AMP added
38
  * Call to Action boxes and notification bars
39
  * 9 Advertisement sizes - 2 More AD slots added recently
40
  * Comments Forms in AMP.
137
 
138
  == Changelog ==
139
 
140
+ = 0.9.56 (31st July 2017) =
141
+ * View more details on https://ampforwp.com/page-break-in-amp/
142
+ * Page Break / NextPage (Pagination) Support Added #834 #857 (Improvement)
143
+ * Show/Hide AMP for Categories of Posts or All posts #872 (Improvement)
144
+ * Adding analytics capabilities to Instant Articles #978
145
+ * JetPack Plugin Conflict Solved #971
146
+ * Social sharing code improved. amp-social-share js is getting added for line and WhatsApp social share #981
147
+ * Code improvement for rel canonicals(home and archive)
148
+ * Perfect SEO URL + Yoast SEO Compatibility #982
149
+ * Some styling for tags to show up properly
150
+ * Undefined index notices #960
151
+ * Non-amp category pages should redirect to non-amp pages if turned off from Hiding AMP #999
152
+ * Page builder text and button module issues #972
153
+ * Documentation links updated in the Options panel
154
+
155
  = 0.9.55 (13th July 2017) =
156
  * View more details on https://ampforwp.com/0-9-55-released-improvement-update-61st-update/
157
  * Disqus Comments show up even when disabled per post #931
templates/design-manager/design-1/archive.php CHANGED
@@ -5,15 +5,6 @@
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
8
- global $redux_builder_amp;
9
- if ( is_home() || is_front_page() || is_archive() ){
10
- global $wp;
11
- $current_archive_url = home_url( $wp->request );
12
- $amp_url = trailingslashit($current_archive_url);
13
- $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
14
- $amp_url = str_replace($remove, '', $amp_url) ;
15
- }
16
-
17
  if ( is_archive() ) {
18
  $description = get_the_archive_description();
19
  $sanitizer = new AMPFORWP_Content( $description, array(),
@@ -29,8 +20,6 @@
29
  )
30
  ) ) );
31
  } ?>
32
- <link rel="canonical" href="<?php echo $amp_url ?>">
33
-
34
  <?php do_action( 'amp_post_template_head', $this ); ?>
35
  <?php
36
  $amp_component_scripts = $sanitizer->amp_scripts;
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
 
 
 
 
 
 
 
 
 
8
  if ( is_archive() ) {
9
  $description = get_the_archive_description();
10
  $sanitizer = new AMPFORWP_Content( $description, array(),
20
  )
21
  ) ) );
22
  } ?>
 
 
23
  <?php do_action( 'amp_post_template_head', $this ); ?>
24
  <?php
25
  $amp_component_scripts = $sanitizer->amp_scripts;
templates/design-manager/design-1/elements/content.php CHANGED
@@ -18,12 +18,20 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
18
 
19
  // Normal Front Page Content
20
  if ( ! $amp_custom_content_enable ) {
21
- echo $this->get( 'post_amp_content' ); // amphtml content; no kses
22
  } else {
23
  // Custom/Alternative AMP content added through post meta
24
- echo $this->get( 'ampforwp_amp_content' );
25
  }
26
-
 
 
 
 
 
 
 
 
27
  do_action('ampforwp_after_post_content',$this) ?>
28
 
29
  <!--Post Next-Previous Links-->
18
 
19
  // Normal Front Page Content
20
  if ( ! $amp_custom_content_enable ) {
21
+ $ampforwp_the_content = $this->get( 'post_amp_content' ); // amphtml content; no kses
22
  } else {
23
  // Custom/Alternative AMP content added through post meta
24
+ $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
25
  }
26
+ $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
27
+ $queried_var = get_query_var('page');
28
+ if ( $queried_var > 1 ) {
29
+ $queried_var = $queried_var -1 ;
30
+ }
31
+ else{
32
+ $queried_var = 0;
33
+ }
34
+ echo $ampforwp_new_content[$queried_var];
35
  do_action('ampforwp_after_post_content',$this) ?>
36
 
37
  <!--Post Next-Previous Links-->
templates/design-manager/design-1/frontpage.php CHANGED
@@ -4,21 +4,7 @@ $template = new AMP_Post_Template( $post_id );?>
4
  <!doctype html>
5
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
6
  <head>
7
- <meta charset="utf-8"> <?php
8
- $page = '';
9
- $query_arg_array = $wp->query_vars;
10
-
11
- if( array_key_exists( "page" , $query_arg_array ) ){
12
- $page = $wp->query_vars['page'];
13
- }
14
-
15
- if ( $page >= '2') { ?>
16
- <link rel="canonical" href="<?php
17
- echo trailingslashit( home_url() ) . '?page=' . $page ?>"> <?php
18
- } else { ?>
19
- <link rel="canonical" href="<?php
20
- echo trailingslashit( home_url() ) ?>"> <?php
21
- } ?>
22
  <?php do_action( 'amp_post_template_head', $this ); ?>
23
  <?php
24
  $amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
4
  <!doctype html>
5
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
6
  <head>
7
+ <meta charset="utf-8">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  <?php do_action( 'amp_post_template_head', $this ); ?>
9
  <?php
10
  $amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
templates/design-manager/design-1/index.php CHANGED
@@ -4,15 +4,6 @@
4
  <head>
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
- <?php global $redux_builder_amp;
8
- if ( is_home() || is_front_page() || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ){
9
- global $wp;
10
- $current_archive_url = home_url( $wp->request );
11
- $amp_url = trailingslashit($current_archive_url);
12
- $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
13
- $amp_url = str_replace($remove, '', $amp_url) ;
14
- } ?>
15
- <link rel="canonical" href="<?php echo $amp_url ?>">
16
  <?php do_action( 'amp_post_template_head', $this ); ?>
17
  <style amp-custom>
18
  <?php $this->load_parts( array( 'style' ) ); ?>
4
  <head>
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
 
 
 
 
 
 
 
 
 
7
  <?php do_action( 'amp_post_template_head', $this ); ?>
8
  <style amp-custom>
9
  <?php $this->load_parts( array( 'style' ) ); ?>
templates/design-manager/design-2/archive.php CHANGED
@@ -5,14 +5,6 @@
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
8
- if ( is_home() || is_front_page() || is_archive() ){
9
- global $wp;
10
- $current_archive_url = home_url( $wp->request );
11
- $amp_url = trailingslashit($current_archive_url);
12
- $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
13
- $amp_url = str_replace($remove, '', $amp_url) ;
14
- }
15
-
16
  if ( is_archive() ) {
17
  $description = get_the_archive_description();
18
  $sanitizer = new AMPFORWP_Content( $description, array(),
@@ -29,9 +21,7 @@
29
  ) ) );
30
  }
31
  ?>
32
- <link rel="canonical" href="<?php echo $amp_url ?>">
33
  <?php do_action( 'amp_post_template_head', $this ); ?>
34
-
35
  <?php
36
  $amp_component_scripts = $sanitizer->amp_scripts;
37
  if ( $sanitizer && $amp_component_scripts) {
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
 
 
 
 
 
 
 
 
8
  if ( is_archive() ) {
9
  $description = get_the_archive_description();
10
  $sanitizer = new AMPFORWP_Content( $description, array(),
21
  ) ) );
22
  }
23
  ?>
 
24
  <?php do_action( 'amp_post_template_head', $this ); ?>
 
25
  <?php
26
  $amp_component_scripts = $sanitizer->amp_scripts;
27
  if ( $sanitizer && $amp_component_scripts) {
templates/design-manager/design-2/elements/content.php CHANGED
@@ -19,15 +19,22 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
19
 
20
  // Normal Front Page Content
21
  if ( ! $amp_custom_content_enable ) {
22
- echo $this->get( 'post_amp_content' ); // amphtml content; no kses
23
  } else {
24
  // Custom/Alternative AMP content added through post meta
25
- echo $this->get( 'ampforwp_amp_content' );
26
  }
27
  // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
28
- ?>
29
-
30
- <?php do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
 
 
 
 
 
 
 
31
 
32
  </div>
33
  <!--Post Content Ends here-->
19
 
20
  // Normal Front Page Content
21
  if ( ! $amp_custom_content_enable ) {
22
+ $ampforwp_the_content = $this->get( 'post_amp_content' ); // amphtml content; no kses
23
  } else {
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
+ $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
29
+ $queried_var = get_query_var('page');
30
+ if ( $queried_var > 1 ) {
31
+ $queried_var = $queried_var -1 ;
32
+ }
33
+ else{
34
+ $queried_var = 0;
35
+ }
36
+ echo $ampforwp_new_content[$queried_var];
37
+ do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
38
 
39
  </div>
40
  <!--Post Content Ends here-->
templates/design-manager/design-2/frontpage.php CHANGED
@@ -4,20 +4,7 @@ $template = new AMP_Post_Template( $post_id );?>
4
  <!doctype html>
5
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
6
  <head>
7
- <meta charset="utf-8"> <?php
8
- $query_arg_array = $wp->query_vars;
9
- $page = '' ;
10
- if( array_key_exists( "page" , $query_arg_array ) ) {
11
- $page = $wp->query_vars['page'];
12
- }
13
-
14
- if ( $page >= '2') { ?>
15
- <link rel="canonical" href="<?php
16
- echo trailingslashit( home_url() ) . '?page=' . $page ?>"> <?php
17
- } else { ?>
18
- <link rel="canonical" href="<?php
19
- echo trailingslashit( home_url() ) ?>"> <?php
20
- } ?>
21
  <?php do_action( 'amp_post_template_head', $this ); ?>
22
  <?php
23
  $amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
4
  <!doctype html>
5
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
6
  <head>
7
+ <meta charset="utf-8">
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  <?php do_action( 'amp_post_template_head', $this ); ?>
9
  <?php
10
  $amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
templates/design-manager/design-2/index.php CHANGED
@@ -4,18 +4,7 @@
4
  <head>
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
- <?php
8
- global $redux_builder_amp;
9
- if ( is_home() || is_front_page() || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ){
10
- global $wp;
11
- $current_archive_url = home_url( $wp->request );
12
- $amp_url = trailingslashit($current_archive_url);
13
- $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
14
- $amp_url = str_replace($remove, '', $amp_url) ;
15
- } ?>
16
- <link rel="canonical" href="<?php echo $amp_url ?>">
17
  <?php do_action( 'amp_post_template_head', $this ); ?>
18
-
19
  <style amp-custom>
20
  <?php $this->load_parts( array( 'style' ) ); ?>
21
  <?php do_action( 'amp_post_template_css', $this ); ?>
4
  <head>
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
 
 
 
 
 
 
 
 
 
 
7
  <?php do_action( 'amp_post_template_head', $this ); ?>
 
8
  <style amp-custom>
9
  <?php $this->load_parts( array( 'style' ) ); ?>
10
  <?php do_action( 'amp_post_template_css', $this ); ?>
templates/design-manager/design-3/archive.php CHANGED
@@ -5,15 +5,6 @@
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
8
- global $redux_builder_amp;
9
- if ( is_home() || is_front_page() || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ){
10
- global $wp;
11
- $current_archive_url = home_url( $wp->request );
12
- $amp_url = trailingslashit($current_archive_url);
13
- $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
14
- $amp_url = str_replace($remove, '', $amp_url) ;
15
- }
16
-
17
  if ( is_archive() ) {
18
  $description = get_the_archive_description();
19
  $sanitizer = new AMPFORWP_Content( $description, array(),
@@ -29,7 +20,6 @@
29
  )
30
  ) ) );
31
  } ?>
32
- <link rel="canonical" href="<?php echo $amp_url ?>">
33
  <?php do_action( 'amp_post_template_head', $this ); ?>
34
  <?php
35
  $amp_component_scripts = $sanitizer->amp_scripts;
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
  <?php
 
 
 
 
 
 
 
 
 
8
  if ( is_archive() ) {
9
  $description = get_the_archive_description();
10
  $sanitizer = new AMPFORWP_Content( $description, array(),
20
  )
21
  ) ) );
22
  } ?>
 
23
  <?php do_action( 'amp_post_template_head', $this ); ?>
24
  <?php
25
  $amp_component_scripts = $sanitizer->amp_scripts;
templates/design-manager/design-3/elements/content.php CHANGED
@@ -20,16 +20,23 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
20
 
21
  // Normal Front Page Content
22
  if ( ! $amp_custom_content_enable ) {
23
- echo $this->get( 'post_amp_content' ); // amphtml content; no kses
24
  } else {
25
  // Custom/Alternative AMP content added through post meta
26
- echo $this->get( 'ampforwp_amp_content' );
27
  }
28
 
29
  // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
30
- ?>
31
-
32
- <?php do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
 
 
 
 
 
 
 
33
 
34
  </div>
35
  <!--Post Content Ends here-->
20
 
21
  // Normal Front Page Content
22
  if ( ! $amp_custom_content_enable ) {
23
+ $ampforwp_the_content = $this->get( 'post_amp_content' ); // amphtml content; no kses
24
  } else {
25
  // Custom/Alternative AMP content added through post meta
26
+ $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
27
  }
28
 
29
  // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
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
+ do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
40
 
41
  </div>
42
  <!--Post Content Ends here-->
templates/design-manager/design-3/elements/social-icons.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php global $redux_builder_amp; ?>
2
- <?php if( is_socialshare_or_socialsticky_enabled_in_ampforwp() && is_single() ) { ?>
3
  <?php do_action('ampforwp_before_social_icons_hook',$this); ?>
4
  <div class="amp-wp-content ampforwp-social-icons-wrapper ampforwp-social-icons">
5
  <i class="icono-share"></i>
1
  <?php global $redux_builder_amp; ?>
2
+ <?php if( is_single() ) { ?>
3
  <?php do_action('ampforwp_before_social_icons_hook',$this); ?>
4
  <div class="amp-wp-content ampforwp-social-icons-wrapper ampforwp-social-icons">
5
  <i class="icono-share"></i>
templates/design-manager/design-3/frontpage.php CHANGED
@@ -5,20 +5,7 @@ $template = new AMP_Post_Template( $post_id );?>
5
  <!doctype html>
6
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
7
  <head>
8
- <meta charset="utf-8"> <?php
9
- $query_arg_array = $wp->query_vars;
10
- $page = '' ;
11
- if( array_key_exists( "page" , $query_arg_array ) ) {
12
- $page = $wp->query_vars['page'];
13
- }
14
-
15
- if ( $page >= '2') { ?>
16
- <link rel="canonical" href="<?php
17
- echo trailingslashit( home_url() ) . '?page=' . $page ?>"> <?php
18
- } else { ?>
19
- <link rel="canonical" href="<?php
20
- echo trailingslashit( home_url() ) ?>"> <?php
21
- } ?>
22
  <?php do_action( 'amp_post_template_head', $this ); ?>
23
  <?php
24
  $amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
5
  <!doctype html>
6
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
7
  <head>
8
+ <meta charset="utf-8">
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  <?php do_action( 'amp_post_template_head', $this ); ?>
10
  <?php
11
  $amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
templates/design-manager/design-3/index.php CHANGED
@@ -4,15 +4,6 @@
4
  <head>
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
7
- <?php
8
- if ( is_home() || is_front_page() || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ){
9
- global $wp;
10
- $current_archive_url = home_url( $wp->request );
11
- $amp_url = trailingslashit($current_archive_url);
12
- $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
13
- $amp_url = str_replace($remove, '', $amp_url) ;
14
- } ?>
15
- <link rel="canonical" href="<?php echo $amp_url ?>">
16
  <?php do_action( 'amp_post_template_head', $this ); ?>
17
 
18
  <style amp-custom>
4
  <head>
5
  <meta charset="utf-8">
6
  <link rel="dns-prefetch" href="https://cdn.ampproject.org">
 
 
 
 
 
 
 
 
 
7
  <?php do_action( 'amp_post_template_head', $this ); ?>
8
 
9
  <style amp-custom>
templates/design-manager/design-3/style.php CHANGED
@@ -134,7 +134,7 @@ h1.amp-wp-title{ margin: 0; color: #333333; font-size: 48px; line-height: 58px;
134
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 22px; font-size: 16px; color:#333; font-family: sans-serif; }
135
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
136
  .amp-wp-article-tags .ampforwp-tax-tag, .amp-wp-article-tags .ampforwp-tax-tag a{ font-size: 12px; color: #555; font-family: sans-serif; margin: 20px 0 0 0; }
137
- .amp-wp-article-tags span{ background: #eee; margin-right: 10px; padding: 5px 12px 5px 12px; border-radius: 3px; }
138
  .ampforwp-social-icons{ margin-bottom: 70px; margin-top: 25px; height: 40px; }
139
  .ampforwp-social-icons amp-social-share{ border-radius:60px; background-size:22px; margin-right:6px; }
140
  .custom-amp-socialsharing-icon-rounded{margin-right:6px;padding: 11px 12px 9px 12px; top: -13px; position: relative; line-height: 1; background: #5cbe4a; display: inline-block; height: inherit; border-radius: 60px; }
134
  .single-post .amp_author_area .amp_author_area_wrapper{ display: inline-block; width: 100%; line-height: 1.4; margin-top: 22px; font-size: 16px; color:#333; font-family: sans-serif; }
135
  .single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
136
  .amp-wp-article-tags .ampforwp-tax-tag, .amp-wp-article-tags .ampforwp-tax-tag a{ font-size: 12px; color: #555; font-family: sans-serif; margin: 20px 0 0 0; }
137
+ .amp-wp-article-tags span{ background: #eee; margin-right: 10px; padding: 5px 12px 5px 12px; border-radius: 3px; display: inline-block; margin: 5px; }
138
  .ampforwp-social-icons{ margin-bottom: 70px; margin-top: 25px; height: 40px; }
139
  .ampforwp-social-icons amp-social-share{ border-radius:60px; background-size:22px; margin-right:6px; }
140
  .custom-amp-socialsharing-icon-rounded{margin-right:6px;padding: 11px 12px 9px 12px; top: -13px; position: relative; line-height: 1; background: #5cbe4a; display: inline-block; height: inherit; border-radius: 60px; }
templates/features.php CHANGED
@@ -76,6 +76,8 @@
76
  64. PageBuilder
77
  65. Remove Filters code added through Class by other plugins
78
  66. Make AMP compatible with Squirrly SEO
 
 
79
  */
80
  // Adding AMP-related things to the main theme
81
  global $redux_builder_amp;
@@ -90,9 +92,15 @@
90
  require 'custom-sanitizer.php';
91
  // Custom Frontpage items
92
  require 'frontpage-elements.php';
 
93
  //0.
94
 
95
- define('AMPFORWP_COMMENTS_PER_PAGE', $redux_builder_amp['ampforwp-number-of-comments'] );
 
 
 
 
 
96
 
97
  // 1. Add Home REL canonical
98
  // Add AMP rel-canonical for home and archive pages
@@ -135,10 +143,27 @@ define('AMPFORWP_COMMENTS_PER_PAGE', $redux_builder_amp['ampforwp-number-of-comm
135
  if ( is_archive() && !$redux_builder_amp['ampforwp-archive-support'] ) {
136
  return;
137
  }
138
- if( is_page() && !$redux_builder_amp['amp-on-off-for-all-pages'] ) {
139
- return;
140
- }
141
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  $query_arg_array = $wp->query_vars;
143
  if( in_array( "cpage" , $query_arg_array ) ) {
144
  if( is_front_page() && $wp->query_vars['cpage'] >= '2' ) {
@@ -1401,6 +1426,8 @@ function ampforwp_remove_schema_data() {
1401
  ampforwp_remove_filters_for_class( 'the_content', 'ET_Monarch', 'display_media', 9999 );
1402
  //Compatibility with wordpress twitter bootstrap #525
1403
  ampforwp_remove_filters_for_class( 'the_content', 'ICWP_WPTB_CssProcessor_V1', 'run', 10 );
 
 
1404
  }
1405
  //Removing the WPTouch Pro social share links from AMP
1406
  remove_filter( 'the_content', 'foundation_handle_share_links_bottom', 100 );
@@ -2306,9 +2333,7 @@ if( !function_exists( 'is_socialshare_or_socialsticky_enabled_in_ampforwp' ) ) {
2306
  $redux_builder_amp['enable-single-gplus-share'] ||
2307
  $redux_builder_amp['enable-single-email-share'] ||
2308
  $redux_builder_amp['enable-single-pinterest-share'] ||
2309
- $redux_builder_amp['enable-single-linkedin-share'] ||
2310
- $redux_builder_amp['enable-single-whatsapp-share'] ||
2311
- $redux_builder_amp['enable-single-line-share'] ) {
2312
  return true;
2313
  }
2314
  return false;
@@ -2584,10 +2609,17 @@ function ampforwp_add_modified_date($post_id){
2584
  }
2585
  }
2586
 
2587
- // 58. YouTube Shortcode compatablity with AMP #557
2588
- if ( ! function_exists( 'shortcode_new_to_old_params') ) {
 
 
 
 
 
 
 
2589
 
2590
- function shortcode_new_to_old_params( $params, $old_format_support = false ) {
2591
  $str = '';
2592
 
2593
  $youtube_url = 'https://www.youtube.com/watch?v=';
@@ -2595,10 +2627,11 @@ if ( ! function_exists( 'shortcode_new_to_old_params') ) {
2595
  $server = 'www.youtube.com';
2596
 
2597
  if ( in_array( $server, $parsed_url ) === false ) {
 
2598
  $new_url = $youtube_url . $params['id'] ;
2599
  $params['id'] = $new_url;
 
2600
  }
2601
-
2602
  if ( $old_format_support && isset( $params[0] ) ) {
2603
  $str = ltrim( $params[0], '=' );
2604
  } elseif ( is_array( $params ) ) {
@@ -2992,4 +3025,250 @@ function fb_instant_article_feed_generator() {
2992
  function fb_instant_article_feed_function() {
2993
  add_filter('pre_option_rss_use_excerpt', '__return_zero');
2994
  load_template( AMPFORWP_PLUGIN_DIR . '/feeds/instant-article-feed.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2995
  }
76
  64. PageBuilder
77
  65. Remove Filters code added through Class by other plugins
78
  66. Make AMP compatible with Squirrly SEO
79
+ 69. Post Pagination #834 #857
80
+ 70. Hide AMP by specific Categories #872
81
  */
82
  // Adding AMP-related things to the main theme
83
  global $redux_builder_amp;
92
  require 'custom-sanitizer.php';
93
  // Custom Frontpage items
94
  require 'frontpage-elements.php';
95
+ require AMPFORWP_PLUGIN_DIR . '/classes/class-ampforwp-youtube-embed.php' ;
96
  //0.
97
 
98
+ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
99
+ // Define number of comments
100
+ function ampforwp_define_comments_number(){
101
+ global $redux_builder_amp;
102
+ return $redux_builder_amp['ampforwp-number-of-comments'];
103
+ }
104
 
105
  // 1. Add Home REL canonical
106
  // Add AMP rel-canonical for home and archive pages
143
  if ( is_archive() && !$redux_builder_amp['ampforwp-archive-support'] ) {
144
  return;
145
  }
146
+ // #872 no-amphtml if selected as hide from settings
147
+ if(is_archive() && $redux_builder_amp['ampforwp-archive-support']){
148
+ $categories = get_the_category();
149
+ $category_id = $categories[0]->cat_ID;
150
+ $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
151
+ // Check if $get_categories_from_checkbox has some cats then only show
152
+ if ( $get_categories_from_checkbox ) {
153
+ $get_selected_cats = array_filter($get_categories_from_checkbox);
154
+ foreach ($get_selected_cats as $key => $value) {
155
+ $selected_cats[] = $key;
156
+ }
157
+ if($selected_cats && $category_id){
158
+ if(in_array($category_id, $selected_cats)){
159
+ return;
160
+ }
161
+ }
162
+ }
163
+ }
164
+ if( is_page() && !$redux_builder_amp['amp-on-off-for-all-pages'] ) {
165
+ return;
166
+ }
167
  $query_arg_array = $wp->query_vars;
168
  if( in_array( "cpage" , $query_arg_array ) ) {
169
  if( is_front_page() && $wp->query_vars['cpage'] >= '2' ) {
1426
  ampforwp_remove_filters_for_class( 'the_content', 'ET_Monarch', 'display_media', 9999 );
1427
  //Compatibility with wordpress twitter bootstrap #525
1428
  ampforwp_remove_filters_for_class( 'the_content', 'ICWP_WPTB_CssProcessor_V1', 'run', 10 );
1429
+ //Perfect SEO url + Yoast SEO Compatibility #982
1430
+ ampforwp_remove_filters_for_class( 'wpseo_canonical', 'PSU', 'canonical', 10 );
1431
  }
1432
  //Removing the WPTouch Pro social share links from AMP
1433
  remove_filter( 'the_content', 'foundation_handle_share_links_bottom', 100 );
2333
  $redux_builder_amp['enable-single-gplus-share'] ||
2334
  $redux_builder_amp['enable-single-email-share'] ||
2335
  $redux_builder_amp['enable-single-pinterest-share'] ||
2336
+ $redux_builder_amp['enable-single-linkedin-share'] ) {
 
 
2337
  return true;
2338
  }
2339
  return false;
2609
  }
2610
  }
2611
 
2612
+ // 58. YouTube Shortcode compatablity with AMP #557 #971
2613
+
2614
+ add_filter('amp_content_embed_handlers','ampforwp_youtube_shortcode_embedder');
2615
+ function ampforwp_youtube_shortcode_embedder($data){
2616
+ unset($data['AMP_YouTube_Embed_Handler']);
2617
+ $data[ 'AMPforWP_YouTube_Embed_Handler' ] = array();
2618
+ return $data;
2619
+ }
2620
+ if ( ! function_exists( 'ampforwp_youtube_shortcode') ) {
2621
 
2622
+ function ampforwp_youtube_shortcode( $params, $old_format_support = false ) {
2623
  $str = '';
2624
 
2625
  $youtube_url = 'https://www.youtube.com/watch?v=';
2627
  $server = 'www.youtube.com';
2628
 
2629
  if ( in_array( $server, $parsed_url ) === false ) {
2630
+ if($params['id']){
2631
  $new_url = $youtube_url . $params['id'] ;
2632
  $params['id'] = $new_url;
2633
+ }
2634
  }
 
2635
  if ( $old_format_support && isset( $params[0] ) ) {
2636
  $str = ltrim( $params[0], '=' );
2637
  } elseif ( is_array( $params ) ) {
3025
  function fb_instant_article_feed_function() {
3026
  add_filter('pre_option_rss_use_excerpt', '__return_zero');
3027
  load_template( AMPFORWP_PLUGIN_DIR . '/feeds/instant-article-feed.php' );
3028
+ }
3029
+
3030
+ // 69. Post Pagination #834 #857
3031
+ function ampforwp_post_pagination( $args = '' ) {
3032
+
3033
+ wp_reset_postdata();
3034
+ global $page, $numpages, $multipage, $more;
3035
+
3036
+ $defaults = array(
3037
+ 'before' => '<p>' . __( 'Page:' ),
3038
+ 'after' => '</p>',
3039
+ 'link_before' => '',
3040
+ 'link_after' => '',
3041
+ 'next_or_number' => 'number',
3042
+ 'separator' => ' ',
3043
+ 'nextpagelink' => __( 'Next page' ),
3044
+ 'previouspagelink' => __( 'Previous page' ),
3045
+ 'pagelink' => '%',
3046
+ 'echo' => 1
3047
+ );
3048
+
3049
+ $params = wp_parse_args( $args, $defaults );
3050
+
3051
+ /**
3052
+ * Filters the arguments used in retrieving page links for paginated posts.
3053
+ * @param array $params An array of arguments for page links for paginated posts.
3054
+ */
3055
+ $r = apply_filters( 'ampforwp_post_pagination_args', $params );
3056
+
3057
+ $output = '';
3058
+ if ( $multipage ) {
3059
+ if ( 'number' == $r['next_or_number'] ) {
3060
+ $output .= $r['before'];
3061
+ for ( $i = 1; $i <= $numpages; $i++ ) {
3062
+ $link = $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'];
3063
+ if ( $i != $page || ! $more && 1 == $page ) {
3064
+ $link = ampforwp_post_paginated_link_generator( $i ) . $link . '</a>';
3065
+ }
3066
+ /**
3067
+ * Filters the HTML output of individual page number links.
3068
+ * @param string $link The page number HTML output.
3069
+ * @param int $i Page number for paginated posts' page links.
3070
+ */
3071
+ $link = apply_filters( 'ampforwp_post_pagination_link', $link, $i );
3072
+
3073
+ // Use the custom links separator beginning with the second link.
3074
+ $output .= ( 1 === $i ) ? ' ' : $r['separator'];
3075
+ $output .= $link;
3076
+ }
3077
+ $output .= $r['after'];
3078
+ } elseif ( $more ) {
3079
+ $output .= $r['before'];
3080
+ $prev = $page - 1;
3081
+ if ( $prev > 0 ) {
3082
+ $link = ampforwp_post_paginated_link_generator( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
3083
+ $output .= apply_filters( 'ampforwp_post_pagination_link', $link, $prev );
3084
+ }
3085
+ $next = $page + 1;
3086
+ if ( $next <= $numpages ) {
3087
+ if ( $prev ) {
3088
+ $output .= $r['separator'];
3089
+ }
3090
+ $link = ampforwp_post_paginated_link_generator( $next ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
3091
+ $output .= apply_filters( 'ampforwp_post_pagination_link', $link, $next );
3092
+ }
3093
+ $output .= $r['after'];
3094
+ }
3095
+ }
3096
+
3097
+ /**
3098
+ * Filters the HTML output of page links for paginated posts.
3099
+ * @param string $output HTML output of paginated posts' page links.
3100
+ * @param array $args An array of arguments.
3101
+ */
3102
+ $html = apply_filters( 'ampforwp_post_pagination', $output, $args );
3103
+ if ( $r['echo'] ) {
3104
+ echo $html;
3105
+ }
3106
+ return $html;
3107
+
3108
+ }
3109
+
3110
+ /**
3111
+ * Helper function for ampforwp_post_pagination().
3112
+ * @access private
3113
+ *
3114
+ * @global WP_Rewrite $wp_rewrite
3115
+ *
3116
+ * @param int $i Page number.
3117
+ * @return string Link.
3118
+ */
3119
+ function ampforwp_post_paginated_link_generator( $i ) {
3120
+ global $wp_rewrite;
3121
+ $post = get_post();
3122
+ $query_args = array();
3123
+ if ( 1 == $i ) {
3124
+ $url = get_permalink();
3125
+ } else {
3126
+ if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
3127
+ $url = add_query_arg( 'page', $i, get_permalink() );
3128
+ elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
3129
+ $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
3130
+ else
3131
+ $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
3132
+ }
3133
+
3134
+ if ( is_preview() ) {
3135
+
3136
+ if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
3137
+ $query_args['preview_id'] = wp_unslash( $_GET['preview_id'] );
3138
+ $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
3139
+ }
3140
+
3141
+ $url = get_preview_post_link( $post, $query_args, $url );
3142
+ }
3143
+
3144
+ return '<a href="' . esc_url( $url ) . '?amp">';
3145
+ }
3146
+
3147
+ add_filter('ampforwp_modify_rel_canonical','ampforwp_modify_rel_amphtml_paginated_post');
3148
+ function ampforwp_modify_rel_amphtml_paginated_post($url) {
3149
+ if(is_single()){
3150
+ $post_paginated_page='';
3151
+ $post_paginated_page = get_query_var('page');
3152
+ if($post_paginated_page){
3153
+ $url = get_permalink();
3154
+ $new_url = $url."$post_paginated_page/?amp";
3155
+ return $new_url;
3156
+ }
3157
+ }
3158
+ return $url;
3159
+ }
3160
+
3161
+ add_action('amp_post_template_head','ampforwp_modify_rel_canonical_paginated_post',9);
3162
+ function ampforwp_modify_rel_canonical_paginated_post(){
3163
+ if(is_single()){
3164
+ $post_paginated_page='';
3165
+ $post_paginated_page = get_query_var('page');
3166
+ if($post_paginated_page){
3167
+ remove_action( 'amp_post_template_head', 'amp_post_template_add_canonical' );
3168
+ add_action('amp_post_template_head','ampforwp_rel_canonical_paginated_post');
3169
+ }
3170
+ }
3171
+ }
3172
+ function ampforwp_rel_canonical_paginated_post(){
3173
+ $post_paginated_page='';
3174
+ $new_canonical_url = '';
3175
+ global $post;
3176
+ $current_post_id = $post->ID;
3177
+ $new_canonical_url = get_permalink($current_post_id);
3178
+ $new_canonical_url = trailingslashit($new_canonical_url);
3179
+ $post_paginated_page = get_query_var('page');
3180
+ if($post_paginated_page){?>
3181
+ <link rel="canonical" href="<?php echo $new_canonical_url.$post_paginated_page ?>/" /><?php }
3182
+ }
3183
+ add_action('ampforwp_after_post_content','ampforwp_post_pagination');
3184
+
3185
+
3186
+ // 70. Hide AMP by specific Categories #872
3187
+
3188
+ function ampforwp_posts_to_remove () {
3189
+ global $redux_builder_amp;
3190
+ $args = array();
3191
+ $get_categories_from_checkbox = '';
3192
+ $get_selected_cats = '';
3193
+ $selected_cats = array();
3194
+ $posts = array();
3195
+ $post_id_array = array();
3196
+
3197
+ $args = array(
3198
+ 'post_type' => 'post',
3199
+ );
3200
+ $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
3201
+ if($get_categories_from_checkbox){
3202
+ $get_selected_cats = array_filter($get_categories_from_checkbox);
3203
+ foreach ($get_selected_cats as $key => $value) {
3204
+ $selected_cats[] = $key;
3205
+ }
3206
+ }
3207
+ if ( ! empty($get_selected_cats)) {
3208
+
3209
+ $posts = get_posts( array(
3210
+ 'category' => $selected_cats,
3211
+ 'numberposts' => '-1',
3212
+ 'post_type' => $args,
3213
+ 'post_status' => 'publish',
3214
+ 'suppress_filters' => false
3215
+ ) );
3216
+ }
3217
+
3218
+ if ( $posts ) {
3219
+ foreach ($posts as $post) {
3220
+ $post_id_array[] = $post->ID;
3221
+ }
3222
+ }
3223
+ return $post_id_array;
3224
+ }
3225
+
3226
+ add_filter( 'amp_skip_post', 'ampforwp_cat_specific_skip_amp_post', 10, 3 );
3227
+ function ampforwp_cat_specific_skip_amp_post( $skip, $post_id, $post ) {
3228
+ $list_of_posts = '';
3229
+ $skip_this_post = '';
3230
+
3231
+ $list_of_posts = ampforwp_posts_to_remove();
3232
+ $skip_this_post = in_array($post_id, $list_of_posts);
3233
+
3234
+ if( $skip_this_post ) {
3235
+ $skip = true;
3236
+ remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' );
3237
+ // #999 Disable mobile redirection
3238
+ remove_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
3239
+ }
3240
+ return $skip;
3241
+ }
3242
+
3243
+ add_action('amp_post_template_head','ampforwp_rel_canonical_home_archive');
3244
+ function ampforwp_rel_canonical_home_archive(){
3245
+ global $redux_builder_amp;
3246
+ global $wp;
3247
+ $current_archive_url = '';
3248
+ $amp_url = '';
3249
+ $remove = '';
3250
+ $query_arg_array = '';
3251
+
3252
+ if ( is_home() && !$redux_builder_amp['amp-frontpage-select-option'] || ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) ){
3253
+ $current_archive_url = home_url( $wp->request );
3254
+ $amp_url = trailingslashit($current_archive_url);
3255
+ $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
3256
+ $amp_url = str_replace($remove, '', $amp_url) ;?>
3257
+ <link rel="canonical" href="<?php echo $amp_url ?>">
3258
+ <?php }
3259
+
3260
+ if((is_front_page() || is_home() ) && $redux_builder_amp['amp-frontpage-select-option'] ){
3261
+ $query_arg_array = $wp->query_vars;
3262
+ $page = '' ;
3263
+ if( array_key_exists( "page" , $query_arg_array ) ) {
3264
+ $page = $wp->query_vars['page'];
3265
+ }
3266
+ if ( $page >= '2') { ?>
3267
+ <link rel="canonical" href="<?php
3268
+ echo trailingslashit( home_url() ) . '?page=' . $page ?>"> <?php
3269
+ } else { ?>
3270
+ <link rel="canonical" href="<?php
3271
+ echo trailingslashit( home_url() ) ?>"> <?php
3272
+ }
3273
+ }
3274
  }
templates/instant-articles/instant-article-sanitizer.php CHANGED
@@ -232,7 +232,14 @@ function no_empty_p_tags($DOMDocument){
232
  global $redux_builder_amp;
233
  $instant_article_ad_id = $redux_builder_amp['fb-instant-article-ad-id'];
234
  return $instant_article_ad_id;
235
- }
 
 
 
 
 
 
 
236
  /*function fb_gallery_shortcode($output, $attr, $instance){
237
  $post = get_post();
238
 
232
  global $redux_builder_amp;
233
  $instant_article_ad_id = $redux_builder_amp['fb-instant-article-ad-id'];
234
  return $instant_article_ad_id;
235
+ }
236
+
237
+ function get_ia_analytics_code(){
238
+ global $redux_builder_amp;
239
+ $instant_article_analytics_code = $redux_builder_amp['fb-instant-article-analytics-code'];
240
+ return $instant_article_analytics_code;
241
+ }
242
+
243
  /*function fb_gallery_shortcode($output, $attr, $instance){
244
  $post = get_post();
245
 
templates/instant-articles/instant-article.php CHANGED
@@ -13,6 +13,15 @@
13
  <body>
14
  <article>
15
  <header>
 
 
 
 
 
 
 
 
 
16
  <!-- title -->
17
  <h1><?php the_title(); ?></h1>
18
 
13
  <body>
14
  <article>
15
  <header>
16
+
17
+ <!-- Analytics code -->
18
+ <?php if ( $redux_builder_amp['fb-instant-article-analytics'] ){ ?>
19
+ <figure class="op-tracker">
20
+ <iframe>
21
+ <?php echo get_ia_analytics_code(); ?>
22
+ </iframe>
23
+ </figure>
24
+ <?php } ?>
25
  <!-- title -->
26
  <h1><?php the_title(); ?></h1>
27