Business Profile - Version 2.2.4

Version Description

(2022-08-08) = - Added an extra option to specify a display number for the Whatsapp field, so you can display a different number in the contact card than the one that is used to send the message. - Corrected an issue that was causing invalid schema. - Removed the trailing comma from the newly-added instance of register_block_pattern_category, to correct an apparent conflict with proxy fcgi, as reported by one user.

Download this release

Release Info

Developer Rustaurius
Plugin Icon 128x128 Business Profile
Version 2.2.4
Comparing to
See all releases

Code changes from version 2.2.3 to 2.2.4

bpfwp-templates/contact-card.php CHANGED
@@ -96,20 +96,20 @@
96
  ?>
97
  <?php $json_ld_data = array( 'type' => bpfwp_setting( 'schema-type', bpfwp_get_display( 'location' ) ) ); ?>
98
  <address class="bp-contact-card">
99
- <?php if ( bpfwp_setting( 'image', bpfwp_get_display( 'location' ) ) ) : ?>
100
- <?php $json_ld_data['image'] = wp_get_attachment_url( bpfwp_setting( 'image', bpfwp_get_display( 'location' ) ) ); ?>
101
- <?php endif; ?>
102
- <?php
103
- foreach ( $data as $data => $callback ) {
104
-
105
- $return_array = call_user_func( $callback, bpfwp_get_display( 'location' ) );
106
- if ( is_array( $return_array ) ) { $json_ld_data = array_merge_recursive( $json_ld_data, $return_array ); }
107
- }
108
- ?>
109
- <script type="application/ld+json">
110
- {
111
- "@context": "https://schema.org/",
112
- <?php echo trim( bpfwp_json_ld_contact_print( false, $json_ld_data ), ',' ); ?>
113
- }
114
- </script>
115
  </address>
96
  ?>
97
  <?php $json_ld_data = array( 'type' => bpfwp_setting( 'schema-type', bpfwp_get_display( 'location' ) ) ); ?>
98
  <address class="bp-contact-card">
99
+ <?php if ( bpfwp_setting( 'image', bpfwp_get_display( 'location' ) ) ) : ?>
100
+ <?php $json_ld_data['image'] = wp_get_attachment_url( bpfwp_setting( 'image', bpfwp_get_display( 'location' ) ) ); ?>
101
+ <?php endif; ?>
102
+ <?php
103
+ foreach ( $data as $data => $callback ) {
104
+
105
+ $return_array = call_user_func( $callback, bpfwp_get_display( 'location' ) );
106
+ if ( is_array( $return_array ) ) { $json_ld_data = array_merge_recursive( $json_ld_data, $return_array ); }
107
+ }
108
+ ?>
109
+ <script type="application/ld+json">
110
+ <?php
111
+ $json_ld_data["@context"] = "https://schema.org/";
112
+ echo trim( bpfwp_json_ld_contact_print( false, $json_ld_data ), ',' );
113
+ ?>
114
+ </script>
115
  </address>
business-profile.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Five Star Business Profile and Schema
4
  * Plugin URI: https://www.fivestarplugins.com/plugins/business-profile/
5
  * Description: Add schema structured data to any page or post type. Create an SEO friendly contact card with your business info and associated schema. Supports Google Map, opening hours and more.
6
- * Version: 2.2.3
7
  * Author: Five Star Plugins
8
  * Author URI: https://www.fivestarplugins.com
9
  * License: GPLv3
