AMP for WP – Accelerated Mobile Pages - Version 0.8.7

Version Description

  • Proper Details at http://ampforwp.com/amp-0-8-7/
  • added option to enable/disable AMP on Archive pages (Ticket #188)
  • Solved 404 on Related Posts (Ticket #178)
  • Related posts by either categories or Tags(Ticket #179)
  • added a link to menu Section from the AMP Options page(Ticket #190)
  • Added Support for Piwik Analytics(Ticket #163)
  • Added Support for Segment.com Analytics(Ticket #50)
  • Added a switch for hiding Non-Amp page link from Footer.( Ticket #189)
  • Added an Option that strips Users URL from Comments Section(Ticket #180) *Fixed stripping tags from the content , Since it was preventing validation issues fixed
  • UX Improved for every section of AMP Options page
  • Added Settings button on plugin page
  • Related posts switch added
  • Removed carousel.js
Download this release

Release Info

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

Code changes from version 0.8.6.1 to 0.8.7

README.md CHANGED
@@ -7,7 +7,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
7
  Donate link: https://www.paypal.me/Kaludi/5
8
  Requires at least: 3.0
9
  Tested up to: 4.6.1
10
- Stable tag: 0.8.6.1
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -116,6 +116,23 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
116
 
117
 
118
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  = 0.8.6.1 =
120
  * Date Tag fix
121
  * Few validation issues after 0.8.6 were fixed (Frontpage amp-img strip issue fixed)
7
  Donate link: https://www.paypal.me/Kaludi/5
8
  Requires at least: 3.0
9
  Tested up to: 4.6.1
10
+ Stable tag: 0.8.7
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
116
 
117
 
118
  == Changelog ==
119
+ = 0.8.7 =
120
+ * Proper Details at http://ampforwp.com/amp-0-8-7/
121
+ * added option to enable/disable AMP on Archive pages (Ticket #188)
122
+ * Solved 404 on Related Posts (Ticket #178 )
123
+ * Related posts by either categories or Tags(Ticket #179)
124
+ * added a link to menu Section from the AMP Options page(Ticket #190)
125
+ * Added Support for Piwik Analytics(Ticket #163)
126
+ * Added Support for Segment.com Analytics(Ticket #50)
127
+ * Added a switch for hiding Non-Amp page link from Footer.( Ticket #189)
128
+ * Added an Option that strips Users URL from Comments Section(Ticket #180)
129
+ * Fixed stripping <date> tags from the content , Since it was preventing validation
– <amp-img > issues fixed
130
+ * UX Improved for every section of AMP Options page
131
+ * Added Settings button on plugin page
132
+ * Related posts switch added
133
+ * Removed carousel.js
134
+
135
+
136
  = 0.8.6.1 =
137
  * Date Tag fix
138
  * Few validation issues after 0.8.6 were fixed (Frontpage amp-img strip issue fixed)
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.6.1
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/5
@@ -24,29 +24,46 @@ add_action( 'init', 'ampforwp_add_custom_post_support',11);
24
 
25
  define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
26
 
27
- /*
28
- * Load Files only in the backend
29
  * As we don't need plugin activation code to run everytime the site loads
30
- */
31
- if ( is_admin()) {
32
- require_once AMPFORWP_PLUGIN_DIR . '/classes/class-tgm-plugin-activation.php';
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  if ( ! class_exists( 'Ampforwp_Init', false ) ) {
36
  class Ampforwp_Init {
37
 
38
  public function __construct(){
39
 
40
- // Load Files required for the plugin to run
41
  require AMPFORWP_PLUGIN_DIR .'/includes/includes.php';
42
 
43
  require AMPFORWP_PLUGIN_DIR .'/classes/class-init.php';
44
- new Ampforwp_Loader;
45
-
46
  }
47
  }
48
  }
49
- /*
50
  * Start the plugin.
51
  * Gentlemen start your engines
52
  */
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.7
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/5
24
 
25
  define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
26
 
27
+ /*
28
+ * Load Files only in the backend
29
  * As we don't need plugin activation code to run everytime the site loads
30
+ */
31
+ if ( is_admin() ) {
32
+ require_once AMPFORWP_PLUGIN_DIR . '/classes/class-tgm-plugin-activation.php';
33
+
34
+ // Add Settings Button in Plugin backend
35
+ if ( ! function_exists( 'ampforwp_plugin_settings_link' ) ) {
36
+ add_filter( 'plugin_action_links', 'ampforwp_plugin_settings_link', 10, 5 );
37
+
38
+ function ampforwp_plugin_settings_link( $actions, $plugin_file ) {
39
+ static $plugin;
40
+ if (!isset($plugin))
41
+ $plugin = plugin_basename(__FILE__);
42
+ if ($plugin == $plugin_file) {
43
+ $settings = array('settings' => '<a href="admin.php?page=amp_options&tab=8">' . __('Settings', 'ampforwp') . '</a>');
44
+ $actions = array_merge( $actions, $settings );
45
+ }
46
+ return $actions;
47
+ }
48
+ }
49
+
50
+ } // is_admin() closing
51
 
52
  if ( ! class_exists( 'Ampforwp_Init', false ) ) {
53
  class Ampforwp_Init {
54
 
55
  public function __construct(){
56
 
57
+ // Load Files required for the plugin to run
58
  require AMPFORWP_PLUGIN_DIR .'/includes/includes.php';
59
 
60
  require AMPFORWP_PLUGIN_DIR .'/classes/class-init.php';
61
+ new Ampforwp_Loader;
62
+
63
  }
64
  }
65
  }
66
+ /*
67
  * Start the plugin.
68
  * Gentlemen start your engines
69
  */
includes/options/options-init.php CHANGED
@@ -127,7 +127,7 @@
127
  'icon' => 'el el-home',
128
  'fields' => array(
129
  array(
130
- 'id' => 'opt-blank',
131
  'title' => __( 'Example Text', 'redux-framework-demo' ),
132
  'desc' => __( 'Example description.', 'redux-framework-demo' ),
133
  'subtitle' => __( 'Example subtitle.', 'redux-framework-demo' ),
@@ -144,19 +144,19 @@
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>'
145
  . '<p><strong>' . __( 'The plugin supposed to redirect all mobile visitors to AMP version of site or not? ', 'redux-framework-demo' ) . '</strong><br/>' . __( 'When you view the website from the mobile, it is not supposed to redirect you to the amp version, amp version is always ready for google in the backend, if Google wants to serve to the people, then it will get the amp version and serve to the customers.
146
  ', 'redux-framework-demo' ) . '</p>'
147
-
148
  . '<p><strong>' . __( 'I am worried that it will cause Duplicate content?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'In the AMP version, we are using Canonical tag to solve this. I am 100% sure that using this plugin will not duplicate the content.
149
  ', 'redux-framework-demo' ) . '</p>'
150
 
151
 
152
  . '<p><strong>' . __( 'How do I know that my site is AMP enabled?
153
  ', 'redux-framework-demo' ) . '</strong><br/>' . __( 'Add /?amp at the end of your website url and you will get amp version of your website.', 'redux-framework-demo' ) . '</p>'
154
-
155
  . '<p><strong>' . sprintf( __( 'I have addded /?amp at the end of the url and still I am not able to see the AMP version of my site?
156
  ', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</strong><br/>'
157
  . sprintf( __( 'Please check if you have "Pretty Permalinks" enabled. If not then activate it.', 'redux-framework-demo' ), '' )
158
  . '</p>'
159
-
160
  . '<p><strong>' . sprintf( __( 'How do I report Bug reports?
161
  ', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</strong><br/>'
162
  . sprintf( __( 'Before you submit a new bug, please check if there already is an existing bug report for it. If so, it may be far more valuable to add to the existing one, than to create a new bug report. You can submit bug reports and feature requests at
@@ -165,13 +165,13 @@
165
 
166
  ', 'redux-framework-demo' ), '<a target="_blank" href="' . esc_url( 'https://github.com/ahmedkaludi/Accelerated-Mobile-Pages/issues' ) . '">', '</a>' )
167
  . '</p>'
168
-
169
- . sprintf( __( '
170
 
171
  <h2>%1$sLike this plugin? Support us by leaving a 5 Star Rating%2$s</h2><br />
172
  ', 'redux-framework-demo' ), '<a target="_blank" href="' . esc_url( 'https://wordpress.org/support/view/plugin-reviews/accelerated-mobile-pages?rate=5#postform' ) . '">', '</a>' )
173
  . '</p></div>'
174
-
175
  , 'redux-framework-demo' ),
176
  'icon' => 'el el-home'
177
  ) );
@@ -184,47 +184,59 @@
184
  'fields' => array(
185
  $fields = array(
186
  'id' => 'opt-media',
187
- 'type' => 'media',
188
  'url' => true,
189
  'title' => __('Logo', 'redux-framework-demo'),
190
- //'desc' => __('', 'redux-framework-demo'),
191
- 'desc' => __('Upload a logo for the AMP version. Recommend logo size is: 190x36', 'redux-framework-demo'),
192
- // 'default' => array(
193
- // 'url'=>'http://s.wordpress.org/style/images/codeispoetry.png'
194
- // ),
 
 
 
 
 
 
 
 
 
195
  ),
196
-
197
- //$fields = array(
198
- // 'id' => 'opt-switch',
199
- // 'type' => 'switch',
200
- // 'title' => __('Switch On', 'redux-framework-demo'),
201
- // 'subtitle' => __('Look, it\'s on!', 'redux-framework-demo'),
202
- // 'default' => true
203
- //),
204
-
205
  array(
206
  'id' => 'ga-feild',
207
- 'type' => 'text',
208
  'title' => __( 'Google Analytics', 'redux-framework-demo' ),
209
- 'subtitle' => __( '', 'redux-framework-demo' ),
210
- 'desc' => __( 'Enter your Google Analytics ID. Example: UA-XXXXX-Y.', 'redux-framework-demo' ),
 
211
  'default' => 'UA-XXXXX-Y',
212
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  array(
214
  'id' => 'opt-color-rgba',
215
  'type' => 'color_rgba',
216
  'title' => 'Color Scheme',
217
- 'subtitle' => 'Set color and alpha channel',
218
- 'desc' => 'Change the color scheme to your branding color',
219
-
220
- // See Notes below about these lines.
221
- //'output' => array('background-color' => '.site-header'),
222
- //'compiler' => array('color' => '.site-header, .site-footer', 'background-color' => '.nav-bar'),
223
  'default' => array(
224
  'color' => '#312C7E',
225
  'alpha' => 1
226
  ),
227
-
228
  // These options display a fully functional color palette. Omit this argument
229
  // for the minimal color picker, and change as desired.
230
  'options' => array(
@@ -243,93 +255,87 @@
243
  'use_extended_classes' => true,
244
  'palette' => null, // show default
245
  'input_text' => 'Select Color'
246
- )
247
  ),
248
  array(
249
  'id' =>'amp-frontpage-select-option',
250
- 'type' => 'switch',
251
  'title' => __('Front Page', 'redux-framework-demo'),
252
  'default' => 0,
253
- 'subtitle' => __('Custom AMP frontpage', 'redux-framework-demo'),
254
  'true' => 'true',
255
- 'false' => 'false',
256
  ),
257
  array(
258
  'id' => 'amp-frontpage-select-option-pages',
259
  'type' => 'select',
260
- 'title' => __('Select Page as Frontpage', 'redux-framework-demo'),
261
  'required' => array('amp-frontpage-select-option', '=' , '1'),
262
  // Must provide key => value pairs for select options
263
  'data' => 'page',
264
  'args' => array(
265
- 'post_type' => 'page',
266
  'posts_per_page' => 500
267
- ),
268
-
269
  'default' => '2',
270
  ),
271
-
272
  array(
273
  'id' => 'amp-footer-text',
274
  'title' => __('Footer', 'redux-framework-demo'),
275
- 'type' => 'text',
276
- 'default' => 'Copyright &copy; 2016'
277
- ),
278
-
 
 
 
 
 
 
 
 
 
 
 
 
279
  array(
280
  'id' =>'amp-rtl-select-option',
281
- 'type' => 'switch',
282
  'title' => __('RTL Support', 'redux-framework-demo'),
283
  'default' => 0,
284
- 'subtitle' => __('Enable Right to Left language support?', 'redux-framework-demo'),
285
  'true' => 'true',
286
- 'false' => 'false',
287
  ),
288
  array(
289
  'id' => 'amp-navigation-text',
290
  'title' => __('Navigation Text', 'redux-framework-demo'),
291
- 'type' => 'text',
 
 
292
  'default' => 'Navigate'
293
  ),
 
 
 
 
 
 
 
294
  )
 
 
 
 
 
 
 
 
 
 
 
295
 
296
-
297
-
298
- ) );
299
-
300
- // Notifications SECTION
301
- Redux::setSection( $opt_name, array(
302
- 'title' => __( 'Notifications', 'redux-framework-demo' ),
303
- 'desc' => __( 'Add notifications to your AMP pages'),
304
- 'id' => 'amp-notifications',
305
- 'subsection' => true,
306
- 'fields' => array(
307
- array(
308
- 'id' =>'amp-enable-notifications',
309
- 'type' => 'switch',
310
- 'title' => __('Enable Notifications', 'redux-framework-demo'),
311
- 'default' => '',
312
- 'subtitle' => __('Show notifications on all of your AMP pages for cookie purposes, or anything else.', 'redux-framework-demo'),
313
- 'true' => 'Enabled',
314
- 'false' => 'Disabled',
315
- ),
316
- array(
317
- 'id' => 'amp-notification-text',
318
- 'title' => __('Notification text', 'redux-framework-demo'),
319
- 'type' => 'text',
320
- 'required' => array('amp-enable-notifications', '=' , '1'),
321
- 'default' => 'This website uses cookies.'
322
- ),
323
- array(
324
- 'id' => 'amp-accept-button-text',
325
- 'title' => __('Notification accept button text', 'redux-framework-demo'),
326
- 'type' => 'text',
327
- 'required' => array('amp-enable-notifications', '=' , '1'),
328
- 'default' => 'Accept'
329
- ),
330
- ),
331
-
332
- ) );
333
 
334
  // ADS SECTION
335
  Redux::setSection( $opt_name, array(
@@ -341,7 +347,7 @@
341
  // Ad 1 Starts
342
  array(
343
  'id' =>'enable-amp-ads-1',
344
- 'type' => 'switch',
345
  'title' => __('AD #1', 'redux-framework-demo'),
346
  'default' => 0,
347
  'subtitle' => __('Below the Header (SiteWide)', 'redux-framework-demo'),
@@ -351,12 +357,12 @@
351
  array(
352
  'id' => 'enable-amp-ads-select-1',
353
  'type' => 'select',
354
- 'title' => __('AD Size', 'redux-framework-demo'),
355
  'required' => array('enable-amp-ads-1', '=' , '1'),
356
  // Must provide key => value pairs for select options
357
  'options' => array(
358
  '1' => '300x250',
359
- '2' => '336x280',
360
  '3' => '728x90',
361
  '4' => '300x600',
362
  '5' => '320x100',
@@ -367,37 +373,38 @@
367
  ),
368
  array(
369
  'id' =>'enable-amp-ads-text-feild-client-1',
370
- 'type' => 'text',
371
  'required' => array('enable-amp-ads-1', '=' , '1'),
372
  'title' => __('Data AD Client', 'redux-framework-demo'),
373
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
374
- 'default' => '',
375
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
376
- ),
377
  array(
378
  'id' => 'enable-amp-ads-text-feild-slot-1',
379
- 'type' => 'text',
380
  'title' => __('Data AD Slot', 'redux-framework-demo'),
381
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
382
- 'default' => '',
383
  'required' => array('enable-amp-ads-1', '=' , '1'),
384
  'placeholder'=> '70XXXXXX12'
385
  ),
386
- // Ad 1 ends
 
387
  // Ad 2 Starts
388
  array(
389
  'id'=>'enable-amp-ads-2',
390
- 'type' => 'switch',
391
  'title' => __('AD #2', 'redux-framework-demo'),
392
  'default' => 0,
393
  'subtitle' => __('Below the Footer (SiteWide)', 'redux-framework-demo'),
394
  'true' => 'Enabled',
395
  'false' => 'Disabled',
396
- ),
397
  array(
398
  'id' => 'enable-amp-ads-select-2',
399
  'type' => 'select',
400
- 'title' => __('AD Size', 'redux-framework-demo'),
401
  'required' => array('enable-amp-ads-2', '=' , '1'),
402
  // Must provide key => value pairs for select options
403
  'options' => array(
@@ -413,37 +420,38 @@
413
  ),
414
  array(
415
  'id' =>'enable-amp-ads-text-feild-client-2',
416
- 'type' => 'text',
417
  'required' => array('enable-amp-ads-2', '=' , '1'),
418
  'title' => __('Data AD Client', 'redux-framework-demo'),
419
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
420
- 'default' => '',
421
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
422
- ),
423
  array(
424
  'id' => 'enable-amp-ads-text-feild-slot-2',
425
- 'type' => 'text',
426
  'title' => __('Data AD Slot', 'redux-framework-demo'),
427
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
428
- 'default' => '',
429
  'required' => array('enable-amp-ads-2', '=' , '1'),
430
  'placeholder'=> '70XXXXXX12'
431
  ),
432
  // Ad 2 ends
 
433
  // Ad 3 starts
434
  array(
435
  'id' => 'enable-amp-ads-3',
436
- 'type' => 'switch',
437
  'title' => __('AD #3', 'redux-framework-demo'),
438
  'default' => 0,
439
  'subtitle' => __('Above the Post Content (Single Post)', 'redux-framework-demo'),
440
  'true' => 'Enabled',
441
  'false' => 'Disabled',
442
- ),
443
  array(
444
  'id' => 'enable-amp-ads-select-3',
445
  'type' => 'select',
446
- 'title' => __('AD Size', 'redux-framework-demo'),
447
  'required' => array('enable-amp-ads-3', '=' , '1'),
448
  // Must provide key => value pairs for select options
449
  'options' => array(
@@ -459,37 +467,38 @@
459
  ),
460
  array(
461
  'id' =>'enable-amp-ads-text-feild-client-3',
462
- 'type' => 'text',
463
  'required' => array('enable-amp-ads-3', '=' , '1'),
464
  'title' => __('Data AD Client', 'redux-framework-demo'),
465
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
466
  'default' => '',
467
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
468
- ),
469
  array(
470
  'id' => 'enable-amp-ads-text-feild-slot-3',
471
- 'type' => 'text',
472
  'title' => __('Data AD Slot', 'redux-framework-demo'),
473
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
474
  'default' => '',
475
  'required' => array('enable-amp-ads-3', '=' , '1'),
476
  'placeholder'=> '70XXXXXX12'
477
  ),
478
  // Ad 3 ends
 
479
  // Ad 4 Starts
480
  array(
481
  'id' => 'enable-amp-ads-4',
482
- 'type' => 'switch',
483
  'title' => __('AD #4', 'redux-framework-demo'),
484
  'default' => 0,
485
  'subtitle' => __('Below the Post Content (Single Post)', 'redux-framework-demo'),
486
  'true' => 'Enabled',
487
  'false' => 'Disabled',
488
- ),
489
  array(
490
  'id' => 'enable-amp-ads-select-4',
491
  'type' => 'select',
492
- 'title' => __('AD Size', 'redux-framework-demo'),
493
  'required' => array('enable-amp-ads-4', '=' , '1'),
494
  // Must provide key => value pairs for select options
495
  'options' => array(
@@ -505,25 +514,24 @@
505
  ),
506
  array(
507
  'id' =>'enable-amp-ads-text-feild-client-4',
508
- 'type' => 'text',
509
  'required' => array('enable-amp-ads-4', '=' , '1'),
510
  'title' => __('Data AD Client', 'redux-framework-demo'),
511
- 'desc' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code. e.g. ca-pub-2005XXXXXXXXX342', 'redux-framework-demo'),
512
  'default' => '',
513
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
514
- ),
515
  array(
516
  'id' => 'enable-amp-ads-text-feild-slot-4',
517
- 'type' => 'text',
518
  'title' => __('Data AD Slot', 'redux-framework-demo'),
519
- 'desc' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. e.g. 70XXXXXX12', 'redux-framework-demo'),
520
  'default' => '',
521
  'required' => array('enable-amp-ads-4', '=' , '1'),
522
  'placeholder'=> '70XXXXXX12'
523
  )
524
  // Ad 4 ends
525
  ),
526
-
527
  ) );
528
 
529
 
@@ -534,81 +542,98 @@
534
  'id' => 'amp-single',
535
  'subsection' => true,
536
  'fields' => array(
537
-
538
  // Featured Image ON/OFF
539
  // array(
540
  // 'id' => 'enable-single-featured-image',
541
- // 'type' => 'switch',
542
  // 'title' => __('Featured Image Above Post Content', 'redux-framework-demo'),
543
  // 'default' => 0,
544
  // 'subtitle' => __('Enable Featured Image in the single post', 'redux-framework-demo'),
545
  // 'true' => 'Enabled',
546
  // 'false' => 'Disabled',
547
- // ),
548
  // Post Meta ON/OFF
549
  array(
550
  'id' => 'enable-single-post-meta',
551
- 'type' => 'switch',
552
  'title' => __('Post Meta Above Post Content', 'redux-framework-demo'),
553
  'default' => 1,
554
  'subtitle' => __('Enable Post Meta in the single post', 'redux-framework-demo'),
555
  'true' => 'Enabled',
556
  'false' => 'Disabled',
557
- ),
558
  // Single Featured ON/OFF
559
  array(
560
  'id' => 'enable-single-featured-img',
561
- 'type' => 'switch',
562
  'title' => __('Featured Image', 'redux-framework-demo'),
563
  'default' => 1,
564
  'subtitle' => __('Enabling this will automatically display the featured image', 'redux-framework-demo'),
565
  'true' => 'Enabled',
566
  'false' => 'Disabled',
567
- ),
568
  // Next/Previous Pagination ON/OFF
569
  array(
570
  'id' => 'enable-next-previous-pagination',
571
- 'type' => 'switch',
572
  'title' => __('Post Pagination', 'redux-framework-demo'),
573
  'default' => 1,
574
  'subtitle' => __('Enable Next / Previous in the single post', 'redux-framework-demo'),
575
  'true' => 'Enabled',
576
  'false' => 'Disabled',
577
- ),
578
- // Tags ON/OFF
579
  array(
580
  'id' => 'ampforwp-single-tags-on-off',
581
- 'type' => 'switch',
582
  'title' => __('Tags', 'redux-framework-demo'),
583
  'default' => 1,
584
  'subtitle' => __('Enable / Disable Tags in the single post', 'redux-framework-demo'),
585
  'true' => 'Enabled',
586
  'false' => 'Disabled',
587
- ),
588
- // Related Post
589
- array(
590
- 'id' => 'ampforwp-single-related-on-off',
591
- 'type' => 'switch',
592
- 'title' => __('Related Post', 'redux-framework-demo'),
593
- 'default' => 1,
594
- 'subtitle' => __('Enable / Disable Related Posts in the single post', 'redux-framework-demo'),
595
- 'true' => 'Enabled',
596
- 'false' => 'Disabled',
597
- ),
598
- // Comments Post
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
  array(
600
  'id' => 'ampforwp-single-comments-on-off',
601
- 'type' => 'switch',
602
  'title' => __('Comments', 'redux-framework-demo'),
603
  'default' => 1,
604
  'subtitle' => __('Enable / Disable Comments in the single post', 'redux-framework-demo'),
605
  'true' => 'Enabled',
606
  'false' => 'Disabled',
607
- ),
608
  // Social Icons ON/OFF
609
  array(
610
  'id' => 'enable-single-social-icons',
611
- 'type' => 'switch',
612
  'title' => __('Social Icons', 'redux-framework-demo'),
613
  'default' => 1,
614
  'subtitle' => __('Enable Social Icons in single', 'redux-framework-demo'),
@@ -616,7 +641,7 @@
616
  // Facebook ON/OFF
617
  array(
618
  'id' => 'enable-single-facebook-share',
619
- 'type' => 'switch',
620
  'required' => array('enable-single-social-icons', '=' , '1'),
621
  'title' => __('Facebook', 'redux-framework-demo'),
622
  'default' => 0,
@@ -625,102 +650,141 @@
625
  array(
626
  'id' => 'amp-facebook-app-id',
627
  'title' => __('Facebook App ID', 'redux-framework-demo'),
628
- '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'),
629
- 'type' => 'text',
 
630
  'required' => array('enable-single-facebook-share', '=' , '1'),
631
  'placeholder' => 'Enter your facebook app id',
632
  'default' => ''
633
- ),
634
  // Twitter ON/OFF
635
  array(
636
  'id' => 'enable-single-twitter-share',
637
- 'type' => 'switch',
638
  'required' => array('enable-single-social-icons', '=' , '1'),
639
  'title' => __('Twitter', 'redux-framework-demo'),
640
  'default' => 1,
641
- ),
642
  // GooglePlus ON/OFF
643
  array(
644
  'id' => 'enable-single-gplus-share',
645
- 'type' => 'switch',
646
  'required' => array('enable-single-social-icons', '=' , '1'),
647
  'title' => __('GooglePlus', 'redux-framework-demo'),
648
  'default' => 1,
649
- ),
650
  // Email ON/OFF
651
  array(
652
  'id' => 'enable-single-email-share',
653
- 'type' => 'switch',
654
  'required' => array('enable-single-social-icons', '=' , '1'),
655
  'title' => __('Email', 'redux-framework-demo'),
656
  'default' => 1,
657
- ),
658
  // Pinterest ON/OFF
659
  array(
660
  'id' => 'enable-single-pinterest-share',
661
- 'type' => 'switch',
662
  'required' => array('enable-single-social-icons', '=' , '1'),
663
  'title' => __('Pinterest', 'redux-framework-demo'),
664
  'default' => 1,
665
- ),
666
  // LinkedIn ON/OFF
667
  array(
668
  'id' => 'enable-single-linkedin-share',
669
- 'type' => 'switch',
670
  'required' => array('enable-single-social-icons', '=' , '1'),
671
  'title' => __('LinkedIn', 'redux-framework-demo'),
672
  'default' => 1,
673
  ),
674
  array(
675
  'id' => 'enable-single-whatsapp-share',
676
- 'type' => 'switch',
677
  'required' => array('enable-single-social-icons', '=' , '1'),
678
  'title' => __('WhatsApp', 'redux-framework-demo'),
679
  'default' => 1,
680
  ),
681
  ),
682
-
683
  ) );
684
-
685
  // Structured Data
686
  Redux::setSection( $opt_name, array(
687
  'title' => __( 'Structured Data', 'redux-framework-demo' ),
688
- // 'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/textarea/" target="_blank">http://docs.reduxframework.com/core/fields/textarea/</a>',
689
  'id' => 'opt-structured-data',
690
  'subsection' => true,
691
  'fields' => array(
692
  array(
693
  'id' => 'amp-structured-data-logo',
694
- 'type' => 'media',
695
  'url' => true,
696
  'title' => __('Default Structured Data Logo', 'redux-framework-demo'),
697
- 'desc' => __('Upload the logo you want to show in Google Structured Data. ', 'redux-framework-demo'),
698
  ),
699
  array(
700
  'id' => 'amp-structured-data-placeholder-image',
701
- 'type' => 'media',
702
  'url' => true,
703
  'title' => __('Default Post Image', 'redux-framework-demo'),
704
- 'desc' => __('Upload the Image you want to show as Placeholder Image, when there is no featured image set in the post.', 'redux-framework-demo'),
 
705
  ),
706
  array(
707
  'id' => 'amp-structured-data-placeholder-image-width',
708
  'title' => __('Default Post Image Width', 'redux-framework-demo'),
709
- 'type' => 'text',
710
- 'placeholder' => '550',
711
- 'desc' => 'Please don\'t add "PX" in the image size.',
712
  'default' => ''
713
- ),
714
  array(
715
  'id' => 'amp-structured-data-placeholder-image-height',
716
  'title' => __('Default Post Image Height', 'redux-framework-demo'),
717
- 'type' => 'text',
718
  'placeholder' => '350',
719
- 'desc' => 'Please don\'t add "PX" in the image size.',
720
  'default' => ''
721
  ),
722
  )
723
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
724
 
725
  // CSS
726
  Redux::setSection( $opt_name, array(
@@ -734,7 +798,7 @@
734
  'type' => 'ace_editor',
735
  'title' => __('Custom CSS', 'redux-framework-demo'),
736
  'subtitle' => __('You can customize the Stylesheet of the AMP version by using this option.', 'redux-framework-demo'),
737
- 'mode' => 'css',
738
  'theme' => 'monokai',
739
  'desc' => '',
740
  'default' => "/******* Paste your Custom CSS in this Editor *******/"
127
  'icon' => 'el el-home',
128
  'fields' => array(
129
  array(
130
+ 'id' => 'opt-blank',
131
  'title' => __( 'Example Text', 'redux-framework-demo' ),
132
  'desc' => __( 'Example description.', 'redux-framework-demo' ),
133
  'subtitle' => __( 'Example subtitle.', 'redux-framework-demo' ),
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>'
145
  . '<p><strong>' . __( 'The plugin supposed to redirect all mobile visitors to AMP version of site or not? ', 'redux-framework-demo' ) . '</strong><br/>' . __( 'When you view the website from the mobile, it is not supposed to redirect you to the amp version, amp version is always ready for google in the backend, if Google wants to serve to the people, then it will get the amp version and serve to the customers.
146
  ', 'redux-framework-demo' ) . '</p>'
147
+
148
  . '<p><strong>' . __( 'I am worried that it will cause Duplicate content?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'In the AMP version, we are using Canonical tag to solve this. I am 100% sure that using this plugin will not duplicate the content.
149
  ', 'redux-framework-demo' ) . '</p>'
150
 
151
 
152
  . '<p><strong>' . __( 'How do I know that my site is AMP enabled?
153
  ', 'redux-framework-demo' ) . '</strong><br/>' . __( 'Add /?amp at the end of your website url and you will get amp version of your website.', 'redux-framework-demo' ) . '</p>'
154
+
155
  . '<p><strong>' . sprintf( __( 'I have addded /?amp at the end of the url and still I am not able to see the AMP version of my site?
156
  ', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</strong><br/>'
157
  . sprintf( __( 'Please check if you have "Pretty Permalinks" enabled. If not then activate it.', 'redux-framework-demo' ), '' )
158
  . '</p>'
159
+
160
  . '<p><strong>' . sprintf( __( 'How do I report Bug reports?
161
  ', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</strong><br/>'
162
  . sprintf( __( 'Before you submit a new bug, please check if there already is an existing bug report for it. If so, it may be far more valuable to add to the existing one, than to create a new bug report. You can submit bug reports and feature requests at
165
 
166
  ', 'redux-framework-demo' ), '<a target="_blank" href="' . esc_url( 'https://github.com/ahmedkaludi/Accelerated-Mobile-Pages/issues' ) . '">', '</a>' )
167
  . '</p>'
168
+
169
+ . sprintf( __( '
170
 
171
  <h2>%1$sLike this plugin? Support us by leaving a 5 Star Rating%2$s</h2><br />
172
  ', 'redux-framework-demo' ), '<a target="_blank" href="' . esc_url( 'https://wordpress.org/support/view/plugin-reviews/accelerated-mobile-pages?rate=5#postform' ) . '">', '</a>' )
173
  . '</p></div>'
174
+
175
  , 'redux-framework-demo' ),
176
  'icon' => 'el el-home'
177
  ) );
184
  'fields' => array(
185
  $fields = array(
186
  'id' => 'opt-media',
187
+ 'type' => 'media',
188
  'url' => true,
189
  'title' => __('Logo', 'redux-framework-demo'),
190
+ 'subtitle' => __('Upload a logo for the AMP version.', 'redux-framework-demo'),
191
+ 'desc' => __('Recommend logo size is: 190x36', 'redux-framework-demo')
192
+ ),
193
+ array(
194
+ 'id' => 'amp-analytics-select-option',
195
+ 'type' => 'select',
196
+ 'title' => __( 'Analytics Type', 'redux-framework-demo' ),
197
+ 'subtitle' => __( 'Select your Analytics provider.', 'redux-framework-demo' ),
198
+ 'options' => array(
199
+ '1' => __('Google Analytics', 'redux-framework-demo' ),
200
+ '2' => __('Segment Analytics', 'redux-framework-demo' ),
201
+ '3' => __('Piwik Analytics', 'redux-framework-demo' )
202
+ ),
203
+ 'default' => '1'
204
  ),
 
 
 
 
 
 
 
 
 
205
  array(
206
  'id' => 'ga-feild',
207
+ 'type' => 'text',
208
  'title' => __( 'Google Analytics', 'redux-framework-demo' ),
209
+ 'required' => array('amp-analytics-select-option', '=' , '1'),
210
+ 'subtitle' => __( 'Enter your Google Analytics ID.', 'redux-framework-demo' ),
211
+ 'desc' => __('Example: UA-XXXXX-Y', 'redux-framework-demo' ),
212
  'default' => 'UA-XXXXX-Y',
213
  ),
214
+ array(
215
+ 'id' => 'sa-feild',
216
+ 'type' => 'text',
217
+ 'title' => __( 'Segment Analytics', 'redux-framework-demo' ),
218
+ 'subtitle' => __( 'Enter your Segment Analytics Key.', 'redux-framework-demo' ),
219
+ 'required' => array('amp-analytics-select-option', '=' , '2'),
220
+ 'default' => 'SEGMENT-WRITE-KEY',
221
+ ),
222
+ array(
223
+ 'id' => 'pa-feild',
224
+ 'type' => 'text',
225
+ 'title' => __( 'Piwik Analytics', 'redux-framework-demo' ),
226
+ 'required' => array('amp-analytics-select-option', '=' , '3'),
227
+ 'desc' => __( 'Example: https://piwik.example.org/piwik.php?idsite=YOUR_SITE_ID&rec=1&action_name=TITLE&urlref=DOCUMENT_REFERRER&url=CANONICAL_URL&rand=RANDOM', 'redux-framework-demo' ),
228
+ 'subtitle' => __('Enter your Piwik Analytics URL.', 'redux-framework-demo' ),
229
+ 'default' => '#',
230
+ ),
231
  array(
232
  'id' => 'opt-color-rgba',
233
  'type' => 'color_rgba',
234
  'title' => 'Color Scheme',
235
+ 'subtitle' => __('Change the color scheme to your branding color','redux-framework-demo' ),
 
 
 
 
 
236
  'default' => array(
237
  'color' => '#312C7E',
238
  'alpha' => 1
239
  ),
 
240
  // These options display a fully functional color palette. Omit this argument
241
  // for the minimal color picker, and change as desired.
242
  'options' => array(
255
  'use_extended_classes' => true,
256
  'palette' => null, // show default
257
  'input_text' => 'Select Color'
258
+ )
259
  ),
260
  array(
261
  'id' =>'amp-frontpage-select-option',
262
+ 'type' => 'switch',
263
  'title' => __('Front Page', 'redux-framework-demo'),
264
  'default' => 0,
265
+ 'subtitle' => __('Custom AMP front page', 'redux-framework-demo'),
266
  'true' => 'true',
267
+ 'false' => 'false',
268
  ),
269
  array(
270
  'id' => 'amp-frontpage-select-option-pages',
271
  'type' => 'select',
272
+ 'title' => __('Select Page as Front Page', 'redux-framework-demo'),
273
  'required' => array('amp-frontpage-select-option', '=' , '1'),
274
  // Must provide key => value pairs for select options
275
  'data' => 'page',
276
  'args' => array(
277
+ 'post_type' => 'page',
278
  'posts_per_page' => 500
279
+ ),
 
280
  'default' => '2',
281
  ),
282
+
283
  array(
284
  'id' => 'amp-footer-text',
285
  'title' => __('Footer', 'redux-framework-demo'),
286
+ 'type' => 'text',
287
+ 'subtitle' => __('Enter Footer text', 'redux-framework-demo'),
288
+ 'placeholder' => 'Copyright &copy; 2016',
289
+ 'default' => 'Copyright &copy; 2016',
290
+ ),
291
+
292
+ array(
293
+ 'id' => 'amp-footer-link-non-amp-page',
294
+ 'type' => 'switch',
295
+ 'title' => __('Link to Non-AMP page', 'redux-framework-demo'),
296
+ 'subtitle' => __('Enable / Disable Link to Non-AMP page in the footer', 'redux-framework-demo'),
297
+ 'true' => 'true',
298
+ 'false' => 'false',
299
+ 'default' => 1
300
+ ),
301
+
302
  array(
303
  'id' =>'amp-rtl-select-option',
304
+ 'type' => 'switch',
305
  'title' => __('RTL Support', 'redux-framework-demo'),
306
  'default' => 0,
307
+ 'subtitle' => __('Enable Right to Left language support', 'redux-framework-demo'),
308
  'true' => 'true',
309
+ 'false' => 'false',
310
  ),
311
  array(
312
  'id' => 'amp-navigation-text',
313
  'title' => __('Navigation Text', 'redux-framework-demo'),
314
+ 'type' => 'text',
315
+ 'subtitle' =>__('Enter text to appear on Navigation Button', 'redux-framework-demo'),
316
+ 'placeholder'=>'Navigate',
317
  'default' => 'Navigate'
318
  ),
319
+ array(
320
+ 'id' => 'ampforwp-amp-on-off-catgs-tags',
321
+ 'type' => 'switch',
322
+ 'title' => __('Hide AMP on Archive Pages', 'redux-framework-demo'),
323
+ 'subtitle' => __('Enable / Disable AMP in the categories and tags pages', 'redux-framework-demo'),
324
+ 'true' => 'true',
325
+ 'false' => 'false'),
326
  )
327
+ ) );//END
328
+
329
+
330
+ // AMP Menu SECTION
331
+ Redux::setSection( $opt_name, array(
332
+ 'title' => __( 'AMP Menu', 'redux-framework-demo' ),
333
+ 'desc' => __( 'Add Menus to your AMP pages by clicking on this <a href="'.trailingslashit(get_admin_url()).'nav-menus.php?action=locations">link</a>'),
334
+ 'id' => 'amp-menus',
335
+ 'subsection' => true)
336
+
337
+ ) ;
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
 
340
  // ADS SECTION
341
  Redux::setSection( $opt_name, array(
347
  // Ad 1 Starts
348
  array(
349
  'id' =>'enable-amp-ads-1',
350
+ 'type' => 'switch',
351
  'title' => __('AD #1', 'redux-framework-demo'),
352
  'default' => 0,
353
  'subtitle' => __('Below the Header (SiteWide)', 'redux-framework-demo'),
357
  array(
358
  'id' => 'enable-amp-ads-select-1',
359
  'type' => 'select',
360
+ 'title' => __('AD Size', 'redux-framework-demo'),
361
  'required' => array('enable-amp-ads-1', '=' , '1'),
362
  // Must provide key => value pairs for select options
363
  'options' => array(
364
  '1' => '300x250',
365
+ '2' => '336x280',
366
  '3' => '728x90',
367
  '4' => '300x600',
368
  '5' => '320x100',
373
  ),
374
  array(
375
  'id' =>'enable-amp-ads-text-feild-client-1',
376
+ 'type' => 'text',
377
  'required' => array('enable-amp-ads-1', '=' , '1'),
378
  'title' => __('Data AD Client', 'redux-framework-demo'),
379
+ 'subtitle' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code.', 'redux-framework-demo'),
380
+ 'default' => '',
381
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
382
+ ),
383
  array(
384
  'id' => 'enable-amp-ads-text-feild-slot-1',
385
+ 'type' => 'text',
386
  'title' => __('Data AD Slot', 'redux-framework-demo'),
387
+ 'subtitle' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code.', 'redux-framework-demo'),
388
+ 'default' => '',
389
  'required' => array('enable-amp-ads-1', '=' , '1'),
390
  'placeholder'=> '70XXXXXX12'
391
  ),
392
+ // Ad 1 ends
393
+
394
  // Ad 2 Starts
395
  array(
396
  'id'=>'enable-amp-ads-2',
397
+ 'type' => 'switch',
398
  'title' => __('AD #2', 'redux-framework-demo'),
399
  'default' => 0,
400
  'subtitle' => __('Below the Footer (SiteWide)', 'redux-framework-demo'),
401
  'true' => 'Enabled',
402
  'false' => 'Disabled',
403
+ ),
404
  array(
405
  'id' => 'enable-amp-ads-select-2',
406
  'type' => 'select',
407
+ 'title' => __('AD Size', 'redux-framework-demo'),
408
  'required' => array('enable-amp-ads-2', '=' , '1'),
409
  // Must provide key => value pairs for select options
410
  'options' => array(
420
  ),
421
  array(
422
  'id' =>'enable-amp-ads-text-feild-client-2',
423
+ 'type' => 'text',
424
  'required' => array('enable-amp-ads-2', '=' , '1'),
425
  'title' => __('Data AD Client', 'redux-framework-demo'),
426
+ 'subtitle' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code.', 'redux-framework-demo'),
427
+ 'default' => '',
428
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
429
+ ),
430
  array(
431
  'id' => 'enable-amp-ads-text-feild-slot-2',
432
+ 'type' => 'text',
433
  'title' => __('Data AD Slot', 'redux-framework-demo'),
434
+ 'subtitle' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code.', 'redux-framework-demo'),
435
+ 'default' => '',
436
  'required' => array('enable-amp-ads-2', '=' , '1'),
437
  'placeholder'=> '70XXXXXX12'
438
  ),
439
  // Ad 2 ends
440
+
441
  // Ad 3 starts
442
  array(
443
  'id' => 'enable-amp-ads-3',
444
+ 'type' => 'switch',
445
  'title' => __('AD #3', 'redux-framework-demo'),
446
  'default' => 0,
447
  'subtitle' => __('Above the Post Content (Single Post)', 'redux-framework-demo'),
448
  'true' => 'Enabled',
449
  'false' => 'Disabled',
450
+ ),
451
  array(
452
  'id' => 'enable-amp-ads-select-3',
453
  'type' => 'select',
454
+ 'title' => __('AD Size', 'redux-framework-demo'),
455
  'required' => array('enable-amp-ads-3', '=' , '1'),
456
  // Must provide key => value pairs for select options
457
  'options' => array(
467
  ),
468
  array(
469
  'id' =>'enable-amp-ads-text-feild-client-3',
470
+ 'type' => 'text',
471
  'required' => array('enable-amp-ads-3', '=' , '1'),
472
  'title' => __('Data AD Client', 'redux-framework-demo'),
473
+ 'subtitle' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code.', 'redux-framework-demo'),
474
  'default' => '',
475
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
476
+ ),
477
  array(
478
  'id' => 'enable-amp-ads-text-feild-slot-3',
479
+ 'type' => 'text',
480
  'title' => __('Data AD Slot', 'redux-framework-demo'),
481
+ 'subtitle' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code.', 'redux-framework-demo'),
482
  'default' => '',
483
  'required' => array('enable-amp-ads-3', '=' , '1'),
484
  'placeholder'=> '70XXXXXX12'
485
  ),
486
  // Ad 3 ends
487
+
488
  // Ad 4 Starts
489
  array(
490
  'id' => 'enable-amp-ads-4',
491
+ 'type' => 'switch',
492
  'title' => __('AD #4', 'redux-framework-demo'),
493
  'default' => 0,
494
  'subtitle' => __('Below the Post Content (Single Post)', 'redux-framework-demo'),
495
  'true' => 'Enabled',
496
  'false' => 'Disabled',
497
+ ),
498
  array(
499
  'id' => 'enable-amp-ads-select-4',
500
  'type' => 'select',
501
+ 'title' => __('AD Size', 'redux-framework-demo'),
502
  'required' => array('enable-amp-ads-4', '=' , '1'),
503
  // Must provide key => value pairs for select options
504
  'options' => array(
514
  ),
515
  array(
516
  'id' =>'enable-amp-ads-text-feild-client-4',
517
+ 'type' => 'text',
518
  'required' => array('enable-amp-ads-4', '=' , '1'),
519
  'title' => __('Data AD Client', 'redux-framework-demo'),
520
+ 'subtitle' => __('Enter the Data Ad Client (data-ad-client) from the adsense ad code.', 'redux-framework-demo'),
521
  'default' => '',
522
  'placeholder'=> 'ca-pub-2005XXXXXXXXX342'
523
+ ),
524
  array(
525
  'id' => 'enable-amp-ads-text-feild-slot-4',
526
+ 'type' => 'text',
527
  'title' => __('Data AD Slot', 'redux-framework-demo'),
528
+ 'subtitle' => __('Enter the Data Ad Slot (data-ad-slot) from the adsense ad code. ', 'redux-framework-demo'),
529
  'default' => '',
530
  'required' => array('enable-amp-ads-4', '=' , '1'),
531
  'placeholder'=> '70XXXXXX12'
532
  )
533
  // Ad 4 ends
534
  ),
 
535
  ) );
536
 
537
 
542
  'id' => 'amp-single',
543
  'subsection' => true,
544
  'fields' => array(
545
+
546
  // Featured Image ON/OFF
547
  // array(
548
  // 'id' => 'enable-single-featured-image',
549
+ // 'type' => 'switch',
550
  // 'title' => __('Featured Image Above Post Content', 'redux-framework-demo'),
551
  // 'default' => 0,
552
  // 'subtitle' => __('Enable Featured Image in the single post', 'redux-framework-demo'),
553
  // 'true' => 'Enabled',
554
  // 'false' => 'Disabled',
555
+ // ),
556
  // Post Meta ON/OFF
557
  array(
558
  'id' => 'enable-single-post-meta',
559
+ 'type' => 'switch',
560
  'title' => __('Post Meta Above Post Content', 'redux-framework-demo'),
561
  'default' => 1,
562
  'subtitle' => __('Enable Post Meta in the single post', 'redux-framework-demo'),
563
  'true' => 'Enabled',
564
  'false' => 'Disabled',
565
+ ),
566
  // Single Featured ON/OFF
567
  array(
568
  'id' => 'enable-single-featured-img',
569
+ 'type' => 'switch',
570
  'title' => __('Featured Image', 'redux-framework-demo'),
571
  'default' => 1,
572
  'subtitle' => __('Enabling this will automatically display the featured image', 'redux-framework-demo'),
573
  'true' => 'Enabled',
574
  'false' => 'Disabled',
575
+ ),
576
  // Next/Previous Pagination ON/OFF
577
  array(
578
  'id' => 'enable-next-previous-pagination',
579
+ 'type' => 'switch',
580
  'title' => __('Post Pagination', 'redux-framework-demo'),
581
  'default' => 1,
582
  'subtitle' => __('Enable Next / Previous in the single post', 'redux-framework-demo'),
583
  'true' => 'Enabled',
584
  'false' => 'Disabled',
585
+ ),
586
+ // Tags ON/OFF
587
  array(
588
  'id' => 'ampforwp-single-tags-on-off',
589
+ 'type' => 'switch',
590
  'title' => __('Tags', 'redux-framework-demo'),
591
  'default' => 1,
592
  'subtitle' => __('Enable / Disable Tags in the single post', 'redux-framework-demo'),
593
  'true' => 'Enabled',
594
  'false' => 'Disabled',
595
+ ),
596
+
597
+ // Related Post
598
+ //new related type posts field
599
+ array(
600
+ 'id' => 'ampforwp-single-select-type-of-related-switch',
601
+ 'type' => 'switch',
602
+ 'title' => __('Related Post', 'redux-framework-demo'),
603
+ 'subtitle' => __('Enable / Disable Related Posts', 'redux-framework-demo'),
604
+ 'default' => '1',
605
+ ),
606
+ array(
607
+ 'id' => 'ampforwp-single-select-type-of-related',
608
+ 'type' => 'select',
609
+ 'title' => __('Show Related Post from', 'redux-framework-demo'),
610
+ 'data' => 'page',
611
+ 'subtitle' => __('select the type of related posts', 'redux-framework-demo'),
612
+ 'options' => array(
613
+ '1' => 'Tags',
614
+ '2' => 'Categories'
615
+ ),
616
+ 'args' => array(
617
+ 'post_type' => 'page',
618
+ 'posts_per_page' => 500
619
+ ),// ampforwp-single-select-type-of-related-switch
620
+ 'required' => array('ampforwp-single-select-type-of-related-switch', '=' , '1'),
621
+ 'default' => '2',
622
+ ),
623
+ // Comments Post
624
  array(
625
  'id' => 'ampforwp-single-comments-on-off',
626
+ 'type' => 'switch',
627
  'title' => __('Comments', 'redux-framework-demo'),
628
  'default' => 1,
629
  'subtitle' => __('Enable / Disable Comments in the single post', 'redux-framework-demo'),
630
  'true' => 'Enabled',
631
  'false' => 'Disabled',
632
+ ),
633
  // Social Icons ON/OFF
634
  array(
635
  'id' => 'enable-single-social-icons',
636
+ 'type' => 'switch',
637
  'title' => __('Social Icons', 'redux-framework-demo'),
638
  'default' => 1,
639
  'subtitle' => __('Enable Social Icons in single', 'redux-framework-demo'),
641
  // Facebook ON/OFF
642
  array(
643
  'id' => 'enable-single-facebook-share',
644
+ 'type' => 'switch',
645
  'required' => array('enable-single-social-icons', '=' , '1'),
646
  'title' => __('Facebook', 'redux-framework-demo'),
647
  'default' => 0,
650
  array(
651
  'id' => 'amp-facebook-app-id',
652
  'title' => __('Facebook App ID', 'redux-framework-demo'),
653
+ 'subtitle' => __('In order to use Facebook share you need to register an app ID.', 'redux-framework-demo'),
654
+ 'type' => 'text',
655
+ 'desc' =>__(' You can register one here: https://developers.facebook.com/apps.', 'redux-framework-demo'),
656
  'required' => array('enable-single-facebook-share', '=' , '1'),
657
  'placeholder' => 'Enter your facebook app id',
658
  'default' => ''
659
+ ),
660
  // Twitter ON/OFF
661
  array(
662
  'id' => 'enable-single-twitter-share',
663
+ 'type' => 'switch',
664
  'required' => array('enable-single-social-icons', '=' , '1'),
665
  'title' => __('Twitter', 'redux-framework-demo'),
666
  'default' => 1,
667
+ ),
668
  // GooglePlus ON/OFF
669
  array(
670
  'id' => 'enable-single-gplus-share',
671
+ 'type' => 'switch',
672
  'required' => array('enable-single-social-icons', '=' , '1'),
673
  'title' => __('GooglePlus', 'redux-framework-demo'),
674
  'default' => 1,
675
+ ),
676
  // Email ON/OFF
677
  array(
678
  'id' => 'enable-single-email-share',
679
+ 'type' => 'switch',
680
  'required' => array('enable-single-social-icons', '=' , '1'),
681
  'title' => __('Email', 'redux-framework-demo'),
682
  'default' => 1,
683
+ ),
684
  // Pinterest ON/OFF
685
  array(
686
  'id' => 'enable-single-pinterest-share',
687
+ 'type' => 'switch',
688
  'required' => array('enable-single-social-icons', '=' , '1'),
689
  'title' => __('Pinterest', 'redux-framework-demo'),
690
  'default' => 1,
691
+ ),
692
  // LinkedIn ON/OFF
693
  array(
694
  'id' => 'enable-single-linkedin-share',
695
+ 'type' => 'switch',
696
  'required' => array('enable-single-social-icons', '=' , '1'),
697
  'title' => __('LinkedIn', 'redux-framework-demo'),
698
  'default' => 1,
699
  ),
700
  array(
701
  'id' => 'enable-single-whatsapp-share',
702
+ 'type' => 'switch',
703
  'required' => array('enable-single-social-icons', '=' , '1'),
704
  'title' => __('WhatsApp', 'redux-framework-demo'),
705
  'default' => 1,
706
  ),
707
  ),
708
+
709
  ) );
710
+
711
  // Structured Data
712
  Redux::setSection( $opt_name, array(
713
  'title' => __( 'Structured Data', 'redux-framework-demo' ),
 
714
  'id' => 'opt-structured-data',
715
  'subsection' => true,
716
  'fields' => array(
717
  array(
718
  'id' => 'amp-structured-data-logo',
719
+ 'type' => 'media',
720
  'url' => true,
721
  'title' => __('Default Structured Data Logo', 'redux-framework-demo'),
722
+ 'subtitle' => __('Upload the logo you want to show in Google Structured Data. ', 'redux-framework-demo'),
723
  ),
724
  array(
725
  'id' => 'amp-structured-data-placeholder-image',
726
+ 'type' => 'media',
727
  'url' => true,
728
  'title' => __('Default Post Image', 'redux-framework-demo'),
729
+ 'subtitle' => __('Upload the Image you want to show as Placeholder Image.', 'redux-framework-demo'),
730
+ 'placeholder' => 'when there is no featured image set in the post',
731
  ),
732
  array(
733
  'id' => 'amp-structured-data-placeholder-image-width',
734
  'title' => __('Default Post Image Width', 'redux-framework-demo'),
735
+ 'type' => 'text',
736
+ 'placeholder' => '550',
737
+ 'subtitle' => 'Please don\'t add "PX" in the image size.',
738
  'default' => ''
739
+ ),
740
  array(
741
  'id' => 'amp-structured-data-placeholder-image-height',
742
  'title' => __('Default Post Image Height', 'redux-framework-demo'),
743
+ 'type' => 'text',
744
  'placeholder' => '350',
745
+ 'subtitle' => 'Please don\'t add "PX" in the image size.',
746
  'default' => ''
747
  ),
748
  )
749
+ ) );
750
+
751
+ // Notifications SECTION
752
+ Redux::setSection( $opt_name, array(
753
+ 'title' => __( 'Notifications', 'redux-framework-demo' ),
754
+ 'desc' => __( 'Add notifications to your AMP pages'),
755
+ 'id' => 'amp-notifications',
756
+ 'subsection' => true,
757
+ 'fields' => array(
758
+ array(
759
+ 'id' =>'amp-enable-notifications',
760
+ 'type' => 'switch',
761
+ 'title' => __('Enable Notifications', 'redux-framework-demo'),
762
+ 'default' => '',
763
+ 'subtitle' => __('Show notifications on all of your AMP pages for cookie purposes, or anything else.', 'redux-framework-demo'),
764
+ 'true' => 'Enabled',
765
+ 'false' => 'Disabled',
766
+ ),
767
+ array(
768
+ 'id' => 'amp-notification-text',
769
+ 'title' => __('Notification text', 'redux-framework-demo'),
770
+ 'type' => 'text',
771
+ 'required' => array('amp-enable-notifications', '=' , '1'),
772
+ 'default' => 'This website uses cookies.',
773
+ 'placeholder' => 'Enter Text here',
774
+ ),
775
+ array(
776
+ 'id' => 'amp-accept-button-text',
777
+ 'title' => __('Notification accept button text', 'redux-framework-demo'),
778
+ 'type' => 'text',
779
+ 'required' => array('amp-enable-notifications', '=' , '1'),
780
+ 'default' => 'Accept',
781
+ 'placeholder' => 'Enter Text here',
782
+ ),
783
+
784
+ ),
785
+
786
+ ) );
787
+
788
 
789
  // CSS
790
  Redux::setSection( $opt_name, array(
798
  'type' => 'ace_editor',
799
  'title' => __('Custom CSS', 'redux-framework-demo'),
800
  'subtitle' => __('You can customize the Stylesheet of the AMP version by using this option.', 'redux-framework-demo'),
801
+ 'mode' => 'css',
802
  'theme' => 'monokai',
803
  'desc' => '',
804
  'default' => "/******* Paste your Custom CSS in this Editor *******/"
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.6.1
7
- Stable tag: 0.8.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -113,6 +113,23 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
113
 
114
 
115
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  = 0.8.6.1 =
117
  * Date Tag fix
118
  * Few validation issues after 0.8.6 were fixed (Frontpage amp-img strip issue fixed)
4
  Donate link: https://www.paypal.me/Kaludi/5
5
  Requires at least: 3.0
6
  Tested up to: 4.6.1
7
+ Stable tag: 0.8.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
113
 
114
 
115
  == Changelog ==
116
+ = 0.8.7 =
117
+ * Proper Details at http://ampforwp.com/amp-0-8-7/
118
+ * added option to enable/disable AMP on Archive pages (Ticket #188)
119
+ * Solved 404 on Related Posts (Ticket #178 )
120
+ * Related posts by either categories or Tags(Ticket #179)
121
+ * added a link to menu Section from the AMP Options page(Ticket #190)
122
+ * Added Support for Piwik Analytics(Ticket #163)
123
+ * Added Support for Segment.com Analytics(Ticket #50)
124
+ * Added a switch for hiding Non-Amp page link from Footer.( Ticket #189)
125
+ * Added an Option that strips Users URL from Comments Section(Ticket #180)
126
+ * Fixed stripping <date> tags from the content , Since it was preventing validation
– <amp-img > issues fixed
127
+ * UX Improved for every section of AMP Options page
128
+ * Added Settings button on plugin page
129
+ * Related posts switch added
130
+ * Removed carousel.js
131
+
132
+
133
  = 0.8.6.1 =
134
  * Date Tag fix
135
  * Few validation issues after 0.8.6 were fixed (Frontpage amp-img strip issue fixed)
templates/features.php CHANGED
@@ -1,42 +1,46 @@
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
- 4.5 Added hook to add more layout.
9
- 5. Customize with Width of the site
10
- 6. Add required Javascripts for extra AMP features
11
- 7. Footer for AMP Pages
12
- 8. Add Main tag as a Wrapper
13
- 9. Advertisement code
14
- 10. Add Analytics to AMP Pages
15
- 11. Strip unwanted codes and tags from the_content
16
- 12. Add Logo URL in the structured metadata
17
- 13. Add Custom Placeholder Image for Structured Data.
18
- 14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
19
- 15. Disable New Relic's extra script that its adds in AMP pages.
20
- 16. Remove Unwanted Scripts
21
- 17. Archives Canonical in AMP version
22
- 18. Custom Canonical for Homepage
23
- 19. Remove Canonical tags
24
- 20. Remove the default Google font for performance
25
- 21. Remove Schema data from All In One Schema.org Rich Snippets Plugin
 
 
 
 
26
  */
27
- // Adding AMP-related things to the main theme
28
  global $redux_builder_amp;
29
-
30
  // 1. Add Home REL canonical
31
- // Add AMP rel-canonical for home and archive pages
32
 
33
  add_action('amp_init','ampforwp_allow_homepage');
34
- function ampforwp_allow_homepage(){
35
  add_action( 'wp', 'ampforwp_add_endpoint_actions' );
36
  }
37
 
38
  function ampforwp_add_endpoint_actions() {
39
- if ( is_home() || is_archive() ) {
40
 
41
  $is_amp_endpoint = is_amp_endpoint();
42
 
@@ -45,33 +49,38 @@
45
  } else {
46
  add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' );
47
  }
48
-
49
  }
50
  }
51
 
52
  function ampforwp_home_archive_rel_canonical() {
53
-
54
  if ( is_home() || is_front_page() || is_archive() ) {
55
 
56
- if ( is_home() || is_front_page() ){
57
  $amp_url = home_url('/?amp');
58
  }
59
- elseif( is_archive()){
60
- global $wp;
61
- $archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
62
- $amp_url = $archive_current_url . '/?amp';
63
- }
64
- else {
65
- $amp_url = trailingslashit( get_permalink().'amp' );
66
  }
67
 
68
- printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
 
 
 
 
 
 
69
  }
70
- }
71
-
72
 
73
  // 2. Custom Design
74
-
75
  // Add Homepage AMP file code
76
  add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 );
77
  function ampforwp_custom_template( $file, $type, $post ) {
@@ -90,7 +99,7 @@
90
  $file = AMPFORWP_PLUGIN_DIR . '/templates/frontpage.php';
91
  }
92
  }
93
- }
94
  // Custom Single file
95
  if ( is_single() || is_page() ) {
96
  if ( 'single' === $type ) {
@@ -117,7 +126,7 @@
117
  }
118
  return $file;
119
  }
120
-
121
  // 4.5 Added hook to add more layout.
122
  do_action('ampforwp_after_features_include');
123
 
@@ -130,8 +139,8 @@
130
 
131
  // 6. Add required Javascripts for extra AMP features
132
  add_action('amp_post_template_head','ampforwp_register_additional_scripts');
133
- function ampforwp_register_additional_scripts() {
134
- global $redux_builder_amp; ?>
135
  <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
136
  <script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
137
  <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
@@ -144,12 +153,12 @@
144
  <!-- AMP Advertisement Script -->
145
  <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
146
 
147
- <?php }
148
 
149
 
150
  // 7. Footer for AMP Pages
151
  add_action('amp_post_template_footer','ampforwp_footer');
152
- function ampforwp_footer() {
153
  global $redux_builder_amp;
154
  if ( is_home() ) {
155
  $ampforwp_backto_nonamp = home_url();
@@ -162,24 +171,25 @@
162
 
163
  <footer class="container">
164
  <div id="footer">
165
- <p><a href="#header"> <?php _e('Top','ampforwp');?></a> <?php if ( $ampforwp_backto_nonamp ) { ?> |
166
- <a href="<?php echo $ampforwp_backto_nonamp; ?>"><?php _e('View Non-AMP Version','ampforwp');?></a> <?php } ?>
 
 
 
167
  </p>
168
  <p><?php echo $redux_builder_amp['amp-footer-text']; ?> </p>
169
  </div>
170
- </footer>
171
-
172
- <!-- Cookie Notification Code
173
- added by @nicholasgriffintn in pull #121 -->
174
- <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
175
- <amp-user-notification layout=nodisplay id="amp-user-notification1">
176
- <p><?php echo $redux_builder_amp['amp-notification-text']; ?> </p>
177
- <button on="tap:amp-user-notification1.dismiss"><?php echo $redux_builder_amp['amp-accept-button-text']; ?></button>
178
- </amp-user-notification>
179
- <?php } ?>
180
-
181
-
182
- <?php }
183
 
184
  // 8. Add Main tag as a Wrapper
185
  add_action('ampforwp_after_header','ampforwp_main_tag_begins');
@@ -190,7 +200,7 @@
190
  add_action('amp_post_template_footer','ampforwp_main_tag_ends',9);
191
  function ampforwp_main_tag_ends() {
192
  echo '</main>';
193
- }
194
 
195
  // 9. Advertisement code
196
  // Below Header Global
@@ -199,7 +209,7 @@
199
  function ampforwp_header_advert() {
200
  global $redux_builder_amp;
201
 
202
- if($redux_builder_amp['enable-amp-ads-1'] == true) {
203
  if($redux_builder_amp['enable-amp-ads-select-1'] == 1) {
204
  $advert_width = '300';
205
  $advert_height = '250';
@@ -225,7 +235,7 @@
225
  $output = '<div class="amp-ad-wrapper amp_ad_1">';
226
  $output .= '<amp-ad class="amp-ad-1"
227
  type="adsense"
228
- width='. $advert_width .' height='. $advert_height . '
229
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-1'].'"
230
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-1'] .'">';
231
  $output .= '</amp-ad>';
@@ -240,7 +250,7 @@
240
  function ampforwp_footer_advert() {
241
  global $redux_builder_amp;
242
 
243
- if($redux_builder_amp['enable-amp-ads-2'] == true) {
244
  if($redux_builder_amp['enable-amp-ads-select-2'] == 1) {
245
  $advert_width = '300';
246
  $advert_height = '250';
@@ -266,7 +276,7 @@
266
  $output = '<div class="amp-ad-wrapper">';
267
  $output .= '<amp-ad class="amp-ad-2"
268
  type="adsense"
269
- width='. $advert_width .' height='. $advert_height . '
270
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-2'].'"
271
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-2'] .'">';
272
  $output .= '</amp-ad>';
@@ -281,7 +291,7 @@
281
  function ampforwp_before_post_content_advert() {
282
  global $redux_builder_amp;
283
 
284
- if($redux_builder_amp['enable-amp-ads-3'] == true) {
285
  if($redux_builder_amp['enable-amp-ads-select-3'] == 1) {
286
  $advert_width = '300';
287
  $advert_height = '250';
@@ -307,7 +317,7 @@
307
  $output = '<div class="amp-ad-wrapper">';
308
  $output .= '<amp-ad class="amp-ad-3"
309
  type="adsense"
310
- width='. $advert_width .' height='. $advert_height . '
311
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-3'].'"
312
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-3'] .'">';
313
  $output .= '</amp-ad>';
@@ -321,7 +331,7 @@
321
  function ampforwp_after_post_content_advert() {
322
  global $redux_builder_amp;
323
 
324
- if($redux_builder_amp['enable-amp-ads-4'] == true) {
325
  if($redux_builder_amp['enable-amp-ads-select-4'] == 1) {
326
  $advert_width = '300';
327
  $advert_height = '250';
@@ -347,7 +357,7 @@
347
  $output = '<div class="amp-ad-wrapper">';
348
  $output .= '<amp-ad class="amp-ad-4"
349
  type="adsense"
350
- width='. $advert_width .' height='. $advert_height . '
351
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-4'].'"
352
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-4'] .'">';
353
  $output .= '</amp-ad>';
@@ -355,30 +365,56 @@
355
  echo $output;
356
  }
357
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
 
359
- // 10. Add Analytics to AMP Pages
360
- add_action('amp_post_template_footer','ampforwp_google_analytics',11);
361
- function ampforwp_google_analytics() { ?>
362
- <amp-analytics type="googleanalytics" id="analytics1">
363
- <script type="application/json">
364
- {
365
- "vars": {
366
- "account": "<?php global $redux_builder_amp; echo $redux_builder_amp['ga-feild']; ?>"
367
- },
368
- "triggers": {
369
- "trackPageview": {
370
- "on": "visible",
371
- "request": "pageview"
372
- }
373
- }
374
- }
375
- </script>
376
- </amp-analytics>
377
- <?php }
378
 
379
  // 11. Strip unwanted codes and tags from the_content
380
  add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content');
381
- function ampforwp_strip_invalid_content(){
382
  add_filter( 'the_content', 'ampforwp_the_content_filter', 20 );
383
  }
384
  function ampforwp_the_content_filter( $content ) {
@@ -400,7 +436,7 @@
400
  $content = preg_replace('#<style scoped.*?>(.*?)</style>#i', '', $content);
401
  $content = preg_replace('/href="javascript:void*/', ' ', $content);
402
  // $content = preg_replace('/<img*/', '<amp-img', $content); // Fallback for plugins
403
- return $content;
404
  }
405
 
406
  // 11.5 Strip unwanted codes the_content of Frontpage
@@ -412,17 +448,14 @@
412
  }
413
  function ampforwp_the_content_filter_frontpage( $content ) {
414
  $content = preg_replace('/<img*/', '<amp-img', $content); // Fallback for plugins
415
- return $content;
416
  }
417
 
418
-
419
-
420
-
421
  // 12. Add Logo URL in the structured metadata
422
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
423
  function ampforwp_update_metadata( $metadata, $post ) {
424
  global $redux_builder_amp;
425
-
426
  $structured_data_logo = $redux_builder_amp['amp-structured-data-logo']['url'];
427
 
428
  if ($structured_data_logo) {
@@ -438,18 +471,18 @@
438
  );
439
  return $metadata;
440
  }
441
-
442
-
443
  // 13. Add Custom Placeholder Image for Structured Data.
444
  // if there is no image in the post, then use this image to validate Structured Data.
445
- add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 );
446
- function ampforwp_update_metadata_featured_image( $metadata, $post ) {
447
  global $redux_builder_amp;
448
  $post_id = $post->ID;
449
  $post_image_id = get_post_thumbnail_id( $post_id );
450
  $structured_data_image = wp_get_attachment_image_src( $post_image_id, 'full' );
451
  $post_image_check = $structured_data_image;
452
-
453
  if ( $post_image_check == false) {
454
  $structured_data_image = $redux_builder_amp['amp-structured-data-placeholder-image']['url'];
455
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
@@ -462,13 +495,12 @@ function ampforwp_update_metadata_featured_image( $metadata, $post ) {
462
  'width' => $structured_data_width,
463
  );
464
  }
465
-
466
  // Custom Structured Data information for Archive, Categories and tag pages.
467
  if ( is_archive() ) {
468
  $structured_data_image = $redux_builder_amp['amp-structured-data-placeholder-image']['url'];
469
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
470
  $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']);
471
-
472
  $structured_data_archive_title = "Archived Posts";
473
  $structured_data_author = get_userdata( 1 );
474
  if ( $structured_data_author ) {
@@ -476,7 +508,7 @@ function ampforwp_update_metadata_featured_image( $metadata, $post ) {
476
  } else {
477
  $structured_data_author = "admin";
478
  }
479
-
480
  $metadata['image'] = array(
481
  '@type' => 'ImageObject',
482
  'url' => $structured_data_image ,
@@ -487,19 +519,19 @@ function ampforwp_update_metadata_featured_image( $metadata, $post ) {
487
  '@type' => 'Person',
488
  'name' => $structured_data_author ,
489
  );
490
- $metadata['headline'] = $structured_data_archive_title;
491
- }
492
  return $metadata;
493
- }
494
 
495
  // 14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
496
  /**
497
  * Adds a meta box to the post editing screen for AMP on-off on specific pages
498
- */
499
  function ampforwp_title_custom_meta() {
500
- add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?' ), 'ampforwp_title_callback', 'post','side' );
501
-
502
- add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?' ), 'ampforwp_title_callback', 'page','side' );
503
  }
504
  add_action( 'add_meta_boxes', 'ampforwp_title_custom_meta' );
505
 
@@ -529,23 +561,23 @@ function ampforwp_title_callback( $post ) {
529
  * Saves the custom meta input for AMP on-off on specific pages
530
  */
531
  function ampforwp_title_meta_save( $post_id ) {
532
-
533
  // Checks save status
534
  $is_autosave = wp_is_post_autosave( $post_id );
535
  $is_revision = wp_is_post_revision( $post_id );
536
  $is_valid_nonce = ( isset( $_POST[ 'ampforwp_title_nonce' ] ) && wp_verify_nonce( $_POST[ 'ampforwp_title_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
537
-
538
  // Exits script depending on save status
539
  if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
540
  return;
541
  }
542
-
543
  // Checks for radio buttons and saves if needed
544
  if( isset( $_POST[ 'ampforwp-amp-on-off' ] ) ) {
545
  $ampforwp_amp_status = sanitize_text_field( $_POST[ 'ampforwp-amp-on-off' ] );
546
  update_post_meta( $post_id, 'ampforwp-amp-on-off', $ampforwp_amp_status );
547
  }
548
-
549
  }
550
  add_action( 'save_post', 'ampforwp_title_meta_save' );
551
 
@@ -578,46 +610,45 @@ if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
578
  add_action( 'wp_enqueue_scripts', 'ampforwp_remove_unwanted_scripts',20 );
579
  }
580
  function ampforwp_remove_unwanted_scripts() {
581
- wp_dequeue_script('jquery');
582
  }
583
  // Remove Print Scripts and styles
584
  function ampforwp_remove_print_scripts() {
585
- if ( is_amp_endpoint() ) {
586
-
587
- function ampforwp_remove_all_scripts() {
588
- global $wp_scripts;
589
- $wp_scripts->queue = array();
590
- }
591
- add_action('wp_print_scripts', 'ampforwp_remove_all_scripts', 100);
592
- function ampforwp_remove_all_styles() {
593
- global $wp_styles;
594
- $wp_styles->queue = array();
595
- }
596
- add_action('wp_print_styles', 'ampforwp_remove_all_styles', 100);
 
 
 
 
597
 
598
- // Remove Print Emoji for Nextgen Gallery support
599
- remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
600
- remove_action( 'wp_print_styles', 'print_emoji_styles' );
601
-
602
- }
603
  }
604
  add_action( 'template_redirect', 'ampforwp_remove_print_scripts' );
605
 
606
-
607
  // 17. Archives Canonical in AMP version
608
  function ampforwp_rel_canonical_archive() {
609
  if ( !is_archive() )
610
- return;
611
- global $wp;
612
- $current_archive_url = home_url( $wp->request );
613
- // $archivelink = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
614
- echo "<link rel='canonical' href='$current_archive_url' />\n";
615
  }
616
  add_action( 'amp_post_template_head', 'ampforwp_rel_canonical_archive' );
617
 
618
  // 18. Custom Canonical for Homepage
619
  function ampforwp_rel_canonical() {
620
- if ( !is_home() )
621
  return;
622
  // $link = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
623
  $homelink = get_home_url();
@@ -627,19 +658,19 @@ add_action( 'amp_post_template_head', 'ampforwp_rel_canonical' );
627
 
628
  // 18.5. Custom Canonical for Frontpage
629
  //function ampforwp_rel_canonical_frontpage() {
630
- // if ( is_home() || is_front_page() )
631
  // return;
632
  //// $link = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
633
  // $homelink = get_home_url();
634
  // echo "<link rel='canonical' href='$homelink' />\n";
635
  //}
636
  //add_action( 'amp_post_template_head', 'ampforwp_rel_canonical_frontpage' );
637
-
638
  // 19. Remove Canonical tags
639
  function ampforwp_amp_remove_actions() {
640
  if ( is_home() || is_front_page() || is_archive() ) {
641
  remove_action( 'amp_post_template_head', 'amp_post_template_add_canonical' );
642
- }
643
  }
644
  add_action( 'amp_post_template_head', 'ampforwp_amp_remove_actions', 9 );
645
 
@@ -648,9 +679,21 @@ add_action( 'amp_post_template_head', function() {
648
  remove_action( 'amp_post_template_head', 'amp_post_template_add_fonts' );
649
  }, 9 );
650
 
651
-
652
  // 21. Remove Schema data from All In One Schema.org Rich Snippets Plugin
653
  add_action( 'pre_amp_render_post', 'ampforwp_remove_schema_data' );
654
  function ampforwp_remove_schema_data() {
655
  remove_filter('the_content','display_rich_snippet');
656
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ 4.5 Added hook to add more layout.
9
+ 5. Customize with Width of the site
10
+ 6. Add required Javascripts for extra AMP features
11
+ 7. Footer for AMP Pages
12
+ 8. Add Main tag as a Wrapper
13
+ 9. Advertisement code
14
+ 10. Analytics Area
15
+ 10.1 Analytics Support added for Google Analytics
16
+ 10.2 Analytics Support added for segment.com
17
+ 10.3 Analytics Support added for Piwik
18
+ 11. Strip unwanted codes and tags from the_content
19
+ 12. Add Logo URL in the structured metadata
20
+ 13. Add Custom Placeholder Image for Structured Data.
21
+ 14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
22
+ 15. Disable New Relic's extra script that its adds in AMP pages.
23
+ 16. Remove Unwanted Scripts
24
+ 17. Archives Canonical in AMP version
25
+ 18. Custom Canonical for Homepage
26
+ 19. Remove Canonical tags
27
+ 20. Remove the default Google font for performance
28
+ 21. Remove Schema data from All In One Schema.org Rich Snippets Plugin
29
+ 22. Removing author links from comments Issue #180
30
  */
31
+ // Adding AMP-related things to the main theme
32
  global $redux_builder_amp;
33
+
34
  // 1. Add Home REL canonical
35
+ // Add AMP rel-canonical for home and archive pages
36
 
37
  add_action('amp_init','ampforwp_allow_homepage');
38
+ function ampforwp_allow_homepage() {
39
  add_action( 'wp', 'ampforwp_add_endpoint_actions' );
40
  }
41
 
42
  function ampforwp_add_endpoint_actions() {
43
+ if ( is_home() || is_archive()) {
44
 
45
  $is_amp_endpoint = is_amp_endpoint();
46
 
49
  } else {
50
  add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' );
51
  }
52
+
53
  }
54
  }
55
 
56
  function ampforwp_home_archive_rel_canonical() {
57
+ global $redux_builder_amp;
58
  if ( is_home() || is_front_page() || is_archive() ) {
59
 
60
+ if ( is_home() || is_front_page() ){
61
  $amp_url = home_url('/?amp');
62
  }
63
+ elseif( is_archive()){
64
+ global $wp;
65
+ $archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
66
+ $amp_url = $archive_current_url . '/?amp';
67
+ }
68
+ else {
69
+ $amp_url = trailingslashit( get_permalink().'amp' );
70
  }
71
 
72
+ //checking if the user wants amp page for archives or not
73
+ if( is_archive() && $redux_builder_amp['ampforwp-amp-on-off-catgs-tags']=='1') {
74
+ // Dont do anything :)
75
+ } else {
76
+ printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
77
+ }
78
+ // end of checking if the user wants amp page for archives or not
79
  }
80
+ } //end of ampforwp_home_archive_rel_canonical()
 
81
 
82
  // 2. Custom Design
83
+
84
  // Add Homepage AMP file code
85
  add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 );
86
  function ampforwp_custom_template( $file, $type, $post ) {
99
  $file = AMPFORWP_PLUGIN_DIR . '/templates/frontpage.php';
100
  }
101
  }
102
+ }
103
  // Custom Single file
104
  if ( is_single() || is_page() ) {
105
  if ( 'single' === $type ) {
126
  }
127
  return $file;
128
  }
129
+
130
  // 4.5 Added hook to add more layout.
131
  do_action('ampforwp_after_features_include');
132
 
139
 
140
  // 6. Add required Javascripts for extra AMP features
141
  add_action('amp_post_template_head','ampforwp_register_additional_scripts');
142
+ function ampforwp_register_additional_scripts() {
143
+ global $redux_builder_amp; ?>
144
  <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
145
  <script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
146
  <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
153
  <!-- AMP Advertisement Script -->
154
  <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
155
 
156
+ <?php }
157
 
158
 
159
  // 7. Footer for AMP Pages
160
  add_action('amp_post_template_footer','ampforwp_footer');
161
+ function ampforwp_footer() {
162
  global $redux_builder_amp;
163
  if ( is_home() ) {
164
  $ampforwp_backto_nonamp = home_url();
171
 
172
  <footer class="container">
173
  <div id="footer">
174
+ <p><a href="#header"> <?php _e('Top','ampforwp');?></a> <?php
175
+ //24. Added an options button for switching on/off link to non amp page
176
+ if($redux_builder_amp['amp-footer-link-non-amp-page']=='1'){ if ( $ampforwp_backto_nonamp ) { ?>
177
+ |
178
+ <a href="<?php echo $ampforwp_backto_nonamp; ?>"><?php _e('View Non-AMP Version','ampforwp');?></a> <?php } }?>
179
  </p>
180
  <p><?php echo $redux_builder_amp['amp-footer-text']; ?> </p>
181
  </div>
182
+ </footer>
183
+
184
+ <!-- Cookie Notification Code
185
+ added by @nicholasgriffintn in pull #121 -->
186
+ <?php if($redux_builder_amp['amp-enable-notifications'] == true) { ?>
187
+ <amp-user-notification layout=nodisplay id="amp-user-notification1">
188
+ <p><?php echo $redux_builder_amp['amp-notification-text']; ?> </p>
189
+ <button on="tap:amp-user-notification1.dismiss"><?php echo $redux_builder_amp['amp-accept-button-text']; ?></button>
190
+ </amp-user-notification>
191
+ <?php }
192
+ }
 
 
193
 
194
  // 8. Add Main tag as a Wrapper
195
  add_action('ampforwp_after_header','ampforwp_main_tag_begins');
200
  add_action('amp_post_template_footer','ampforwp_main_tag_ends',9);
201
  function ampforwp_main_tag_ends() {
202
  echo '</main>';
203
+ }
204
 
205
  // 9. Advertisement code
206
  // Below Header Global
209
  function ampforwp_header_advert() {
210
  global $redux_builder_amp;
211
 
212
+ if($redux_builder_amp['enable-amp-ads-1'] == true) {
213
  if($redux_builder_amp['enable-amp-ads-select-1'] == 1) {
214
  $advert_width = '300';
215
  $advert_height = '250';
235
  $output = '<div class="amp-ad-wrapper amp_ad_1">';
236
  $output .= '<amp-ad class="amp-ad-1"
237
  type="adsense"
238
+ width='. $advert_width .' height='. $advert_height . '
239
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-1'].'"
240
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-1'] .'">';
241
  $output .= '</amp-ad>';
250
  function ampforwp_footer_advert() {
251
  global $redux_builder_amp;
252
 
253
+ if($redux_builder_amp['enable-amp-ads-2'] == true) {
254
  if($redux_builder_amp['enable-amp-ads-select-2'] == 1) {
255
  $advert_width = '300';
256
  $advert_height = '250';
276
  $output = '<div class="amp-ad-wrapper">';
277
  $output .= '<amp-ad class="amp-ad-2"
278
  type="adsense"
279
+ width='. $advert_width .' height='. $advert_height . '
280
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-2'].'"
281
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-2'] .'">';
282
  $output .= '</amp-ad>';
291
  function ampforwp_before_post_content_advert() {
292
  global $redux_builder_amp;
293
 
294
+ if($redux_builder_amp['enable-amp-ads-3'] == true) {
295
  if($redux_builder_amp['enable-amp-ads-select-3'] == 1) {
296
  $advert_width = '300';
297
  $advert_height = '250';
317
  $output = '<div class="amp-ad-wrapper">';
318
  $output .= '<amp-ad class="amp-ad-3"
319
  type="adsense"
320
+ width='. $advert_width .' height='. $advert_height . '
321
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-3'].'"
322
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-3'] .'">';
323
  $output .= '</amp-ad>';
331
  function ampforwp_after_post_content_advert() {
332
  global $redux_builder_amp;
333
 
334
+ if($redux_builder_amp['enable-amp-ads-4'] == true) {
335
  if($redux_builder_amp['enable-amp-ads-select-4'] == 1) {
336
  $advert_width = '300';
337
  $advert_height = '250';
357
  $output = '<div class="amp-ad-wrapper">';
358
  $output .= '<amp-ad class="amp-ad-4"
359
  type="adsense"
360
+ width='. $advert_width .' height='. $advert_height . '
361
  data-ad-client="'. $redux_builder_amp['enable-amp-ads-text-feild-client-4'].'"
362
  data-ad-slot="'. $redux_builder_amp['enable-amp-ads-text-feild-slot-4'] .'">';
363
  $output .= '</amp-ad>';
365
  echo $output;
366
  }
367
  }
368
+
369
+ // 10. Analytics Area
370
+ add_action('amp_post_template_footer','ampforwp_analytics',11);
371
+ function ampforwp_analytics() {
372
+
373
+ // 10.1 Analytics Support added for Google Analytics
374
+ global $redux_builder_amp;
375
+ if ( $redux_builder_amp['amp-analytics-select-option']=='1' ){ ?>
376
+ <amp-analytics type="googleanalytics" id="analytics1">
377
+ <script type="application/json">
378
+ {
379
+ "vars": {
380
+ "account": "<?php global $redux_builder_amp; echo $redux_builder_amp['ga-feild']; ?>"
381
+ },
382
+ "triggers": {
383
+ "trackPageview": {
384
+ "on": "visible",
385
+ "request": "pageview"
386
+ }
387
+ }
388
+ }
389
+ </script>
390
+ </amp-analytics>
391
+ <?php
392
+ }//code ends for supporting Google Analytics
393
+
394
+ // 10.2 Analytics Support added for segment.com
395
+ if ( $redux_builder_amp['amp-analytics-select-option']=='2' ) { ?>
396
+ <amp-analytics type="segment">
397
+ <script>
398
+ {
399
+ "vars": {
400
+ "writeKey": "<?php global $redux_builder_amp; echo $redux_builder_amp['sa-feild']; ?>",
401
+ "name": "<?php echo the_title(); ?>"
402
+ }
403
+ }
404
+ </script>
405
+ </amp-analytics>
406
+ <?php
407
+ }
408
 
409
+ // 10.3 Analytics Support added for Piwik
410
+ if( $redux_builder_amp['amp-analytics-select-option']=='3' ) { ?>
411
+ <amp-pixel src="<?php global $redux_builder_amp; echo $redux_builder_amp['pa-feild']; ?>"></amp-pixel>
412
+ <?php }
413
+ }//analytics function ends here
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
 
415
  // 11. Strip unwanted codes and tags from the_content
416
  add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content');
417
+ function ampforwp_strip_invalid_content() {
418
  add_filter( 'the_content', 'ampforwp_the_content_filter', 20 );
419
  }
420
  function ampforwp_the_content_filter( $content ) {
436
  $content = preg_replace('#<style scoped.*?>(.*?)</style>#i', '', $content);
437
  $content = preg_replace('/href="javascript:void*/', ' ', $content);
438
  // $content = preg_replace('/<img*/', '<amp-img', $content); // Fallback for plugins
439
+ return $content;
440
  }
441
 
442
  // 11.5 Strip unwanted codes the_content of Frontpage
448
  }
449
  function ampforwp_the_content_filter_frontpage( $content ) {
450
  $content = preg_replace('/<img*/', '<amp-img', $content); // Fallback for plugins
451
+ return $content;
452
  }
453
 
 
 
 
454
  // 12. Add Logo URL in the structured metadata
455
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
456
  function ampforwp_update_metadata( $metadata, $post ) {
457
  global $redux_builder_amp;
458
+
459
  $structured_data_logo = $redux_builder_amp['amp-structured-data-logo']['url'];
460
 
461
  if ($structured_data_logo) {
471
  );
472
  return $metadata;
473
  }
474
+
475
+
476
  // 13. Add Custom Placeholder Image for Structured Data.
477
  // if there is no image in the post, then use this image to validate Structured Data.
478
+ add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 );
479
+ function ampforwp_update_metadata_featured_image( $metadata, $post ) {
480
  global $redux_builder_amp;
481
  $post_id = $post->ID;
482
  $post_image_id = get_post_thumbnail_id( $post_id );
483
  $structured_data_image = wp_get_attachment_image_src( $post_image_id, 'full' );
484
  $post_image_check = $structured_data_image;
485
+
486
  if ( $post_image_check == false) {
487
  $structured_data_image = $redux_builder_amp['amp-structured-data-placeholder-image']['url'];
488
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
495
  'width' => $structured_data_width,
496
  );
497
  }
 
498
  // Custom Structured Data information for Archive, Categories and tag pages.
499
  if ( is_archive() ) {
500
  $structured_data_image = $redux_builder_amp['amp-structured-data-placeholder-image']['url'];
501
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
502
  $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']);
503
+
504
  $structured_data_archive_title = "Archived Posts";
505
  $structured_data_author = get_userdata( 1 );
506
  if ( $structured_data_author ) {
508
  } else {
509
  $structured_data_author = "admin";
510
  }
511
+
512
  $metadata['image'] = array(
513
  '@type' => 'ImageObject',
514
  'url' => $structured_data_image ,
519
  '@type' => 'Person',
520
  'name' => $structured_data_author ,
521
  );
522
+ $metadata['headline'] = $structured_data_archive_title;
523
+ }
524
  return $metadata;
525
+ }
526
 
527
  // 14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
528
  /**
529
  * Adds a meta box to the post editing screen for AMP on-off on specific pages
530
+ */
531
  function ampforwp_title_custom_meta() {
532
+ add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?' ), 'ampforwp_title_callback', 'post','side' );
533
+
534
+ add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?' ), 'ampforwp_title_callback', 'page','side' );
535
  }
536
  add_action( 'add_meta_boxes', 'ampforwp_title_custom_meta' );
537
 
561
  * Saves the custom meta input for AMP on-off on specific pages
562
  */
563
  function ampforwp_title_meta_save( $post_id ) {
564
+
565
  // Checks save status
566
  $is_autosave = wp_is_post_autosave( $post_id );
567
  $is_revision = wp_is_post_revision( $post_id );
568
  $is_valid_nonce = ( isset( $_POST[ 'ampforwp_title_nonce' ] ) && wp_verify_nonce( $_POST[ 'ampforwp_title_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
569
+
570
  // Exits script depending on save status
571
  if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
572
  return;
573
  }
574
+
575
  // Checks for radio buttons and saves if needed
576
  if( isset( $_POST[ 'ampforwp-amp-on-off' ] ) ) {
577
  $ampforwp_amp_status = sanitize_text_field( $_POST[ 'ampforwp-amp-on-off' ] );
578
  update_post_meta( $post_id, 'ampforwp-amp-on-off', $ampforwp_amp_status );
579
  }
580
+
581
  }
582
  add_action( 'save_post', 'ampforwp_title_meta_save' );
583
 
610
  add_action( 'wp_enqueue_scripts', 'ampforwp_remove_unwanted_scripts',20 );
611
  }
612
  function ampforwp_remove_unwanted_scripts() {
613
+ wp_dequeue_script('jquery');
614
  }
615
  // Remove Print Scripts and styles
616
  function ampforwp_remove_print_scripts() {
617
+ if ( is_amp_endpoint() ) {
618
+
619
+ function ampforwp_remove_all_scripts() {
620
+ global $wp_scripts;
621
+ $wp_scripts->queue = array();
622
+ }
623
+ add_action('wp_print_scripts', 'ampforwp_remove_all_scripts', 100);
624
+ function ampforwp_remove_all_styles() {
625
+ global $wp_styles;
626
+ $wp_styles->queue = array();
627
+ }
628
+ add_action('wp_print_styles', 'ampforwp_remove_all_styles', 100);
629
+
630
+ // Remove Print Emoji for Nextgen Gallery support
631
+ remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
632
+ remove_action( 'wp_print_styles', 'print_emoji_styles' );
633
 
634
+ }
 
 
 
 
635
  }
636
  add_action( 'template_redirect', 'ampforwp_remove_print_scripts' );
637
 
 
638
  // 17. Archives Canonical in AMP version
639
  function ampforwp_rel_canonical_archive() {
640
  if ( !is_archive() )
641
+ return;
642
+ global $wp;
643
+ $current_archive_url = home_url( $wp->request );
644
+ // $archivelink = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
645
+ echo "<link rel='canonical' href='$current_archive_url' />\n";
646
  }
647
  add_action( 'amp_post_template_head', 'ampforwp_rel_canonical_archive' );
648
 
649
  // 18. Custom Canonical for Homepage
650
  function ampforwp_rel_canonical() {
651
+ if ( !is_home() )
652
  return;
653
  // $link = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
654
  $homelink = get_home_url();
658
 
659
  // 18.5. Custom Canonical for Frontpage
660
  //function ampforwp_rel_canonical_frontpage() {
661
+ // if ( is_home() || is_front_page() )
662
  // return;
663
  //// $link = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
664
  // $homelink = get_home_url();
665
  // echo "<link rel='canonical' href='$homelink' />\n";
666
  //}
667
  //add_action( 'amp_post_template_head', 'ampforwp_rel_canonical_frontpage' );
668
+
669
  // 19. Remove Canonical tags
670
  function ampforwp_amp_remove_actions() {
671
  if ( is_home() || is_front_page() || is_archive() ) {
672
  remove_action( 'amp_post_template_head', 'amp_post_template_add_canonical' );
673
+ }
674
  }
675
  add_action( 'amp_post_template_head', 'ampforwp_amp_remove_actions', 9 );
676
 
679
  remove_action( 'amp_post_template_head', 'amp_post_template_add_fonts' );
680
  }, 9 );
681
 
 
682
  // 21. Remove Schema data from All In One Schema.org Rich Snippets Plugin
683
  add_action( 'pre_amp_render_post', 'ampforwp_remove_schema_data' );
684
  function ampforwp_remove_schema_data() {
685
  remove_filter('the_content','display_rich_snippet');
686
+ }
687
+
688
+ // 22. Removing author links from comments Issue #180
689
+ if( ! function_exists( "disable_comment_author_links" ) ) {
690
+ function ampforwp_disable_comment_author_links( $author_link ){
691
+ $is_amp_endpoint = is_amp_endpoint();
692
+ if ( $is_amp_endpoint ) {
693
+ return strip_tags( $author_link );
694
+ } else {
695
+ return $author_link;
696
+ }
697
+ }
698
+ add_filter( 'get_comment_author_link', 'ampforwp_disable_comment_author_links' );
699
+ }
templates/header.php CHANGED
@@ -2,14 +2,16 @@
2
  <div id="headerwrap">
3
  <div id="header">
4
 
5
- <?php global $redux_builder_amp; ?>
 
 
6
 
7
- <?php if (true == ($redux_builder_amp['opt-media']['url'])) { ?>
8
- <a href="<?php bloginfo('url'); ?>">
9
  <amp-img src="<?php echo $redux_builder_amp['opt-media']['url']; ?>" width="190" height="36" alt="logo" class="amp-logo"></amp-img>
10
  </a>
11
- <?php } else {?>
12
- <h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
13
  <?php } ?>
14
 
15
  </div>
@@ -31,4 +33,4 @@
31
  <div role="button" tabindex="0" on='tap:sidebar.close' class="close-nav">X</div>
32
  <?php wp_nav_menu( array( 'theme_location' => 'amp-menu' ) ); ?>
33
  </div>
34
- </amp-sidebar>
2
  <div id="headerwrap">
3
  <div id="header">
4
 
5
+ <?php global $redux_builder_amp;
6
+ $ampforwp_home_url = trailingslashit( get_bloginfo('url') ) . '?' . AMP_QUERY_VAR;
7
+ ?>
8
 
9
+ <?php if ( true == ($redux_builder_amp['opt-media']['url']) ) { ?>
10
+ <a href="<?php echo esc_url( $ampforwp_home_url ); ?>">
11
  <amp-img src="<?php echo $redux_builder_amp['opt-media']['url']; ?>" width="190" height="36" alt="logo" class="amp-logo"></amp-img>
12
  </a>
13
+ <?php } else { ?>
14
+ <h1><a href="<?php echo esc_url( $ampforwp_home_url ); ?>"><?php bloginfo('name'); ?></a></h1>
15
  <?php } ?>
16
 
17
  </div>
33
  <div role="button" tabindex="0" on='tap:sidebar.close' class="close-nav">X</div>
34
  <?php wp_nav_menu( array( 'theme_location' => 'amp-menu' ) ); ?>
35
  </div>
36
+ </amp-sidebar>
templates/index.php CHANGED
@@ -17,7 +17,11 @@
17
  <?php do_action( 'ampforwp_after_header', $this ); ?>
18
 
19
  <?php if ( have_posts() ) :
20
- while ( have_posts() ) : the_post(); ?>
 
 
 
 
21
 
22
  <div class="amp-wp-content amp-loop-list">
23
  <?php if ( has_post_thumbnail() ) { ?>
@@ -26,12 +30,12 @@
26
  $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true);
27
  $thumb_url = $thumb_url_array[0];
28
  ?>
29
- <div class="home-post_image"><a href="<?php the_permalink(); ?>"><amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img></a></div>
30
  <?php } ?>
31
 
32
  <div class="amp-wp-post-content">
33
 
34
- <h2 class="amp-wp-title"> <a href="<?php the_permalink();?>"> <?php the_title(); ?></a></h2>
35
 
36
  <?php $content = get_the_content();?>
37
  <p><?php echo wp_trim_words( $content , '15' ); ?></p>
@@ -59,4 +63,4 @@
59
 
60
  <?php do_action( 'amp_post_template_footer', $this ); ?>
61
  </body>
62
- </html>
17
  <?php do_action( 'ampforwp_after_header', $this ); ?>
18
 
19
  <?php if ( have_posts() ) :
20
+ while ( have_posts() ) : the_post();
21
+
22
+ $ampforwp_amp_post_url = trailingslashit( get_permalink() ) . AMP_QUERY_VAR ;
23
+
24
+ ?>
25
 
26
  <div class="amp-wp-content amp-loop-list">
27
  <?php if ( has_post_thumbnail() ) { ?>
30
  $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true);
31
  $thumb_url = $thumb_url_array[0];
32
  ?>
33
+ <div class="home-post_image"><a href="<?php echo esc_url( $ampforwp_amp_post_url ); ?>"><amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img></a></div>
34
  <?php } ?>
35
 
36
  <div class="amp-wp-post-content">
37
 
38
+ <h2 class="amp-wp-title"> <a href="<?php echo esc_url( $ampforwp_amp_post_url ); ?>"> <?php the_title(); ?></a></h2>
39
 
40
  <?php $content = get_the_content();?>
41
  <p><?php echo wp_trim_words( $content , '15' ); ?></p>
63
 
64
  <?php do_action( 'amp_post_template_footer', $this ); ?>
65
  </body>
66
+ </html>
templates/single.php CHANGED
@@ -21,7 +21,7 @@
21
  <ul class="amp-wp-meta">
22
  <?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-author') ) ); ?>
23
 
24
- <li> <?php _e(' on ','ampforwp'); the_time( get_option( 'date_format' ) ) ?></li>
25
 
26
  <?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array('meta-taxonomy' ) ) ); ?>
27
 
@@ -36,37 +36,45 @@
36
  <?php
37
  $thumb_id = get_post_thumbnail_id();
38
  $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'large', true);
39
- $thumb_url = $thumb_url_array[0];
40
- ?>
41
  <div class="post-featured-img"><amp-img src=<?php echo $thumb_url ?> width=512 height=300 layout=responsive></amp-img></div>
42
  <?php } } ?>
43
  </div>
44
  <div class="amp-wp-content the_content">
45
 
46
  <?php do_action( 'ampforwp_before_post_content', $this ); ?>
47
-
48
  <?php echo $this->get( 'post_amp_content' ); // amphtml content; no kses ?>
49
  <?php do_action( 'ampforwp_after_post_content', $this ); ?>
50
  </div>
51
 
52
  <div class="amp-wp-content post-pagination-meta">
53
- <?php if($redux_builder_amp['ampforwp-single-tags-on-off'] == true) {
54
  $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) );
55
-
56
- } ?>
57
-
58
-
59
  <?php if($redux_builder_amp['enable-next-previous-pagination'] == true) { ?>
60
- <div id="pagination">
61
- <div class="next"><?php next_post_link(); ?></div>
62
- <div class="prev"><?php previous_post_link(); ?></div>
63
- <div class="clearfix"></div>
64
- </div>
 
 
 
 
 
 
 
 
 
 
65
  <?php } ?>
66
  </div>
67
 
68
  <?php if($redux_builder_amp['enable-single-social-icons'] == true) { ?>
69
- <div class="sticky_social">
70
  <?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
71
  <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>
72
  <?php } ?>
@@ -86,7 +94,7 @@
86
  <amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
87
  <?php } ?>
88
  <?php if($redux_builder_amp['enable-single-whatsapp-share'] == true) { ?>
89
- <a href="whatsapp://send">
90
  <div class="whatsapp-share-icon">
91
  <amp-img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjUxMnB4IiBoZWlnaHQ9IjUxMnB4IiB2aWV3Qm94PSIwIDAgOTAgOTAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDkwIDkwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnPgoJPHBhdGggaWQ9IldoYXRzQXBwIiBkPSJNOTAsNDMuODQxYzAsMjQuMjEzLTE5Ljc3OSw0My44NDEtNDQuMTgyLDQzLjg0MWMtNy43NDcsMC0xNS4wMjUtMS45OC0yMS4zNTctNS40NTVMMCw5MGw3Ljk3NS0yMy41MjIgICBjLTQuMDIzLTYuNjA2LTYuMzQtMTQuMzU0LTYuMzQtMjIuNjM3QzEuNjM1LDE5LjYyOCwyMS40MTYsMCw0NS44MTgsMEM3MC4yMjMsMCw5MCwxOS42MjgsOTAsNDMuODQxeiBNNDUuODE4LDYuOTgyICAgYy0yMC40ODQsMC0zNy4xNDYsMTYuNTM1LTM3LjE0NiwzNi44NTljMCw4LjA2NSwyLjYyOSwxNS41MzQsNy4wNzYsMjEuNjFMMTEuMTA3LDc5LjE0bDE0LjI3NS00LjUzNyAgIGM1Ljg2NSwzLjg1MSwxMi44OTEsNi4wOTcsMjAuNDM3LDYuMDk3YzIwLjQ4MSwwLDM3LjE0Ni0xNi41MzMsMzcuMTQ2LTM2Ljg1N1M2Ni4zMDEsNi45ODIsNDUuODE4LDYuOTgyeiBNNjguMTI5LDUzLjkzOCAgIGMtMC4yNzMtMC40NDctMC45OTQtMC43MTctMi4wNzYtMS4yNTRjLTEuMDg0LTAuNTM3LTYuNDEtMy4xMzgtNy40LTMuNDk1Yy0wLjk5My0wLjM1OC0xLjcxNy0wLjUzOC0yLjQzOCwwLjUzNyAgIGMtMC43MjEsMS4wNzYtMi43OTcsMy40OTUtMy40Myw0LjIxMmMtMC42MzIsMC43MTktMS4yNjMsMC44MDktMi4zNDcsMC4yNzFjLTEuMDgyLTAuNTM3LTQuNTcxLTEuNjczLTguNzA4LTUuMzMzICAgYy0zLjIxOS0yLjg0OC01LjM5My02LjM2NC02LjAyNS03LjQ0MWMtMC42MzEtMS4wNzUtMC4wNjYtMS42NTYsMC40NzUtMi4xOTFjMC40ODgtMC40ODIsMS4wODQtMS4yNTUsMS42MjUtMS44ODIgICBjMC41NDMtMC42MjgsMC43MjMtMS4wNzUsMS4wODItMS43OTNjMC4zNjMtMC43MTcsMC4xODItMS4zNDQtMC4wOS0xLjg4M2MtMC4yNy0wLjUzNy0yLjQzOC01LjgyNS0zLjM0LTcuOTc3ICAgYy0wLjkwMi0yLjE1LTEuODAzLTEuNzkyLTIuNDM2LTEuNzkyYy0wLjYzMSwwLTEuMzU0LTAuMDktMi4wNzYtMC4wOWMtMC43MjIsMC0xLjg5NiwwLjI2OS0yLjg4OSwxLjM0NCAgIGMtMC45OTIsMS4wNzYtMy43ODksMy42NzYtMy43ODksOC45NjNjMCw1LjI4OCwzLjg3OSwxMC4zOTcsNC40MjIsMTEuMTEzYzAuNTQxLDAuNzE2LDcuNDksMTEuOTIsMTguNSwxNi4yMjMgICBDNTguMiw2NS43NzEsNTguMiw2NC4zMzYsNjAuMTg2LDY0LjE1NmMxLjk4NC0wLjE3OSw2LjQwNi0yLjU5OSw3LjMxMi01LjEwN0M2OC4zOTgsNTYuNTM3LDY4LjM5OCw1NC4zODYsNjguMTI5LDUzLjkzOHoiIGZpbGw9IiNGRkZGRkYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" width="30" height="20" />
92
  </div>
@@ -95,61 +103,87 @@
95
  </div>
96
  <?php } ?>
97
 
98
- <?php if($redux_builder_amp['ampforwp-single-related-on-off'] == true) {
 
99
  $orig_post = $post;
100
  global $post;
101
- $categories = get_the_category($post->ID);
102
- if ($categories) {
103
- $category_ids = array();
104
- foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
105
- $args=array(
106
- 'category__in' => $category_ids,
107
- 'post__not_in' => array($post->ID),
108
- 'posts_per_page'=> 3, // Number of related posts that will be shown.
109
- 'caller_get_posts'=>1
110
- );
111
- $my_query = new wp_query( $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  if( $my_query->have_posts() ) { ?>
113
  <div class="amp-wp-content relatedpost">
114
  <div class="related_posts">
115
- <ol class="clearfix">
116
  <h3>Related Posts</h3>
117
  <?php
118
  while( $my_query->have_posts() ) {
119
- $my_query->the_post();?>
120
- <li class="<?php if ( has_post_thumbnail() ) { echo'has_related_thumbnail'; } else { echo 'no_related_thumbnail'; } ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
 
 
 
 
121
  <?php
122
  $thumb_id_2 = get_post_thumbnail_id();
123
  $thumb_url_array_2 = wp_get_attachment_image_src($thumb_id_2, 'thumbnail', true);
124
  $thumb_url_2 = $thumb_url_array_2[0];
125
  ?>
126
-
127
  <?php if ( has_post_thumbnail() ) { ?>
128
- <amp-img src="<?php echo $thumb_url_2 ?>" width="150" height="150" layout="responsive"></amp-img>
129
  <?php } ?>
130
  <div class="related_link">
131
- <a href="<?php the_permalink(); ?><?php echo AMP_QUERY_VAR ;?>"><?php the_title(); ?></a>
132
  <?php $content = get_the_content();?>
133
  <p><?php echo wp_trim_words( $content , '15' ); ?></p>
134
  </div>
135
- </li>
136
  <?php
137
  }
138
- }
139
  } ?>
140
  </ol>
141
  </div>
142
  </div>
143
- <?php
144
  $post = $orig_post;
145
  wp_reset_query();
146
- } ?>
 
 
147
 
148
-
149
  <?php if($redux_builder_amp['ampforwp-single-comments-on-off'] == true) { ?>
150
  <!-- Comments -->
151
  <?php
152
- // Gather comments for a specific page/post
153
  $postID = get_the_ID();
154
  $comments = get_comments(array(
155
  'post_id' => $postID,
@@ -168,14 +202,14 @@
168
  'max_depth' => 0,
169
  'avatar_size' => 0,
170
  'reverse_top_level' => false //Show the latest comments at the top of the list
171
- ), $comments);
172
-
173
  ?>
174
  </ul>
175
  </div>
176
  <div class="comment-button-wrapper">
177
  <a href="<?php echo get_permalink().'#commentform' ?>">Leave a Comment</a>
178
- </div><?php
179
  }
180
  } ?>
181
 
21
  <ul class="amp-wp-meta">
22
  <?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-author') ) ); ?>
23
 
24
+ <li> <?php _e(' on ','ampforwp'); the_time( get_option( 'date_format' ) ) ?></li>
25
 
26
  <?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array('meta-taxonomy' ) ) ); ?>
27
 
36
  <?php
37
  $thumb_id = get_post_thumbnail_id();
38
  $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'large', true);
39
+ $thumb_url = $thumb_url_array[0];
40
+ ?>
41
  <div class="post-featured-img"><amp-img src=<?php echo $thumb_url ?> width=512 height=300 layout=responsive></amp-img></div>
42
  <?php } } ?>
43
  </div>
44
  <div class="amp-wp-content the_content">
45
 
46
  <?php do_action( 'ampforwp_before_post_content', $this ); ?>
47
+
48
  <?php echo $this->get( 'post_amp_content' ); // amphtml content; no kses ?>
49
  <?php do_action( 'ampforwp_after_post_content', $this ); ?>
50
  </div>
51
 
52
  <div class="amp-wp-content post-pagination-meta">
53
+ <?php if($redux_builder_amp['ampforwp-single-tags-on-off'] == true) {
54
  $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) );
55
+ } ?>
56
+
 
 
57
  <?php if($redux_builder_amp['enable-next-previous-pagination'] == true) { ?>
58
+ <div id="pagination">
59
+ <div class="next">
60
+ <?php $next_post = get_next_post();
61
+ if (!empty( $next_post )) { ?>
62
+ <a href="<?php echo get_permalink( $next_post->ID ) . AMP_QUERY_VAR; ?>"><?php echo $next_post->post_title; ?></a> <?php
63
+ } ?>
64
+ </div>
65
+ <div class="prev">
66
+ <?php $prev_post = get_previous_post();
67
+ if (!empty( $prev_post )) { ?>
68
+ <a href="<?php echo get_permalink( $prev_post->ID ). AMP_QUERY_VAR; ?>"><?php echo $prev_post->post_title ?></a> <?php
69
+ } ?>
70
+ </div>
71
+ <div class="clearfix"></div>
72
+ </div>
73
  <?php } ?>
74
  </div>
75
 
76
  <?php if($redux_builder_amp['enable-single-social-icons'] == true) { ?>
77
+ <div class="sticky_social">
78
  <?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
79
  <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>
80
  <?php } ?>
94
  <amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
95
  <?php } ?>
96
  <?php if($redux_builder_amp['enable-single-whatsapp-share'] == true) { ?>
97
+ <a href="whatsapp://send?text=<?php the_title(); ?> - <?php echo the_permalink(); ?>">
98
  <div class="whatsapp-share-icon">
99
  <amp-img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjUxMnB4IiBoZWlnaHQ9IjUxMnB4IiB2aWV3Qm94PSIwIDAgOTAgOTAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDkwIDkwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnPgoJPHBhdGggaWQ9IldoYXRzQXBwIiBkPSJNOTAsNDMuODQxYzAsMjQuMjEzLTE5Ljc3OSw0My44NDEtNDQuMTgyLDQzLjg0MWMtNy43NDcsMC0xNS4wMjUtMS45OC0yMS4zNTctNS40NTVMMCw5MGw3Ljk3NS0yMy41MjIgICBjLTQuMDIzLTYuNjA2LTYuMzQtMTQuMzU0LTYuMzQtMjIuNjM3QzEuNjM1LDE5LjYyOCwyMS40MTYsMCw0NS44MTgsMEM3MC4yMjMsMCw5MCwxOS42MjgsOTAsNDMuODQxeiBNNDUuODE4LDYuOTgyICAgYy0yMC40ODQsMC0zNy4xNDYsMTYuNTM1LTM3LjE0NiwzNi44NTljMCw4LjA2NSwyLjYyOSwxNS41MzQsNy4wNzYsMjEuNjFMMTEuMTA3LDc5LjE0bDE0LjI3NS00LjUzNyAgIGM1Ljg2NSwzLjg1MSwxMi44OTEsNi4wOTcsMjAuNDM3LDYuMDk3YzIwLjQ4MSwwLDM3LjE0Ni0xNi41MzMsMzcuMTQ2LTM2Ljg1N1M2Ni4zMDEsNi45ODIsNDUuODE4LDYuOTgyeiBNNjguMTI5LDUzLjkzOCAgIGMtMC4yNzMtMC40NDctMC45OTQtMC43MTctMi4wNzYtMS4yNTRjLTEuMDg0LTAuNTM3LTYuNDEtMy4xMzgtNy40LTMuNDk1Yy0wLjk5My0wLjM1OC0xLjcxNy0wLjUzOC0yLjQzOCwwLjUzNyAgIGMtMC43MjEsMS4wNzYtMi43OTcsMy40OTUtMy40Myw0LjIxMmMtMC42MzIsMC43MTktMS4yNjMsMC44MDktMi4zNDcsMC4yNzFjLTEuMDgyLTAuNTM3LTQuNTcxLTEuNjczLTguNzA4LTUuMzMzICAgYy0zLjIxOS0yLjg0OC01LjM5My02LjM2NC02LjAyNS03LjQ0MWMtMC42MzEtMS4wNzUtMC4wNjYtMS42NTYsMC40NzUtMi4xOTFjMC40ODgtMC40ODIsMS4wODQtMS4yNTUsMS42MjUtMS44ODIgICBjMC41NDMtMC42MjgsMC43MjMtMS4wNzUsMS4wODItMS43OTNjMC4zNjMtMC43MTcsMC4xODItMS4zNDQtMC4wOS0xLjg4M2MtMC4yNy0wLjUzNy0yLjQzOC01LjgyNS0zLjM0LTcuOTc3ICAgYy0wLjkwMi0yLjE1LTEuODAzLTEuNzkyLTIuNDM2LTEuNzkyYy0wLjYzMSwwLTEuMzU0LTAuMDktMi4wNzYtMC4wOWMtMC43MjIsMC0xLjg5NiwwLjI2OS0yLjg4OSwxLjM0NCAgIGMtMC45OTIsMS4wNzYtMy43ODksMy42NzYtMy43ODksOC45NjNjMCw1LjI4OCwzLjg3OSwxMC4zOTcsNC40MjIsMTEuMTEzYzAuNTQxLDAuNzE2LDcuNDksMTEuOTIsMTguNSwxNi4yMjMgICBDNTguMiw2NS43NzEsNTguMiw2NC4zMzYsNjAuMTg2LDY0LjE1NmMxLjk4NC0wLjE3OSw2LjQwNi0yLjU5OSw3LjMxMi01LjEwN0M2OC4zOTgsNTYuNTM3LDY4LjM5OCw1NC4zODYsNjguMTI5LDUzLjkzOHoiIGZpbGw9IiNGRkZGRkYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" width="30" height="20" />
100
  </div>
103
  </div>
104
  <?php } ?>
105
 
106
+ <?php
107
+ //related posts code starts here
108
  $orig_post = $post;
109
  global $post;
110
+ // ampforwp-single-select-type-of-related-switch
111
+ if($redux_builder_amp['ampforwp-single-select-type-of-related-switch']==1){ //code block for categories
112
+ if($redux_builder_amp['ampforwp-single-select-type-of-related']==2){
113
+ $categories = get_the_category($post->ID);
114
+ if ($categories) {
115
+ $category_ids = array();
116
+ foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
117
+ $args=array(
118
+ 'category__in' => $category_ids,
119
+ 'post__not_in' => array($post->ID),
120
+ 'posts_per_page'=> 3,
121
+ 'caller_get_posts'=>1
122
+ );
123
+ }
124
+ }//end of block for categories
125
+
126
+ //code block for tags
127
+ if($redux_builder_amp['ampforwp-single-select-type-of-related']==1) {
128
+ $ampforwp_tags = get_the_tags($post->ID);
129
+ if ($ampforwp_tags) {
130
+ $tag_ids = array();
131
+ foreach($ampforwp_tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
132
+ $args=array(
133
+ 'tag__and' => $tag_ids,
134
+ 'post__not_in' => array($post->ID),
135
+ 'posts_per_page'=> 3,
136
+ 'caller_get_posts'=>1
137
+ );
138
+ }
139
+ }//end of block for tags
140
+ } $my_query = new wp_query( $args );
141
  if( $my_query->have_posts() ) { ?>
142
  <div class="amp-wp-content relatedpost">
143
  <div class="related_posts">
144
+ <ol class="clearfix">
145
  <h3>Related Posts</h3>
146
  <?php
147
  while( $my_query->have_posts() ) {
148
+ $my_query->the_post();
149
+ $related_post_permalink = get_permalink();
150
+ $related_post_permalink = trailingslashit($related_post_permalink);
151
+ $related_post_permalink = $related_post_permalink . AMP_QUERY_VAR ;;
152
+ ?>
153
+ <li class="<?php if ( has_post_thumbnail() ) { echo'has_related_thumbnail'; } else { echo 'no_related_thumbnail'; } ?>"><a href="<?php echo esc_url( $related_post_permalink ); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
154
  <?php
155
  $thumb_id_2 = get_post_thumbnail_id();
156
  $thumb_url_array_2 = wp_get_attachment_image_src($thumb_id_2, 'thumbnail', true);
157
  $thumb_url_2 = $thumb_url_array_2[0];
158
  ?>
159
+
160
  <?php if ( has_post_thumbnail() ) { ?>
161
+ <amp-img src="<?php echo esc_url( $thumb_url_2 ); ?>" width="150" height="150" layout="responsive"></amp-img>
162
  <?php } ?>
163
  <div class="related_link">
164
+ <a href="<?php echo esc_url( $related_post_permalink ); ?>"><?php the_title(); ?></a>
165
  <?php $content = get_the_content();?>
166
  <p><?php echo wp_trim_words( $content , '15' ); ?></p>
167
  </div>
168
+ </li>
169
  <?php
170
  }
171
+
172
  } ?>
173
  </ol>
174
  </div>
175
  </div>
176
+ <?php
177
  $post = $orig_post;
178
  wp_reset_query();
179
+ //related posts code ends here
180
+ ?>
181
+
182
 
 
183
  <?php if($redux_builder_amp['ampforwp-single-comments-on-off'] == true) { ?>
184
  <!-- Comments -->
185
  <?php
186
+ // Gather comments for a specific page/post
187
  $postID = get_the_ID();
188
  $comments = get_comments(array(
189
  'post_id' => $postID,
202
  'max_depth' => 0,
203
  'avatar_size' => 0,
204
  'reverse_top_level' => false //Show the latest comments at the top of the list
205
+ ), $comments);
206
+
207
  ?>
208
  </ul>
209
  </div>
210
  <div class="comment-button-wrapper">
211
  <a href="<?php echo get_permalink().'#commentform' ?>">Leave a Comment</a>
212
+ </div><?php
213
  }
214
  } ?>
215