mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- fixed #1085;
This commit is contained in:
@@ -1058,21 +1058,24 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
),
|
||||
|
||||
'youtube' => array(
|
||||
'title' => __('YouTube','ultimate-member'),
|
||||
'metakey' => 'youtube',
|
||||
'type' => 'url',
|
||||
'label' => __('YouTube','ultimate-member'),
|
||||
'required' => 0,
|
||||
'public' => 1,
|
||||
'editable' => 1,
|
||||
'title' => __( 'YouTube', 'ultimate-member' ),
|
||||
'metakey' => 'youtube',
|
||||
'type' => 'url',
|
||||
'label' => __( 'YouTube', 'ultimate-member' ),
|
||||
'required' => 0,
|
||||
'public' => 1,
|
||||
'editable' => 1,
|
||||
'url_target' => '_blank',
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-faicon-youtube',
|
||||
'validate' => 'youtube_url',
|
||||
'url_text' => 'YouTube',
|
||||
'advanced' => 'social',
|
||||
'color' => '#e52d27',
|
||||
'match' => 'https://youtube.com/',
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-faicon-youtube',
|
||||
'validate' => 'youtube_url',
|
||||
'url_text' => __( 'YouTube', 'ultimate-member' ),
|
||||
'advanced' => 'social',
|
||||
'color' => '#e52d27',
|
||||
'match' => array(
|
||||
'https://youtube.com/',
|
||||
'https://youtu.be/',
|
||||
),
|
||||
),
|
||||
|
||||
'soundcloud' => array(
|
||||
|
||||
@@ -86,9 +86,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
|
||||
foreach ( $social as $k => $arr ) {
|
||||
if ( um_profile( $k ) ) { ?>
|
||||
if ( um_profile( $k ) ) {
|
||||
$match = is_array( $arr['match'] ) ? $arr['match'][0] : $arr['match']; ?>
|
||||
|
||||
<a href="<?php echo esc_url( um_filtered_social_link( $k, $arr['match'] ) ); ?>"
|
||||
<a href="<?php echo esc_url( um_filtered_social_link( $k, $match ) ); ?>"
|
||||
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
||||
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
||||
|
||||
|
||||
@@ -657,19 +657,47 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
$v = sanitize_text_field( $form[ $k ] );
|
||||
|
||||
// Make a proper social link
|
||||
if ( ! empty( $v ) && ! strstr( $v, $f['match'] ) ) {
|
||||
$domain = trim( strtr( $f['match'], array(
|
||||
'https://' => '',
|
||||
'http://' => '',
|
||||
) ), ' /' );
|
||||
if ( ! empty( $v ) ) {
|
||||
$replace_match = is_array( $f['match'] ) ? $f['match'][0] : $f['match'];
|
||||
|
||||
if ( ! strstr( $v, $domain ) ) {
|
||||
$v = $f['match'] . $v;
|
||||
} else {
|
||||
$v = 'https://' . trim( strtr( $v, array(
|
||||
'https://' => '',
|
||||
'http://' => '',
|
||||
) ), ' /' );
|
||||
$need_replace = false;
|
||||
if ( is_array( $f['match'] ) ) {
|
||||
$need_replace = true;
|
||||
foreach ( $f['match'] as $arr_match ) {
|
||||
if ( strstr( $v, $arr_match ) ) {
|
||||
$need_replace = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_array( $f['match'] ) || $need_replace ) {
|
||||
if ( ! strstr( $v, $replace_match ) ) {
|
||||
$domain = trim(
|
||||
strtr(
|
||||
$replace_match,
|
||||
array(
|
||||
'https://' => '',
|
||||
'http://' => '',
|
||||
)
|
||||
),
|
||||
' /'
|
||||
);
|
||||
|
||||
if ( ! strstr( $v, $domain ) ) {
|
||||
$v = $replace_match . $v;
|
||||
} else {
|
||||
$v = 'https://' . trim(
|
||||
strtr(
|
||||
$v,
|
||||
array(
|
||||
'https://' => '',
|
||||
'http://' => '',
|
||||
)
|
||||
),
|
||||
' /'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -702,7 +702,7 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
break;
|
||||
|
||||
case 'youtube_url':
|
||||
if ( ! UM()->validation()->is_url( $args[ $key ], 'youtube.com' ) ) {
|
||||
if ( ! UM()->validation()->is_url( $args[ $key ], 'youtube.com' ) && ! UM()->validation()->is_url( $args[ $key ], 'youtu.be' ) ) {
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user