AMP for WP – Accelerated Mobile Pages - Version 0.8.4

Version Description

  • Proper Details at http://ampforwp.com/blog/structured-data-validation/
  • Structured Data Validation
  • Navigation Text Change
  • Inline Style Validation
  • Form Validation
  • Frontpage shows the amphtml rel twice fixed
  • Facebook Sharing not working
Download this release

Release Info

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

Code changes from version 0.8.3 to 0.8.4

README.md CHANGED
@@ -6,7 +6,7 @@ Contributors: mohammed_kaludi, ahmedkaludi
6
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
7
  Requires at least: 3.0
8
  Tested up to: 4.6.1
9
- Stable tag: 0.8.3
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -15,7 +15,9 @@ The Must have AMP plugin for WordPress. Automatically add Accelerated Mobile Pag
15
  == Description ==
16
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
17
 
18
- [What's New in Version 0.8.2?](http://ampforwp.com/blog/the-custom-frontpage/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
 
 
19
 
20
  **Features:**
21
 
@@ -110,6 +112,15 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
110
 
111
 
112
  == Changelog ==
 
 
 
 
 
 
 
 
 
113
  = 0.8.3 =
114
  * Prefix added in the Content filter
115
  * Extra space after quote in Ads
6
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
7
  Requires at least: 3.0
8
  Tested up to: 4.6.1
9
+ Stable tag: 0.8.4
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
15
  == Description ==
16
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
17
 
18
+ [What's New in Version 0.8.4?](http://ampforwp.com/blog/structured-data-validation/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
19
+
20
+ [youtube https://www.youtube.com/watch?v=zzRy6Q_VGGc]
21
 
22
  **Features:**
23
 
112
 
113
 
114
  == Changelog ==
115
+ = 0.8.4 =
116
+ * Proper Details at http://ampforwp.com/blog/structured-data-validation/
117
+ * Structured Data Validation
118
+ * Navigation Text Change
119
+ * Inline Style Validation
120
+ * Form Validation
121
+ * Frontpage shows the amphtml rel twice fixed
122
+ * Facebook Sharing not working
123
+
124
  = 0.8.3 =
125
  * Prefix added in the Content filter
126
  * Extra space after quote in Ads
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 Toolbox - Accelerated Mobile Pages for WordPress
6
- Version: 0.8.3
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  License: GPL2
@@ -45,7 +45,6 @@ if ( ! class_exists( 'Ampforwp_Init', false ) ) {
45
  }
46
  }
47
  }
48
-
49
  /*
50
  * Start the plugin.
51
  * Gentlemen start your engines
@@ -55,16 +54,4 @@ function ampforwp_plugin_init() {
55
  new Ampforwp_Init;
56
  }
57
  }
58
- add_action('init','ampforwp_plugin_init',9);
59
-
60
- /**/
61
-
62
- // Strip the styles
63
- add_filter( 'the_content', 'ampforwp_the_content_filter', 20 );
64
- function ampforwp_the_content_filter( $content ) {
65
- $content = preg_replace('/property[^>]*/', '', $content);
66
- $content = preg_replace('/vocab[^>]*/', '', $content);
67
- $content = preg_replace('#<comments-count.*?>(.*?)</comments-count>#i', '', $content);
68
- $content = preg_replace('/href="javascript:void*/', ' ', $content);
69
- return $content;
70
- }
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP Toolbox - Accelerated Mobile Pages for WordPress
6
+ Version: 0.8.4
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  License: GPL2
45
  }
46
  }
47
  }
 
