diff --git a/inc/class-opalestate-html.php b/inc/class-opalestate-html.php
index 613511af..5f1da4da 100755
--- a/inc/class-opalestate-html.php
+++ b/inc/class-opalestate-html.php
@@ -364,12 +364,7 @@ class Opalestate_HTML_Elements {
}
public function render_form( $fields ) {
- static $id_counter = 0;
- if ( function_exists( 'wp_unique_id' ) ) {
- $form_id = wp_unique_id( 'opalestate-form-' );
- } else {
- $form_id = 'opalestate-form-' . (string) ++$id_counter;
- }
+ $form_id = opalestate_unique_id( 'opalestate-form-' );
$output = '';
$this->form_id = $form_id;
diff --git a/inc/mixes-functions.php b/inc/mixes-functions.php
index 54940a46..478b90cf 100755
--- a/inc/mixes-functions.php
+++ b/inc/mixes-functions.php
@@ -1306,3 +1306,26 @@ function opalestate_clean( $var ) {
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
}
}
+
+/**
+ * Get unique ID.
+ *
+ * This is a PHP implementation of Underscore's uniqueId method. A static variable
+ * contains an integer that is incremented with each call. This number is returned
+ * with the optional prefix. As such the returned value is not universally unique,
+ * but it is unique across the life of the PHP process.
+ *
+ * @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead.
+ *
+ * @staticvar int $id_counter
+ *
+ * @param string $prefix Prefix for the returned ID.
+ * @return string Unique ID.
+ */
+function opalestate_unique_id( $prefix = '' ) {
+ static $id_counter = 0;
+ if ( function_exists( 'wp_unique_id' ) ) {
+ return wp_unique_id( $prefix );
+ }
+ return $prefix . (string) ++$id_counter;
+}
diff --git a/templates/search-box/collapse-advanced.php b/templates/search-box/collapse-advanced.php
index cd5a1393..d8df51c5 100755
--- a/templates/search-box/collapse-advanced.php
+++ b/templates/search-box/collapse-advanced.php
@@ -7,7 +7,7 @@
defined( 'ABSPATH' ) || exit;
-$unique_id = esc_attr( wp_unique_id() );
+$unique_id = esc_attr( opalestate_unique_id() );
$GLOBALS['group-info-column'] = 3;
if ( isset( $nobutton ) && $nobutton ) {
diff --git a/templates/search-box/collapse-city.php b/templates/search-box/collapse-city.php
index 21adae08..e0019ca2 100755
--- a/templates/search-box/collapse-city.php
+++ b/templates/search-box/collapse-city.php
@@ -7,7 +7,7 @@
defined( 'ABSPATH' ) || exit;
-$unique_id = esc_attr( wp_unique_id() );
+$unique_id = esc_attr( opalestate_unique_id() );
$GLOBALS['group-info-column'] = 4;
if ( isset( $nobutton ) && $nobutton ) {
diff --git a/templates/search-box/fields/more-options.php b/templates/search-box/fields/more-options.php
index c297e8df..00845dc8 100755
--- a/templates/search-box/fields/more-options.php
+++ b/templates/search-box/fields/more-options.php
@@ -7,7 +7,7 @@
defined( 'ABSPATH' ) || exit;
-$unique_id = esc_attr( wp_unique_id() );
+$unique_id = esc_attr( opalestate_unique_id() );
$amenities = Opalestate_Taxonomy_Amenities::get_list();
if ( ! $amenities ) {