mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- Skype field code review;
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
function um_upgrade_skype_id226() {
|
||||
UM()->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' ) ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
return array(
|
||||
'skype_id226' => 'skype_id226',
|
||||
);
|
||||
+30
@@ -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( __( 'Upgrade SkypeID fields...', 'ultimate-member' ) ) ?>' );
|
||||
|
||||
jQuery.ajax({
|
||||
url: wp.ajax.settings.url,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'um_skype_id226',
|
||||
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>
|
||||
@@ -972,7 +972,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
'skype' => array(
|
||||
'title' => __('Skype ID','ultimate-member'),
|
||||
'metakey' => 'skype',
|
||||
'type' => 'url',
|
||||
'type' => 'text',
|
||||
'label' => __('Skype ID','ultimate-member'),
|
||||
'required' => 0,
|
||||
'public' => 1,
|
||||
@@ -981,7 +981,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-faicon-skype',
|
||||
'validate' => 'skype',
|
||||
'url_text' => 'Skype',
|
||||
'url_text' => __( 'Join chat', 'ultimate-member' ),
|
||||
),
|
||||
|
||||
'viber' => array(
|
||||
@@ -1008,7 +1008,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
'editable' => 1,
|
||||
'url_target' => '_blank',
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-icon-ios-telephone-outline',
|
||||
'icon' => 'um-icon-social-whatsapp',
|
||||
'validate' => 'phone_number',
|
||||
),
|
||||
|
||||
|
||||
@@ -876,7 +876,8 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
function slider_range_placeholder( $filter, $attrs ) {
|
||||
switch ( $filter ) {
|
||||
default: {
|
||||
$label = ucwords( str_replace( array( 'um_', '_' ), array( '', ' ' ), $attrs['label'] ) );
|
||||
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $filter;
|
||||
$label = ucwords( str_replace( array( 'um_', '_' ), array( '', ' ' ), $label ) );
|
||||
$placeholders = apply_filters( 'um_member_directory_filter_slider_range_placeholder', false, $filter );
|
||||
|
||||
if ( ! $placeholders ) {
|
||||
|
||||
@@ -767,7 +767,9 @@ function um_profile_dynamic_meta_desc() {
|
||||
<meta property="og:url" content="<?php echo esc_url( $url ); ?>"/>
|
||||
|
||||
<meta name="twitter:card" content="summary"/>
|
||||
<?php if( $twitter ) { ?><meta name="twitter:site" content="@<?php echo esc_attr( $twitter ); ?>"/><?php } ?>
|
||||
<?php if ( $twitter ) { ?>
|
||||
<meta name="twitter:site" content="@<?php echo esc_attr( $twitter ); ?>"/>
|
||||
<?php } ?>
|
||||
<meta name="twitter:title" content="<?php echo esc_attr( $title ); ?>"/>
|
||||
<meta name="twitter:description" content="<?php echo esc_attr( $description ); ?>"/>
|
||||
<meta name="twitter:image" content="<?php echo esc_url( $image ); ?>"/>
|
||||
|
||||
@@ -385,52 +385,44 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ( isset( $data['validate'] ) && $data['validate'] !== '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
|
||||
$alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
||||
if ( isset( $data['type'] ) && 'text' === $data['type'] && isset( $data['validate'] ) && 'skype' === $data['validate'] ) {
|
||||
$alt = ! empty( $data['url_text'] ) ? $data['url_text'] : $value;
|
||||
$url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
|
||||
if ( ! strstr( $value, 'http' )
|
||||
&& !strstr( $value, '://' )
|
||||
&& !strstr( $value, 'www.' )
|
||||
&& !strstr( $value, '.com' )
|
||||
&& !strstr( $value, '.net' )
|
||||
&& !strstr( $value, '.org' )
|
||||
&& !strstr( $value, '.me' )
|
||||
) {
|
||||
if ( $data['validate'] == 'soundcloud_url' ) $value = 'https://soundcloud.com/' . $value;
|
||||
if ( $data['validate'] == 'youtube_url' ) $value = 'https://youtube.com/user/' . $value;
|
||||
if ( $data['validate'] == 'telegram_url' ) $value = 'https://t.me/' . $value;
|
||||
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'] == 'skype' ) $value = 'skype:'.$value.'?chat';
|
||||
if ( $data['validate'] == 'googleplus_url' ) $value = 'https://plus.google.com/' . $value;
|
||||
if ( $data['validate'] == 'instagram_url' ) $value = 'https://instagram.com/' . $value;
|
||||
if ( $data['validate'] == 'vk_url' ) $value = 'https://vk.com/' . $value;
|
||||
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
||||
|
||||
if ( false === strstr( $value, 'join.skype.com' ) ) {
|
||||
$value = 'skype:' . $value . '?chat';
|
||||
}
|
||||
|
||||
|
||||
if ( ! ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) ) {
|
||||
$value = '<a href="'. esc_attr( $value ) .'" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . '>' . esc_html( $alt ) . '</a>';
|
||||
} else {
|
||||
if ( ( isset( $data['validate'] ) && $data['validate'] !== '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
|
||||
$alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
||||
$url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
|
||||
if ( ! strstr( $value, 'http' )
|
||||
&& !strstr( $value, '://' )
|
||||
&& !strstr( $value, 'www.' )
|
||||
&& !strstr( $value, '.com' )
|
||||
&& !strstr( $value, '.net' )
|
||||
&& !strstr( $value, '.org' )
|
||||
&& !strstr( $value, '.me' )
|
||||
) {
|
||||
if ( $data['validate'] == 'soundcloud_url' ) $value = 'https://soundcloud.com/' . $value;
|
||||
if ( $data['validate'] == 'youtube_url' ) $value = 'https://youtube.com/user/' . $value;
|
||||
if ( $data['validate'] == 'telegram_url' ) $value = 'https://t.me/' . $value;
|
||||
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'] == 'vk_url' ) $value = 'https://vk.com/' . $value;
|
||||
}
|
||||
|
||||
if ( strpos( $value, 'http://' ) !== 0 ) {
|
||||
$value = 'http://' . $value;
|
||||
}
|
||||
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
||||
$value = '<a href="'. $value .'" title="'.$alt.'" target="'.$data['url_target'].'" ' . $url_rel . '>'.$alt.'</a>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) {
|
||||
|
||||
$value = str_replace('https://','',$value );
|
||||
$value = str_replace('http://','',$value );
|
||||
|
||||
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
||||
if ( strpos( $value, '.cid.' ) !== 0 ) {
|
||||
$value = '<a href="' . 'skype:' . $value . '?chat' . '" title="' . $value . '" target="' . $data['url_target'] . '" ' . $url_rel . '>' . $value . '</a>';
|
||||
} else {
|
||||
$value = '<a href="' . 'skype:live:' . $value . '?chat' . '" title="' . $value . '" target="' . $data['url_target'] . '" ' . $url_rel . '>' . esc_html__( 'Skype' ) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,15 +887,3 @@ function um_edit_url_field_value( $value, $key ) {
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
|
||||
|
||||
|
||||
add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
||||
function my_submit_post_form( $data ) {
|
||||
$skype_key = 'skype-'. $data['form_id'];
|
||||
if ( array_key_exists( $skype_key , $data ) ) {
|
||||
$skype = str_replace('live:', '', $data[ $skype_key ] );
|
||||
$data[ $skype_key ] = $skype;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ add_filter( 'the_title', 'um_dynamic_user_profile_title', 100000, 2 );
|
||||
* @return string|false The canonical URL, or false if current URL is canonical.
|
||||
*/
|
||||
function um_get_canonical_url( $canonical_url, $post ) {
|
||||
if ( UM()->config()->permalinks['user'] == $post->ID || (UM()->external_integrations()->is_wpml_active() && UM()->config()->permalinks['user'] == wpml_object_id_filter( $post->ID, 'page', true, icl_get_default_language() )) ) {
|
||||
if ( UM()->config()->permalinks['user'] == $post->ID || ( UM()->external_integrations()->is_wpml_active() && UM()->config()->permalinks['user'] == wpml_object_id_filter( $post->ID, 'page', true, icl_get_default_language() ) ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
|
||||
+6
-2
@@ -155,11 +155,15 @@ 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: October xx, 2021 =
|
||||
= 2.2.6: December xx, 2021 =
|
||||
|
||||
* Bugfixes:
|
||||
|
||||
- Fixed: "Clear All" button for the filters with "&" symbol in the label
|
||||
- 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 <meta name="twitter:site"> will be filled by this value.
|
||||
- Fixed: Member directory a slider filter's label displaying. It uses the filed label for now.
|
||||
- Fixed: Some typos in the fields' labels.
|
||||
|
||||
= 2.2.5: September 22, 2021 =
|
||||
|
||||
|
||||
+1
-1
@@ -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-alpha
|
||||
Version: 2.2.6
|
||||
Author: Ultimate Member
|
||||
Author URI: http://ultimatemember.com/
|
||||
Text Domain: ultimate-member
|
||||
|
||||
Reference in New Issue
Block a user