48
  /*
49
  * Start the plugin.
50
  * Gentlemen start your engines
54
  new Ampforwp_Init;
55
  }
56
  }
57
+ add_action('init','ampforwp_plugin_init',9);
 
 
 
 
 
 
 
 
 
 
 
 
includes/includes.php CHANGED
@@ -24,5 +24,4 @@
24
 
25
  // 3. Redux panel inclusion code
26
  require_once( AMPFORWP_PLUGIN_DIR . '/includes/options/admin-init.php' );
27
-
28
  ?>
24
 
25
  // 3. Redux panel inclusion code
26
  require_once( AMPFORWP_PLUGIN_DIR . '/includes/options/admin-init.php' );
 
27
  ?>
includes/options/options-init.php CHANGED
@@ -138,7 +138,7 @@
138
  Redux::setSection( $opt_name, array(
139
  'title' => __( 'Welcome', 'redux-framework-demo' ),
140
  'id' => 'basic',
141
- 'desc' => __( '<div class="amp-faq">Thank you for using Accelerated Mobile Pages plugin. <b> <a href="http://ampforwp.com/blog/the-custom-frontpage/" target="_blank"> What\'s New in this Version?</a></b>'. '<p>' . sprintf( __( 'We are actively working on updating the plugin. We have built user friendly options which allows you to make changes on your AMP version. I have put togeather some frequently asked questions below.', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</p>'
142
  . '<h2>' . __( 'Frequently Asked Questions', 'redux-framework-demo' ) . '</h2>'
143
  . '<p><strong>' . __( 'How to Setup Navigation Menu?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'We have created a Seperate Navigation menu for AMP version which you can setup from the WordPress Menus, then navigate to Menu Locations, their you will notice AMP Menu. You can assign existing menus to this locations.', 'redux-framework-demo' ) . '</p>'
144
  . '<p><strong>' . __( 'I added /?amp on the end of one of my URLs and a minimalist version of my page appeared. It looks just like on one of your screenshots, so I guess its installed properly. Okay what now? Is it just enough to install it and the plugin will do the rest?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'After you see the minimalist view if you use the url with ?amp then it means that it has been installed properly. You dont need any extra steps to enable it.', 'redux-framework-demo' ) . '</p>'
@@ -263,35 +263,30 @@
263
  'posts_per_page' => 500
264
  ),
265
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
 
267
-
268
- array(
269
- 'id' =>'amp-frontpage-select-option',
270
- 'type' => 'switch',
271
- 'title' => __('Front Page', 'redux-framework-demo'),
272
- 'default' => 0,
273
- 'subtitle' => __('Custom AMP frontpage', 'redux-framework-demo'),
274
- 'true' => 'true',
275
- 'false' => 'false',
276
- ),
277
- array(
278
- 'id' => 'amp-frontpage-select-option-pages',
279
- 'type' => 'select',
280
- 'title' => __('Select Page as Frontpage', 'redux-framework-demo'),
281
- 'required' => array('amp-frontpage-select-option', '=' , '1'),
282
- // Must provide key => value pairs for select options
283
- 'data' => 'page',
284
- 'args' => array(
285
- 'post_type' => 'page',
286
- 'posts_per_page' => 500
287
- ),
288
-
289
- 'default' => '2',
290
- ),
291
-
292
-
293
-
294
-
295
  array(
296
  'id' => 'amp-footer-text',
297
  'title' => __('Footer', 'redux-framework-demo'),
@@ -308,7 +303,13 @@ array(
308
  'true' => 'true',
309
  'false' => 'false',
310
  ),
311
- )
 
 
 
 
 
 
312
 
313
 
314
 
@@ -387,16 +388,18 @@ array(
387
  'type' => 'text',
388
  'required' => array('enable-amp-ads-1', '=' , '1'),
389
  'title' => __('Data AD Client', 'redux-framework-demo'),
390
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005682797531342', 'redux-framework-demo'),
391
- 'default' => ''
 
392
  ),
393
  array(
394
  'id' => 'enable-amp-ads-text-feild-slot-1',
395
  'type' => 'text',
396
  'title' => __('Data AD Slot', 'redux-framework-demo'),
397
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 7046626912', 'redux-framework-demo'),
398
  'default' => '',
399
  'required' => array('enable-amp-ads-1', '=' , '1'),
 
400
  ),
401
  // Ad 1 ends
402
  // Ad 2 Starts
@@ -431,16 +434,18 @@ array(
431
  'type' => 'text',
432
  'required' => array('enable-amp-ads-2', '=' , '1'),
433
  'title' => __('Data AD Client', 'redux-framework-demo'),
434
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005682797531342', 'redux-framework-demo'),
435
- 'default' => ''
 
436
  ),
437
  array(
438
  'id' => 'enable-amp-ads-text-feild-slot-2',
439
  'type' => 'text',
440
  'title' => __('Data AD Slot', 'redux-framework-demo'),
441
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 7046626912', 'redux-framework-demo'),
442
  'default' => '',
443
  'required' => array('enable-amp-ads-2', '=' , '1'),
 
444
  ),
445
  // Ad 2 ends
446
  // Ad 3 starts
@@ -475,16 +480,18 @@ array(
475
  'type' => 'text',
476
  'required' => array('enable-amp-ads-3', '=' , '1'),
477
  'title' => __('Data AD Client', 'redux-framework-demo'),
478
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005682797531342', 'redux-framework-demo'),
479
- 'default' => ''
 
480
  ),
481
  array(
482
  'id' => 'enable-amp-ads-text-feild-slot-3',
483
  'type' => 'text',
484
  'title' => __('Data AD Slot', 'redux-framework-demo'),
485
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 7046626912', 'redux-framework-demo'),
486
  'default' => '',
487
  'required' => array('enable-amp-ads-3', '=' , '1'),
 
488
  ),
489
  // Ad 3 ends
490
  // Ad 4 Starts
@@ -519,16 +526,18 @@ array(
519
  'type' => 'text',
520
  'required' => array('enable-amp-ads-4', '=' , '1'),
521
  'title' => __('Data AD Client', 'redux-framework-demo'),
522
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005682797531342', 'redux-framework-demo'),
523
- 'default' => ''
 
524
  ),
525
  array(
526
  'id' => 'enable-amp-ads-text-feild-slot-4',
527
  'type' => 'text',
528
  'title' => __('Data AD Slot', 'redux-framework-demo'),
529
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 7046626912', 'redux-framework-demo'),
530
  'default' => '',
531
  'required' => array('enable-amp-ads-4', '=' , '1'),
 
532
  )
533
  // Ad 4 ends
534
  ),
@@ -598,8 +607,18 @@ array(
598
  'type' => 'switch',
599
  'required' => array('enable-single-social-icons', '=' , '1'),
600
  'title' => __('Facebook', 'redux-framework-demo'),
601
- 'default' => 1,
602
  ),
 
 
 
 
 
 
 
 
 
 
603
  // Twitter ON/OFF
604
  array(
605
  'id' => 'enable-single-twitter-share',
138
  Redux::setSection( $opt_name, array(
139
  'title' => __( 'Welcome', 'redux-framework-demo' ),
140
  'id' => 'basic',
141
+ 'desc' => __( '<div class="amp-faq">Thank you for using Accelerated Mobile Pages plugin. <b> <a href="http://ampforwp.com/blog/structured-data-validation/" target="_blank"> What\'s New in this Version?</a></b>'. '<p>' . sprintf( __( 'We are actively working on updating the plugin. We have built user friendly options which allows you to make changes on your AMP version. I have put togeather some frequently asked questions below.', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</p>'
142
  . '<h2>' . __( 'Frequently Asked Questions', 'redux-framework-demo' ) . '</h2>'
143
  . '<p><strong>' . __( 'How to Setup Navigation Menu?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'We have created a Seperate Navigation menu for AMP version which you can setup from the WordPress Menus, then navigate to Menu Locations, their you will notice AMP Menu. You can assign existing menus to this locations.', 'redux-framework-demo' ) . '</p>'
144
  . '<p><strong>' . __( 'I added /?amp on the end of one of my URLs and a minimalist version of my page appeared. It looks just like on one of your screenshots, so I guess its installed properly. Okay what now? Is it just enough to install it and the plugin will do the rest?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'After you see the minimalist view if you use the url with ?amp then it means that it has been installed properly. You dont need any extra steps to enable it.', 'redux-framework-demo' ) . '</p>'
263
  'posts_per_page' => 500
264
  ),
265
  ),
266
+ array(
267
+ 'id' =>'amp-frontpage-select-option',
268
+ 'type' => 'switch',
269
+ 'title' => __('Front Page', 'redux-framework-demo'),
270
+ 'default' => 0,
271
+ 'subtitle' => __('Custom AMP frontpage', 'redux-framework-demo'),
272
+ 'true' => 'true',
273
+ 'false' => 'false',
274
+ ),
275
+ array(
276
+ 'id' => 'amp-frontpage-select-option-pages',
277
+ 'type' => 'select',
278
+ 'title' => __('Select Page as Frontpage', 'redux-framework-demo'),
279
+ 'required' => array('amp-frontpage-select-option', '=' , '1'),
280
+ // Must provide key => value pairs for select options
281
+ 'data' => 'page',
282
+ 'args' => array(
283
+ 'post_type' => 'page',
284
+ 'posts_per_page' => 500
285
+ ),
286
 
287
+ 'default' => '2',
288
+ ),
289
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  array(
291
  'id' => 'amp-footer-text',
292
  'title' => __('Footer', 'redux-framework-demo'),
303
  'true' => 'true',
304
  'false' => 'false',
305
  ),
306
+ array(
307
+ 'id' => 'amp-navigation-text',
308
+ 'title' => __('Navigation Text', 'redux-framework-demo'),
309
+ 'type' => 'text',
310
+ 'default' => 'Navigate'
311
+ ),
312
+ )
313
 
314
 
315
 
388
  'type' => 'text',
389
  'required' => array('enable-amp-ads-1', '=' , '1'),
390
  'title' => __('Data AD Client', 'redux-framework-demo'),
391
+ 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
392
+ 'default' => '',
393
+ 'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
394
  ),
395
  array(
396
  'id' => 'enable-amp-ads-text-feild-slot-1',
397
  'type' => 'text',
398
  'title' => __('Data AD Slot', 'redux-framework-demo'),
399
+ 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
400
  'default' => '',
401
  'required' => array('enable-amp-ads-1', '=' , '1'),
402
+ 'placeholder'=> '70XXXXXX12'
403
  ),
404
  // Ad 1 ends
405
  // Ad 2 Starts
434
  'type' => 'text',
435
  'required' => array('enable-amp-ads-2', '=' , '1'),
436
  'title' => __('Data AD Client', 'redux-framework-demo'),
437
+ 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
438
+ 'default' => '',
439
+ 'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
440
  ),
441
  array(
442
  'id' => 'enable-amp-ads-text-feild-slot-2',
443
  'type' => 'text',
444
  'title' => __('Data AD Slot', 'redux-framework-demo'),
445
+ 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
446
  'default' => '',
447
  'required' => array('enable-amp-ads-2', '=' , '1'),
448
+ 'placeholder'=> '70XXXXXX12'
449
  ),
450
  // Ad 2 ends
451
  // Ad 3 starts
480
  'type' => 'text',
481
  'required' => array('enable-amp-ads-3', '=' , '1'),
482
  'title' => __('Data AD Client', 'redux-framework-demo'),
483
+ 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
484
+ 'default' => '',
485
+ 'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
486
  ),
487
  array(
488
  'id' => 'enable-amp-ads-text-feild-slot-3',
489
  'type' => 'text',
490
  'title' => __('Data AD Slot', 'redux-framework-demo'),
491
+ 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
492
  'default' => '',
493
  'required' => array('enable-amp-ads-3', '=' , '1'),
494
+ 'placeholder'=> '70XXXXXX12'
495
  ),
496
  // Ad 3 ends
497
  // Ad 4 Starts
526
  'type' => 'text',
527
  'required' => array('enable-amp-ads-4', '=' , '1'),
528
  'title' => __('Data AD Client', 'redux-framework-demo'),
529
+ 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
530
+ 'default' => '',
531
+ 'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
532
  ),
533
  array(
534
  'id' => 'enable-amp-ads-text-feild-slot-4',
535
  'type' => 'text',
536
  'title' => __('Data AD Slot', 'redux-framework-demo'),
537
+ 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
538
  'default' => '',
539
  'required' => array('enable-amp-ads-4', '=' , '1'),
540
+ 'placeholder'=> '70XXXXXX12'
541
  )
542
  // Ad 4 ends
543
  ),
607
  'type' => 'switch',
608
  'required' => array('enable-single-social-icons', '=' , '1'),
609
  'title' => __('Facebook', 'redux-framework-demo'),
610
+ 'default' => 0,
611
  ),
612
+ // Facebook app ID
613
+ array(
614
+ 'id' => 'amp-facebook-app-id',
615
+ 'title' => __('Facebook App ID', 'redux-framework-demo'),
616
+ 'subtitle' => __('In order to use Facebook share you need to register an app ID, you can register one here: https://developers.facebook.com/apps.', 'redux-framework-demo'),
617
+ 'type' => 'text',
618
+ 'required' => array('enable-single-facebook-share', '=' , '1'),
619
+ 'placeholder' => 'Enter your facebook app id',
620
+ 'default' => ''
621
+ ),
622
  // Twitter ON/OFF
623
  array(
624
  'id' => 'enable-single-twitter-share',
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mohammed_kaludi, ahmedkaludi
3
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
4
  Requires at least: 3.0
5
  Tested up to: 4.6.1
6
- Stable tag: 0.8.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -12,7 +12,9 @@ The Must have AMP plugin for WordPress. Automatically add Accelerated Mobile Pag
12
  == Description ==
13
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
14
 
15
- [What's New in Version 0.8.2?](http://ampforwp.com/blog/the-custom-frontpage/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
 
 
16
 
17
  **Features:**
18
 
@@ -107,6 +109,15 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
107
 
108
 
109
  == Changelog ==
 
 
 
 
 
 
 
 
 
110
  = 0.8.3 =
111
  * Prefix added in the Content filter
112
  * Extra space after quote in Ads
3
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
4
  Requires at least: 3.0
5
  Tested up to: 4.6.1
6
+ Stable tag: 0.8.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
12
  == Description ==
13
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
14
 
15
+ [What's New in Version 0.8.4?](http://ampforwp.com/blog/structured-data-validation/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
16
+
17
+ [youtube https://www.youtube.com/watch?v=zzRy6Q_VGGc]
18
 
19
  **Features:**
20
 
109
 
110
 
111
  == Changelog ==
112
+ = 0.8.4 =
113
+ * Proper Details at http://ampforwp.com/blog/structured-data-validation/
114
+ * Structured Data Validation
115
+ * Navigation Text Change
116
+ * Inline Style Validation
117
+ * Form Validation
118
+ * Frontpage shows the amphtml rel twice fixed
119
+ * Facebook Sharing not working
120
+
121
  = 0.8.3 =
122
  * Prefix added in the Content filter
123
  * Extra space after quote in Ads
templates/features.php CHANGED
@@ -1,33 +1,33 @@
1
  <?php
2
- /* This file will contain all the FEATURES to add like.
3
-
4
- 1. Add homepage and Page support
5
- 2. Add Home REL canonical
6
- 3. Custom Single and homepage code
7
- 4. Custom Style files
8
- 5. Custom Header
9
- 6.
10
- 7. Customize with Width of the site
11
- 8. Customize endpoints
12
- 9. Add required Javascripts for extra AMP features
13
- 10. Footer for AMP Pages
 
 
14
  */
