mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- add a spotify field
This commit is contained in:
@@ -635,6 +635,22 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
)
|
||||
),
|
||||
|
||||
'spotify' => array(
|
||||
'name' => 'Spotify URL',
|
||||
'col1' => array('_title','_metakey','_help','_visibility'),
|
||||
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
||||
'col3' => array('_required','_editable','_icon'),
|
||||
'validate' => array(
|
||||
'_title' => array(
|
||||
'mode' => 'required',
|
||||
'error' => __('You must provide a title','ultimate-member')
|
||||
),
|
||||
'_metakey' => array(
|
||||
'mode' => 'unique',
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
/*'group' => array(
|
||||
'name' => 'Field Group',
|
||||
'col1' => array('_title','_max_entries'),
|
||||
@@ -1497,6 +1513,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
||||
$array['url'] = __('Website URL','ultimate-member');
|
||||
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
||||
$array['spotify_url'] = __('Spotify URL','ultimate-member');
|
||||
$array['telegram_url'] = __('Telegram URL','ultimate-member');
|
||||
$array['discord'] = __('Discord ID','ultimate-member');
|
||||
$array['tiktok_url'] = __('TikTok URL','ultimate-member');
|
||||
|
||||
@@ -1652,6 +1652,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
case 'youtube_video':
|
||||
case 'vimeo_video':
|
||||
case 'soundcloud_track':
|
||||
case 'spotify':
|
||||
$array['disabled'] = '';
|
||||
$array['input'] = 'text';
|
||||
break;
|
||||
@@ -2381,6 +2382,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
case 'googlemap':
|
||||
case 'youtube_video':
|
||||
case 'vimeo_video':
|
||||
case 'spotify':
|
||||
case 'soundcloud_track':
|
||||
|
||||
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
||||
|
||||
@@ -743,6 +743,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
case 'youtube_video':
|
||||
case 'vimeo_video':
|
||||
case 'soundcloud_track':
|
||||
case 'spotify':
|
||||
$form[ $k ] = sanitize_text_field( $form[ $k ] );
|
||||
break;
|
||||
case 'multiselect':
|
||||
|
||||
@@ -715,6 +715,12 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'spotify_url':
|
||||
if ( ! UM()->validation()->is_url( $args[ $key ], 'open.spotify.com' ) ) {
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s URL', 'ultimate-member' ), $array['label'] ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'telegram_url':
|
||||
if ( ! UM()->validation()->is_url( $args[ $key ], 't.me' ) ) {
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
||||
|
||||
@@ -77,6 +77,30 @@ function um_profile_field_filter_hook__youtube_video( $value, $data ) {
|
||||
add_filter( 'um_profile_field_filter_hook__youtube_video', 'um_profile_field_filter_hook__youtube_video', 99, 2 );
|
||||
|
||||
|
||||
/**
|
||||
* Outputs a spotify iframe
|
||||
*
|
||||
* @param $value
|
||||
* @param $data
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
function um_profile_field_filter_hook__spotify( $value, $data ) {
|
||||
if ( preg_match( '/https:\/\/open.spotify.com\/.*/', $value ) ) {
|
||||
$url = str_replace( 'open.spotify.com/', 'open.spotify.com/embed/', $value );
|
||||
|
||||
$value = '<div class="um-spotify">
|
||||
<iframe width="100%" height="352" style="border-radius:12px" frameBorder="0" allowfullscreen="" loading="lazy" src="' . esc_url( $url ) . '"></iframe>
|
||||
</div>';
|
||||
} else {
|
||||
return __( 'Invalid Spotify URL', 'ultimate-member' );
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_profile_field_filter_hook__spotify', 'um_profile_field_filter_hook__spotify', 99, 2 );
|
||||
|
||||
|
||||
/**
|
||||
* Outputs a vimeo video
|
||||
*
|
||||
@@ -428,6 +452,7 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
) {
|
||||
if ( $data['validate'] == 'soundcloud_url' ) $value = 'https://soundcloud.com/' . $value;
|
||||
if ( $data['validate'] == 'youtube_url' ) $value = 'https://youtube.com/user/' . $value;
|
||||
// if ( $data['validate'] == 'spotify_url' ) $value = 'https://open.spotify.com/' . $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;
|
||||
|
||||
Reference in New Issue
Block a user