Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions includes/classes/class-add-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,6 @@ public static function filter_empty_meta_data( $meta_data ) {
return false;
}

if ( is_numeric( $value ) && $value == 0 ) {
return false;
}

return true;
}, ARRAY_FILTER_USE_BOTH
);
Expand Down
4 changes: 0 additions & 4 deletions includes/classes/class-submission-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,6 @@ protected static function filter_empty_meta_data( $meta_data ) {
return false;
}

if ( is_numeric( $value ) && $value == 0 ) {
return false;
}

return true;
}, ARRAY_FILTER_USE_BOTH
);
Expand Down
4 changes: 4 additions & 0 deletions includes/fields/class-directorist-number-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public function validate( $posted_data ) {
}

public function sanitize( $posted_data ) {
if ( $this->is_value_empty( $posted_data ) ) {
return '';
}

return round( (float) $this->get_value( $posted_data ), 2 );
}
}
Expand Down
4 changes: 0 additions & 4 deletions includes/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4628,10 +4628,6 @@ function directorist_filter_listing_empty_metadata( $meta_data ) {
return false;
}

if ( is_numeric( $value ) && $value == 0 ) {
return false;
}

return true;
}, ARRAY_FILTER_USE_BOTH
);
Expand Down
8 changes: 6 additions & 2 deletions includes/model/Listings.php
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,12 @@ public function parse_search_query_args() {

if ( isset( $_REQUEST['custom_field'] ) ) {
// Multi-dimensional array, sanitized inside
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$custom_fields = array_filter( wp_unslash( $_REQUEST['custom_field'] ) );
$custom_fields = array_filter(
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
wp_unslash( $_REQUEST['custom_field'] ), static function( $value ) {
return is_array( $value ) ? ! empty( $value ) : null !== $value && '' !== $value;
}
);

foreach ( $custom_fields as $key => $values ) {
$key = sanitize_text_field( $key );
Expand Down
2 changes: 1 addition & 1 deletion includes/model/SearchForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public function field_template( $field_data ) {
$field_data['lazy_load'] = false;

if ( $this->is_custom_field( $field_data ) ) {
if ( ! empty( $_REQUEST['custom_field'][$key] ) ) {
if ( isset( $_REQUEST['custom_field'][$key] ) ) {
$value = is_array( $_REQUEST['custom_field'][$key] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['custom_field'][$key] ) ) : sanitize_text_field( wp_unslash( $_REQUEST['custom_field'][$key] ) );
} else {
$value = '';
Expand Down
Loading