15
 
16
- global $redux_builder_amp;
17
-
18
  // Adding AMP-related things to the main theme
 
19
 
20
- // 2. Add Home REL canonical
21
  // Add AMP rel-canonical for home and archive pages
22
 
23
- add_action('amp_init','allow_homepage');
24
-
25
- function allow_homepage(){
26
- add_action( 'wp', 'new_amp_maybe_add_actions' );
27
  }
28
 
29
- function new_amp_maybe_add_actions() {
30
- if ( is_home() || is_front_page() || is_archive() ) {
31
 
32
  $is_amp_endpoint = is_amp_endpoint();
33
 
@@ -53,12 +53,11 @@
53
  printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
54
  }
55
  }
56
-
57
 
58
 
59
- // 3. Custom Single and homepage code
60
- // Add Homepage AMP file code
61
 
 
62
  add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 );
63
  function ampforwp_custom_template( $file, $type, $post ) {
64
  // Custom Homepage and Archive file
@@ -77,8 +76,6 @@
77
  }
78
  }
79
  }
80
-
81
-
82
  // Custom Single file
83
  if ( is_single() || is_page() ) {
84
  if ( 'single' === $type ) {
@@ -88,38 +85,37 @@
88
  return $file;
89
  }
90
 
91
-
92
- // 4. Custom Style files
93
- add_filter( 'amp_post_template_file', 'mohammed_amp_set_custom_style', 10, 3 );
94
- function mohammed_amp_set_custom_style( $file, $type, $post ) {
95
- if ( 'style' === $type ) {
96
- $file = AMPFORWP_PLUGIN_DIR . '/templates/style.php';
97
- }
98
- return $file;
99
  }
100
 
101
- // 5. Custom Header files
102
  add_filter( 'amp_post_template_file', 'mohammed_amp_set_custom_header', 10, 3 );
103
  function mohammed_amp_set_custom_header( $file, $type, $post ) {
104
- if ( 'header-bar' === $type ) {
105
- $file = AMPFORWP_PLUGIN_DIR . '/templates/header.php';
106
- }
107
- return $file;
108
  }
109
 
110
 
111
- // 7. Customize with Width of the site
112
  add_filter( 'amp_content_max_width', 'ampforwp_change_content_width' );
113
-
114
  function ampforwp_change_content_width( $content_max_width ) {
115
- return 1000;
116
  }
117
 
118
- // 9. Add required Javascripts for extra AMP features
119
  add_action('amp_post_template_head','ampforwp_register_additional_scripts');
120
  function ampforwp_register_additional_scripts() {
121
  global $redux_builder_amp; ?>
122
  <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
 
123
  <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
124
  <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
125
  <script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
@@ -133,18 +129,18 @@
133
  <?php }
134
 
135
 
136
- // 10. Footer for AMP Pages
137
  add_action('amp_post_template_footer','ampforwp_footer');
138
  function ampforwp_footer() {
139
- global $redux_builder_amp;
140
- if ( is_home() ) {
141
- $ampforwp_backto_nonamp = home_url();
142
- } elseif ( is_single() ){
143
- $ampforwp_backto_nonamp = get_permalink( $post->ID );
144
- } else {
145
- $ampforwp_backto_nonamp = '';
146
- }
147
- ?>
148
 
149
  <footer class="container">
150
  <div id="footer">
@@ -167,7 +163,7 @@
167
 
168
  <?php }
169
 
170
- // 11. Add Main tag as a Wrapper
171
  add_action('ampforwp_after_header','ampforwp_main_tag_begins');
172
  function ampforwp_main_tag_begins() {
173
  echo ' <main>';
@@ -178,8 +174,7 @@
178
  echo '</main>';
179
  }
180
 
181
- // 12. Advertisement code
182
-
183
  // Below Header Global
184
  add_action('ampforwp_after_header','ampforwp_header_advert');
185
 
@@ -305,7 +300,6 @@
305
 
306
  // Below Content Single
307
  add_action('ampforwp_after_post_content','ampforwp_after_post_content_advert');
308
-
309
  function ampforwp_after_post_content_advert() {
310
  global $redux_builder_amp;
311
 
@@ -344,22 +338,49 @@
344
  }
345
  }
