From fca6de05d67a0451ccffda798bda1c7831228aae Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Tue, 22 Oct 2019 12:24:36 +0300 Subject: [PATCH] - added custom date format ability for datepicker field; --- includes/admin/core/class-admin-metabox.php | 10 +++++++ includes/core/class-builtin.php | 30 ++++++++++----------- includes/core/um-filters-fields.php | 3 ++- readme.txt | 5 ++++ 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index fed3a7ce..d3aa7ba3 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -1736,6 +1736,16 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { } break; + case '_format_custom': + ?> + +

+ +

+ + diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index 326c3432..528d3480 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -398,27 +398,27 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { ), 'date' => array( - 'name' => 'Date Picker', - 'col1' => array('_title','_metakey','_help','_default','_range','_years','_years_x','_range_start','_range_end','_visibility'), - 'col2' => array('_label','_placeholder','_public','_roles','_format','_pretty_format','_disabled_weekdays'), - 'col3' => array('_required','_editable','_icon'), - 'validate' => array( - '_title' => array( - 'mode' => 'required', + 'name' => 'Date Picker', + 'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ), + 'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ), + 'col3' => array( '_required', '_editable', '_icon' ), + 'validate' => array( + '_title' => array( + 'mode' => 'required', 'error' => __( 'You must provide a title', 'ultimate-member' ) ), - '_metakey' => array( - 'mode' => 'unique', + '_metakey' => array( + 'mode' => 'unique', ), - '_years' => array( - 'mode' => 'numeric', + '_years' => array( + 'mode' => 'numeric', 'error' => __( 'Number of years is not valid', 'ultimate-member' ) ), - '_range_start' => array( - 'mode' => 'range-start', + '_range_start' => array( + 'mode' => 'range-start', ), - '_range_end' => array( - 'mode' => 'range-end', + '_range_end' => array( + 'mode' => 'range-end', ), ) ), diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index 274ea830..b114bc87 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -227,7 +227,8 @@ function um_profile_field_filter_hook__date( $value, $data ) { if ( isset( $data['pretty_format'] ) && $data['pretty_format'] == 1 ) { $value = UM()->datetime()->get_age( $value ); } else { - $value = date_i18n( $data['format'], strtotime( $value ) ); + $format = empty( $data['format_custom'] ) ? $data['format'] : $data['format_custom']; + $value = date_i18n( $format, strtotime( $value ) ); } return $value; diff --git a/readme.txt b/readme.txt index 65ce6e22..376b9fbf 100644 --- a/readme.txt +++ b/readme.txt @@ -154,6 +154,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat - Additional parameter 'user_id' to action hook 'um_user_after_updating_profile' - Added ability to set profile/cover image sizes from Ultimate Member -> General -> Uploads settings or Original size - Added ability edit cover photo HTML (e.g. for adding some HTML attributes. See how add srcset attribute based on all generated cover sizes [here](https://docs.ultimatemember.com/article/1519-change-cover-photo-html)) + - Added custom date format for Date Picker field * Bugfixes: - Optimized usermeta for Account submit security @@ -168,6 +169,10 @@ The plugin works with popular caching plugins by automatically excluding Ultimat (it makes the same for {site_url}/user and {site_url}/user/{user_slug} ) - Fixed security issue on registration form submission when username or email have conditional logic - Fixed RTL styles issues on user profile and account pages + - Fixed upload profile/cover photos at the profile page, don't apply until the crop finished + - Fixed alphabetical field validation for cyrillic and not UTF-8 symbols + - Localized um-raty.js library + = 2.0.56: August 21, 2019 =