diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 087ee59e..57c9ab73 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -1,4 +1,4 @@ -name: JobBoardWP GitHub Actions +name: Ultimate Member - Checking Code quality through PHPCS + WPCS on: push: diff --git a/assets/js/um-gdpr.js b/assets/js/um-gdpr.js index 31c0fde9..f06d5907 100644 --- a/assets/js/um-gdpr.js +++ b/assets/js/um-gdpr.js @@ -1,22 +1,22 @@ -(function( $ ) { +(function ( $ ) { 'use strict'; - $(document).on('click', "a.um-toggle-gdpr" ,function() { - - var me = jQuery(this); + $( document ).on( 'click', 'a.um-toggle-gdpr', function ( e ) { + let $a = jQuery( e.currentTarget ); + let $area = $a.closest( '.um-field-area' ); + let $content = $area.find( '.um-gdpr-content' ); - $( ".um-gdpr-content" ).toggle( "fast", function() { - if( $( ".um-gdpr-content" ).is(':visible') ){ - me.text( me.data('toggle-hide') ); - } - - if( $( ".um-gdpr-content" ).is(':hidden') ){ - me.text( me.data('toggle-show') ); - } - - }); - - }); + if ( $content.is( ':visible' ) ) { + $area.find( 'a.um-toggle-gdpr' ).text( $a.data( 'toggle-show' ) ); + $content.hide().find( 'a.um-toggle-gdpr' ).remove(); + if ( $a.length ) { + $a.get( 0 ).scrollIntoView(); + } + } else { + $area.find( 'a.um-toggle-gdpr' ).text( $a.data( 'toggle-hide' ) ); + $content.show().prepend( $a.clone() ); + } + } ); })( jQuery ); diff --git a/assets/js/um-gdpr.min.js b/assets/js/um-gdpr.min.js index f3e35c42..d862d028 100644 --- a/assets/js/um-gdpr.min.js +++ b/assets/js/um-gdpr.min.js @@ -1 +1 @@ -!function(e){"use strict";e(document).on("click","a.um-toggle-gdpr",function(){var t=jQuery(this);e(".um-gdpr-content").toggle("fast",function(){e(".um-gdpr-content").is(":visible")&&t.text(t.data("toggle-hide")),e(".um-gdpr-content").is(":hidden")&&t.text(t.data("toggle-show"))})})}(jQuery); \ No newline at end of file +!function(){"use strict";jQuery(document).on("click","a.um-toggle-gdpr",function(e){let t=jQuery(e.currentTarget),g=t.closest(".um-field-area"),o=g.find(".um-gdpr-content");o.is(":visible")?(g.find("a.um-toggle-gdpr").text(t.data("toggle-show")),o.hide().find("a.um-toggle-gdpr").remove(),t.length&&t.get(0).scrollIntoView()):(g.find("a.um-toggle-gdpr").text(t.data("toggle-hide")),o.show().prepend(t.clone()))})}(); \ No newline at end of file diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index d503b5cf..c6cf0c80 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -72,6 +72,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) ); add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) ); + add_action( 'um_admin_do_action__user_status_cache', array( &$this, 'user_status_cache' ) ); add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) ); add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) ); add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) ); @@ -1673,8 +1674,53 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" ); - $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) ); - exit( wp_redirect( $url ) ); + $url = add_query_arg( + array( + 'page' => 'ultimatemember', + 'update' => 'cleared_cache', + ), + admin_url( 'admin.php' ) + ); + wp_redirect( $url ); + exit; + } + + + /** + * Clear all users statuses count cache + * + * @param $action + */ + function user_status_cache( $action ) { + if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) { + die(); + } + + $statuses = array( + 'approved', + 'awaiting_admin_review', + 'awaiting_email_confirmation', + 'inactive', + 'rejected', + 'pending_dot', // not real status key, just for the transient + 'unassigned', // not real status key, just for the transient + ); + + foreach ( $statuses as $status ) { + delete_transient( "um_count_users_{$status}" ); + } + + do_action( 'um_flush_user_status_cache' ); + + $url = add_query_arg( + array( + 'page' => 'ultimatemember', + 'update' => 'cleared_status_cache', + ), + admin_url( 'admin.php' ) + ); + wp_redirect( $url ); + exit; } diff --git a/includes/admin/core/class-admin-menu.php b/includes/admin/core/class-admin-menu.php index 26c07eb3..7ec8b88c 100644 --- a/includes/admin/core/class-admin-menu.php +++ b/includes/admin/core/class-admin-menu.php @@ -121,7 +121,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { return; } - $count = UM()->user()->get_pending_users_count(); + $count = UM()->query()->get_pending_users_count(); if ( is_array( $menu ) ) { foreach ( $menu as $key => $menu_item ) { if ( 0 === strpos( $menu_item[0], _x( 'Users', 'Admin menu name' ) ) ) { diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index 7b6e98ee..5bdc533e 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -440,6 +440,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { $messages[0]['content'] = __( 'Your user cache is now removed.', 'ultimate-member' ); break; + case 'cleared_status_cache': + $messages[0]['content'] = __( 'Your user statuses cache is now removed.', 'ultimate-member' ); + break; + case 'got_updates': $messages[0]['content'] = __( 'You have the latest updates.', 'ultimate-member' ); break; @@ -528,13 +532,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { continue; if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ) { - $arr_inactive_license_keys[ ] = $license->item_name; + $arr_inactive_license_keys[] = $license->item_name; } $invalid_license++; } - if ( ! empty( $arr_inactive_license_keys ) ) { + if ( ! empty( $arr_inactive_license_keys ) ) { $this->add_notice( 'license_key', array( 'class' => 'error', 'message' => '