346
 
347
-
348
- add_action('amp_post_template_footer','ampforwp_google_analytics',11);
349
- function ampforwp_google_analytics() { ?>
350
- <amp-analytics type="googleanalytics" id="analytics1">
351
- <script type="application/json">
352
- {
353
- "vars": {
354
- "account": "<?php global $redux_builder_amp; echo $redux_builder_amp['ga-feild']; ?>"
355
- },
356
- "triggers": {
357
- "trackPageview": {
358
- "on": "visible",
359
- "request": "pageview"
360
- }
361
- }
 
 
 
 
 
 
 
 
 
362
  }
363
- </script>
364
- </amp-analytics>
365
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /* This file will contain all the Extra FEATURES.
3
+
4
+ 1. Add Home REL canonical
5
+ 2. Custom Design
6
+ 3. Custom Style files
7
+ 4. Custom Header files
8
+ 5. Customize with Width of the site
9
+ 6. Add required Javascripts for extra AMP features
10
+ 7. Footer for AMP Pages
11
+ 8. Add Main tag as a Wrapper
12
+ 9. Advertisement code
13
+ 10. Add Analytics to AMP Pages
14
+ 11. Strip unwanted codes and tags from the_content
15
+ 12. Add Logo URL in the structured metadata
16
  */
17
 
 
 
18
  // Adding AMP-related things to the main theme
19
+ global $redux_builder_amp;
20
 
21
+ // 1. Add Home REL canonical
22
  // Add AMP rel-canonical for home and archive pages
23
 
24
+ add_action('amp_init','ampforwp_allow_homepage');
25
+ function ampforwp_allow_homepage(){
26
+ add_action( 'wp', 'ampforwp_add_endpoint_actions' );
 
27
  }
28
 
29
+ function ampforwp_add_endpoint_actions() {
30
+ if ( is_home() || is_archive() ) {
31
 
32
  $is_amp_endpoint = is_amp_endpoint();
33
 
53
  printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
54
  }
55
  }
 
56
 
57
 
58
+ // 2. Custom Design
 
59
 
60
+ // Add Homepage AMP file code
61
  add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 );
