AMP for WP – Accelerated Mobile Pages - Version 0.9.97.4

Version Description

(09th July 2018) = * Fixed: Huge Performance upgrade in the way fetching the logo url #2317 * Fixed: Fatal Error due to unable to modify values in Structured Data Object #2327 * Fixed: Seperate option for Featured Image in pages in Swift theme #2328 * Fixed: <p> tags disabling where not wanted #2330 * Fixed: Fatal error in contact form module while ninja form or gravity form plugins are not activated #2310 * Fixed: Woo Commerce Category page not working properly #2333 * Fixed: Few issues related to amp-facebook-comments #2300 * Fixed: Limit number of Tags and Category to 500 in Hide AMP-Bulk tools #2336

Download this release

Release Info

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

Code changes from version 0.9.97.3 to 0.9.97.4

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.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -183,6 +183,16 @@ You can contact us from [here](https://ampforwp.com/contact/)
183
 
184
  == Changelog ==
185
 
 
 
 
 
 
 
 
 
 
 
186
  = 0.9.97 (27th June 2018) =
187
  * For more details check out [the blog post](https://ampforwp.com/0-9-97-released-strengthening-of-foundation-89th-update/)
188
  * Fixed: Extraposition attribute left in CSS Design #2 #2119
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.4
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.4 (09th July 2018) =
187
+ * Fixed: Huge Performance upgrade in the way fetching the logo url #2317
188
+ * Fixed: Fatal Error due to unable to modify values in Structured Data Object #2327
189
+ * Fixed: Seperate option for Featured Image in pages in Swift theme #2328
190
+ * Fixed: `<p>` tags disabling where not wanted #2330
191
+ * Fixed: Fatal error in contact form module while ninja form or gravity form plugins are not activated #2310
192
+ * Fixed: Woo Commerce Category page not working properly #2333
193
+ * Fixed: Few issues related to amp-facebook-comments #2300
194
+ * Fixed: Limit number of Tags and Category to 500 in Hide AMP-Bulk tools #2336
195
+
196
  = 0.9.97 (27th June 2018) =
197
  * For more details check out [the blog post](https://ampforwp.com/0-9-97-released-strengthening-of-foundation-89th-update/)
198
  * Fixed: Extraposition attribute left in CSS Design #2 #2119
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.3
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.3');
23
  // any changes to AMP_QUERY_VAR should be refelected here
24
  function ampforwp_generate_endpoint(){
25
  $ampforwp_slug = '';
@@ -191,11 +191,14 @@ function ampforwp_add_custom_rewrite_rules() {
191
  $taxonomies = get_taxonomies( $args, $output, $operator );
192
 
193
 
194
- if( class_exists( 'WooCommerce' ) ) {
195
- $wc_permalinks = get_option( 'woocommerce_permalinks' );
196
-
197
- if ( $wc_permalinks ) {
198
- $taxonomies = array_merge($taxonomies, $wc_permalinks);
 
 
 
199
  }
200
  }
201
 
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.4
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.4');
23
  // any changes to AMP_QUERY_VAR should be refelected here
24
  function ampforwp_generate_endpoint(){
25
  $ampforwp_slug = '';
191
  $taxonomies = get_taxonomies( $args, $output, $operator );
192
 
193
 
194
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
195
+ if(!is_plugin_active('amp-woocommerce-pro/amp-woocommerce.php' )) {
196
+ if( class_exists( 'WooCommerce' ) ) {
197
+ $wc_permalinks = get_option( 'woocommerce_permalinks' );
198
+
199
+ if ( $wc_permalinks ) {
200
+ $taxonomies = array_merge($taxonomies, $wc_permalinks);
201
+ }
202
  }
203
  }
204
 
components/comments/comments.php CHANGED
@@ -132,11 +132,11 @@ global $redux_builder_amp;
132
  $facebook_comments_markup = '<section class="amp-facebook-comments">';
133
  $facebook_comments_markup .= '<amp-facebook-comments width=486 height=357
134
  layout="responsive" '.$locale.' data-numposts=';
135
- $facebook_comments_markup .= '"'. $redux_builder_amp['ampforwp-number-of-fb-no-of-comments']. '" ';
136
  if(ampforwp_get_data_consent()){
137
- $facebook_comments_markup .= 'data-block-on-consent';
138
  }
139
- $facebook_comments_markup .= 'data-href=" ' . get_permalink() . ' "';
140
  $facebook_comments_markup .= '></amp-facebook-comments></section>';
141
  }
142
  return $facebook_comments_markup;
132
  $facebook_comments_markup = '<section class="amp-facebook-comments">';
133
  $facebook_comments_markup .= '<amp-facebook-comments width=486 height=357
134
  layout="responsive" '.$locale.' data-numposts=';
135
+ $facebook_comments_markup .= '"'. $redux_builder_amp['ampforwp-number-of-fb-no-of-comments']. '"';
136
  if(ampforwp_get_data_consent()){
137
+ $facebook_comments_markup .= ' data-block-on-consent ';
138
  }
139
+ $facebook_comments_markup .= 'data-href="' . get_permalink() . '"';
140
  $facebook_comments_markup .= '></amp-facebook-comments></section>';
141
  }
142
  return $facebook_comments_markup;
includes/options/admin-config.php CHANGED
@@ -126,6 +126,18 @@ $extension_listing_array = array(
126
  'is_activated'=>(is_plugin_active('amp-cache/ampforwp-cache.php')? 1 : 2),
127
  'settingUrl'=>'{opt-go-amp-cache}',
128
  ),
 
 
 
 
 
 
 
 
 
 
 
 
129
  array(
130
  'name'=>'Call To Action (CTA)',
131
  'desc'=>'Higher Visibility & More Conversions',
@@ -6029,7 +6041,15 @@ Redux::setSection( $opt_name, array(
6029
  ),
6030
 
6031
  // Meta ON/OFF Pages
6032
- array(
 
 
 
 
 
 
 
 
6033
  'id' => 'meta_page',
6034
  'type' => 'switch',
6035
  'default' => '0',
126
  'is_activated'=>(is_plugin_active('amp-cache/ampforwp-cache.php')? 1 : 2),
127
  'settingUrl'=>'{opt-go-amp-cache}',
128
  ),
129
+ array(
130
+ 'name'=>'PWA For WordPress',
131
+ 'desc'=>'Add Progressive Web App support for WordPress website',
132
+ 'img_src'=>AMPFORWP_IMAGE_DIR . '/cache-icon.png',
133
+ 'price'=>'$89',
134
+ 'url_link'=>'http://ampforwp.com/pwa/#utm_source=options-panel&utm_medium=extension-tab_pwa-for-wordpress&utm_campaign=AMP%20Plugin',
135
+ 'plugin_active_path'=> 'pwa-for-wordpress/amp-pwa.php',
136
+ 'item_name'=>'PWA For WordPress',
137
+ 'store_url'=>'https://accounts.ampforwp.com',
138
+ 'is_activated'=>(is_plugin_active('pwa-for-wordpress/amp-pwa.php')? 1 : 2),
139
+ 'settingUrl'=>admin_url( 'admin.php?page=ampforwp-pwa' ),
140
+ ),
141
  array(
142
  'name'=>'Call To Action (CTA)',
143
  'desc'=>'Higher Visibility & More Conversions',
6041
  ),
6042
 
6043
  // Meta ON/OFF Pages
6044
+ array(
6045
+ 'id' => 'featured_image_swift_page',
6046
+ 'type' => 'switch',
6047
+ 'default' => '0',
6048
+ 'title' => __('Featured Image', 'accelerated-mobile-pages'),
6049
+ 'tooltip-subtitle' => __('Enable Featured Image on Pages.'),
6050
+ 'required' => array('amp-design-selector','=','4'),
6051
+ ),
6052
+ array(
6053
  'id' => 'meta_page',
6054
  'type' => 'switch',
6055
  'default' => '0',
includes/options/extensions/checkbox_hierarchy/checkbox_hierarchy/field_checkbox_hierarchy.php CHANGED
@@ -146,7 +146,7 @@ if ( !class_exists ( 'ReduxFramework_checkbox_hierarchy' ) ) {
146
 
147
 
148
  if (!$categories )
149
- $categories = get_categories( );//array('hide_empty' => 0)
150
 
151
  if ( $categories ) {
152
  foreach ( $categories as $category ) {
146
 
147
 
148
  if (!$categories )
149
+ $categories = get_categories( array('number'=>500) );//array('hide_empty' => 0)
150
 
151
  if ( $categories ) {
152
  foreach ( $categories as $category ) {
includes/options/redux-core/framework.php CHANGED
@@ -987,6 +987,7 @@
987
  }
988
  }
989
  } else if ( $type == "tags" || $type == "tag" ) { // NOT WORKING!
 
990
  $tags = get_tags( $args );
991
  if ( ! empty ( $tags ) ) {
992
  foreach ( $tags as $tag ) {
987
  }
988
  }
989
  } else if ( $type == "tags" || $type == "tag" ) { // NOT WORKING!
990
+ $args['number'] = 500;
991
  $tags = get_tags( $args );
992
  if ( ! empty ( $tags ) ) {
993
  foreach ( $tags as $tag ) {
includes/vendor/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php CHANGED
@@ -209,9 +209,6 @@ class AMP_Tag_And_Attribute_Sanitizer extends AMP_Base_Sanitizer {
209
  'latest'
210
  );
211
  }
212
- if(count($scriptArray)>0){
213
- remove_filter('the_content', 'wpautop');
214
- }
215
  return $scriptArray;
216
  }
217
 
209
  'latest'
210
  );
211
  }
 
 
 
212
  return $scriptArray;
213
  }
214
 
pagebuilder/modules/contact-form-shortcode-module.php CHANGED
@@ -45,7 +45,7 @@ if(is_plugin_active('amp-cf7/amp-cf7.php')){
45
  ));
46
 
47
  }
48
- if(is_plugin_active('amp-gravity-forms/amp-gravity-forms.php')){
49
  $formSupported = array_merge($formSupported, array('gravityform'=>'Gravity Form'));
50
 
51
  $apbGFforms = RGFormsModel::get_forms();
@@ -98,7 +98,7 @@ if(is_plugin_active('amp-wp-forms/amp-wpforms.php')){
98
  'required' => array('form_type' => 'wpforms'),
99
  ));
100
  }
101
- if(is_plugin_active('amp-ninja-forms/amp-ninja-forms.php')){
102
  $formSupported = array_merge($formSupported, array('ninja_form'=>'Ninja Forms'));
103
 
104
  $ninjaforms_modified = array();
45
  ));
46
 
47
  }
48
+ if(is_plugin_active('amp-gravity-forms/amp-gravity-forms.php') && class_exists('RGFormsModel')){
49
  $formSupported = array_merge($formSupported, array('gravityform'=>'Gravity Form'));
50
 
51
  $apbGFforms = RGFormsModel::get_forms();
98
  'required' => array('form_type' => 'wpforms'),
99
  ));
100
  }
