AMP for WP – Accelerated Mobile Pages - Version 0.8.5

Version Description

  • Proper Details at http://ampforwp.com/the-0-4-compatibility/
  • AMP 0.4 Compatibility Check
  • Even better Structured Data Validation, Once in for all!
  • Structured Data Options to eliminate Validation errors
  • AMP Page Exclude option
Download this release

Release Info

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

Code changes from version 0.8.4 to 0.8.5

README.md CHANGED
@@ -6,7 +6,7 @@ Contributors: mohammed_kaludi, ahmedkaludi
6
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
7
  Requires at least: 3.0
8
  Tested up to: 4.6.1
9
- Stable tag: 0.8.4
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -15,7 +15,7 @@ The Must have AMP plugin for WordPress. Automatically add Accelerated Mobile Pag
15
  == Description ==
16
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
17
 
18
- [What's New in Version 0.8.4?](http://ampforwp.com/blog/structured-data-validation/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
19
 
20
  [youtube https://www.youtube.com/watch?v=zzRy6Q_VGGc]
21
 
@@ -63,7 +63,7 @@ To view the AMP version, add /?amp at the end of your url. An example would be h
63
  Yes, Absolutely! I would suggest you to send your feature request by creating an issue in Github at https://github.com/ahmedkaludi/Accelerated-Mobile-Pages/issues/new/ . It helps us organize the feedback easily.
64
 
65
  **How do I get in touch?**
66
- You can contact me using this url: http://ahmedkaludi.com/contact-me/
67
 
68
 
69
  == Installation ==
@@ -112,6 +112,13 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
112
 
113
 
114
  == Changelog ==
 
 
 
 
 
 
 
115
  = 0.8.4 =
116
  * Proper Details at http://ampforwp.com/blog/structured-data-validation/
117
  * Structured Data Validation
6
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
7
  Requires at least: 3.0
8
  Tested up to: 4.6.1
9
+ Stable tag: 0.8.5
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
15
  == Description ==
16
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
17
 
18
+ [What's New in Version 0.8.5?](http://ampforwp.com/new/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
19
 
20
  [youtube https://www.youtube.com/watch?v=zzRy6Q_VGGc]
21
 
63
  Yes, Absolutely! I would suggest you to send your feature request by creating an issue in Github at https://github.com/ahmedkaludi/Accelerated-Mobile-Pages/issues/new/ . It helps us organize the feedback easily.
64
 
65
  **How do I get in touch?**
66
+ You can contact me using this url: http://ampforwp.com/contact/
67
 
68
 
69
  == Installation ==
112
 
113
 
114
  == Changelog ==
115
+ = 0.8.5 =
116
+ * Proper Details at http://ampforwp.com/the-0-4-compatibility/
117
+ * AMP 0.4 Compatibility Check
118
+ * Even better Structured Data Validation, Once in for all!
119
+ * Structured Data Options to eliminate Validation errors
120
+ * AMP Page Exclude option
121
+
122
  = 0.8.4 =
123
  * Proper Details at http://ampforwp.com/blog/structured-data-validation/
124
  * Structured Data Validation
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.4
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  License: GPL2
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.5
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: http://ampforwp.com/
9
  License: GPL2
includes/options/options-init.php CHANGED
@@ -138,7 +138,7 @@
138
  Redux::setSection( $opt_name, array(
139
  'title' => __( 'Welcome', 'redux-framework-demo' ),
140
  'id' => 'basic',
141
- 'desc' => __( '<div class="amp-faq">Thank you for using Accelerated Mobile Pages plugin. <b> <a href="http://ampforwp.com/blog/structured-data-validation/" target="_blank"> What\'s New in this Version?</a></b>'. '<p>' . sprintf( __( 'We are actively working on updating the plugin. We have built user friendly options which allows you to make changes on your AMP version. I have put togeather some frequently asked questions below.', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</p>'
142
  . '<h2>' . __( 'Frequently Asked Questions', 'redux-framework-demo' ) . '</h2>'
143
  . '<p><strong>' . __( 'How to Setup Navigation Menu?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'We have created a Seperate Navigation menu for AMP version which you can setup from the WordPress Menus, then navigate to Menu Locations, their you will notice AMP Menu. You can assign existing menus to this locations.', 'redux-framework-demo' ) . '</p>'
144
  . '<p><strong>' . __( 'I added /?amp on the end of one of my URLs and a minimalist version of my page appeared. It looks just like on one of your screenshots, so I guess its installed properly. Okay what now? Is it just enough to install it and the plugin will do the rest?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'After you see the minimalist view if you use the url with ?amp then it means that it has been installed properly. You dont need any extra steps to enable it.', 'redux-framework-demo' ) . '</p>'
@@ -245,24 +245,6 @@
245
  'input_text' => 'Select Color'
246
  )
247
  ),
248
- array(
249
- 'id' => 'amp-multi-select-pages',
250
- 'type' => 'select',
251
- 'multi' => true,
252
- 'title' => __('Hide AMP on Specific Pages', 'redux-framework-demo'),
253
- 'data' => 'pages',
254
- ),
255
- array(
256
- 'id' => 'amp-multi-select-posts',
257
- 'type' => 'select',
258
- 'multi' => true,
259
- 'title' => __('Hide AMP on Specific Posts', 'redux-framework-demo'),
260
- 'data' => 'post',
261
- 'args' => array(
262
- 'post_type' => 'post',
263
- 'posts_per_page' => 500
264
- ),
265
- ),
266
  array(
267
  'id' =>'amp-frontpage-select-option',
268
  'type' => 'switch',
@@ -662,6 +644,46 @@
662
  ),
663
 
664
  ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665
 
666
  // CSS
667
  Redux::setSection( $opt_name, array(
138
  Redux::setSection( $opt_name, array(
139
  'title' => __( 'Welcome', 'redux-framework-demo' ),
140
  'id' => 'basic',
141
+ 'desc' => __( '<div class="amp-faq">Thank you for using Accelerated Mobile Pages plugin. <b> <a href="http://ampforwp.com/new/" target="_blank"> What\'s New in this Version?</a></b>'. '<p>' . sprintf( __( 'We are actively working on updating the plugin. We have built user friendly options which allows you to make changes on your AMP version. I have put togeather some frequently asked questions below.', 'redux-framework-demo' ), 'redux-framework-demo' ) . '</p>'
142
  . '<h2>' . __( 'Frequently Asked Questions', 'redux-framework-demo' ) . '</h2>'
143
  . '<p><strong>' . __( 'How to Setup Navigation Menu?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'We have created a Seperate Navigation menu for AMP version which you can setup from the WordPress Menus, then navigate to Menu Locations, their you will notice AMP Menu. You can assign existing menus to this locations.', 'redux-framework-demo' ) . '</p>'
144
  . '<p><strong>' . __( 'I added /?amp on the end of one of my URLs and a minimalist version of my page appeared. It looks just like on one of your screenshots, so I guess its installed properly. Okay what now? Is it just enough to install it and the plugin will do the rest?', 'redux-framework-demo' ) . '</strong><br/>' . __( 'After you see the minimalist view if you use the url with ?amp then it means that it has been installed properly. You dont need any extra steps to enable it.', 'redux-framework-demo' ) . '</p>'
245
  'input_text' => 'Select Color'
246
  )
247
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  array(
249
  'id' =>'amp-frontpage-select-option',
250
  'type' => 'switch',
644
  ),
645
 
646
  ) );
647
+
648
+ // Structured Data
649
+ Redux::setSection( $opt_name, array(
650
+ 'title' => __( 'Structured Data', 'redux-framework-demo' ),
651
+ // '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>',
652
+ 'id' => 'opt-structured-data',
653
+ 'subsection' => true,
654
+ 'fields' => array(
655
+ array(
656
+ 'id' => 'amp-structured-data-logo',
657
+ 'type' => 'media',
658
+ 'url' => true,
659
+ 'title' => __('Default Structured Data Logo', 'redux-framework-demo'),
660
+ 'desc' => __('Upload the logo you want to show in Google Structured Data. ', 'redux-framework-demo'),
661
+ ),
662
+ array(
663
+ 'id' => 'amp-structured-data-placeholder-image',
664
+ 'type' => 'media',
665
+ 'url' => true,
666
+ 'title' => __('Default Post Image', 'redux-framework-demo'),
667
+ 'desc' => __('Upload the Image you want to show as Placeholder Image, when there is no featured image set in the post.', 'redux-framework-demo'),
668
+ ),
669
+ array(
670
+ 'id' => 'amp-structured-data-placeholder-image-width',
671
+ 'title' => __('Default Post Image Width', 'redux-framework-demo'),
672
+ 'type' => 'text',
673
+ 'placeholder' => '550',
674
+ 'desc' => 'Please don\'t add "PX" in the image size.',
675
+ 'default' => ''
676
+ ),
677
+ array(
678
+ 'id' => 'amp-structured-data-placeholder-image-height',
679
+ 'title' => __('Default Post Image Height', 'redux-framework-demo'),
680
+ 'type' => 'text',
681
+ 'placeholder' => '350',
682
+ 'desc' => 'Please don\'t add "PX" in the image size.',
683
+ 'default' => ''
684
+ ),
685
+ )
686
+ ) );
687
 
688
  // CSS
689
  Redux::setSection( $opt_name, array(
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mohammed_kaludi, ahmedkaludi
3
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
4
  Requires at least: 3.0
5
  Tested up to: 4.6.1
6
- Stable tag: 0.8.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -12,7 +12,7 @@ The Must have AMP plugin for WordPress. Automatically add Accelerated Mobile Pag
12
  == Description ==
13
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
14
 
15
- [What's New in Version 0.8.4?](http://ampforwp.com/blog/structured-data-validation/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
16
 
17
  [youtube https://www.youtube.com/watch?v=zzRy6Q_VGGc]
18
 
@@ -60,7 +60,7 @@ To view the AMP version, add /?amp at the end of your url. An example would be h
60
  Yes, Absolutely! I would suggest you to send your feature request by creating an issue in Github at https://github.com/ahmedkaludi/Accelerated-Mobile-Pages/issues/new/ . It helps us organize the feedback easily.
61
 
62
  **How do I get in touch?**
63
- You can contact me using this url: http://ahmedkaludi.com/contact-me/
64
 
65
 
66
  == Installation ==
@@ -109,6 +109,13 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F
109
 
110
 
111
  == Changelog ==
 
 
 
 
 
 
 
112
  = 0.8.4 =
113
  * Proper Details at http://ampforwp.com/blog/structured-data-validation/
114
  * Structured Data Validation
3
  Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
4
  Requires at least: 3.0
5
  Tested up to: 4.6.1
6
+ Stable tag: 0.8.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
12
  == Description ==
13
  Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
14
 
15
+ [What's New in Version 0.8.5?](http://ampforwp.com/new/) | [Priority Support](http://ampforwp.com/priority-support/) | [View Demo and Screenshot of the plugin](http://ahmedkaludi.com/accelerated-mobile-pages/)
16
 
17
  [youtube https://www.youtube.com/watch?v=zzRy6Q_VGGc]
18
 
60
  Yes, Absolutely! I would suggest you to send your feature request by creating an issue in Github at https://github.com/ahmedkaludi/Accelerated-Mobile-Pages/issues/new/ . It helps us organize the feedback easily.
61
 
62
  **How do I get in touch?**
63
+ You can contact me using this url: http://ampforwp.com/contact/
64
 
65
 
66
  == Installation ==
109
 
110
 
111
  == Changelog ==
112
+ = 0.8.5 =
113
+ * Proper Details at http://ampforwp.com/the-0-4-compatibility/
114
+ * AMP 0.4 Compatibility Check
115
+ * Even better Structured Data Validation, Once in for all!
116
+ * Structured Data Options to eliminate Validation errors
117
+ * AMP Page Exclude option
118
+
119
  = 0.8.4 =
120
  * Proper Details at http://ampforwp.com/blog/structured-data-validation/
121
  * Structured Data Validation
templates/features.php CHANGED
@@ -5,7 +5,7 @@
5
  2. Custom Design
6
  3. Custom Style files
7
  4. Custom Header files
8
- 5. Customize with Width of the site
9
  6. Add required Javascripts for extra AMP features
10
  7. Footer for AMP Pages
11
  8. Add Main tag as a Wrapper
@@ -13,6 +13,8 @@
13
  10. Add Analytics to AMP Pages
14
  11. Strip unwanted codes and tags from the_content
15
  12. Add Logo URL in the structured metadata
 
 
16
  */
17
 
18
  // Adding AMP-related things to the main theme
@@ -376,11 +378,112 @@
376
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
377
  function ampforwp_update_metadata( $metadata, $post ) {
378
  global $redux_builder_amp;
 
 
 
 
 
 
 
 
379
  $metadata['publisher']['logo'] = array(
380
- '@type' => 'ImageObject',
381
- 'url' => $redux_builder_amp['opt-media']['url'],
382
- 'height' => 36,
383
- 'width' => 190,
384
  );
385
  return $metadata;
386
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  2. Custom Design
6
  3. Custom Style files
7
  4. Custom Header files
8
+ 5. Customize with Width of the site
9
  6. Add required Javascripts for extra AMP features
10
  7. Footer for AMP Pages
11
  8. Add Main tag as a Wrapper
13
  10. Add Analytics to AMP Pages
14
  11. Strip unwanted codes and tags from the_content
15
  12. Add Logo URL in the structured metadata
16
+ 13. Add Custom Placeholder Image for Structured Data.
17
+ 14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
18
  */
19
 
20
  // Adding AMP-related things to the main theme
378
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
379
  function ampforwp_update_metadata( $metadata, $post ) {
380
  global $redux_builder_amp;
381
+
382
+ $structured_data_logo = $redux_builder_amp['amp-structured-data-logo']['url'];
383
+
384
+ if ($structured_data_logo) {
385
+ $structured_data_logo = $structured_data_logo;
386
+ } else {
387
+ $structured_data_logo = $redux_builder_amp['opt-media']['url'];
388
+ }
389
  $metadata['publisher']['logo'] = array(
390
+ '@type' => 'ImageObject',
391
+ 'url' => $structured_data_logo ,
392
+ 'height' => 36,
393
+ 'width' => 190,
394
  );
395
  return $metadata;
396
+ }
397
+
398
+
399
+ // 13. Add Custom Placeholder Image for Structured Data.
400
+ // if there is no image in the post, then use this image to validate Structured Data.
401
+ add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 );
402
+ function ampforwp_update_metadata_featured_image( $metadata, $post ) {
403
+ global $redux_builder_amp;
404
+ $post_id = $post->ID;
405
+ $post_image_id = get_post_thumbnail_id( $post_id );
406
+ $structured_data_image = wp_get_attachment_image_src( $post_image_id, 'full' );
407
+ $post_image_check = $structured_data_image;
408
+
409
+ if ( $post_image_check == false) {
410
+ $structured_data_image = $redux_builder_amp['amp-structured-data-placeholder-image']['url'];
411
+ $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
412
+ $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']);
413
+
414
+ $metadata['image'] = array(
415
+ '@type' => 'ImageObject',
416
+ 'url' => $structured_data_image ,
417
+ 'height' => $structured_data_height,
418
+ 'width' => $structured_data_width,
419
+ );
420
+ }
421
+ return $metadata;
422
+ }
423
+
424
+ // 14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
425
+ /**
426
+ * Adds a meta box to the post editing screen for AMP on-off on specific pages
427
+ */
428
+ function ampforwp_title_custom_meta() {
429
+ add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?' ), 'ampforwp_title_callback', 'post','side' );
430
+
431
+ add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?' ), 'ampforwp_title_callback', 'page','side' );
432
+ }
433
+ add_action( 'add_meta_boxes', 'ampforwp_title_custom_meta' );
434
+
435
+ /**
436
+ * Outputs the content of the meta box for AMP on-off on specific pages
437
+ */
438
+ function ampforwp_title_callback( $post ) {
439
+ wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' );
440
+ $ampforwp_stored_meta = get_post_meta( $post->ID );
441
+ ?>
442
+ <p>
443
+ <div class="prfx-row-content">
444
+ <label for="meta-radio-one">
445
+ <input type="radio" name="ampforwp-amp-on-off" id="meta-radio-one" value="default" checked="checked" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-amp-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-amp-on-off'][0], 'default' ); ?>>
446
+ <?php _e( 'Show' )?>
447
+ </label>
448
+ <label for="meta-radio-two">
449
+ <input type="radio" name="ampforwp-amp-on-off" id="meta-radio-two" value="hide-amp" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-amp-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-amp-on-off'][0], 'hide-amp' ); ?>>
450
+ <?php _e( 'Hide' )?>
451
+ </label>
452
+ </div>
453
+ </p>
454
+ <?php
455
+ }
456
+
457
+ /**
458
+ * Saves the custom meta input for AMP on-off on specific pages
459
+ */
460
+ function ampforwp_title_meta_save( $post_id ) {
461
+
462
+ // Checks save status
463
+ $is_autosave = wp_is_post_autosave( $post_id );
464
+ $is_revision = wp_is_post_revision( $post_id );
465
+ $is_valid_nonce = ( isset( $_POST[ 'ampforwp_title_nonce' ] ) && wp_verify_nonce( $_POST[ 'ampforwp_title_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
466
+
467
+ // Exits script depending on save status
468
+ if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
469
+ return;
470
+ }
471
+
472
+ // Checks for radio buttons and saves if needed
473
+ if( isset( $_POST[ 'ampforwp-amp-on-off' ] ) ) {
474
+ $ampforwp_amp_status = sanitize_text_field( $_POST[ 'ampforwp-amp-on-off' ] );
475
+ update_post_meta( $post_id, 'ampforwp-amp-on-off', $ampforwp_amp_status );
476
+ }
477
+
478
+ }
479
+ add_action( 'save_post', 'ampforwp_title_meta_save' );
480
+
481
+ add_filter('amp_frontend_show_canonical','ampforwp_hide_amp_for_specific_pages');
482
+ function ampforwp_hide_amp_for_specific_pages($input){
483
+ global $post;
484
+ $ampforwp_amp_status = get_post_meta($post->ID, 'ampforwp-amp-on-off', true);
485
+ if ( $ampforwp_amp_status == 'hide-amp' ) {
486
+ $input = false;
487
+ }
488
+ return $input;
489
+ }
templates/style.php CHANGED
@@ -281,6 +281,9 @@ h1.amp-wp-title {
281
  .amp-wp-meta {
282
  padding-left: 0;
283
  }
 
 
 
284
  .amp-wp-tax-tag,
285
  .amp-wp-meta li {
286
  list-style: none;
281
  .amp-wp-meta {
282
  padding-left: 0;
283
  }
284
+ .amp-wp-tax-category {
285
+ float:right
286
+ }
287
  .amp-wp-tax-tag,
288
  .amp-wp-meta li {
289
  list-style: none;