62
  function ampforwp_custom_template( $file, $type, $post ) {
63
  // Custom Homepage and Archive file
76
  }
77
  }
78
  }
 
 
79
  // Custom Single file
80
  if ( is_single() || is_page() ) {
81
  if ( 'single' === $type ) {
85
  return $file;
86
  }
87
 
88
+ // 3. Custom Style files
89
+ add_filter( 'amp_post_template_file', 'ampforwp_set_custom_style', 10, 3 );
90
+ function ampforwp_set_custom_style( $file, $type, $post ) {
91
+ if ( 'style' === $type ) {
92
+ $file = AMPFORWP_PLUGIN_DIR . '/templates/style.php';
93
+ }
94
+ return $file;
 
95
  }
96
 
97
+ // 4. Custom Header files
98
  add_filter( 'amp_post_template_file', 'mohammed_amp_set_custom_header', 10, 3 );
99
  function mohammed_amp_set_custom_header( $file, $type, $post ) {
100
+ if ( 'header-bar' === $type ) {
101
+ $file = AMPFORWP_PLUGIN_DIR . '/templates/header.php';
102
+ }
103
+ return $file;
104
  }
105
 
106
 
107
+ // 5. Customize with Width of the site
108
  add_filter( 'amp_content_max_width', 'ampforwp_change_content_width' );
 
109
  function ampforwp_change_content_width( $content_max_width ) {
110
+ return 1000;
111
  }
112
 
113
+ // 6. Add required Javascripts for extra AMP features
114
  add_action('amp_post_template_head','ampforwp_register_additional_scripts');
115
  function ampforwp_register_additional_scripts() {
116
  global $redux_builder_amp; ?>
117
  <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
118
+ <script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
119
  <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
120
  <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
121
  <script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
129
  <?php }
130
 
131
 
132
+ // 7. Footer for AMP Pages
133
  add_action('amp_post_template_footer','ampforwp_footer');
134
  function ampforwp_footer() {
135
+ global $redux_builder_amp;
136
+ if ( is_home() ) {
137
+ $ampforwp_backto_nonamp = home_url();
138
+ } elseif ( is_single() ){
139
+ $ampforwp_backto_nonamp = get_permalink( $post->ID );
140
+ } else {
141
+ $ampforwp_backto_nonamp = '';
142
+ }
143
+ ?>
144
 
145
  <footer class="container">
146
  <div id="footer">
163
 
164
  <?php }
165
 
166
+ // 8. Add Main tag as a Wrapper
167
  add_action('ampforwp_after_header','ampforwp_main_tag_begins');
168
  function ampforwp_main_tag_begins() {
169
  echo ' <main>';
174
  echo '</main>';
175
  }
176
 
177
+ // 9. Advertisement code
 
178
  // Below Header Global
179
  add_action('ampforwp_after_header','ampforwp_header_advert');
180
 
300
 
301
  // Below Content Single
302
  add_action('ampforwp_after_post_content','ampforwp_after_post_content_advert');
 
303
  function ampforwp_after_post_content_advert() {
304
  global $redux_builder_amp;
305
 
338
  }
339
  }
