Skip to content

Instantly share code, notes, and snippets.

@X-Raym
Last active January 24, 2017 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save X-Raym/5c388e6554b30ca6a56646fb8d96d17f to your computer and use it in GitHub Desktop.
Save X-Raym/5c388e6554b30ca6a56646fb8d96d17f to your computer and use it in GitHub Desktop.
WaveSurfer-WP filters exemples. Required v2.6.
<?php
/**
* Plugin Name: WaveSurfer-WP Custom Functions
* Description: Custom functions for WaveSurfer-WP
*/
//------------------------------- CONDITIONAL SHORTCODE ATTRIBUTES -------------------------------------
// Add shortcode attributes
add_filter( 'wavesurfer_wp_shortcode_attributes', 'add_data_shortcodes_attributes', 10, 2 );
function add_data_shortcodes_attributes( $attr, $player ) {
if ( $player === 'audio' || $player === 'playlist' ) { // Choose both, or erase conditions if not needed. You can also write your own, based on page ID, post type etc...
$attr['loop_button'] = 'true'; // This will add loop button. See WaveSurfer-WP WordPress doc for list of all attributes.
$attr['download_button'] = 'true'; // This will add download button. See WaveSurfer-WP WordPress doc for list of all attributes.
}
return $attr;
}
//-------------------------------- ADDITIONAL DATA ON MARKUP --------------------------------------------
// Add waveform custom data attribute
add_filter( 'wavesurfer_wp_shortcode_data', 'add_data_shortcodes_infos', 10, 3 );
function add_data_shortcodes_infos( $empty, $link, $split ) {
// Add conditions if needed.
$value = 'value';
return ' data-attribute="' . $value . '"';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment