Business Directory Plugin - Version 5.0.1

Version Description

Download this release

Release Info

Developer businessdirectoryplugin
Plugin Icon 128x128 Business Directory Plugin
Version 5.0.1
Comparing to
See all releases

Code changes from version 5.0 to 5.0.1

README.TXT CHANGED
@@ -5,8 +5,8 @@ Tags: business directory, directory plugin, company business directory, chamber
5
  Requires at least: 4.3
6
  Requires PHP: 5.6
7
  Tested up to: 4.8.2
8
- Last Updated: 2017-Oct-24
9
- Stable tag: 5.0
10
  License: GPLv2 or later
11
 
12
  Build any kind of local directory, directory of business providers, a Yellow-Pages business directory, Yelp-like review directory and much more!
@@ -144,6 +144,14 @@ If you are having problems please visit [support forum](http://www.businessdirec
144
 
145
  == Changelog ==
146
 
 
 
 
 
 
 
 
 
147
  = Version 5.0 =
148
  * Added support for new fee plan pricing models: flat price, category-based, base + extra amount per category
149
  * Added a new Payments screen to manage all payments.
5
  Requires at least: 4.3
6
  Requires PHP: 5.6
7
  Tested up to: 4.8.2
8
+ Last Updated: 2017-Oct-25
9
+ Stable tag: 5.0.1
10
  License: GPLv2 or later
11
 
12
  Build any kind of local directory, directory of business providers, a Yellow-Pages business directory, Yelp-like review directory and much more!
144
 
145
  == Changelog ==
146
 
147
+ = Version 5.0.1 =
148
+ * Fix link generation bug in WPML integration.
149
+ * Do not disable "Choose One" option on search for single-valued selects.
150
+ * Fix Fatal error in PHP 7.1 when too few arguments are passed to one of the plugin functions.
151
+ * Prevent PHP Warning "Invalid argument supplied for foreach()" in Query Integration class.
152
+ * Fix "Fatal error: Cannot create references to elements of a temporary array expression" from PHP 5.4 to allow users to see they're on an old PHP.
153
+ * Prevent a Fatal error caused by Featured Levels 4.x during manual upgrade
154
+
155
  = Version 5.0 =
156
  * Added support for new fee plan pricing models: flat price, category-based, base + extra amount per category
157
  * Added a new Payments screen to manage all payments.
business-directory-plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Business Directory Plugin
4
  * Plugin URI: http://www.businessdirectoryplugin.com
5
  * Description: Provides the ability to maintain a free or paid business directory on your WordPress powered site.
6
- * Version: 5.0
7
  * Author: D. Rodenbaugh
8
  * Author URI: https://businessdirectoryplugin.com
9
  * Text Domain: WPBDM
3
  * Plugin Name: Business Directory Plugin
4
  * Plugin URI: http://www.businessdirectoryplugin.com
5
  * Description: Provides the ability to maintain a free or paid business directory on your WordPress powered site.
6
+ * Version: 5.0.1
7
  * Author: D. Rodenbaugh
8
  * Author URI: https://businessdirectoryplugin.com
9
  * Text Domain: WPBDM
includes/admin/class-admin.php CHANGED
@@ -151,8 +151,7 @@ to how WordPress stores the data.", 'WPBDM' )
151
  * @since 3.4.1
152
  */
153
  public function drip_pointer() {
154
- global $current_user;
155
- get_currentuserinfo();
156
 
157
  $js = '$.post( ajaxurl, { action: "wpbdp-drip_subscribe",
158
  email: $( "#wpbdp-drip-pointer-email" ).val(),
@@ -208,8 +207,7 @@ to how WordPress stores the data.", 'WPBDM' )
208
  * @since 3.4.1
209
  */
210
  public function ajax_drip_subscribe() {
211
- global $current_user;
212
- get_currentuserinfo();
213
 
214
  $res = new WPBDP_Ajax_Response();
215
  $subscribe = ( '1' == $_POST['subscribe'] ) ? true : false;
151
  * @since 3.4.1
152
  */
153
  public function drip_pointer() {
154
+ $current_user = wp_get_current_user();
 
155
 
156
  $js = '$.post( ajaxurl, { action: "wpbdp-drip_subscribe",
157
  email: $( "#wpbdp-drip-pointer-email" ).val(),
207
  * @since 3.4.1
208
  */
209
  public function ajax_drip_subscribe() {
210
+ $current_user = wp_get_current_user();
 
211
 
212
  $res = new WPBDP_Ajax_Response();
213
  $subscribe = ( '1' == $_POST['subscribe'] ) ? true : false;
includes/admin/page-debug.php CHANGED
@@ -51,7 +51,8 @@ class WPBDP_Admin_Debug_Page {
51
  $debug_info['options']['_title'] = _x( 'BD Options', 'debug-info', 'WPBDM' );
52
 
53
  $settings_api = wpbdp_settings_api();
54
- foreach ( $settings_api->get_registered_settings() as &$s ) {
 
55
  if ( in_array( $s['id'], $blacklisted ) )
56
  continue;
57
 
51
  $debug_info['options']['_title'] = _x( 'BD Options', 'debug-info', 'WPBDM' );
52
 
53
  $settings_api = wpbdp_settings_api();
54
+ $all_settings = $settings_api->get_registered_settings();
55
+ foreach ( $all_settings as $s ) {
56
  if ( in_array( $s['id'], $blacklisted ) )
57
  continue;
58
 
includes/admin/upgrades/migrations/migration-18_2.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WPBDP__Migrations__18_2 extends WPBDP__Migration {
4
+
5
+ public function migrate() {
6
+ delete_site_transient( 'wpbdp_updates' );
7
+ delete_transient( 'wpbdp_updates' );
8
+ set_site_transient( 'update_plugins', null );
9
+ }
10
+
11
+ }
includes/class-fee-plan.php CHANGED
@@ -212,7 +212,7 @@ final class WPBDP__Fee_Plan {
212
  /**
213
  * @since 5.0
214
  */
215
- public function calculate_expiration_time( $base_time ) {
216
  if ( ! $base_time )
217
  $base_time = current_time( 'timestamp' );
218
 
212
  /**
213
  * @since 5.0
214
  */
215
+ public function calculate_expiration_time( $base_time = null ) {
216
  if ( ! $base_time )
217
  $base_time = current_time( 'timestamp' );
218
 
includes/class-query-integration.php CHANGED
@@ -187,6 +187,12 @@ class WPBDP__Query_Integration {
187
  $sortbar_fields = wpbdp_sortbar_get_field_options();
188
  $sortbar = wpbdp_get_option( 'listings-sortbar-fields' );
189
 
 
 
 
 
 
 
190
  foreach ( $sortbar as $field_id) {
191
  if ( ! array_key_exists( $field_id, $sortbar_fields ) )
192
  continue;
187
  $sortbar_fields = wpbdp_sortbar_get_field_options();
188
  $sortbar = wpbdp_get_option( 'listings-sortbar-fields' );
189
 
190
+ // Using the default argument for wpbdp_get_option does not work,
191
+ // because a non-array value may already be stored in the settings array.
192
+ if ( ! is_array( $sortbar ) ) {
193
+ $sortbar = array();
194
+ }
195
+
196
  foreach ( $sortbar as $field_id) {
197
  if ( ! array_key_exists( $field_id, $sortbar_fields ) )
198
  continue;
includes/class-wpbdp.php CHANGED
@@ -19,7 +19,7 @@ final class WPBDP {
19
  }
20
 
21
  private function setup_constants() {
22
- define( 'WPBDP_VERSION', '5.0' );
23
 
24
  define( 'WPBDP_PATH', wp_normalize_path( plugin_dir_path( WPBDP_PLUGIN_FILE ) ) );
25
  define( 'WPBDP_INC', trailingslashit( WPBDP_PATH . 'includes' ) );
19
  }
20
 
21
  private function setup_constants() {
22
+ define( 'WPBDP_VERSION', '5.0.1' );
23
 
24
  define( 'WPBDP_PATH', wp_normalize_path( plugin_dir_path( WPBDP_PLUGIN_FILE ) ) );
25
  define( 'WPBDP_INC', trailingslashit( WPBDP_PATH . 'includes' ) );
includes/compatibility/class-wpml-compat.php CHANGED
@@ -96,6 +96,9 @@ class WPBDP_WPML_Compat {
96
  // page of the website. The IF below cause listing links to use / as the
97
  // base URL, while the rewrite rules use the page's URI as the base URL.
98
  // As a result, every listing link returns a 404 Not Found.
 
 
 
99
  /*if ( $trans_id = icl_object_id( wpbdp_get_page_id(), 'page', false, $lang ) ) {
100
  $real_link = get_permalink( $trans_id );
101
  $used_link = _get_page_link( $trans_id );
@@ -112,7 +115,6 @@ class WPBDP_WPML_Compat {
112
  }
113
 
114
  function correct_page_link( $link, $name = '', $arg0 = '' ) {
115
- global $sitepress;
116
  $lang = $this->get_current_language();
117
 
118
  if ( ! $lang )
@@ -127,7 +129,7 @@ class WPBDP_WPML_Compat {
127
  case 'all_listings':
128
  case 'view_listings':
129
  case 'submit_listing':
130
- $link = add_query_arg( 'lang', $lang, $link );
131
  break;
132
 
133
  default:
@@ -137,6 +139,15 @@ class WPBDP_WPML_Compat {
137
  return $link;
138
  }
139
 
 
 
 
 
 
 
 
 
 
140
 
141
  function translate_link( $link, $lang = null ) {
142
  global $sitepress;
@@ -158,11 +169,7 @@ class WPBDP_WPML_Compat {
158
 
159
  $link = str_replace( $main_link, $main_trans_link, $link );
160
 
161
- $nego_type = absint( $sitepress->get_setting( 'language_negotiation_type' ) );
162
-
163
- if ( 3 == $nego_type ) {
164
- $link = add_query_arg( 'lang', $lang, $link );
165
- }
166
  } else {
167
  $link = add_query_arg( 'lang', $lang, $link );
168
  }
96
  // page of the website. The IF below cause listing links to use / as the
97
  // base URL, while the rewrite rules use the page's URI as the base URL.
98
  // As a result, every listing link returns a 404 Not Found.
99
+ //
100
+ // UPDATE: Maybe this is related to:
101
+ // https://github.com/drodenbaugh/BusinessDirectoryPlugin/issues/3122
102
  /*if ( $trans_id = icl_object_id( wpbdp_get_page_id(), 'page', false, $lang ) ) {
103
  $real_link = get_permalink( $trans_id );
104
  $used_link = _get_page_link( $trans_id );
115
  }
116
 
117
  function correct_page_link( $link, $name = '', $arg0 = '' ) {
 
118
  $lang = $this->get_current_language();
119
 
120
  if ( ! $lang )
129
  case 'all_listings':
130
  case 'view_listings':
131
  case 'submit_listing':
132
+ $link = $this->maybe_add_lang_query_arg( $link, $lang );
133
  break;
134
 
135
  default:
139
  return $link;
140
  }
141
 
142
+ private function maybe_add_lang_query_arg( $link, $lang ) {
143
+ $negotionation_type = intval( $this->wpml->get_setting( 'language_negotiation_type' ) );
144
+
145
+ if ( 3 !== $negotionation_type ) {
146
+ return $link;
147
+ }
148
+
149
+ return add_query_arg( 'lang', $lang, $link );
150
+ }
151
 
152
  function translate_link( $link, $lang = null ) {
153
  global $sitepress;
169
 
170
  $link = str_replace( $main_link, $main_trans_link, $link );
171
 
172
+ $link = $this->maybe_add_lang_query_arg( $link, $lang );
 
 
 
 
173
  } else {
174
  $link = add_query_arg( 'lang', $lang, $link );
175
  }
includes/compatibility/deprecated.php CHANGED
@@ -279,3 +279,7 @@ function wpbdp_categories_list($parent=0, $hierarchical=true) {
279
  function wpbdp_has_module( $module ) {
280
  return wpbdp()->modules->is_loaded( $module );
281
  }
 
 
 
 
279
  function wpbdp_has_module( $module ) {
280
  return wpbdp()->modules->is_loaded( $module );
281
  }
282
+
283
+ function wpbdp_listing_upgrades_api() {
284
+ return new WPBDP_NoopObject();
285
+ }
includes/fields/class-fieldtypes-select.php CHANGED
@@ -99,7 +99,7 @@ class WPBDP_FieldTypes_Select extends WPBDP_Form_Field_Type {
99
  }
100
  }
101
 
102
- if ( 'search' == $context ) {
103
  // Disable "Choose Terms".
104
  $html = preg_replace( "/\\<option(.*)value=('|\")-1('|\")(.*)\\>/uiU",
105
  "<option value=\"-1\" disabled=\"disabled\" $1 $4>",
99
  }
100
  }
101
 
102
+ if ( 'search' == $context && $this->is_multiple() ) {
103
  // Disable "Choose Terms".
104
  $html = preg_replace( "/\\<option(.*)value=('|\")-1('|\")(.*)\\>/uiU",
105
  "<option value=\"-1\" disabled=\"disabled\" $1 $4>",
includes/installer.php CHANGED
@@ -4,7 +4,7 @@ require_once ( WPBDP_PATH . 'includes/admin/upgrades/class-migration.php' );
4
 
5
  class WPBDP_Installer {
6
 
7
- const DB_VERSION = '18.1';
8
 
9
  private $installed_version = null;
10
 
4
 
5
  class WPBDP_Installer {
6
 
7
+ const DB_VERSION = '18.2';
8
 
9
  private $installed_version = null;
10
 
includes/licensing.php CHANGED
@@ -598,7 +598,9 @@ class WPBDP_Licensing {
598
  }
599
  }
600
 
601
- public function maybe_check_for_updates() {
 
 
602
  if ( ! $this->items ) {
603
  return;
604
  }
@@ -611,14 +613,18 @@ class WPBDP_Licensing {
611
  $this->updates = get_transient( 'wpbdp_updates' );
612
  $needs_refresh = false;
613
 
614
- if ( ! is_array( $this->updates ) ) {
615
  $needs_refresh = true;
616
  } else {
617
- foreach ( $this->items as $item ) {
618
- if ( ! isset( $this->updates[ $item['item_type'] . '-' . $item['id'] ] ) ) {
619
- // wpbdp_debug_e( $item, $this->updates );
620
- $needs_refresh = true;
621
- break;
 
 
 
 
622
  }
623
  }
624
  }
@@ -686,7 +692,7 @@ class WPBDP_Licensing {
686
  return $transient;
687
  }
688
 
689
- $this->maybe_check_for_updates();
690
 
691
  if ( ! $this->updates ) {
692
  return $transient;
@@ -767,6 +773,48 @@ class WPBDP_Licensing {
767
  * @deprecated since 5.0.
768
  */
769
  function wpbdp_licensing_register_module( $name, $file_, $version ) {
 
 
 
 
 
 
770
  wpbdp_deprecation_warning( sprintf( _x( '"%s" version %s is not compatible with Business Directory Plugin 5.0. Please update this module to the latest available version.', 'deprecation', 'WPBDM' ), '<strong>' . esc_html( $name ) . '</strong>', '<strong>' . $version . '</strong>' ) );
 
 
771
  return false;
772
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
598
  }
599
  }
600
 
601
+ public function maybe_check_for_updates( $force_refresh = false ) {
602
+ do_action( 'wpbdp_licensing_before_updates_check' );
603
+
604
  if ( ! $this->items ) {
605
  return;
606
  }
613
  $this->updates = get_transient( 'wpbdp_updates' );
614
  $needs_refresh = false;
615
 
616
+ if ( $force_refresh ) {
617
  $needs_refresh = true;
618
  } else {
619
+ if ( ! is_array( $this->updates ) ) {
620
+ $needs_refresh = true;
621
+ } else {
622
+ foreach ( $this->items as $item ) {
623
+ if ( ! isset( $this->updates[ $item['item_type'] . '-' . $item['id'] ] ) ) {
624
+ // wpbdp_debug_e( $item, $this->updates );
625
+ $needs_refresh = true;
626
+ break;
627
+ }
628
  }
629
  }
630
  }
692
  return $transient;
693
  }
694
 
695
+ $this->maybe_check_for_updates( true );
696
 
697
  if ( ! $this->updates ) {
698
  return $transient;
773
  * @deprecated since 5.0.
774
  */
775
  function wpbdp_licensing_register_module( $name, $file_, $version ) {
776
+ global $wpbdp_compat_modules_registry;
777
+
778
+ if ( ! isset( $wpbdp_compat_modules_registry ) ) {
779
+ $wpbdp_compat_modules_registry = array();
780
+ }
781
+
782
  wpbdp_deprecation_warning( sprintf( _x( '"%s" version %s is not compatible with Business Directory Plugin 5.0. Please update this module to the latest available version.', 'deprecation', 'WPBDM' ), '<strong>' . esc_html( $name ) . '</strong>', '<strong>' . $version . '</strong>' ) );
783
+ $wpbdp_compat_modules_registry[] = array( $name, $file_, $version );
784
+
785
  return false;
786
  }
787
+
788
+ /**
789
+ * Added for compatibility with < 5.x modules.
790
+ * @since 5.0.1
791
+ */
792
+ function wpbdp_compat_register_old_modules() {
793
+ global $wpbdp_compat_modules_registry;
794
+
795
+ if ( ! isset( $wpbdp_compat_modules_registry ) || empty( $wpbdp_compat_modules_registry ) ) {
796
+ $wpbdp_compat_modules_registry = array();
797
+ }
798
+
799
+ // Gateways are a special case since they are registered in 'wpbdp_register_gateways'.
800
+ if ( has_filter( 'wpbdp_register_gateways' ) ) {
801
+ if ( function_exists( 'wp_get_active_and_valid_plugins' ) ) {
802
+ $plugins = wp_get_active_and_valid_plugins();
803
+
804
+ foreach ( $plugins as $plugin_file ) {
805
+ $plugin_file_basename = basename( $plugin_file );
806
+
807
+ if ( 'business-directory-paypal.php' == $plugin_file_basename ) {
808
+ $wpbdp_compat_modules_registry[] = array( 'PayPal Gateway Module', $plugin_file, '3.5.6' );
809
+ } else if ( 'business-directory-twocheckout.php' == $plugin_file_basename ) {
810
+ $wpbdp_compat_modules_registry[] = array( '2Checkout Gateway Module', $plugin_file, '3.6.2' );
811
+ }
812
+ }
813
+ }
814
+ }
815
+
816
+ foreach ( $wpbdp_compat_modules_registry as $m ) {
817
+ wpbdp()->licensing->add_item( array( 'item_type' => 'module', 'name' => $m[0], 'file' => $m[1], 'version' => $m[2] ) );
818
+ }
819
+ }
820
+ add_action( 'wpbdp_licensing_before_updates_check', 'wpbdp_compat_register_old_modules' );