340
 
341
+ // 10. Add Analytics to AMP Pages
342
+ add_action('amp_post_template_footer','ampforwp_google_analytics',11);
343
+ function ampforwp_google_analytics() { ?>
344
+ <amp-analytics type="googleanalytics" id="analytics1">
345
+ <script type="application/json">
346
+ {
347
+ "vars": {
348
+ "account": "<?php global $redux_builder_amp; echo $redux_builder_amp['ga-feild']; ?>"
349
+ },
350
+ "triggers": {
351
+ "trackPageview": {
352
+ "on": "visible",
353
+ "request": "pageview"
354
+ }
355
+ }
356
+ }
357
+ </script>
358
+ </amp-analytics>
359
+ <?php }
360
+
361
+ // 11. Strip unwanted codes and tags from the_content
362
+ add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content');
363
+ function ampforwp_strip_invalid_content(){
364
+ add_filter( 'the_content', 'ampforwp_the_content_filter', 20 );
365
  }
366
+ function ampforwp_the_content_filter( $content ) {
367
+ $content = preg_replace('/property=[^>]*/', '', $content);
368
+ $content = preg_replace('/vocab=[^>]*/', '', $content);
369
+ $content = preg_replace('/style=[^>]*/', '', $content);
370
+ $content = preg_replace('#<comments-count.*?>(.*?)</comments-count>#i', '', $content);
371
+ $content = preg_replace('/href="javascript:void*/', ' ', $content);
372
+ return $content;
373
+ }
374
+
375
+ // 12. Add Logo URL in the structured metadata
376
+ add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
377
+ function ampforwp_update_metadata( $metadata, $post ) {
378
+ global $redux_builder_amp;
379
+ $metadata['publisher']['logo'] = array(
380
+ '@type' => 'ImageObject',
381
+ 'url' => $redux_builder_amp['opt-media']['url'],
382
+ 'height' => 36,
383
+ 'width' => 190,
384
+ );
385
+ return $metadata;
386
+ }
templates/header.php CHANGED
@@ -20,7 +20,7 @@
20
 
