I'm learning hooks and filters recently; I understand the basics and, using a test wordpress installation and an interesting plugin (for volunteer signup sheets), I have gotten several "add filters" to work properly in the functions.php of a child theme.
Now I am trying to change the wording of some of the headers generated by the plugin, but just can't understand the plugin code so that I can setup the proper "add filter". Hoping someone could give me a short explanation of what is going on here:
$return .= apply_filters( 'pta_sus_before_user_signups_list_headers', '' );
$return .= '<h3 class="pta-sus user-heading">'.apply_filters( 'pta_sus_public_output', __('You have signed up for the following', 'pta_volunteer_sus'), 'user_signups_list_headers_h3' ).'</h3>';
$return .= '<h4 class="pta-sus user-heading">'.apply_filters( 'pta_sus_public_output', __('Click on Clear to remove yourself from a signup.', 'pta_volunteer_sus'), 'user_signups_list_headers_h4' ).'</h4>';
$return .= apply_filters( 'pta_sus_before_user_signups_list_table', '' );
The goal is to change the words "Click on Clear..." to something else. I've tried many different versions of add_filter(), but nothing happens or sometimes the wordpress installation stops working until I remove the offending code from the child functions.php.
Thanks for any help in advance.
Zimbu
Update:
I just dug up some random info on the internet from the plugin author where he/she explains roughly what is going on here:
"You can scan the code in the class-pta_sus_public.php file to see those filters that have the filter hook ‘pta_sus_public_output’, with 2 variables pass to the filter: the first being the original text string, and the second being an identifier key string to let you know which specific text string is being output (so you only modify the one you want to change)."
Now I just have to figure out what that means!
Update2:
Figured it out from something written in the support forum for the plugin. To add a filter to the h4 element, i.e. to change the text that gets displayed in the h4 text section, I added the following to the child functions.php file:
add_filter( 'pta_sus_public_output', 'function_to_change_user_signups_list_headers_h4');
function function_to_change_user_signups_list_headers_h4( $text ) {
$text = str_replace(
array( 'Click on Clear to remove yourself from a signup.' ),
array( 'Sorry you can not clear' ),
$text
);
return $text;
}