AMP for WP – Accelerated Mobile Pages - Version 0.9.97.6

Version Description

(14th July 2018) = * Fixed: Error and Warning on Structured Data for Logo. #2360 * Fixed: Category Bilk tool breaking meta boxes #2335

Download this release

Release Info

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

Code changes from version 0.9.97.5 to 0.9.97.6

README.md 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/25
5
  Requires at least: 3.0
6
  Tested up to: 4.9.5
7
- Stable tag: 0.9.97.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -183,6 +183,10 @@ You can contact us from [here](https://ampforwp.com/contact/)
183
 
184
  == Changelog ==
185
 
 
 
 
 
186
  = 0.9.97.5 (11th July 2018) =
187
  * Fixed: Title disappearing in Design 1,2,3 when legacy pagebuilder is enabled #2341
188
  * Fixed: ld+json getting a broken when special characters are added in the image. #2346
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 4.9.5
7
+ Stable tag: 0.9.97.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
183
 
184
  == Changelog ==
185
 
186
+ = 0.9.97.6 (14th July 2018) =
187
+ * Fixed: Error and Warning on Structured Data for Logo. #2360
188
+ * Fixed: Category Bilk tool breaking meta boxes #2335
189
+
190
  = 0.9.97.5 (11th July 2018) =
191
  * Fixed: Title disappearing in Design 1,2,3 when legacy pagebuilder is enabled #2341
192
  * Fixed: ld+json getting a broken when special characters are added in the image. #2346
accelerated-moblie-pages.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
- Version: 0.9.97.5
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
@@ -19,7 +19,7 @@ define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
19
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
20
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
21
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
22
- define('AMPFORWP_VERSION','0.9.97.5');
23
  // any changes to AMP_QUERY_VAR should be refelected here
24
  function ampforwp_generate_endpoint(){
25
  $ampforwp_slug = '';
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
+ Version: 0.9.97.6
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
19
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
20
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
21
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
22
+ define('AMPFORWP_VERSION','0.9.97.6');
23
  // any changes to AMP_QUERY_VAR should be refelected here
24
  function ampforwp_generate_endpoint(){
25
  $ampforwp_slug = '';
includes/redirect.php CHANGED
@@ -152,17 +152,21 @@ function ampforwp_page_template_redirect() {
152
 
153
  $selected_cats = array();
154
  $categories = get_the_category();
155
- $category_id = $categories[0]->cat_ID;
156
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
157
  // Check if $get_categories_from_checkbox has some cats then only show
158
  if ( $get_categories_from_checkbox ) {
159
  $get_selected_cats = array_filter($get_categories_from_checkbox);
160
  foreach ( $get_selected_cats as $key => $value ) {
161
  $selected_cats[] = $key;
 
 
 
 
 
162
  }
163
- if ( $selected_cats && $category_id ) {
164
- if ( in_array($category_id, $selected_cats) ) {
165
- return;
166
  }
167
  }
168
  }
152
 
153
  $selected_cats = array();
154
  $categories = get_the_category();
 
155
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
156
  // Check if $get_categories_from_checkbox has some cats then only show
157
  if ( $get_categories_from_checkbox ) {
158
  $get_selected_cats = array_filter($get_categories_from_checkbox);
159
  foreach ( $get_selected_cats as $key => $value ) {
160
  $selected_cats[] = $key;
161
+ }
162
+ if ( $categories ) {
163
+ foreach ($categories as $key => $cats) {
164
+ $current_cats_ids[] =$cats->cat_ID;
165
+ }
166
  }
167
+ if ( $selected_cats && $current_cats_ids ) {
168
+ if( count(array_intersect($selected_cats,$current_cats_ids))>0 ){
169
+ return;
170
  }
171
  }
172
  }
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/25
5
  Requires at least: 3.0
6
  Tested up to: 4.9.5
7
- Stable tag: 0.9.97.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -183,6 +183,10 @@ You can contact us from [here](https://ampforwp.com/contact/)
183
 
184
  == Changelog ==
185
 
 
 
 
 
186
  = 0.9.97.5 (11th July 2018) =
187
  * Fixed: Title disappearing in Design 1,2,3 when legacy pagebuilder is enabled #2341
188
  * Fixed: ld+json getting a broken when special characters are added in the image. #2346
4
  Donate link: https://www.paypal.me/Kaludi/25
5
  Requires at least: 3.0
6
  Tested up to: 4.9.5
7
+ Stable tag: 0.9.97.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
183
 
184
  == Changelog ==
185
 
186
+ = 0.9.97.6 (14th July 2018) =
187
+ * Fixed: Error and Warning on Structured Data for Logo. #2360
188
+ * Fixed: Category Bilk tool breaking meta boxes #2335
189
+
190
  = 0.9.97.5 (11th July 2018) =
191
  * Fixed: Title disappearing in Design 1,2,3 when legacy pagebuilder is enabled #2341
192
  * Fixed: ld+json getting a broken when special characters are added in the image. #2346
templates/features.php CHANGED
@@ -256,25 +256,25 @@ define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
256
  }//tags area closed
257
 
258
 
259
- $selected_cats = array();
260
- $categories = get_the_category();
261
- if ( $categories ) {
262
- $category_id = $categories[0]->cat_ID;
263
- $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
264
- // Check if $get_categories_from_checkbox has some cats then only show
265
- if ( $get_categories_from_checkbox ) {
266
- $get_selected_cats = array_filter($get_categories_from_checkbox);
267
- foreach ($get_selected_cats as $key => $value) {
268
- $selected_cats[] = $key;
269
- }
270
- if($selected_cats && $category_id){
271
- if(in_array($category_id, $selected_cats)){
272
- return;
273
- }
274
- }
275
- }
276
- }
277
- }
278
  if ( is_page() && ! $redux_builder_amp['amp-on-off-for-all-pages'] && ! is_home() && ! is_front_page() ) {
279
  return;
280
  }
@@ -1469,6 +1469,9 @@ function ampforwp_new_dir( $dir ) {
1469
  // 12. Add Logo URL in the structured metadata
1470
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
1471
  function ampforwp_update_metadata( $metadata, $post ) {
 
 
 
1472
  global $redux_builder_amp;
1473
  $structured_data_logo = '';
1474
  $structured_data_main_logo = '';
@@ -1487,14 +1490,13 @@ function ampforwp_new_dir( $dir ) {
1487
  } else {
1488
  $structured_data_logo = $structured_data_main_logo;
1489
  }
1490
- if(isset($metadata['publisher']) && $metadata['publisher']){
1491
- $metadata['publisher']['logo'] = array(
1492
- '@type' => 'ImageObject',
1493
- 'url' => $structured_data_logo ,
1494
- 'height' => $ampforwp_sd_height,
1495
- 'width' => $ampforwp_sd_width,
1496
- );
1497
- }
1498
 
1499
  //code for adding 'description' meta from Yoast SEO
1500
 
@@ -1529,6 +1531,9 @@ function ampforwp_new_dir( $dir ) {
1529
  // if there is no image in the post, then use this image to validate Structured Data.
1530
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 );
1531
  function ampforwp_update_metadata_featured_image( $metadata, $post ) {
 
 
 
1532
  global $redux_builder_amp;
1533
  global $post;
1534
  $post_id = get_the_ID() ;
@@ -1545,14 +1550,13 @@ function ampforwp_new_dir( $dir ) {
1545
  $structured_data_image = $structured_data_image_url;
1546
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
1547
  $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']);
1548
- if(isset($metadata['image']) && $metadata['image'] ){
1549
- $metadata['image'] = array(
1550
- '@type' => 'ImageObject',
1551
- 'url' => $structured_data_image ,
1552
- 'height' => $structured_data_height,
1553
- 'width' => $structured_data_width,
1554
- );
1555
- }
1556
  }
1557
  // Custom Structured Data information for Archive, Categories and tag pages.
1558
  if ( is_archive() ) {
@@ -1566,15 +1570,14 @@ function ampforwp_new_dir( $dir ) {
1566
  $structured_data_author = $structured_data_author->display_name ;
1567
  } else {
1568
  $structured_data_author = "admin";
1569
- }
1570
- if(isset($metadata['image']) && $metadata['image'] ){
1571
- $metadata['image'] = array(
1572
- '@type' => 'ImageObject',
1573
- 'url' => $structured_data_image ,
1574
- 'height' => $structured_data_height,
1575
- 'width' => $structured_data_width,
1576
- );
1577
- }
1578
  $metadata['author'] = array(
1579
  '@type' => 'Person',
1580
  'name' => $structured_data_author ,
@@ -1584,26 +1587,23 @@ function ampforwp_new_dir( $dir ) {
1584
 
1585
  // Get Image metadata from the Custom Field
1586
  if(ampforwp_is_custom_field_featured_image() && ampforwp_cf_featured_image_src()){
1587
- if(isset($metadata['image']) && $metadata['image'] ){
1588
- $metadata['image'] = array(
1589
- '@type' => 'ImageObject',
1590
- 'url' => ampforwp_cf_featured_image_src('url') ,
1591
- 'width' => ampforwp_cf_featured_image_src('width'),
1592
- 'height' => ampforwp_cf_featured_image_src('height'),
1593
- );
1594
- }
1595
  }
1596
 
1597
  // Get image metadata from The Content
1598
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content() ){
1599
- if(isset($metadata['image']) && $metadata['image'] ){
1600
- $metadata['image'] = array(
1601
- '@type' => 'ImageObject',
1602
- 'url' => ampforwp_get_featured_image_from_content('url') ,
1603
- 'width' => ampforwp_get_featured_image_from_content('width'),
1604
- 'height' => ampforwp_get_featured_image_from_content('height'),
1605
- );
1606
- }
1607
  }
1608
 
1609
  if( in_array( "image" , $metadata ) ) {
@@ -1718,12 +1718,8 @@ function ampforwp_title_callback( $post ) {
1718
  }
1719
  $list_of_posts = ampforwp_posts_to_remove();
1720
  if ( $list_of_posts && $post->post_type == 'post' ) {
1721
- $skip_this_post = in_array($post->ID, $list_of_posts);
1722
- }
1723
- if ( $skip_this_post ) {
1724
  $ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'hide-amp';
1725
- }
1726
- ?>
1727
  <p>
1728
  <div class="prfx-row-content">
1729
  <label class="meta-radio-two" for="ampforwp-on-off-meta-radio-one">
@@ -3411,6 +3407,9 @@ function ampforwp_auto_add_amp_in_menu_link( $atts, $item, $args ) {
3411
  // 45. searchpage, frontpage, homepage structured data
3412
  add_filter( 'amp_post_template_metadata', 'ampforwp_search_or_homepage_or_staticpage_metadata', 10, 2 );
3413
  function ampforwp_search_or_homepage_or_staticpage_metadata( $metadata, $post ) {
 
 
 
3414
  global $redux_builder_amp,$wp;
3415
  $desc = '';
3416
  if( is_search() || is_home() || ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) ) {
@@ -3476,15 +3475,14 @@ function ampforwp_search_or_homepage_or_staticpage_metadata( $metadata, $post )
3476
  // time difference is 2 minute between published and modified date
3477
  $dateModified = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
3478
  }
3479
- }
3480
- if(isset($metadata['image']) && $metadata['image'] ){
3481
- $metadata['image'] = array(
3482
- '@type' => 'ImageObject',
3483
- 'url' => $structured_data_image ,
3484
- 'height' => $structured_data_height,
3485
- 'width' => $structured_data_width,
3486
- );
3487
- }
3488
  $metadata['datePublished'] = $datePublished; // proper published date added
3489
  $metadata['dateModified'] = $dateModified; // proper modified date
3490
  $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
@@ -4535,10 +4533,11 @@ add_action('ampforwp_after_post_content','ampforwp_post_pagination');
4535
 
4536
  function ampforwp_posts_to_remove () {
4537
  global $redux_builder_amp;
4538
- $get_categories_from_checkbox = '';
4539
  $get_selected_cats = array();
4540
  $selected_cats = array();
4541
  $post_id_array = array();
 
4542
  if(isset($redux_builder_amp['hide-amp-categories'])){
4543
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
4544
  }
@@ -4548,7 +4547,17 @@ function ampforwp_posts_to_remove () {
4548
  $selected_cats[] = $key;
4549
  }
4550
  }
4551
- $new_selected_cats = implode(',' , $selected_cats);
 
 
 
 
 
 
 
 
 
 
4552
  if(!empty($get_selected_cats)){
4553
  $the_query = new WP_Query(
4554
  array(
@@ -4568,24 +4577,19 @@ function ampforwp_posts_to_remove () {
4568
  }
4569
  }
4570
  wp_reset_postdata();
4571
- return $post_id_array;
4572
  }
4573
 
4574
  add_filter( 'amp_skip_post', 'ampforwp_cat_specific_skip_amp_post', 10, 3 );
4575
  function ampforwp_cat_specific_skip_amp_post( $skip, $post_id, $post ) {
4576
- $list_of_posts = '';
4577
  $skip_this_post = '';
4578
-
4579
- $list_of_posts = ampforwp_posts_to_remove();
4580
- if ( $list_of_posts ) {
4581
- $skip_this_post = in_array($post_id, $list_of_posts);
4582
- }
4583
- if( $skip_this_post ) {
4584
  $skip = true;
4585
  remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
4586
  // #999 Disable mobile redirection
4587
  remove_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
4588
- }
4589
  return $skip;
4590
  }
4591
 
@@ -4791,9 +4795,10 @@ global $redux_builder_amp;
4791
  return $supported_types;
4792
  }
4793
 
 
4794
  function is_category_amp_disabled(){
4795
  global $redux_builder_amp;
4796
-
4797
  if(is_archive() && $redux_builder_amp['ampforwp-archive-support']==1){
4798
  if(is_tag() && is_array($redux_builder_amp['hide-amp-tags-bulk-option'])) {
4799
  $all_tags = get_the_tags();
@@ -4810,22 +4815,22 @@ function is_category_amp_disabled(){
4810
  return false;
4811
  }
4812
  }//tags check area closed
4813
-
4814
  $categories = get_the_category();
4815
- $selected_cats = array();
4816
  if ( $categories) {
4817
- $category_id = $categories[0]->cat_ID;
4818
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
4819
  // Check if $get_categories_from_checkbox has some cats then only show
4820
  if ( $get_categories_from_checkbox ) {
4821
  $get_selected_cats = array_filter($get_categories_from_checkbox);
4822
  foreach ($get_selected_cats as $key => $value) {
4823
  $selected_cats[] = $key;
 
 
 
4824
  }
4825
- if($selected_cats && $category_id){
4826
- if(in_array($category_id, $selected_cats)){
4827
- return true;
4828
- }
4829
  else
4830
  return false;
4831
  }
256
  }//tags area closed
257
 
258
 
259
+ $selected_cats = $current_cats_ids = array();
260
+ $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
261
+ // Check if $get_categories_from_checkbox has some cats then only show
262
+ if ( $get_categories_from_checkbox ) {
263
+ $get_selected_cats = array_filter($get_categories_from_checkbox);
264
+ foreach ($get_selected_cats as $key => $value) {
265
+ $selected_cats[] = $key;
266
+ }
267
+ $current_cats = get_the_category(get_the_ID());
268
+ if ( $current_cats ) {
269
+ foreach ($current_cats as $key => $cats) {
270
+ $current_cats_ids[] =$cats->cat_ID;
271
+ }
272
+ if( count(array_intersect($selected_cats,$current_cats_ids))>0 ){
273
+ return;
274
+ }
275
+ }
276
+ }
277
+ }
278
  if ( is_page() && ! $redux_builder_amp['amp-on-off-for-all-pages'] && ! is_home() && ! is_front_page() ) {
279
  return;
280
  }
1469
  // 12. Add Logo URL in the structured metadata
1470
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
1471
  function ampforwp_update_metadata( $metadata, $post ) {
1472
+ if ( !is_array($metadata) ) {
1473
+ return $metadata;
1474
+ }
1475
  global $redux_builder_amp;
1476
  $structured_data_logo = '';
1477
  $structured_data_main_logo = '';
1490
  } else {
1491
  $structured_data_logo = $structured_data_main_logo;
1492
  }
1493
+
1494
+ $metadata['publisher']['logo'] = array(
1495
+ '@type' => 'ImageObject',
1496
+ 'url' => $structured_data_logo ,
1497
+ 'height' => $ampforwp_sd_height,
1498
+ 'width' => $ampforwp_sd_width,
1499
+ );
 
1500
 
1501
  //code for adding 'description' meta from Yoast SEO
1502
 
1531
  // if there is no image in the post, then use this image to validate Structured Data.
1532
  add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 );
1533
  function ampforwp_update_metadata_featured_image( $metadata, $post ) {
1534
+ if ( !is_array($metadata) ) {
1535
+ return $metadata;
1536
+ }
1537
  global $redux_builder_amp;
1538
  global $post;
1539
  $post_id = get_the_ID() ;
1550
  $structured_data_image = $structured_data_image_url;
1551
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
1552
  $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']);
1553
+ $metadata['image'] = array(
1554
+ '@type' => 'ImageObject',
1555
+ 'url' => $structured_data_image ,
1556
+ 'height' => $structured_data_height,
1557
+ 'width' => $structured_data_width,
1558
+ );
1559
+
 
1560
  }
1561
  // Custom Structured Data information for Archive, Categories and tag pages.
1562
  if ( is_archive() ) {
1570
  $structured_data_author = $structured_data_author->display_name ;
1571
  } else {
1572
  $structured_data_author = "admin";
1573
+ }
1574
+ $metadata['image'] = array(
1575
+ '@type' => 'ImageObject',
1576
+ 'url' => $structured_data_image ,
1577
+ 'height' => $structured_data_height,
1578
+ 'width' => $structured_data_width,
1579
+ );
1580
+
 
1581
  $metadata['author'] = array(
1582
  '@type' => 'Person',
1583
  'name' => $structured_data_author ,
1587
 
1588
  // Get Image metadata from the Custom Field
1589
  if(ampforwp_is_custom_field_featured_image() && ampforwp_cf_featured_image_src()){
1590
+ $metadata['image'] = array(
1591
+ '@type' => 'ImageObject',
1592
+ 'url' => ampforwp_cf_featured_image_src('url') ,
1593
+ 'width' => ampforwp_cf_featured_image_src('width'),
1594
+ 'height' => ampforwp_cf_featured_image_src('height'),
1595
+ );
1596
+
 
1597
  }
1598
 
1599
  // Get image metadata from The Content
1600
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content() ){
1601
+ $metadata['image'] = array(
1602
+ '@type' => 'ImageObject',
1603
+ 'url' => ampforwp_get_featured_image_from_content('url') ,
1604
+ 'width' => ampforwp_get_featured_image_from_content('width'),
1605
+ 'height' => ampforwp_get_featured_image_from_content('height'),
1606
+ );
 
 
1607
  }
1608
 
1609
  if( in_array( "image" , $metadata ) ) {
1718
  }
1719
  $list_of_posts = ampforwp_posts_to_remove();
1720
  if ( $list_of_posts && $post->post_type == 'post' ) {
 
 
 
1721
  $ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'hide-amp';
1722
+ } ?>
 
1723
  <p>
1724
  <div class="prfx-row-content">
1725
  <label class="meta-radio-two" for="ampforwp-on-off-meta-radio-one">
3407
  // 45. searchpage, frontpage, homepage structured data
3408
  add_filter( 'amp_post_template_metadata', 'ampforwp_search_or_homepage_or_staticpage_metadata', 10, 2 );
3409
  function ampforwp_search_or_homepage_or_staticpage_metadata( $metadata, $post ) {
3410
+ if ( !is_array($metadata) ) {
3411
+ return $metadata;
3412
+ }
3413
  global $redux_builder_amp,$wp;
3414
  $desc = '';
3415
  if( is_search() || is_home() || ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) ) {
3475
  // time difference is 2 minute between published and modified date
3476
  $dateModified = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
3477
  }
3478
+ }
3479
+ $metadata['image'] = array(
3480
+ '@type' => 'ImageObject',
3481
+ 'url' => $structured_data_image ,
3482
+ 'height' => $structured_data_height,
3483
+ 'width' => $structured_data_width,
3484
+ );
3485
+
 
3486
  $metadata['datePublished'] = $datePublished; // proper published date added
3487
  $metadata['dateModified'] = $dateModified; // proper modified date
3488
  $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
4533
 
4534
  function ampforwp_posts_to_remove () {
4535
  global $redux_builder_amp;
4536
+ $get_categories_from_checkbox = $current_cats = '';
4537
  $get_selected_cats = array();
4538
  $selected_cats = array();
4539
  $post_id_array = array();
4540
+ $current_cats_ids = array();
4541
  if(isset($redux_builder_amp['hide-amp-categories'])){
4542
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
4543
  }
4547
  $selected_cats[] = $key;
4548
  }
4549
  }
4550
+
4551
+ $current_cats = get_the_category(get_the_ID());
4552
+ foreach ($current_cats as $key => $cats) {
4553
+ $current_cats_ids[] =$cats->cat_ID;
4554
+ }
4555
+ if( count(array_intersect($selected_cats,$current_cats_ids))>0 ){
4556
+ return true;
4557
+ }
4558
+ return false;
4559
+
4560
+ /* $new_selected_cats = implode(',' , $selected_cats);
4561
  if(!empty($get_selected_cats)){
4562
  $the_query = new WP_Query(
4563
  array(
4577
  }
4578
  }
4579
  wp_reset_postdata();
4580
+ return $post_id_array;*/
4581
  }
4582
 
4583
  add_filter( 'amp_skip_post', 'ampforwp_cat_specific_skip_amp_post', 10, 3 );
4584
  function ampforwp_cat_specific_skip_amp_post( $skip, $post_id, $post ) {
 
4585
  $skip_this_post = '';
4586
+ $skip_this_post = ampforwp_posts_to_remove();
4587
+ if ( $skip_this_post ) {
 
 
 
 
4588
  $skip = true;
4589
  remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
4590
  // #999 Disable mobile redirection
4591
  remove_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
4592
+ }
4593
  return $skip;
4594
  }
4595
 
4795
  return $supported_types;
4796
  }
4797
 
4798
+
4799
  function is_category_amp_disabled(){
4800
  global $redux_builder_amp;
4801
+ $current_cats_ids = array();
4802
  if(is_archive() && $redux_builder_amp['ampforwp-archive-support']==1){
4803
  if(is_tag() && is_array($redux_builder_amp['hide-amp-tags-bulk-option'])) {
4804
  $all_tags = get_the_tags();
4815
  return false;
4816
  }
4817
  }//tags check area closed
 
4818
  $categories = get_the_category();
 
4819
  if ( $categories) {
 
4820
  $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories'];
4821
  // Check if $get_categories_from_checkbox has some cats then only show
4822
  if ( $get_categories_from_checkbox ) {
4823
  $get_selected_cats = array_filter($get_categories_from_checkbox);
4824
  foreach ($get_selected_cats as $key => $value) {
4825
  $selected_cats[] = $key;
4826
+ }
4827
+ foreach ($categories as $key => $cats) {
4828
+ $current_cats_ids[] =$cats->cat_ID;
4829
  }
4830
+ if($selected_cats && $current_cats_ids){
4831
+ if( count(array_intersect($selected_cats,$current_cats_ids))>0 ){
4832
+ return true;
4833
+ }
4834
  else
4835
  return false;
4836
  }
templates/structured-data.php CHANGED
@@ -2,6 +2,9 @@
2
  // Structured Data Type
3
  add_filter( 'amp_post_template_metadata', 'ampforwp_structured_data_type', 20, 1 );
4
  function ampforwp_structured_data_type( $metadata ) {
 
 
 
5
  global $redux_builder_amp, $post;
6
  $post_types = '';
7
  $set_sd_post = '';
@@ -58,6 +61,9 @@ function ampforwp_structured_data_type( $metadata ) {
58
  add_filter( 'amp_post_template_metadata', 'ampforwp_structured_data_video_thumb', 20, 1 );
59
  if ( ! function_exists('ampforwp_structured_data_video_thumb') ) {
60
  function ampforwp_structured_data_video_thumb( $metadata ) {
 
 
 
61
  global $redux_builder_amp, $post;
62
  // VideoObject
63
  if ( isset($metadata['@type']) && 'VideoObject' == $metadata['@type'] ) {
2
  // Structured Data Type
3
  add_filter( 'amp_post_template_metadata', 'ampforwp_structured_data_type', 20, 1 );
4
  function ampforwp_structured_data_type( $metadata ) {
5
+ if ( !is_array($metadata) ) {
6
+ return $metadata;
7
+ }
8
  global $redux_builder_amp, $post;
9
  $post_types = '';
10
  $set_sd_post = '';
61
  add_filter( 'amp_post_template_metadata', 'ampforwp_structured_data_video_thumb', 20, 1 );
62
  if ( ! function_exists('ampforwp_structured_data_video_thumb') ) {
63
  function ampforwp_structured_data_video_thumb( $metadata ) {
64
+ if ( !is_array($metadata) ) {
65
+ return $metadata;
66
+ }
67
  global $redux_builder_amp, $post;
68
  // VideoObject
69
  if ( isset($metadata['@type']) && 'VideoObject' == $metadata['@type'] ) {