lesterchan / wp-polls

Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
https://wordpress.org/plugins/wp-polls/
91 stars 78 forks source link

Adds filters for result templates #139

Closed Jaska closed 4 years ago

Jaska commented 4 years ago

With this commit, there are 8 filters to modify templates with php: wp_polls_template_voteheader_markup wp_polls_template_votebody_markup wp_polls_template_votefooter_markup wp_polls_template_resultheader_markup (new) wp_polls_template_resultbody_markup (new) wp_polls_template_resultbody2_markup (new) wp_polls_template_resultfooter_markup (new) wp_polls_template_resultfooter2_markup (new)

Usage:

add_filter('wp_polls_template_resultbody2_markup', 'my_poll_result_header', 10, 3);

function my_poll_result_header($template, $object, $variables){
    $template = '<b>My custom template!</b>'.$template;
    return str_replace( array_keys( $variables ), array_values( $variables ), $template );
}

I'm not 100% sure the $object parameter is the correct one with these new filters.

lesterchan commented 4 years ago

I think the $object is fine. It is not in used in the core functions =D