From 90904b8093a08a9e09d973f64f635e2364d2fb48 Mon Sep 17 00:00:00 2001 From: Kiran Prajapati Date: Wed, 6 Dec 2023 18:11:08 +0530 Subject: [PATCH] prevent PHP notice on empty extra fields option --- .../admin/settings/class-geodir-settings-cpt-cf-extras.php | 4 ++++ includes/custom-fields/input-functions-aui.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/admin/settings/class-geodir-settings-cpt-cf-extras.php b/includes/admin/settings/class-geodir-settings-cpt-cf-extras.php index 7b8a0206..a72a2b0b 100644 --- a/includes/admin/settings/class-geodir-settings-cpt-cf-extras.php +++ b/includes/admin/settings/class-geodir-settings-cpt-cf-extras.php @@ -395,6 +395,10 @@ public static function file_types( $output, $result_str, $cf, $field_info ) { $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? maybe_unserialize($extra_fields['gd_file_types']) : array('*'); if ( ! empty( $gd_file_types ) ) { + if ( is_scalar( $gd_file_types ) ) { + $gd_file_types = explode( ",", $gd_file_types ); + } + $gd_file_types = array_filter( $gd_file_types ); } diff --git a/includes/custom-fields/input-functions-aui.php b/includes/custom-fields/input-functions-aui.php index df23ed51..694da98c 100644 --- a/includes/custom-fields/input-functions-aui.php +++ b/includes/custom-fields/input-functions-aui.php @@ -1336,7 +1336,7 @@ function geodir_cfi_address( $html, $cf ) { $required_msg = $cf['required_msg']; $frontend_title = $cf['frontend_title']; $is_admin = $cf['for_admin_use']; - $extra_fields = stripslashes_deep(maybe_unserialize($cf['extra_fields'])); + $extra_fields = ! empty( $cf['extra_fields'] ) ? stripslashes_deep( maybe_unserialize( $cf['extra_fields'] ) ) : array(); $prefix = $name . '_'; $street2_title = '';