' . sprintf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on www.ultimatemember.com.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, UM()->store_url ) . '

', diff --git a/includes/admin/core/class-admin-users.php b/includes/admin/core/class-admin-users.php index b7a0d2a1..ee9eff56 100644 --- a/includes/admin/core/class-admin-users.php +++ b/includes/admin/core/class-admin-users.php @@ -411,7 +411,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { 'rejected' => __( 'Rejected', 'ultimate-member' ), ); - UM()->query()->count_users_by_status( 'unassigned' ); + // set default statuses if not already done + UM()->setup()->set_default_user_status(); foreach ( $status as $k => $v ) { if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) { diff --git a/includes/admin/core/packages/2.5.0/functions.php b/includes/admin/core/packages/2.5.0/functions.php new file mode 100644 index 00000000..2eece725 --- /dev/null +++ b/includes/admin/core/packages/2.5.0/functions.php @@ -0,0 +1,44 @@ +admin()->check_ajax_nonce(); + + um_maybe_unset_time_limit(); + + $forms_query = new \WP_Query; + $forms = $forms_query->query( array( + 'post_type' => 'um_form', + 'posts_per_page' => -1, + 'fields' => 'ids', + ) ); + + foreach ( $forms as $form_id ) { + $forms_fields = get_post_meta( $form_id, '_um_custom_fields', true ); + if ( ! is_array( $forms_fields ) ) { + continue; + } + + $need_update = false; + foreach ( $forms_fields as $key => &$field ) { + if ( in_array( $key, array( 'phone_number', 'mobile_number' ), true ) ) { + $field['type'] = 'tel'; + $need_update = true; + } + } + + if ( $need_update ) { + update_post_meta( $form_id, '_um_custom_fields', $forms_fields ); + } + } + + // remove cached option with users count, don't create separate AJAX upgrade for that + delete_option( 'um_cached_users_queue' ); + + // delete temporarily option for fields upgrade + update_option( 'um_last_version_upgrade', '2.5.0' ); + + wp_send_json_success( array( 'message' => __( 'Phone Number and Mobile Number fields have been successfully updated.', 'ultimate-member' ) ) ); +} diff --git a/includes/admin/core/packages/2.5.0/hooks.php b/includes/admin/core/packages/2.5.0/hooks.php new file mode 100644 index 00000000..341848e3 --- /dev/null +++ b/includes/admin/core/packages/2.5.0/hooks.php @@ -0,0 +1,5 @@ + 'phone_fields250', +); diff --git a/includes/admin/core/packages/2.5.0/init.php b/includes/admin/core/packages/2.5.0/init.php new file mode 100644 index 00000000..b729b357 --- /dev/null +++ b/includes/admin/core/packages/2.5.0/init.php @@ -0,0 +1,30 @@ + + + + diff --git a/includes/admin/templates/dashboard/cache.php b/includes/admin/templates/dashboard/cache.php index cd2e44f1..364417ac 100644 --- a/includes/admin/templates/dashboard/cache.php +++ b/includes/admin/templates/dashboard/cache.php @@ -1,5 +1,6 @@ -get_var( "SELECT COUNT( option_id ) FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" -); ?> +); +?>

