- removed Google+, VKonakte but leaves these custom fields as just URL type with Website URL validation;

- added 2.6.0 version upgrade script for changing 'vk_url', 'google_url', 'googleplus_url' just to 'url' validate value;
- close #1145;
This commit is contained in:
Nikita Sinelnikov
2023-03-27 16:56:58 +03:00
parent 74e1ea260d
commit 4af87d9834
9 changed files with 107 additions and 57 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ GNU Version 2 or Any Later Version
## Releases
[Official Release Version: 2.5.4](https://github.com/ultimatemember/ultimatemember/releases/tag/2.5.4).
[Official Release Version: 2.6.0](https://github.com/ultimatemember/ultimatemember/releases/tag/2.6.0).
## Changelog
+65
View File
@@ -0,0 +1,65 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function um_upgrade_social_fields260() {
UM()->admin()->check_ajax_nonce();
um_maybe_unset_time_limit();
$fields_for_upgrade = array();
$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 ( array_key_exists( 'validate', $field ) && in_array( $field['validate'], array( 'google_url', 'googleplus_url', 'vk_url' ), true ) ) { // Looks like googleplus_url is old legacy value.
$field['validate'] = 'url';
$need_update = true;
$fields_for_upgrade[] = $key;
}
}
if ( $need_update ) {
update_post_meta( $form_id, '_um_custom_fields', $forms_fields );
}
}
$need_update = false;
$custom_fields = get_option( 'um_fields', array() );
foreach ( $custom_fields as &$field ) {
if ( array_key_exists( 'validate', $field ) && in_array( $field['validate'], array( 'google_url', 'googleplus_url', 'vk_url' ), true ) ) { // Looks like googleplus_url is old legacy value.
$field['validate'] = 'url';
$need_update = true;
$fields_for_upgrade[] = $field['metakey'];
}
}
if ( $need_update ) {
update_option( 'um_fields', $custom_fields );
}
$fields_for_upgrade = array_unique( $fields_for_upgrade );
// delete temporarily option for fields upgrade
update_option( 'um_last_version_upgrade', '2.6.0' );
if ( ! empty( $fields_for_upgrade ) ) {
wp_send_json_success( array( 'message' => __( 'Social URLs fields have been successfully updated.', 'ultimate-member' ) ) );
} else {
wp_send_json_success( array( 'message' => __( 'Database has been updated successfully', 'ultimate-member' ) ) );
}
}
+5
View File
@@ -0,0 +1,5 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
return array(
'social_fields260' => 'social_fields260',
);
+30
View File
@@ -0,0 +1,30 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<script type="text/javascript">
jQuery( document ).ready( function() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Updated social URLs fields in the UM Forms fields...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: wp.ajax.settings.url,
type: 'POST',
dataType: 'json',
data: {
action: 'um_social_fields260',
nonce: um_admin_scripts.nonce
},
success: function( response ) {
if ( typeof response.data.message != 'undefined' ) {
um_add_upgrade_log( response.data.message );
//switch to the next package
um_run_upgrade();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
});
</script>
-38
View File
@@ -949,24 +949,6 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
'match' => 'https://linkedin.com/',
),
'googleplus' => array(
'title' => __('Google+','ultimate-member'),
'metakey' => 'googleplus',
'type' => 'url',
'label' => __('Google+','ultimate-member'),
'required' => 0,
'public' => 1,
'editable' => 1,
'url_target' => '_blank',
'url_rel' => 'nofollow',
'icon' => 'um-faicon-google-plus',
'validate' => 'google_url',
'url_text' => 'Google+',
'advanced' => 'social',
'color' => '#dd4b39',
'match' => 'https://google.com/+',
),
'instagram' => array(
'title' => __('Instagram','ultimate-member'),
'metakey' => 'instagram',
@@ -1150,24 +1132,6 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
'match' => 'https://soundcloud.com/',
),
'vkontakte' => array(
'title' => __('VKontakte','ultimate-member'),
'metakey' => 'vkontakte',
'type' => 'url',
'label' => __('VKontakte','ultimate-member'),
'required' => 0,
'public' => 1,
'editable' => 1,
'url_target' => '_blank',
'url_rel' => 'nofollow',
'icon' => 'um-faicon-vk',
'validate' => 'vk_url',
'url_text' => 'VKontakte',
'advanced' => 'social',
'color' => '#2B587A',
'match' => 'https://vk.com/',
),
'role_select' => array(
'title' => __('Roles (Dropdown)','ultimate-member'),
'metakey' => 'role_select',
@@ -1522,10 +1486,8 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
$array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
$array['english'] = __('English letters only','ultimate-member');
$array['facebook_url'] = __('Facebook URL','ultimate-member');
$array['google_url'] = __('Google+ URL','ultimate-member');
$array['instagram_url'] = __('Instagram URL','ultimate-member');
$array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
$array['vk_url'] = __('VKontakte URL','ultimate-member');
$array['lowercase'] = __('Lowercase only','ultimate-member');
$array['numeric'] = __('Numeric value only','ultimate-member');
$array['phone_number'] = __('Phone Number','ultimate-member');
-12
View File
@@ -746,24 +746,12 @@ function um_submit_form_errors_hook_( $args ) {
}
break;
case 'google_url':
if ( ! UM()->validation()->is_url( $args[ $key ], 'plus.google.com' ) ) {
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
}
break;
case 'linkedin_url':
if ( ! UM()->validation()->is_url( $args[ $key ], 'linkedin.com' ) ) {
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
}
break;
case 'vk_url':
if ( ! UM()->validation()->is_url( $args[ $key ], 'vk.com' ) ) {
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
}
break;
case 'discord':
if ( ! UM()->validation()->is_discord_id( $args[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'Please enter a valid Discord ID', 'ultimate-member' ) );
-2
View File
@@ -432,12 +432,10 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
if ( $data['validate'] == 'facebook_url' ) $value = 'https://facebook.com/' . $value;
if ( $data['validate'] == 'twitter_url' ) $value = 'https://twitter.com/' . $value;
if ( $data['validate'] == 'linkedin_url' ) $value = 'https://linkedin.com/' . $value;
if ( $data['validate'] == 'googleplus_url' ) $value = 'https://plus.google.com/' . $value;
if ( $data['validate'] == 'instagram_url' ) $value = 'https://instagram.com/' . $value;
if ( $data['validate'] == 'tiktok_url' ) $value = 'https://tiktok.com/' . $value;
if ( $data['validate'] == 'twitch_url' ) $value = 'https://twitch.tv/' . $value;
if ( $data['validate'] == 'reddit_url' ) $value = 'https://www.reddit.com/user/' . $value;
if ( $data['validate'] == 'vk_url' ) $value = 'https://vk.com/' . $value;
}
if ( strpos( $value, 'http://' ) !== 0 ) {
+5 -3
View File
@@ -6,8 +6,8 @@ Donate link:
Tags: community, member, membership, user-profile, user-registration
Requires PHP: 5.6
Requires at least: 5.0
Tested up to: 6.1
Stable tag: 2.5.4
Tested up to: 6.2
Stable tag: 2.6.0
License: GNU Version 2 or Any Later Version
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -163,9 +163,11 @@ No, you do not need to use our plugins login or registration pages and can us
* 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.5.5: March xx, 2023 =
= 2.6.0: March 29, 2023 =
* Deprecated:
- Deprecated: VKontakte and Google+ predefined fields. VKontakte and Google+ fields validation changed to just URL validation.
= 2.5.4: February 17, 2023 =
+1 -1
View File
@@ -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.5.5-alpha
Version: 2.6.0
Author: Ultimate Member
Author URI: http://ultimatemember.com/
Text Domain: ultimate-member