@@ -120,7 +120,7 @@ if ( ! class_exists( 'bpfwpInit', false ) ) :
120
  define( 'BPFWP_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
121
  define( 'BPFWP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
122
  define( 'BPFWP_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
123
- define( 'BPFWP_VERSION', '2.2.3' );
124
  }
125
 
126
  /**
3
  * Plugin Name: Five Star Business Profile and Schema
4
  * Plugin URI: https://www.fivestarplugins.com/plugins/business-profile/
5
  * Description: Add schema structured data to any page or post type. Create an SEO friendly contact card with your business info and associated schema. Supports Google Map, opening hours and more.
6
+ * Version: 2.2.4
7
  * Author: Five Star Plugins
8
  * Author URI: https://www.fivestarplugins.com
9
  * License: GPLv3
120
  define( 'BPFWP_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
121
  define( 'BPFWP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
122
  define( 'BPFWP_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
123
+ define( 'BPFWP_VERSION', '2.2.4' );
124
  }
125
 
126
  /**
includes/class-custom-post-types.php CHANGED
@@ -449,35 +449,42 @@ if ( ! class_exists( 'bpfwpCustomPostTypes', false ) ) :
449
  <input type="tel" name="clickphone" id="bpfwp_clickphone" value="<?php esc_attr_e( get_post_meta( $post->ID, 'clickphone', true ) ); ?>">
450
  </div>
451
 
452
- <div class="bpfwp-meta-input bpfwp-meta-phone">
453
  <label for="bpfwp_cell_phone">
454
  <?php esc_html_e( 'Cell Phone', 'business-profile' ); ?>
455
  </label>
456
  <input type="tel" name="cell-phone" id="bpfwp_cell_phone" value="<?php esc_attr_e( get_post_meta( $post->ID, 'cell-phone', true ) ); ?>">
457
  </div>
458
 
459
- <div class="bpfwp-meta-input bpfwp-meta-phone">
460
  <label for="clickcellphone">
461
  <?php esc_html_e( 'Click-to-Call Cell Phone', 'business-profile' ); ?>
462
  </label>
463
  <input type="tel" name="clickcellphone" id="clickcellphone" value="<?php esc_attr_e( get_post_meta( $post->ID, 'clickcellphone', true ) ); ?>">
464
  </div>
465
 
466
- <div class="bpfwp-meta-input bpfwp-meta-phone">
467
  <label for="bpfwp_whatsapp">
468
  <?php esc_html_e( 'Whatsapp', 'business-profile' ); ?>
469
  </label>
470
  <input type="tel" name="whatsapp" id="bpfwp_whatsapp" value="<?php esc_attr_e( get_post_meta( $post->ID, 'whatsapp', true ) ); ?>">
471
  </div>
472
 
473
- <div class="bpfwp-meta-input bpfwp-meta-phone">
 
 
 
 
 
 
 
474
  <label for="bpfwp_whatsapptxt">
475
  <?php esc_html_e( 'Whatsapp Text', 'business-profile' ); ?>
476
  </label>
477
  <input type="text" name="whatsapptext" id="bpfwp_whatsapptxt" value="<?php esc_attr_e( get_post_meta( $post->ID, 'whatsapptext', true ) ); ?>">
478
  </div>
479
 
480
- <div class="bpfwp-meta-input bpfwp-meta-phone">
481
  <label for="bpfwp_fax">
482
  <?php esc_html_e( 'Fax', 'business-profile' ); ?>
483
  </label>
@@ -860,6 +867,7 @@ if ( ! class_exists( 'bpfwpCustomPostTypes', false ) ) :
860
  'cell-phone' => 'sanitize_text_field',
861
  'clickcellphone' => 'sanitize_text_field',
862
  'whatsapp' => 'sanitize_text_field',
 
863
  'whatsapptext' => 'sanitize_text_field',
864
  'fax' => 'sanitize_text_field',
865
  'contact_post' => 'absint',
449
  <input type="tel" name="clickphone" id="bpfwp_clickphone" value="<?php esc_attr_e( get_post_meta( $post->ID, 'clickphone', true ) ); ?>">
450
  </div>
451
 
452
+ <div class="bpfwp-meta-input bpfwp-meta-cell-phone">
453
  <label for="bpfwp_cell_phone">
454
  <?php esc_html_e( 'Cell Phone', 'business-profile' ); ?>
455
  </label>
456
  <input type="tel" name="cell-phone" id="bpfwp_cell_phone" value="<?php esc_attr_e( get_post_meta( $post->ID, 'cell-phone', true ) ); ?>">
457
  </div>
458
 
459
+ <div class="bpfwp-meta-input bpfwp-meta-clickcellphone">
460
  <label for="clickcellphone">
461
  <?php esc_html_e( 'Click-to-Call Cell Phone', 'business-profile' ); ?>
462
  </label>
463
  <input type="tel" name="clickcellphone" id="clickcellphone" value="<?php esc_attr_e( get_post_meta( $post->ID, 'clickcellphone', true ) ); ?>">
464
  </div>
465
 
466
+ <div class="bpfwp-meta-input bpfwp-meta-whatsapp">
467
  <label for="bpfwp_whatsapp">
468
  <?php esc_html_e( 'Whatsapp', 'business-profile' ); ?>
469
  </label>
470
  <input type="tel" name="whatsapp" id="bpfwp_whatsapp" value="<?php esc_attr_e( get_post_meta( $post->ID, 'whatsapp', true ) ); ?>">
471
  </div>
472
 
473
+ <div class="bpfwp-meta-input bpfwp-meta-whatsappdisplay">
474
+ <label for="bpfwp_whatsappdisplay">
475
+ <?php esc_html_e( 'Whatsapp Display Number', 'business-profile' ); ?>
476
+ </label>
477
+ <input type="tel" name="whatsappdisplay" id="bpfwp_whatsappdisplay" value="<?php esc_attr_e( get_post_meta( $post->ID, 'whatsappdisplay', true ) ); ?>">
478
+ </div>
479
+
480
+ <div class="bpfwp-meta-input bpfwp-meta-whatsapptext">
481
  <label for="bpfwp_whatsapptxt">
482
  <?php esc_html_e( 'Whatsapp Text', 'business-profile' ); ?>
483
  </label>
484
  <input type="text" name="whatsapptext" id="bpfwp_whatsapptxt" value="<?php esc_attr_e( get_post_meta( $post->ID, 'whatsapptext', true ) ); ?>">
485
  </div>
486
 
487
+ <div class="bpfwp-meta-input bpfwp-meta-fax">
488
  <label for="bpfwp_fax">
489
  <?php esc_html_e( 'Fax', 'business-profile' ); ?>
490
  </label>
867
  'cell-phone' => 'sanitize_text_field',
868
  'clickcellphone' => 'sanitize_text_field',
869
  'whatsapp' => 'sanitize_text_field',
870
+ 'whatsappdisplay' => 'sanitize_text_field',
871
  'whatsapptext' => 'sanitize_text_field',
872
  'fax' => 'sanitize_text_field',
873
  'contact_post' => 'absint',
includes/class-patterns.php CHANGED
@@ -68,7 +68,7 @@ if ( ! class_exists( 'bpfwpPatterns', false ) ) :
68
  'bpfwp-block-patterns',
69
  array(
70
  'label' => __( 'Five Star Business Profile & Schema', 'business-profile' )
71
- ),
72
  );
73
  }
74
  }
68
  'bpfwp-block-patterns',
69
  array(
70
  'label' => __( 'Five Star Business Profile & Schema', 'business-profile' )
71
+ )
72
  );
73
  }
74
  }
includes/class-settings.php CHANGED
@@ -243,6 +243,7 @@ if ( ! class_exists( 'bpfwpSettings' ) ) :
243
  case 'cell-phone' :
244
  case 'clickcellphone' :
245
  case 'whatsapp' :
 
246
  case 'whatsapptext' :
247
  case 'fax' :
248
  case 'exceptions' :
@@ -517,8 +518,8 @@ if ( ! class_exists( 'bpfwpSettings' ) ) :
517
  'id' => 'cell-phone',
518
  'title' => __( 'Cell Phone', 'business-profile' ),
519
  'args' => array(
520
- 'label_for' => 'bpfwp-settings[phone]',
521
- 'class' => 'bpfwp-phone'
522
  )
523
  )
524
  );
@@ -532,8 +533,8 @@ if ( ! class_exists( 'bpfwpSettings' ) ) :
532
  'title' => __( 'Click-to-Call Cell Phone', 'business-profile' ),
533
  'description' => __( 'Use this field to set a different number for when the cell phone number is clicked in the contact card (e.g. if you\'d like it to be just an unformatted string of numbers). If left blank, the click-to-call will use the cell phone number provided in the option above.', 'business-profile' ),
534
  'args' => array(
535
- 'label_for' => 'bpfwp-settings[clickphone]',
536
- 'class' => 'bpfwp-clickphone'
537
  )
538
  )
539
  );
@@ -545,10 +546,25 @@ if ( ! class_exists( 'bpfwpSettings' ) ) :
545
  array(
546
  'id' => 'whatsapp',
547
  'title' => __( 'Whatsapp', 'business-profile' ),
548
- 'description' => __( 'This is a full phone number in international format. Omit any zeroes, brackets, or dashes when adding the phone number in international format.<br>Examples:<br>Use: 1XXXXXXXXXX<br>Don\'t use: +001-(XXX)XXXXXXX', 'business-profile' ),
549
  'args' => array(
550
- 'label_for' => 'bpfwp-settings[phone]',
551
- 'class' => 'bpfwp-phone'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  )
553
  )
554
  );
@@ -562,8 +578,8 @@ if ( ! class_exists( 'bpfwpSettings' ) ) :
562
  'title' => __( 'Whatsapp Text', 'business-profile' ),
563
  'description' => __( 'The pre-filled message will automatically appear in the text field of a chat.', 'business-profile' ),
564
  'args' => array(
565
- 'label_for' => 'bpfwp-settings[clickphone]',
566
- 'class' => 'bpfwp-clickphone'
567
  )
568
  )
569
  );
@@ -576,8 +592,8 @@ if ( ! class_exists( 'bpfwpSettings' ) ) :
576
  'id' => 'fax',
577
  'title' => __( 'Fax', 'business-profile' ),
578
  'args' => array(
579
- 'label_for' => 'bpfwp-settings[phone]',
580
- 'class' => 'bpfwp-phone'
581
  )
582
  )
583
  );
243
  case 'cell-phone' :
244
  case 'clickcellphone' :
245
  case 'whatsapp' :
246
+ case 'whatsappdisplay' :
247
  case 'whatsapptext' :
248
  case 'fax' :
249
  case 'exceptions' :
518
  'id' => 'cell-phone',
519
  'title' => __( 'Cell Phone', 'business-profile' ),
520
  'args' => array(
521
+ 'label_for' => 'bpfwp-settings[cell-phone]',
522
+ 'class' => 'bpfwp-cell-phone'
523
  )
524
  )
525
  );
533
  'title' => __( 'Click-to-Call Cell Phone', 'business-profile' ),
534
  'description' => __( 'Use this field to set a different number for when the cell phone number is clicked in the contact card (e.g. if you\'d like it to be just an unformatted string of numbers). If left blank, the click-to-call will use the cell phone number provided in the option above.', 'business-profile' ),
535
  'args' => array(
536
+ 'label_for' => 'bpfwp-settings[clickcellphone]',
537
+ 'class' => 'bpfwp-clickcellphone'
538
  )
539
  )
540
  );
546
  array(
547
  'id' => 'whatsapp',
548
  'title' => __( 'Whatsapp', 'business-profile' ),
549
+ 'description' => __( 'This is the number that will be used to send the message. It must be a full phone number in international format. Omit any zeroes, brackets, or dashes when adding the phone number in international format.<br>Examples:<br>Use: 1XXXXXXXXXX<br>Don\'t use: +001-(XXX)XXXXXXX', 'business-profile' ),
550
  'args' => array(
551
+ 'label_for' => 'bpfwp-settings[whatsapp]',
552
+ 'class' => 'bpfwp-whatsapp'
553
+ )
554
+ )
555
+ );
556
+
557
+ $sap->add_setting(
558
+ 'bpfwp-settings',
559
+ 'bpfwp-contact',
560
+ 'text',
561
+ array(
562
+ 'id' => 'whatsappdisplay',
563
+ 'title' => __( 'Whatsapp Display Number', 'business-profile' ),
564
+ 'description' => __( 'This is the number that will display in the contact card. For the number used to actually send the message, please see the setting above this one.', 'business-profile' ),
565
+ 'args' => array(
566
+ 'label_for' => 'bpfwp-settings[whatsappdisplay]',
567
+ 'class' => 'bpfwp-whatsappdisplay'
568
  )
569
  )
570
  );
578
  'title' => __( 'Whatsapp Text', 'business-profile' ),
579
  'description' => __( 'The pre-filled message will automatically appear in the text field of a chat.', 'business-profile' ),
580
  'args' => array(
581
+ 'label_for' => 'bpfwp-settings[whatsapptext]',
582
+ 'class' => 'bpfwp-whatsapptext'
583
  )
584
  )
585
  );
592
  'id' => 'fax',
593
  'title' => __( 'Fax', 'business-profile' ),
594
  'args' => array(
595
+ 'label_for' => 'bpfwp-settings[fax]',
596
+ 'class' => 'bpfwp-fax'
597
  )
598
  )
599
  );
includes/template-functions.php CHANGED
@@ -374,11 +374,16 @@ if ( ! function_exists( 'bpwfwp_print_whatsapp_phone' ) ) {
374
 
375
  $whatsapp = bpfwp_setting( 'whatsapp', $location );
376
  $whatsapp_txt = bpfwp_setting( 'whatsapptext', $location );
 
377
 
378
  if ( empty( $whatsapp ) ) {
379
  return '';
380
  }
381
 
 
 
 
 
382
  if( !empty( $whatsapp_txt ) ) {
383
  $whatsapp_txt = '?text='.urlencode( $whatsapp_txt );
384
  }
@@ -386,7 +391,7 @@ if ( ! function_exists( 'bpwfwp_print_whatsapp_phone' ) ) {
386
  if ( bpfwp_get_display( 'show_whatsapp' ) ) : ?>
387
 
388
  <div class="bp-whatsapp">
389
- <a href="https://wa.me/<?php echo esc_attr( $whatsapp . $whatsapp_txt ); ?>"><?php echo esc_html( $whatsapp ); ?></a>
390
  </div>
391
 
392
  <?php endif;
@@ -1010,16 +1015,27 @@ if ( ! function_exists( 'bpfwp_json_ld_contact_print' ) ) {
1010
 
1011
  $return_string = '';
1012
 
1013
- if ( is_array( $json_data ) ) {
 
 
 
 
 
 
 
 
1014
 
1015
- if ( $json_key === 'specialOpeningHoursSpecification' ) { $return_string .= '"' . $json_key . '": ['; }
1016
- elseif ( $json_key and ! is_int( $json_key ) ) { $return_string .= '"' . $json_key . '": {'; }
1017
- elseif ( is_int( $json_key ) ) { $return_string .= '{'; }
1018
 
1019
- foreach ( $json_data as $key => $data ) { $return_string .= bpfwp_json_ld_contact_print( $key, $data ); }
1020
 
1021
- if ( $json_key === 'specialOpeningHoursSpecification' ) { $return_string = trim( $return_string, ',' ) . '],'; }
1022
- elseif ( $json_key or is_int( $json_key ) ) { $return_string = trim ( $return_string, ',' ) . '},'; }
 
 
 
 
1023
  }
1024
  elseif ( $json_key == 'openingHours' ) {
1025
  $return_string .= '"' . $json_key . '": ' . $json_data . ',';
@@ -1030,4 +1046,13 @@ if ( ! function_exists( 'bpfwp_json_ld_contact_print' ) ) {
1030
 
1031
  return $return_string;
1032
  }
1033
- }
 
 
 
 
 
 
 
 
 
374
 
375
  $whatsapp = bpfwp_setting( 'whatsapp', $location );
376
  $whatsapp_txt = bpfwp_setting( 'whatsapptext', $location );
377
+ $whatsapp_display = bpfwp_setting( 'whatsappdisplay', $location );
378
 
379
  if ( empty( $whatsapp ) ) {
380
  return '';
381
  }
382
 
383
+ if ( empty( $whatsapp_display ) ) {
384
+ return '';
385
+ }
386
+
387
  if( !empty( $whatsapp_txt ) ) {
388
  $whatsapp_txt = '?text='.urlencode( $whatsapp_txt );
389
  }
391
  if ( bpfwp_get_display( 'show_whatsapp' ) ) : ?>
392
 
393
  <div class="bp-whatsapp">
394
+ <a href="https://wa.me/<?php echo esc_attr( $whatsapp . $whatsapp_txt ); ?>"><?php echo esc_html( $whatsapp_display ); ?></a>
395
  </div>
396
 
397
  <?php endif;
1015
 
1016
  $return_string = '';
1017
 
1018
+ if ( is_array( $json_data ) )
1019
+ {
1020
+ $closing = '';
1021
+ if ( bpfwp_array_any( array_keys( $json_data ), 'is_int' ) ) {
1022
+ $return_string .= '"' . $json_key . '": [';
1023
+ $closing = '],';
1024
+ }
1025
+ else {
1026
+ $return_string .= empty( $json_key ) || is_int( $json_key ) ? '' : '"' . $json_key . '" : ';
1027
 
1028
+ $return_string .= '{';
1029
+ $closing = '},';
1030
+ }
1031
 
 
1032
 
1033
+ foreach ( $json_data as $key => $data ) {
1034
+ // recurse
1035
+ $return_string .= bpfwp_json_ld_contact_print( $key, $data );
1036
+ }
1037
+
1038
+ $return_string = trim( $return_string, ',' ) . $closing;
1039
  }
1040
  elseif ( $json_key == 'openingHours' ) {
1041
  $return_string .= '"' . $json_key . '": ' . $json_data . ',';
1046
 
1047
  return $return_string;
1048
  }
1049
+
1050
+ function bpfwp_array_any(array $array, callable $fn) {
1051
+ foreach ( $array as $value ) {
1052
+ if( $fn( $value ) ) {
1053
+ return true;
1054
+ }
1055
+ }
1056
+ return false;
1057
+ }
1058
+ }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URL: https://www.fivestarplugins.com/plugins/business-profile/
5
  Requires at Least: 5.3
6
  Tested Up To: 6.0
7
  Tags: business profile, seo, local seo, schema, address, google map, contact, phone, contact card, vcard, contact info, business location, business address, business map, business schema, organization schema, corporation schema, contact schema, address schema, location schema, map schema, business structured data, business microdata, address microdata, location structured data, location microdata, contact shortcode, location shortcode, address shortcode, schema shortcode, gutenberg schema, gutenberg address
8
- Stable tag: 2.2.3
9
  License: GPLv3
10
  License URI:http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -192,6 +192,11 @@ You'll find more help in the [User Guide](http://doc.themeofthecrop.com/plugins/
192
 
193
  == Changelog ==
194
 
 
 
 
 
 
195
  = 2.2.3 (2022-08-03) =
196
  - Introducing new block patterns, which can be used to integrate contact card info directly into your block-based theme templates.
197
  - Added fields for cell phone, fax and Whatsapp.
5
  Requires at Least: 5.3
6
  Tested Up To: 6.0
7
  Tags: business profile, seo, local seo, schema, address, google map, contact, phone, contact card, vcard, contact info, business location, business address, business map, business schema, organization schema, corporation schema, contact schema, address schema, location schema, map schema, business structured data, business microdata, address microdata, location structured data, location microdata, contact shortcode, location shortcode, address shortcode, schema shortcode, gutenberg schema, gutenberg address
8
+ Stable tag: 2.2.4
9
  License: GPLv3
10
  License URI:http://www.gnu.org/licenses/gpl-3.0.html
11
 
192
 
193
  == Changelog ==
194
 
195
+ = 2.2.4 (2022-08-08) =
196
+ - Added an extra option to specify a display number for the Whatsapp field, so you can display a different number in the contact card than the one that is used to send the message.
197
+ - Corrected an issue that was causing invalid schema.
198
+ - Removed the trailing comma from the newly-added instance of register_block_pattern_category, to correct an apparent conflict with proxy fcgi, as reported by one user.
199
+
200
  = 2.2.3 (2022-08-03) =
201
  - Introducing new block patterns, which can be used to integrate contact card info directly into your block-based theme templates.
202
  - Added fields for cell phone, fax and Whatsapp.