mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Allow soundcloud URLs to be passed in addition to track ids
This commit is contained in:
@@ -30,10 +30,20 @@ add_filter( 'um_edit_label_all_fields', 'um_edit_label_all_fields', 10, 2 );
|
||||
*/
|
||||
function um_profile_field_filter_hook__soundcloud_track( $value, $data ) {
|
||||
|
||||
if ( ! is_numeric( $value ) ) {
|
||||
return __( 'Invalid soundcloud track ID', 'ultimate-member' );
|
||||
if ( !is_numeric( $value ) ) {
|
||||
# if we're passed a track url:
|
||||
if ( preg_match( '/https:\/\/soundcloud.com\/.*/', $value ) ) {
|
||||
$value = '<div class="um-soundcloud">
|
||||
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=' . urlencode($value) . '&color=ff6600&auto_play=false&show_artwork=true"></iframe>
|
||||
</div>';
|
||||
return $value;
|
||||
} else {
|
||||
# neither a track id nor url:
|
||||
return __( 'Invalid soundcloud track ID', 'ultimate-member' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# if we're passed a track id:
|
||||
$value = '<div class="um-soundcloud">
|
||||
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' . $value . '&color=ff6600&auto_play=false&show_artwork=true"></iframe>
|
||||
</div>';
|
||||
@@ -849,4 +859,4 @@ function um_edit_url_field_value( $value, $key ) {
|
||||
$value = esc_attr( $value );
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
|
||||
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
|
||||
|
||||
Reference in New Issue
Block a user