diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index 975fa17d..19c8b181 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -1725,7 +1725,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { ?>

- edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> /> + edit_mode_value ) ? $this->edit_mode_value : UM()->options()->get( 'require_strongpass' ) ) ?> />

array( 'sanitize' => 'bool', ), - 'reset_require_strongpass' => array( + 'require_strongpass' => array( 'sanitize' => 'bool', ), 'password_min_chars' => array( @@ -721,9 +721,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'account_general_password' => array( 'sanitize' => 'bool', ), - 'account_require_strongpass' => array( - 'sanitize' => 'bool', - ), 'account_hide_in_directory' => array( 'sanitize' => 'bool', ), @@ -1049,10 +1046,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ), ), array( - 'id' => 'reset_require_strongpass', + 'id' => 'require_strongpass', 'type' => 'checkbox', - 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ), - 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ), + 'label' => __( 'Require a strong password?', 'ultimate-member' ), + 'tooltip' => __( 'Enable or disable a strong password rules common for all Ultimate Member forms. Note: Individual settings for the password-type field still have a higher priority.', 'ultimate-member' ), ), array( 'id' => 'password_min_chars', @@ -1165,12 +1162,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'label' => __( 'Password is required?', 'ultimate-member' ), 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ), ), - array( - 'id' => 'account_require_strongpass', - 'type' => 'checkbox', - 'label' => __( 'Require a strong password?', 'ultimate-member' ), - 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ), - ), array( 'id' => 'account_hide_in_directory', 'type' => 'checkbox', @@ -3172,7 +3163,7 @@ Enable Members Directory: info_value( UM()->options()->get('me Use Gravatars: info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?> options()->get('use_gravatars') ): ?>Gravatar builtin image: options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?> UM Avatar as blank Gravatar: info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?> -Require a strong password: info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?> +Require a strong password: info_value( UM()->options()->get('require_strongpass'), 'onoff', true ); ?> --- UM Access Configuration --- diff --git a/includes/admin/core/packages/2.2.6/functions.php b/includes/admin/core/packages/2.2.6/functions.php deleted file mode 100644 index e7fe34b9..00000000 --- a/includes/admin/core/packages/2.2.6/functions.php +++ /dev/null @@ -1,82 +0,0 @@ -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' - ) ); - - $fields_for_upgrade = array(); - - foreach ( $forms as $form_id ) { - $forms_fields = get_post_meta( $form_id, '_um_custom_fields', true ); - - $changed = false; - foreach ( $forms_fields as $key => &$field ) { - if ( isset( $field['validate'] ) && 'skype' === $field['validate'] ) { - if ( isset( $field['type'] ) && 'url' === $field['type'] ) { - $field['type'] = 'text'; - $changed = true; - - $fields_for_upgrade[] = $field['metakey']; - } - } - } - - if ( $changed ) { - update_post_meta( $form_id, '_um_custom_fields', $forms_fields ); - } - } - - $changed = false; - $custom_fields = get_option( 'um_fields', array() ); - foreach ( $custom_fields as &$custom_field ) { - if ( isset( $custom_field['validate'] ) && 'skype' === $custom_field['validate'] ) { - if ( isset( $custom_field['type'] ) && 'url' === $custom_field['type'] ) { - $custom_field['type'] = 'text'; - $changed = true; - - $fields_for_upgrade[] = $custom_field['metakey']; - } - } - } - if ( $changed ) { - update_option( 'um_fields', $custom_fields ); - } - - $fields_for_upgrade = array_unique( $fields_for_upgrade ); - - // avoid 'https://', 'http://' at the start of the Skype field is there is nickname but not https://join.skype.com/ - // change only links with nickname skip https://join.skype.com/ - if ( ! empty( $fields_for_upgrade ) ) { - global $wpdb; - $usermetas = $wpdb->get_results( "SELECT user_id, meta_key, meta_value FROM {$wpdb->usermeta} WHERE meta_key IN( '" . implode( "','", $fields_for_upgrade ) . "' )", ARRAY_A ); - if ( ! empty( $usermetas ) ) { - foreach ( $usermetas as $usermeta ) { - if ( false !== strstr( $usermeta['meta_value'], 'https://' ) || false !== strstr( $usermeta['meta_value'], 'http://' ) ) { - if ( false === strstr( $usermeta['meta_value'], 'join.skype.com/' ) ) { - $usermeta['meta_value'] = str_replace( array( 'https://', 'http://' ), '', $usermeta['meta_value'] ); - update_user_meta( $usermeta['user_id'], $usermeta['meta_key'], $usermeta['meta_value'] ); - - delete_option( "um_cache_userdata_{$usermeta['user_id']}" ); - } - } - } - } - } - - update_option( 'um_last_version_upgrade', '2.2.6' ); - - if ( ! empty( $fields_for_upgrade ) ) { - wp_send_json_success( array( 'message' => __( 'SkypeID fields have been updated successfully', 'ultimate-member' ) ) ); - } else { - wp_send_json_success( array( 'message' => __( 'Database has been updated successfully', 'ultimate-member' ) ) ); - } -} diff --git a/includes/admin/core/packages/2.2.6/hooks.php b/includes/admin/core/packages/2.2.6/hooks.php deleted file mode 100644 index ad5e7f11..00000000 --- a/includes/admin/core/packages/2.2.6/hooks.php +++ /dev/null @@ -1,5 +0,0 @@ - 'skype_id226', -); diff --git a/includes/admin/core/packages/2.2.6/init.php b/includes/admin/core/packages/2.2.6/init.php deleted file mode 100644 index 2445132d..00000000 --- a/includes/admin/core/packages/2.2.6/init.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - diff --git a/includes/admin/core/packages/2.3.0/functions.php b/includes/admin/core/packages/2.3.0/functions.php new file mode 100644 index 00000000..51f0b60d --- /dev/null +++ b/includes/admin/core/packages/2.3.0/functions.php @@ -0,0 +1,152 @@ +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' + ) ); + + $fields_for_upgrade = array(); + + foreach ( $forms as $form_id ) { + $forms_fields = get_post_meta( $form_id, '_um_custom_fields', true ); + + $changed = false; + foreach ( $forms_fields as $key => &$field ) { + if ( isset( $field['validate'] ) && 'skype' === $field['validate'] ) { + if ( isset( $field['type'] ) && 'url' === $field['type'] ) { + $field['type'] = 'text'; + $changed = true; + + $fields_for_upgrade[] = $field['metakey']; + } + } + } + + if ( $changed ) { + update_post_meta( $form_id, '_um_custom_fields', $forms_fields ); + } + } + + $changed = false; + $custom_fields = get_option( 'um_fields', array() ); + foreach ( $custom_fields as &$custom_field ) { + if ( isset( $custom_field['validate'] ) && 'skype' === $custom_field['validate'] ) { + if ( isset( $custom_field['type'] ) && 'url' === $custom_field['type'] ) { + $custom_field['type'] = 'text'; + $changed = true; + + $fields_for_upgrade[] = $custom_field['metakey']; + } + } + } + if ( $changed ) { + update_option( 'um_fields', $custom_fields ); + } + + $fields_for_upgrade = array_unique( $fields_for_upgrade ); + + if ( ! empty( $fields_for_upgrade ) ) { + update_option( 'um_upgrade_230_skype_fields_for_upgrade', $fields_for_upgrade ); + wp_send_json_success( array( 'message' => __( 'SkypeID fields have been updated successfully', 'ultimate-member' ), 'count' => count( $fields_for_upgrade ) ) ); + } else { + wp_send_json_success( array( 'message' => __( 'Database has been updated successfully', 'ultimate-member' ), 'count' => 0 ) ); + } +} + + +function um_upgrade_usermeta_count230() { + UM()->admin()->check_ajax_nonce(); + + um_maybe_unset_time_limit(); + + $fields_for_upgrade = get_option( 'um_upgrade_230_skype_fields_for_upgrade', array() ); + + if ( ! empty( $fields_for_upgrade ) ) { + global $wpdb; + $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key IN( '" . implode( "','", $fields_for_upgrade ) . "' )" ); + } else { + $count = 0; + } + + wp_send_json_success( array( 'count' => $count ) ); +} + + +function um_upgrade_usermeta_part230() { + UM()->admin()->check_ajax_nonce(); + + um_maybe_unset_time_limit(); + + if ( empty( $_POST['page'] ) ) { + wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) ); + } + + $fields_for_upgrade = get_option( 'um_upgrade_230_skype_fields_for_upgrade', array() ); + if ( empty( $fields_for_upgrade ) ) { + wp_send_json_success( array( 'message' => __( 'Database has been updated successfully', 'ultimate-member' ) ) ); + } + + $per_page = 100; + + // avoid 'https://', 'http://' at the start of the Skype field is there is nickname but not https://join.skype.com/ + // change only links with nickname skip https://join.skype.com/ + global $wpdb; + $usermetas = $wpdb->get_results( + $wpdb->prepare( + "SELECT user_id, + meta_key, + meta_value + FROM {$wpdb->usermeta} + WHERE meta_key IN( '" . implode( "','", $fields_for_upgrade ) . "' ) + LIMIT %d, %d", + ( absint( $_POST['page'] ) - 1 ) * $per_page, + $per_page + ), + ARRAY_A + ); + + if ( ! empty( $usermetas ) ) { + foreach ( $usermetas as $usermeta ) { + if ( false !== strstr( $usermeta['meta_value'], 'https://' ) || false !== strstr( $usermeta['meta_value'], 'http://' ) ) { + if ( false === strstr( $usermeta['meta_value'], 'join.skype.com/' ) ) { + $usermeta['meta_value'] = str_replace( array( 'https://', 'http://' ), '', $usermeta['meta_value'] ); + update_user_meta( $usermeta['user_id'], $usermeta['meta_key'], $usermeta['meta_value'] ); + + delete_option( "um_cache_userdata_{$usermeta['user_id']}" ); + } + } + } + } + + $from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1; + $to = absint( $_POST['page'] ) * $per_page; + + wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s row were upgraded successfully...', 'ultimate-member' ), $from, $to ) ) ); +} + + +function um_upgrade_reset_password230() { + UM()->admin()->check_ajax_nonce(); + + um_maybe_unset_time_limit(); + + $require_strongpass = UM()->options()->get( 'account_require_strongpass' ) || UM()->options()->get( 'reset_require_strongpass' ); + + UM()->options()->update( 'require_strongpass', $require_strongpass ); + UM()->options()->remove( 'account_require_strongpass' ); + UM()->options()->remove( 'reset_require_strongpass' ); + + // delete temporarily option for fields upgrade + delete_option( 'um_upgrade_230_skype_fields_for_upgrade' ); + update_option( 'um_last_version_upgrade', '2.3.0' ); + + wp_send_json_success( array( 'message' => __( 'Reset Password options have been updated successfully.', 'ultimate-member' ) ) ); +} diff --git a/includes/admin/core/packages/2.3.0/hooks.php b/includes/admin/core/packages/2.3.0/hooks.php new file mode 100644 index 00000000..6535c2c0 --- /dev/null +++ b/includes/admin/core/packages/2.3.0/hooks.php @@ -0,0 +1,8 @@ + 'skypeid_fields230', + 'usermeta_count230' => 'usermeta_count230', + 'usermeta_part230' => 'usermeta_part230', + 'reset_password230' => 'reset_password230', +); diff --git a/includes/admin/core/packages/2.3.0/init.php b/includes/admin/core/packages/2.3.0/init.php new file mode 100644 index 00000000..3c620efe --- /dev/null +++ b/includes/admin/core/packages/2.3.0/init.php @@ -0,0 +1,133 @@ + + + + diff --git a/includes/class-config.php b/includes/class-config.php index ab3fa770..2c968714 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -522,7 +522,7 @@ if ( ! class_exists( 'um\Config' ) ) { 'use_gravatars' => 0, 'use_um_gravatar_default_builtin_image' => 'default', 'use_um_gravatar_default_image' => 0, - 'reset_require_strongpass' => 0, + 'require_strongpass' => 0, 'password_min_chars' => 8, 'password_max_chars' => 30, 'account_tab_password' => 1, @@ -538,7 +538,6 @@ if ( ! class_exists( 'um\Config' ) ) { 'account_general_password' => 0, 'account_hide_in_directory' => 1, 'account_hide_in_directory_default' => 'No', - 'account_require_strongpass' => 0, 'photo_thumb_sizes' => array( 40, 80, 190 ), 'cover_thumb_sizes' => array( 300, 600 ), 'accessible' => 0, diff --git a/includes/core/class-password.php b/includes/core/class-password.php index b6e0605b..a6c18f92 100644 --- a/includes/core/class-password.php +++ b/includes/core/class-password.php @@ -541,7 +541,7 @@ if ( ! class_exists( 'um\core\Password' ) ) { $args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] ); } - if ( UM()->options()->get( 'reset_require_strongpass' ) ) { + if ( UM()->options()->get( 'require_strongpass' ) ) { $min_length = UM()->options()->get( 'password_min_chars' ); $min_length = ! empty( $min_length ) ? $min_length : 8; diff --git a/includes/core/um-actions-account.php b/includes/core/um-actions-account.php index cd8b7bd1..674f0dc2 100644 --- a/includes/core/um-actions-account.php +++ b/includes/core/um-actions-account.php @@ -81,7 +81,7 @@ function um_submit_account_errors_hook( $args ) { return; } - if ( UM()->options()->get( 'account_require_strongpass' ) ) { + if ( UM()->options()->get( 'require_strongpass' ) ) { $min_length = UM()->options()->get( 'password_min_chars' ); $min_length = ! empty( $min_length ) ? $min_length : 8; $max_length = UM()->options()->get( 'password_max_chars' ); diff --git a/readme.txt b/readme.txt index c248ad53..8b00a49e 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration Requires PHP: 5.6 Requires at least: 5.0 Tested up to: 5.8 -Stable tag: 2.2.5 +Stable tag: 2.3.0 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -155,13 +155,18 @@ The plugin works with popular caching plugins by automatically excluding Ultimat * To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0) * UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin -= 2.2.6: December xx, 2021 = += 2.3.0: December xx, 2021 = -* Bugfixes: +* Enhancements: - Added: WhatsApp, Telegram, Discord, Viber messengers predefined fields. - Added: Callback for deleting the custom field data from member direcroty settings when this custom field has been deleted in Form Builder. - Added: 'um_account_active_tab_inited' JS hook. + - Updated: Require a strong password option (`Ultimate Member > Settings > General > Users > Require a strong password?`) to make it common for all Ultimate Member forms. Renamed option key from `reset_require_strongpass` to `require_strongpass`. + - Deprecated: `Ultimate Member > Settings > General > Account > Require a strong password?` option and merged with `Ultimate Member > Settings > General > Users > Require a strong password?` option. + +* Bugfixes: + - Fixed: "Clear All" button for the filters with "&" symbol in the label. - Fixed: Uninstall process when delete UM data. Avoid the issue when 3rd-party pages that had been selected as UM page are removed on UM uninstall. - Fixed: Header meta for the Twitter Card. If the user has twitter field filled then will be filled by this value. diff --git a/ultimate-member.php b/ultimate-member.php index 52b4c41a..de72c967 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.2.6 +Version: 2.3.0 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member