+

- + -

\ No newline at end of file + + + +

diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index c3bc14fe..8a507fe0 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -245,6 +245,22 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { ) ), + 'tel' => array( + 'name' => __( 'Telephone Box', 'ultimate-member' ), + 'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'), + 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'), + 'col3' => array('_required','_editable','_icon'), + 'validate' => array( + '_title' => array( + 'mode' => 'required', + 'error' => __('You must provide a title','ultimate-member'), + ), + '_metakey' => array( + 'mode' => 'unique', + ), + ) + ), + 'number' => array( 'name' => __('Number','ultimate-member'), 'col1' => array('_title','_metakey','_help','_default','_min','_visibility'), @@ -1133,7 +1149,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { 'phone_number' => array( 'title' => __('Phone Number','ultimate-member'), 'metakey' => 'phone_number', - 'type' => 'text', + 'type' => 'tel', 'label' => __('Phone Number','ultimate-member'), 'required' => 0, 'public' => 1, @@ -1145,7 +1161,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { 'mobile_number' => array( 'title' => __('Mobile Number','ultimate-member'), 'metakey' => 'mobile_number', - 'type' => 'text', + 'type' => 'tel', 'label' => __('Mobile Number','ultimate-member'), 'required' => 0, 'public' => 1, diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 7d9b1ffe..f31a17f8 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -1579,6 +1579,12 @@ if ( ! class_exists( 'um\core\Fields' ) ) { break; + case 'tel': + + $array['input'] = 'tel'; + + break; + case 'password': $array['input'] = 'password'; @@ -2324,6 +2330,43 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $output .= ''; break; + /* Tel */ + case 'tel': + + $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>'; + + if ( isset( $data['label'] ) ) { + $output .= $this->field_label( $label, $key, $data ); + } + + $output .= '
'; + + if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) { + + $output .= '
'; + + } + + $field_name = $key . UM()->form()->form_suffix; + $field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) ); + + $output .= ' + +
'; + + if ( ! empty( $disabled ) ) { + $output .= $this->disabled_hidden_field( $field_name, $field_value ); + } + + if ( $this->is_error( $key ) ) { + $output .= $this->field_error( $this->show_error( $key ) ); + }else if ( $this->is_notice( $key ) ) { + $output .= $this->field_notice( $this->show_notice( $key ) ); + } + + $output .= '
'; + break; + /* Number */ case 'number': diff --git a/includes/core/class-member-directory.php b/includes/core/class-member-directory.php index 752018f5..664f9d15 100644 --- a/includes/core/class-member-directory.php +++ b/includes/core/class-member-directory.php @@ -684,7 +684,13 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { $attrs['options'] = apply_filters( 'um_member_directory_filter_select_options_sorted', $attrs['options'], $attrs ); - $label = isset( $attrs['label'] ) ? $attrs['label'] : ''; ?> + $label = ''; + if ( isset( $attrs['label'] ) ) { + $label = $attrs['label']; + } elseif ( ! isset( $attrs['label'] ) && isset( $attrs['title'] ) ) { + $label = $attrs['title']; + } + ?> - +
- +
@@ -96,4 +96,4 @@ do_action( 'um_after_form_fields', $args ); ?> - \ No newline at end of file + diff --git a/templates/password-reset.php b/templates/password-reset.php index 384da0be..9b706317 100644 --- a/templates/password-reset.php +++ b/templates/password-reset.php @@ -13,6 +13,14 @@ + +
+
+
+ +
+
+
@@ -93,7 +101,7 @@
- +
diff --git a/ultimate-member.php b/ultimate-member.php index 8d9c9910..609ffb7d 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.4.2 +Version: 2.5.0 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member diff --git a/uninstall.php b/uninstall.php index c1d6626a..63e24f8b 100644 --- a/uninstall.php +++ b/uninstall.php @@ -115,6 +115,20 @@ if ( ! empty( $delete_options ) ) { delete_option( '__ultimatemember_sitekey' ); delete_option( 'um_flush_rewrite_rules' ); + $statuses = array( + 'approved', + 'awaiting_admin_review', + 'awaiting_email_confirmation', + 'inactive', + 'rejected', + ); + + foreach ( $statuses as $status ) { + delete_transient( "um_count_users_{$status}" ); + } + delete_transient( 'um_count_users_pending_dot' ); + delete_transient( 'um_count_users_unassigned' ); + //remove all users cache UM()->user()->remove_cache_all_users();