101
+ if(is_plugin_active('amp-ninja-forms/amp-ninja-forms.php') && function_exists('Ninja_Forms')){
102
  $formSupported = array_merge($formSupported, array('ninja_form'=>'Ninja Forms'));
103
 
104
  $ninjaforms_modified = array();
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.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -183,6 +183,16 @@ You can contact us from [here](https://ampforwp.com/contact/)
183
 
184
  == Changelog ==
185
 
 
 
 
 
 
 
 
 
 
 
186
  = 0.9.97 (27th June 2018) =
187
  * For more details check out [the blog post](https://ampforwp.com/0-9-97-released-strengthening-of-foundation-89th-update/)
188
  * Fixed: Extraposition attribute left in CSS Design #2 #2119
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.4
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.4 (09th July 2018) =
187
+ * Fixed: Huge Performance upgrade in the way fetching the logo url #2317
188
+ * Fixed: Fatal Error due to unable to modify values in Structured Data Object #2327
189
+ * Fixed: Seperate option for Featured Image in pages in Swift theme #2328
190
+ * Fixed: `<p>` tags disabling where not wanted #2330
191
+ * Fixed: Fatal error in contact form module while ninja form or gravity form plugins are not activated #2310
192
+ * Fixed: Woo Commerce Category page not working properly #2333
193
+ * Fixed: Few issues related to amp-facebook-comments #2300
194
+ * Fixed: Limit number of Tags and Category to 500 in Hide AMP-Bulk tools #2336
195
+
196
  = 0.9.97 (27th June 2018) =
197
  * For more details check out [the blog post](https://ampforwp.com/0-9-97-released-strengthening-of-foundation-89th-update/)
198
  * Fixed: Extraposition attribute left in CSS Design #2 #2119
templates/design-manager/swift/page.php CHANGED
@@ -8,7 +8,7 @@ amp_header(); ?>
8
  }?>
9
  <?php amp_title(); ?>
10
  <?php } ?>
11
- <?php if ( isset($redux_builder_amp['swift-featued-image']) && $redux_builder_amp['swift-featued-image'] && ampforwp_has_post_thumbnail() ) { ?>
12
  <div class="sf-img">
13
  <?php amp_featured_image();?>
14
  </div>
8
  }?>
9
  <?php amp_title(); ?>
10
  <?php } ?>
11
+ <?php if ( isset($redux_builder_amp['featured_image_swift_page']) && $redux_builder_amp['featured_image_swift_page'] && ampforwp_has_post_thumbnail() ) { ?>
12
  <div class="sf-img">
13
  <?php amp_featured_image();?>
14
  </div>
templates/features.php CHANGED
@@ -1486,12 +1486,14 @@ function ampforwp_new_dir( $dir ) {
1486
  } else {
1487
  $structured_data_logo = $structured_data_main_logo;
1488
  }
1489
- $metadata['publisher']['logo'] = array(
1490
- '@type' => 'ImageObject',
1491
- 'url' => $structured_data_logo ,
1492
- 'height' => $ampforwp_sd_height,
1493
- 'width' => $ampforwp_sd_width,
1494
- );
 
 
1495
 
1496
  //code for adding 'description' meta from Yoast SEO
1497
 
@@ -1499,7 +1501,7 @@ function ampforwp_new_dir( $dir ) {
1499
  if ( class_exists('WPSEO_Frontend') ) {
1500
  $front = WPSEO_Frontend::get_instance();
1501
  $desc = $front->metadesc( false );
1502
- if ( $desc ) {
1503
  $metadata['description'] = $desc;
1504
  }
1505
 
@@ -1508,7 +1510,7 @@ function ampforwp_new_dir( $dir ) {
1508
  if ( class_exists('WPSEO_Meta') ) {
1509
  $custom_fp_desc = WPSEO_Meta::get_value('metadesc', $post_id );
1510
  if ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) {
1511
- if ( $custom_fp_desc ) {
1512
  $metadata['description'] = $custom_fp_desc;
1513
  } else {
1514
  unset( $metadata['description'] );
@@ -1542,13 +1544,14 @@ function ampforwp_new_dir( $dir ) {
1542
  $structured_data_image = $structured_data_image_url;
1543
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
1544
  $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']);
1545
-
1546
- $metadata['image'] = array(
1547
- '@type' => 'ImageObject',
1548
- 'url' => $structured_data_image ,
1549
- 'height' => $structured_data_height,
1550
- 'width' => $structured_data_width,
1551
- );
 
1552
  }
1553
  // Custom Structured Data information for Archive, Categories and tag pages.
1554
  if ( is_archive() ) {
@@ -1563,13 +1566,14 @@ function ampforwp_new_dir( $dir ) {
1563
  } else {
1564
  $structured_data_author = "admin";
1565
  }
1566
-
1567
- $metadata['image'] = array(
1568
- '@type' => 'ImageObject',
1569
- 'url' => $structured_data_image ,
1570
- 'height' => $structured_data_height,
1571
- 'width' => $structured_data_width,
1572
- );
 
1573
  $metadata['author'] = array(
1574
  '@type' => 'Person',
1575
  'name' => $structured_data_author ,
@@ -1579,22 +1583,26 @@ function ampforwp_new_dir( $dir ) {
1579
 
1580
  // Get Image metadata from the Custom Field
1581
  if(ampforwp_is_custom_field_featured_image() && ampforwp_cf_featured_image_src()){
1582
- $metadata['image'] = array(
1583
- '@type' => 'ImageObject',
1584
- 'url' => ampforwp_cf_featured_image_src('url') ,
1585
- 'width' => ampforwp_cf_featured_image_src('width'),
1586
- 'height' => ampforwp_cf_featured_image_src('height'),
1587
- );
 
 
1588
  }
1589
 
1590
  // Get image metadata from The Content
1591
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content() ){
1592
- $metadata['image'] = array(
1593
- '@type' => 'ImageObject',
1594
- 'url' => ampforwp_get_featured_image_from_content('url') ,
1595
- 'width' => ampforwp_get_featured_image_from_content('width'),
1596
- 'height' => ampforwp_get_featured_image_from_content('height'),
1597
- );
 
 
1598
  }
1599
 
1600
  if( in_array( "image" , $metadata ) ) {
@@ -3462,12 +3470,14 @@ function ampforwp_search_or_homepage_or_staticpage_metadata( $metadata, $post )
3462
  $dateModified = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
3463
  }
3464
  }
3465
- $metadata['image'] = array(
3466
- '@type' => 'ImageObject',
3467
- 'url' => $structured_data_image ,
3468
- 'height' => $structured_data_height,
3469
- 'width' => $structured_data_width,
3470
- );
 
 
3471
  $metadata['datePublished'] = $datePublished; // proper published date added
3472
  $metadata['dateModified'] = $dateModified; // proper modified date
3473
  $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
@@ -3484,7 +3494,9 @@ function ampforwp_search_or_homepage_or_staticpage_metadata( $metadata, $post )
3484
  }
3485
  // Description for Structured Data
3486
  $desc = esc_attr( convert_chars( stripslashes( ampforwp_generate_meta_desc('json'))) );
3487
- $metadata['description'] = $desc;
 
 
3488
  return $metadata;
3489
  }
3490
 
@@ -6197,56 +6209,94 @@ if( ! function_exists(' ampforwp_modify_menu_content ') ){
6197
  return $menu;
6198
  }
6199
  }
 
 
 
 
 
 
 
 
 
 
 
 
6200
 
6201
- // 101. Function for Logo attributes
6202
- function ampforwp_default_logo($param=""){
6203
- global $redux_builder_amp;
6204
  $logo_id = '';
6205
- $image = '';
6206
  $value = '';
6207
  $logo_alt = '';
6208
- $logo_url = $redux_builder_amp['opt-media']['url'];
6209
- if($logo_url){
6210
- $logo_id = get_theme_mod( 'custom_logo' );
6211
- $logo_alt = get_post_meta( $logo_id, '_wp_attachment_image_alt', true) ;
6212
- $image = @getimagesize($redux_builder_amp['opt-media']['url']);
6213
-
6214
- if(empty($image) || $image==false){
6215
- $logo_id = attachment_url_to_postid($redux_builder_amp['opt-media']['url']);
6216
- $imageDetail = wp_get_attachment_image_src( $logo_id , 'full');
6217
- $image[0] = $imageDetail[1];
6218
- $image[1] = $imageDetail[2];
6219
- }
6220
- switch ($param) {
6221
- case 'url':
6222
- $value = $logo_url;
6223
- break;
6224
- case 'width':
6225
- if (true == $redux_builder_amp['ampforwp-custom-logo-dimensions'] && 'prescribed' == $redux_builder_amp['ampforwp-custom-logo-dimensions-options']) {
6226
- $value = $redux_builder_amp['opt-media-width'];
6227
- }
6228
- else
6229
- $value = $image[0];
6230
- break;
6231
- case 'height':
6232
- if (true == $redux_builder_amp['ampforwp-custom-logo-dimensions'] && 'prescribed' == $redux_builder_amp['ampforwp-custom-logo-dimensions-options']) {
6233
- $value = $redux_builder_amp['opt-media-height'];
6234
- }
6235
- else
6236
- $value = $image[1];
6237
- break;
6238
- case 'alt':
6239
- if($logo_alt){
6240
- $value = $logo_alt;
6241
- }
6242
- else
6243
- $value = get_bloginfo('name');
6244
- break;
6245
- default:
6246
- $value = $logo_url;
6247
- break;
6248
- }
6249
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6250
  return $value;
6251
  }
6252
  // Envira Lazy Load compatibility
1486
  } else {
1487
  $structured_data_logo = $structured_data_main_logo;
1488
  }
1489
+ if(isset($metadata['publisher']) && $metadata['publisher']){
1490
+ $metadata['publisher']['logo'] = array(
1491
+ '@type' => 'ImageObject',
1492
+ 'url' => $structured_data_logo ,
1493
+ 'height' => $ampforwp_sd_height,
1494
+ 'width' => $ampforwp_sd_width,
1495
+ );
1496
+ }
1497
 
1498
  //code for adding 'description' meta from Yoast SEO
1499
 
1501
  if ( class_exists('WPSEO_Frontend') ) {
1502
  $front = WPSEO_Frontend::get_instance();
1503
  $desc = $front->metadesc( false );
1504
+ if ( $desc && isset($metadata['description']) ) {
1505
  $metadata['description'] = $desc;
1506
  }
1507
 
1510
  if ( class_exists('WPSEO_Meta') ) {
1511
  $custom_fp_desc = WPSEO_Meta::get_value('metadesc', $post_id );
1512
  if ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) {
1513
+ if ( $custom_fp_desc && isset($metadata['description']) ){
1514
  $metadata['description'] = $custom_fp_desc;
1515
  } else {
1516
  unset( $metadata['description'] );
1544
  $structured_data_image = $structured_data_image_url;
1545
  $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']);
1546
  $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']);
1547
+ if(isset($metadata['image']) && $metadata['image'] ){
1548
+ $metadata['image'] = array(
1549
+ '@type' => 'ImageObject',
1550
+ 'url' => $structured_data_image ,
1551
+ 'height' => $structured_data_height,
1552
+ 'width' => $structured_data_width,
1553
+ );
1554
+ }
1555
  }
1556
  // Custom Structured Data information for Archive, Categories and tag pages.
1557
  if ( is_archive() ) {
1566
  } else {
1567
  $structured_data_author = "admin";
1568
  }
1569
+ if(isset($metadata['image']) && $metadata['image'] ){
1570
+ $metadata['image'] = array(
1571
+ '@type' => 'ImageObject',
1572
+ 'url' => $structured_data_image ,
1573
+ 'height' => $structured_data_height,
1574
+ 'width' => $structured_data_width,
1575
+ );
1576
+ }
1577
  $metadata['author'] = array(
1578
  '@type' => 'Person',
1579
  'name' => $structured_data_author ,
1583
 
1584
  // Get Image metadata from the Custom Field
1585
  if(ampforwp_is_custom_field_featured_image() && ampforwp_cf_featured_image_src()){
1586
+ if(isset($metadata['image']) && $metadata['image'] ){
1587
+ $metadata['image'] = array(
1588
+ '@type' => 'ImageObject',
1589
+ 'url' => ampforwp_cf_featured_image_src('url') ,
1590
+ 'width' => ampforwp_cf_featured_image_src('width'),
1591
+ 'height' => ampforwp_cf_featured_image_src('height'),
1592
+ );
1593
+ }
1594
  }
1595
 
1596
  // Get image metadata from The Content
1597
  if( true == $redux_builder_amp['ampforwp-featured-image-from-content'] && ampforwp_get_featured_image_from_content() ){
1598
+ if(isset($metadata['image']) && $metadata['image'] ){
1599
+ $metadata['image'] = array(
1600
+ '@type' => 'ImageObject',
1601
+ 'url' => ampforwp_get_featured_image_from_content('url') ,
1602
+ 'width' => ampforwp_get_featured_image_from_content('width'),
1603
+ 'height' => ampforwp_get_featured_image_from_content('height'),
1604
+ );
1605
+ }
1606
  }
1607
 
1608
  if( in_array( "image" , $metadata ) ) {
3470
  $dateModified = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
3471
  }
3472
  }
3473
+ if(isset($metadata['image']) && $metadata['image'] ){
3474
+ $metadata['image'] = array(
3475
+ '@type' => 'ImageObject',
3476
+ 'url' => $structured_data_image ,
3477
+ 'height' => $structured_data_height,
3478
+ 'width' => $structured_data_width,
3479
+ );
3480
+ }
3481
  $metadata['datePublished'] = $datePublished; // proper published date added
3482
  $metadata['dateModified'] = $dateModified; // proper modified date
3483
  $remove = '/'. AMPFORWP_AMP_QUERY_VAR;
3494
  }
3495
  // Description for Structured Data
3496
  $desc = esc_attr( convert_chars( stripslashes( ampforwp_generate_meta_desc('json'))) );
3497
+ if(isset($metadata['description']) && $metadata['description'] ){
3498
+ $metadata['description'] = $desc;
3499
+ }
3500
  return $metadata;
3501
  }
3502
 
6209
  return $menu;
6210
  }
6211
  }
6212
+ /*
6213
+ * Fetches the logo data
6214
+ * More details about the fix https://github.com/ahmedkaludi/accelerated-mobile-pages/pull/2317
6215
+ * Props to: https://github.com/saucal for suggesting the fix.
6216
+ */
6217
+
6218
+ function ampforwp_default_logo_data() {
6219
+ global $redux_builder_amp, $ampwforwp_default_logo_data;
6220
+
6221
+ if( $ampwforwp_default_logo_data ) {
6222
+ return $ampwforwp_default_logo_data;
6223
+ }
6224
 
 
 
 
6225
  $logo_id = '';
6226
+ $image = array();
6227
  $value = '';
6228
  $logo_alt = '';
6229
+
6230
+ $logo_id = get_theme_mod( 'custom_logo' );
6231
+ if( empty( $logo_id ) ) {
6232
+ $logo_id = (integer) $redux_builder_amp['opt-media']['id'];
6233
+ }
6234
+
6235
+ if( empty( $logo_id ) ) {
6236
+ return false;
6237
+ }
6238
+
6239
+ if( ! wp_attachment_is( 'image', $logo_id ) ) {
6240
+ $logo_url = $redux_builder_amp['opt-media']['url'];
6241
+ $image = @getimagesize( $logo_url );
6242
+ } else {
6243
+ $imageDetail = wp_get_attachment_image_src( $logo_id , 'full');
6244
+ $logo_url = $imageDetail[0];
6245
+ $image[0] = $imageDetail[1];
6246
+ $image[1] = $imageDetail[2];
6247
+ }
6248
+
6249
+ $logo_alt = get_post_meta( $logo_id, '_wp_attachment_image_alt', true);
6250
+
6251
+ $ampwforwp_default_logo_data = array(
6252
+ 'logo_id' => $logo_id,
6253
+ 'logo_url' => $logo_url,
6254
+ 'logo_alt' => $logo_alt,
6255
+ 'logo_size' => $image
6256
+ );
6257
+ return $ampwforwp_default_logo_data;
6258
+ }
6259
+
6260
+ // 101. Function for Logo attributes
6261
+ function ampforwp_default_logo($param=""){
6262
+ global $redux_builder_amp;
6263
+ $value = '';
6264
+ $logo_alt = '';
6265
+ $data = ampforwp_default_logo_data();
6266
+ if( ! $data ) {
6267
+ return $value;
 
 
6268
  }
6269
+
6270
+ switch ($param) {
6271
+ case 'url':
6272
+ $value = $data['logo_url'];
6273
+ break;
6274
+ case 'width':
6275
+ if (true == $redux_builder_amp['ampforwp-custom-logo-dimensions'] && 'prescribed' == $redux_builder_amp['ampforwp-custom-logo-dimensions-options']) {
6276
+ $value = $redux_builder_amp['opt-media-width'];
6277
+ }
6278
+ else
6279
+ $value = $data['logo_size'][0];
6280
+ break;
6281
+ case 'height':
6282
+ if (true == $redux_builder_amp['ampforwp-custom-logo-dimensions'] && 'prescribed' == $redux_builder_amp['ampforwp-custom-logo-dimensions-options']) {
6283
+ $value = $redux_builder_amp['opt-media-height'];
6284
+ }
6285
+ else
6286
+ $value = $data['logo_size'][1];
6287
+ break;
6288
+ case 'alt':
6289
+ if($logo_alt){
6290
+ $value = $data['logo_alt'];
6291
+ }
6292
+ else
6293
+ $value = get_bloginfo('name');
6294
+ break;
6295
+ default:
6296
+ $value = $data['logo_url'];
6297
+ break;
6298
+ }
6299
+
6300
  return $value;
6301
  }
6302
  // Envira Lazy Load compatibility
templates/structured-data.php CHANGED
@@ -22,7 +22,9 @@ function ampforwp_structured_data_type( $metadata ) {
22
  if ( empty( $redux_builder_amp['ampforwp-sd-type-'.$post_type.''] ) && $redux_builder_amp['ampforwp-seo-yoast-description'] == 0 ) {
23
  return;
24
  }
25
- $metadata['@type'] = $redux_builder_amp['ampforwp-sd-type-'.$post_type.''];
 
 
26
  return $metadata;
27
  }
28
  }
@@ -36,14 +38,18 @@ function ampforwp_structured_data_type( $metadata ) {
36
  return;
37
  }
38
  if ( isset( $post->post_type ) && 'post' == $post->post_type ) {
39
- $metadata['@type'] = $set_sd_post;
 
 
40
  }
41
 
42
  if ( (isset( $post->post_type ) && 'page' == $post->post_type) || ampforwp_is_front_page() || ampforwp_is_blog()) {
43
  if ( empty( $set_sd_page )){
44
  return;
45
  }
46
- $metadata['@type'] = $set_sd_page;
 
 
47
  }
48
 
49
  return $metadata;
@@ -54,7 +60,7 @@ if ( ! function_exists('ampforwp_structured_data_video_thumb') ) {
54
  function ampforwp_structured_data_video_thumb( $metadata ) {
55
  global $redux_builder_amp, $post;
56
  // VideoObject
57
- if ( 'VideoObject' == $metadata['@type'] ) {
58
  $post_image_id = '';
59
  $post_image_id = get_post_thumbnail_id( get_the_ID() );
60
  $post_image = wp_get_attachment_image_src( $post_image_id, 'full' );
@@ -74,7 +80,7 @@ if ( ! function_exists('ampforwp_structured_data_video_thumb') ) {
74
  $metadata['thumbnailUrl'] = $structured_data_video_thumb_url;
75
  }
76
  // Recipe
77
- if ( 'Recipe' == $metadata['@type'] ) {
78
  $metadata['name'] = $metadata['headline'];
79
  }
80
  return $metadata;
@@ -86,7 +92,7 @@ if ( ! function_exists('ampforwp_structured_data_product') ) {
86
  function ampforwp_structured_data_product( $metadata ) {
87
  global $redux_builder_amp, $post;
88
  // Adding Product's Name and unsetting the Google unrecognized data for type Product
89
- if ( 'Product' == $metadata['@type'] ) {
90
  $metadata['name'] = $metadata['headline'];
91
  unset($metadata['dateModified']);
92
  unset($metadata['datePublished']);
22
  if ( empty( $redux_builder_amp['ampforwp-sd-type-'.$post_type.''] ) && $redux_builder_amp['ampforwp-seo-yoast-description'] == 0 ) {
23
  return;
24
  }
25
+ if(isset($metadata['@type']) && $metadata['@type']){
26
+ $metadata['@type'] = $redux_builder_amp['ampforwp-sd-type-'.$post_type.''];
27
+ }
28
  return $metadata;
29
  }
30
  }
38
  return;
39
  }
40
  if ( isset( $post->post_type ) && 'post' == $post->post_type ) {
41
+ if(isset($metadata['@type']) && $metadata['@type']){
42
+ $metadata['@type'] = $set_sd_post;
43
+ }
44
  }
45
 
46
  if ( (isset( $post->post_type ) && 'page' == $post->post_type) || ampforwp_is_front_page() || ampforwp_is_blog()) {
47
  if ( empty( $set_sd_page )){
48
  return;
49
  }
50
+ if(isset($metadata['@type']) && $metadata['@type']){
51
+ $metadata['@type'] = $set_sd_page;
52
+ }
53
  }
54
 
55
  return $metadata;
60
  function ampforwp_structured_data_video_thumb( $metadata ) {
61
  global $redux_builder_amp, $post;
62
  // VideoObject
63
+ if ( isset($metadata['@type']) && 'VideoObject' == $metadata['@type'] ) {
64
  $post_image_id = '';
65
  $post_image_id = get_post_thumbnail_id( get_the_ID() );
66
  $post_image = wp_get_attachment_image_src( $post_image_id, 'full' );
80
  $metadata['thumbnailUrl'] = $structured_data_video_thumb_url;
81
  }
82
  // Recipe
83
+ if ( isset($metadata['@type']) && 'Recipe' == $metadata['@type'] ) {
84
  $metadata['name'] = $metadata['headline'];
85
  }
86
  return $metadata;
92
  function ampforwp_structured_data_product( $metadata ) {
93
  global $redux_builder_amp, $post;
94
  // Adding Product's Name and unsetting the Google unrecognized data for type Product
95
+ if ( isset($metadata['@type']) && 'Product' == $metadata['@type'] ) {
96
  $metadata['name'] = $metadata['headline'];
97
  unset($metadata['dateModified']);
98
  unset($metadata['datePublished']);