Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.