mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-17 21:53:43 +09:00
- fixed YouTube link validation
This commit is contained in:
@@ -792,7 +792,7 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
|
||||
case 'youtube_video':
|
||||
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'youtube.com/watch?v=' ) && ! UM()->validation()->is_url( $submitted_data[ $key ], 'youtu.be' ) && ! UM()->validation()->is_url( $submitted_data[ $key ], 'youtube.com/shorts/' ) ) {
|
||||
if ( ! UM()->validation()->is_url( $submitted_data[ $key ] ) || false === um_youtube_id_from_url( $submitted_data[ $key ] ) ) {
|
||||
// translators: %s: label.
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s URL', 'ultimate-member' ), $array['label'] ) );
|
||||
}
|
||||
|
||||
@@ -94,10 +94,11 @@ function um_profile_field_filter_hook__youtube_video( $value, $data ) {
|
||||
return '';
|
||||
}
|
||||
$value = ( strstr( $value, 'http' ) || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
|
||||
$value = '<div class="um-youtube">
|
||||
<iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>
|
||||
</div>';
|
||||
|
||||
if ( false !== $value ) {
|
||||
$value = '<div class="um-youtube">'
|
||||
. '<iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>'
|
||||
. '</div>';
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_profile_field_filter_hook__youtube_video', 'um_profile_field_filter_hook__youtube_video', 99, 2 );
|
||||
|
||||
Reference in New Issue
Block a user