Last active
January 24, 2017 20:42
-
-
Save X-Raym/5c388e6554b30ca6a56646fb8d96d17f to your computer and use it in GitHub Desktop.
WaveSurfer-WP filters exemples. Required v2.6.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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