21
 
22
  <div on='tap:sidebar.toggle' role="button" tabindex="0" class="nav_container">
23
- <a href="#" class="toggle-text">Navigate</a>
24
  </div>
25
 
26
 
20
 
21
 
22
  <div on='tap:sidebar.toggle' role="button" tabindex="0" class="nav_container">
23
+ <a href="#" class="toggle-text"><?php echo $redux_builder_amp['amp-navigation-text']; ?></a>
24
  </div>
25
 
26
 
templates/single.php CHANGED
@@ -66,7 +66,7 @@
66
  <?php if($redux_builder_amp['enable-single-social-icons'] == true) { ?>
67
  <div class="sticky_social">
68
  <?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
69
- <amp-social-share type="facebook" width="50" height="28"></amp-social-share>
70
  <?php } ?>
71
  <?php if($redux_builder_amp['enable-single-twitter-share'] == true) { ?>
72
  <amp-social-share type="twitter" width="50" height="28"></amp-social-share>
@@ -89,4 +89,4 @@
89
 
90
  <?php do_action( 'amp_post_template_footer', $this ); ?>
91
  </body>
92
- </html>
66
  <?php if($redux_builder_amp['enable-single-social-icons'] == true) { ?>
67
  <div class="sticky_social">
68
  <?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
69
+ <amp-social-share type="facebook" data-param-app_id="<?php echo $redux_builder_amp['amp-facebook-app-id']; ?>" width="50" height="28"></amp-social-share>
70
  <?php } ?>
71
  <?php if($redux_builder_amp['enable-single-twitter-share'] == true) { ?>
72
  <amp-social-share type="twitter" width="50" height="28"></amp-social-share>
89
 
90
  <?php do_action( 'amp_post_template_footer', $this ); ?>
91
  </body>
92
+ </html>
templates/style.php CHANGED
@@ -462,4 +462,4 @@ amp-user-notification button {
462
  <?php } ?>
463
 
464
  /* Custom Style Code */
465
- <?php echo $redux_builder_amp['css_editor']; ?>
462
  <?php } ?>
463
 
464
  /* Custom Style Code */
465
+ <?php echo $redux_builder_amp['css_editor']; ?>