diff --git a/admin/core/um-admin-actions-fields.php b/admin/core/um-admin-actions-fields.php index e6dcaedd..7d9faf4e 100644 --- a/admin/core/um-admin-actions-fields.php +++ b/admin/core/um-admin-actions-fields.php @@ -27,6 +27,7 @@ $save = ''; $save[ $_metakey ]['roles'] = ''; + $save[ $_metakey ]['disabled_weekdays'] = ''; $save[ $_metakey ]['icon'] = ''; foreach( $array['post'] as $key => $val){ diff --git a/admin/core/um-admin-actions.php b/admin/core/um-admin-actions.php new file mode 100644 index 00000000..56ac5378 --- /dev/null +++ b/admin/core/um-admin-actions.php @@ -0,0 +1,13 @@ +uninstall->remove_um(); + + } \ No newline at end of file diff --git a/admin/core/um-admin-metabox.php b/admin/core/um-admin-metabox.php index 61b24f94..6fac8fcb 100644 --- a/admin/core/um-admin-metabox.php +++ b/admin/core/um-admin-metabox.php @@ -826,7 +826,12 @@ class UM_Admin_Metabox { ?>

- +

diff --git a/admin/um-admin-init.php b/admin/um-admin-init.php index 4e725e2c..3e322d2a 100644 --- a/admin/um-admin-init.php +++ b/admin/um-admin-init.php @@ -39,6 +39,7 @@ class UM_Admin_API { require_once um_path . 'admin/core/um-admin-actions-modal.php'; require_once um_path . 'admin/core/um-admin-actions-fields.php'; require_once um_path . 'admin/core/um-admin-actions-ajax.php'; + require_once um_path . 'admin/core/um-admin-actions.php'; require_once um_path . 'admin/core/um-admin-filters-fields.php'; @@ -56,11 +57,12 @@ class UM_Admin_API { if ( is_admin() && current_user_can('manage_options') && - isset($_REQUEST['um_action']) && - $_REQUEST['um_action'] == 'uninstall_ultimatemember' - ) + isset($_REQUEST['um_adm_action']) && + $_REQUEST['um_adm_action'] != '' + ) { - $ultimatemember->uninstall->remove_um(); + do_action("um_admin_do_action__", $_REQUEST['um_adm_action'] ); + do_action("um_admin_do_action__{$_REQUEST['um_adm_action']}", $_REQUEST['um_adm_action'] ); } } diff --git a/assets/js/um-scripts.js b/assets/js/um-scripts.js index 7a279621..5ce4a02b 100644 --- a/assets/js/um-scripts.js +++ b/assets/js/um-scripts.js @@ -80,12 +80,33 @@ jQuery(document).ready(function() { }); /* datepicker */ - jQuery('.um-datepicker').pickadate({ - min: [1900,1,1], - max: true, - selectYears: 100, - formatSubmit: 'yyyy/mm/dd', - hiddenSuffix: '__true' + jQuery('.um-datepicker').each(function(){ + elem = jQuery(this); + + if ( elem.attr('data-years_x') == 'past' ) {var max = true;} + if ( elem.attr('data-years_x') == 'equal' ) {var max = false;} + if ( elem.attr('data-years_x') == 'future' ) {var min = true;var max = '';} + + if ( elem.attr('data-disabled_weekdays') != '' ) { + var disable = JSON.parse( elem.attr('data-disabled_weekdays') ); + } else { + var disable = false; + } + + if ( elem.attr('data-range') == 'date_range' ) { + var min = new Date( elem.attr('data-date_min') ); + var max = new Date( elem.attr('data-date_max') ); + } + + elem.pickadate({ + selectYears: elem.attr('data-years'), + min: min, + max: max, + disable: disable, + format: elem.attr('data-format'), + formatSubmit: 'yyyy/mm/dd', + hiddenName: true, + }); }); /* timepicker */ diff --git a/core/um-builtin.php b/core/um-builtin.php index c556c1d3..a58b37f0 100644 --- a/core/um-builtin.php +++ b/core/um-builtin.php @@ -548,7 +548,7 @@ class UM_Builtin { 'pretty_format' => 1, 'years' => 115, 'years_x' => 'past', - 'icon' => 'um-icon-calendar-7' + 'icon' => 'um-icon-calendar-2' ), 'gender' => array( diff --git a/core/um-datetime.php b/core/um-datetime.php index 938f8ca1..1369b739 100644 --- a/core/um-datetime.php +++ b/core/um-datetime.php @@ -13,6 +13,22 @@ class UM_DateTime { return current_time( $format ); } + /*** + *** @Get age + ***/ + function get_age($then) { + $then_ts = strtotime($then); + $then_year = date('Y', $then_ts); + $age = date('Y') - $then_year; + if(strtotime('+' . $age . ' years', $then_ts) > time()) $age--; + if ( $age == 1 ) + return sprintf(__('%s year old','ultimatemember'), $age ); + if ( $age > 1 ) + return sprintf(__('%s years old','ultimatemember'), $age ); + if ( $age == 0 ) + return __('Less than 1 year old','ultimatemember'); + } + /*** *** @Reformat dates ***/ diff --git a/core/um-fields.php b/core/um-fields.php index 5938e1dd..4d418339 100644 --- a/core/um-fields.php +++ b/core/um-fields.php @@ -245,7 +245,13 @@ class UM_Fields { if ( isset($data['icon']) && $data['icon'] != '' && isset( $this->field_icons ) && ( $this->field_icons == 'label' || $this->viewing == true ) ) { $output .= '
'; } - + + if ( $this->viewing == true ) { + $label = apply_filters("um_view_label_{$key}", $label ); + } else { + $label = apply_filters("um_edit_label_{$key}", $label ); + } + $output .= ''; if ( isset( $data['help'] ) && !empty( $data['help'] ) && $this->viewing == false ) { @@ -545,6 +551,42 @@ class UM_Fields { $array['input'] = 'text'; + if ( !isset( $array['format'] ) ) $array['format'] = 'j M Y'; + + switch( $array['format'] ) { + case 'j M Y': + $js_format = 'd mmm yyyy'; + break; + case 'j F Y': + $js_format = 'd mmmm yyyy'; + break; + case 'M j Y': + $js_format = 'mmm d yyyy'; + break; + case 'F j Y': + $js_format = 'mmmm d yyyy'; + break; + } + + $array['js_format'] = $js_format; + + if ( !isset( $array['range'] ) ) $array['range'] = 'years'; + if ( !isset( $array['years'] ) ) $array['years'] = 100; + if ( !isset( $array['years_x'] ) ) $array['years_x'] = 'past'; + if ( !isset( $array['disabled_weekdays'] ) ) $array['disabled_weekdays'] = ''; + + if ( !empty( $array['disabled_weekdays'] ) ) { + $array['disabled_weekdays'] = '[' . implode(',',$array['disabled_weekdays']) . ']'; + } + + if ( $array['range'] == 'date_range' ) { + $array['date_min'] = str_replace('/',',',$array['range_start']); + $array['date_max'] = str_replace('/',',',$array['range_end']); + } + + if ( !isset( $array['date_min'] ) ) $array['date_min'] = ''; + if ( !isset( $array['date_max'] ) ) $array['date_max'] = ''; + if (!isset($array['autocomplete'])) $array['autocomplete'] = 'on'; break; @@ -908,7 +950,7 @@ class UM_Fields { } - $output .= ' + $output .= ' '; diff --git a/core/um-filters-fields.php b/core/um-filters-fields.php index 268c8990..9d612dca 100644 --- a/core/um-filters-fields.php +++ b/core/um-filters-fields.php @@ -1,5 +1,30 @@ datetime->get_age( $value ); + } else { + $value = $ultimatemember->datetime->format( $value, $data['format'] ); + } + + return $value; + } + /*** *** @Images ***/ @@ -45,7 +70,7 @@ } /*** - *** @some required changes before value is shown + *** @Global ***/ add_filter('um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 2); function um_profile_field_filter_hook__( $value, $data ) { diff --git a/core/um-short-functions.php b/core/um-short-functions.php index 2aa682cb..48e5570d 100644 --- a/core/um-short-functions.php +++ b/core/um-short-functions.php @@ -492,18 +492,25 @@ function um_get_avatar_uri( $image, $attrs ) { global $ultimatemember; $uri = false; + $find = false; if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $attrs. '.jpg' ) ) { + $uri = um_user_uploads_uri() . 'profile_photo-'.$attrs.'.jpg?' . time(); + } else { $sizes = um_get_option('photo_thumb_sizes'); - $find = um_closest_num( $sizes, $attrs ); + if ( is_array( $sizes ) ) $find = um_closest_num( $sizes, $attrs ); if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $find. '.jpg' ) ) { + $uri = um_user_uploads_uri() . 'profile_photo-'.$find.'.jpg?' . time(); + } else if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo.jpg' ) ) { + $uri = um_user_uploads_uri() . 'profile_photo.jpg?' . time(); + } } diff --git a/core/um-validation.php b/core/um-validation.php index 9dc89089..1001cb1b 100644 --- a/core/um-validation.php +++ b/core/um-validation.php @@ -152,8 +152,8 @@ class UM_Validation { /*** *** @To validate given date input ***/ - function validate_date( $date, $format='YYYY/MM/DD' ) { - if ( strlen( $date ) != strlen($format) ) return false; + function validate_date( $date, $format='YYYY/MM/D' ) { + if ( strlen( $date ) < strlen($format) ) return false; if ( $date[4] != '/' ) return false; if ( $date[7] != '/' ) return false; if ( false === strtotime($date) ) return false; diff --git a/index.php b/index.php index 304a3051..bb3ed7bc 100644 --- a/index.php +++ b/index.php @@ -55,7 +55,7 @@ Author URI: http://ultimatemember.com/ $links = $more_links + $links; - $links[] = '' . __( 'Uninstall','ultimatemember' ) . ''; + $links[] = '' . __( 'Uninstall','ultimatemember' ) . ''; return $links;