Below, you’ll find a detailed guide on how to add the Mp3 Music Player By Sonaar Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Mp3 Music Player By Sonaar Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Mp3 Music Player By Sonaar Plugin and the shortcodes it provides:
"MP3 Audio Player for Music, Radio & Podcast by Sonaar is a versatile plugin designed for seamless audio streaming. Ideal for music, radio broadcasts, and podcasts, it brings excellent audio experience to your WordPress site."
- [sonaar_audioplayer]
Mp3 Music Player By Sonaar [sonaar_audioplayer] Shortcode
The ‘sonaar_audioplayer’ shortcode is used to embed an audio player on a webpage. It enqueues necessary CSS and JS files for the Sonaar Music player. This shortcode allows customization of the player, including title, album display, playlist visibility, artwork, and market options. It then generates the player widget, returning its HTML for display.
Shortcode: [sonaar_audioplayer]
Parameters
Here is a list of all possible sonaar_audioplayer shortcode parameters and attributes:
title
– Sets the title of the audio player.albums
– Determines which albums to display in the player.show_playlist
– If set, the playlist is visible in the player.hide_artwork
– If set, the album artwork will not be shown.show_album_market
– If set, the album’s marketplace will be visible.show_track_market
– If set, each track’s marketplace will be visible.remove_player
– If set, the player will be removed from the page.enable_sticky_player
– If set, the player will stick to the bottom of the page.
Examples and Usage
Basic example – A simple usage of the shortcode to embed an audio player with a specific album.
[sonaar_audioplayer albums="Album1" /]
Advanced examples
Using the shortcode to create an audio player with a specific album and title, with the playlist visible, artwork hidden, and the album market shown.
[sonaar_audioplayer title="My Audio Player" albums="Album1" show_playlist="true" hide_artwork="true" show_album_market="true" /]
Creating an audio player with multiple albums, hiding the playlist and artwork, and enabling the sticky player feature.
[sonaar_audioplayer albums="Album1, Album2, Album3" show_playlist="false" hide_artwork="true" enable_sticky_player="true" /]
Embedding an audio player with a specific album, showing the track market, and removing the player controls.
[sonaar_audioplayer albums="Album1" show_track_market="true" remove_player="true" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [sonaar_audioplayer]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'sonaar_audioplayer', 'sonaar_shortcode_audioplayer' );
Shortcode PHP function:
function sonaar_shortcode_audioplayer( $atts ) {
/* Enqueue Sonaar Music related CSS and Js file */
wp_enqueue_style( 'sonaar-music' );
wp_enqueue_style( 'sonaar-music-pro' );
wp_enqueue_script( 'sonaar-music-mp3player' );
wp_enqueue_script( 'sonaar-music-pro-mp3player' );
wp_enqueue_script( 'sonaar_player' );
if ( function_exists('sonaar_player') ) {
add_action('wp_footer','sonaar_player', 12);
}
extract( shortcode_atts( array(
'title' => '',
'albums' => '',
'show_playlist' => '',
'hide_artwork' => '',
'show_album_market' => '',
'show_track_market' => '',
'remove_player' => '',
'enable_sticky_player' => '',
), $atts ) );
ob_start();
the_widget('Sonaar_Music_Widget', $atts, array('widget_id'=>'arbitrary-instance-'.uniqid(), 'before_widget'=>'<article class="iron_widget_radio">', 'after_widget'=>'</article>'));
$output = ob_get_contents();
ob_end_clean();
return $output;
}
Code file location:
mp3-music-player-by-sonaar/mp3-music-player-by-sonaar/admin/class-sonaar-music-admin.php
Conclusion
Now that you’ve learned how to embed the Mp3 Music Player By Sonaar Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply