'Plugin Name', 'PluginURI' => 'Plugin URI', ); $plugin_data = get_file_data(__FILE__, $default_headers, 'plugin'); $url = $plugin_data['PluginURI']; $name = $plugin_data['Name']; $data['name'] = $name; $data['url'] = $url; return $data; } /** * This function processes [audiomack src=""] shortcode and replaces it with Audiomack player. * It expects the src to contain album or song prefix e.g. * - http://www.audiomack.com/song/hiphopfeeling/nowish * - http://www.audiomack.com/album/tutankhamun-brothers/whats-a-black-beatle * @param array $attr * @return string */ function audiomack_shortcode_audiomack($attr = array()) { $plugin_data = audiomack_get_plugin_data(); $opts = audiomack_get_options(); // should be like this. // - http://www.audiomack.com/song/djsemtex/say-my-name-kendrick-lamar-response // - http://www.audiomack.com/album/tutankhamun-brothers/whats-a-black-beatle $src = empty($attr['src']) ? '' : $attr['src']; $buff = ''; $buff .= "\n\n"; // Embed source needs to be like this // http://www.audiomack.com/embed3/hiphopfeeling/nowish?c1=fc881e&bg=f2f2f2&c2=222222 // http://www.audiomack.com/embed3-album/tutankhamun-brothers/whats-a-black-beatle?c1=fc881e&bg=f2f2f2&c2=222222 $embed_src = $src; $width = $opts['width']; // % or a number $height = 144; /* * The height of the player based on the embedded media * - Album - 352px * - Song Regular - 144px * - Song Slim - 62px */ if (stripos($embed_src, '/song/') !== false) { // song if (!empty($opts['slim'])) { $height = 62; $embed_src = str_replace('/song/', '/embed3-thin/', $embed_src); } else { $embed_src = str_replace('/song/', '/embed3/', $embed_src); } } else { $height = 352; $embed_src = str_replace('/album/', '/embed3-album/', $embed_src); } // the embed code expects the colours not to have pound signs $player_opts['c1'] = $opts['player_color']; $player_opts['c2'] = $opts['text_color']; $player_opts['bg'] = $opts['background_color']; $player_params = http_build_query($player_opts); $embed_src .= '?' . $player_params; $height_str = "height='$height'"; $embed_code = "\n"; $buff .= "
\n"; $buff .= $embed_code; $buff .= "
\n"; $buff .= "\n\n"; return $buff; } /** * This functions returns .min suffix for live installations and none on dev machine. * The idea is to load different css/js files depending on the environment. * e.g. for live: use main.min.js and dev main.js. * Minified version should load faster. */ function audiomack_get_asset_suffix() { $dev = empty($_SERVER['DEV_ENV']) ? 0 : 1; $suffix = $dev ? '' : '.min'; return $suffix; } /** * Schdules css, js for loading when WP is ready. */ function audiomack_load_assets() { $suffix = audiomack_get_asset_suffix(); wp_enqueue_script('jquery'); //Access the global $wp_version variable to see which version of WordPress is installed. global $wp_version; $color_picker = version_compare($wp_version, '3.5') >= 0 ? 'wp-color-picker' // new WP : 'farbtastic'; // old WP wp_enqueue_style($color_picker); wp_enqueue_script($color_picker); wp_register_style('audiomack_css', plugins_url("/assets/main{$suffix}.css", __FILE__)); wp_enqueue_style('audiomack_css'); wp_register_script('audiomack_js', plugins_url("/assets/main{$suffix}.js", __FILE__), array('jquery',), '1.0', true); wp_enqueue_script('audiomack_js'); } /** * Adds the menu under Settings > Audiomack */ function audiomack_create_menu() { //create a submenu under Settings add_options_page('Audiomack', 'Audiomack', 'manage_options', __FILE__, 'audiomack_settings_page'); // when plugins are shown add a settings link near my plugin for a quick access to the settings page. add_filter('plugin_action_links', 'audiomack_add_plugin_settings_link', 10, 2); } // Add the ? settings link in Plugins page very good function audiomack_add_plugin_settings_link($links, $file) { if ($file == plugin_basename(__FILE__)) { $link = admin_url('options-general.php?page=' . plugin_basename(__FILE__)); $dashboard_link = "Settings"; array_unshift($links, $dashboard_link); } return $links; } /** * Loads the options for the current plugin. If the some variables do not exist * defaults will be used instead. * * @params void * @return array */ function audiomack_get_options() { $defaults = array( 'width' => '100%', 'player_color' => 'fc881e', 'background_color' => 'f2f2f2', 'text_color' => '222222', 'slim' => '', // for songs only ); // if you change the key update the uninstall.php too $current_options = get_option('audiomack_options', $defaults); $current_options = array_merge($defaults, $current_options); return $current_options; } /** * Saving options. Options are passed in an array. They should have been * filtered and cleaned already. * * @param array $opts * @return array */ function audiomack_set_options($opts) { // let's do some cleanup foreach ($opts as $key => $value) { $value = wp_kses($value, array()); $value = trim($value); $opts[$key] = $value; } // this is a checkbox so if no value is passed we'll assume it's unchecked. $opts['slim'] = empty($opts['slim']) ? 0 : 1; update_option('audiomack_options', $opts); return $opts; } // Generates Options for the plugin function audiomack_settings_page() { $saved = 0; $current_options = audiomack_get_options(); if (!empty($_POST)) { // this is a checkbox so if no value is passed we'll assume it's unchecked. $current_options['slim'] = empty($_REQUEST['slim']) ? 0 : 1; $current_options_keys = array_keys($current_options); foreach ($_REQUEST as $key => $value) { // Is the current variable expected (part of options array) ? if (in_array($key, $current_options_keys)) { $value = wp_kses($value, array()); $value = trim($value); // Are we processing a color field? We need hex color if (strpos($key, 'color') !== false) { $value = preg_replace('#[^a-z0-9]#si', '', $value); // clean up non alpha nums // if nothing is left then the user is being lazy and didn't enter the color // correctly so we'll skip it. if (empty($value)) { continue; } } elseif ($key == 'width') { // this could be 100% or 250 $value = preg_replace('#[^0-9%]#si', '', $value); $value = empty($value) ? '100%' : $value; } $current_options[$key] = $value; } } $current_options = audiomack_set_options($current_options); $saved = 1; } ?>

Audiomack

This plugin allows you to embed a song or an album from Audiomack on your site.

Settings were saved.

   e.g. 100% or 250 (← in pixels)
/>

Usage

You can use the plugin in several ways.
1. Click on this icon: in edit post/page
OR
2. Paste the shortcodes below with src attribute pointing to a song or an album. The plugin will generate the necessary embed code.

[audiomack src="http://www.audiomack.com/song/nas/let-nas-down-remix-feat-nas"] ← This will generate the embed code for a song
[audiomack src="http://www.audiomack.com/album/tutankhamun-brothers/whats-a-black-beatle"] ← This will generate the embed code for an album

Support & Feature Requests

If you have suggestions or run into an issue please email us at support@audiomack.com

Video Demo

Social Media

Share


= 3.9; return $wp_3_9_plus ? 1 : 0; } /** * This is triggered by editor_plugin.min.js and WP proxies the ajax calls to this action. * * @return void */ function audiomack_ajax_render_popup_content() { // check for rights if (!is_user_logged_in()) { wp_die(__("You must be logged in order to use this plugin.")); } $site_url = site_url(); ?> Audiomack

You can paste the web link to an album or song and this window will generate the shortcode for you.

Example: http://www.audiomack.com/song/nas/let-nas-down-remix-feat-nas
Example: http://www.audiomack.com/album/tutankhamun-brothers/whats-a-black-beatle
" onclick="audiomack.handle_regular_embed();" />
" onclick="audiomack.close();" />

Search for an album or song. Type a keyword.

" onclick="audiomack.search();" />
Example: moses rockwell