Commit 9500797c authored by Timi-Artturi Mäkelä's avatar Timi-Artturi Mäkelä
Browse files

Variables filters and changelog

parent 89360782
......@@ -24,6 +24,10 @@ WP-Polls is extremely customizable via templates and css styles and there are to
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
## Changelog
### Version 2.75.6
* NEW: New filter for template variables: wp_polls_template_resultheader_variables, wp_polls_template_resultbody_variables, wp_polls_template_resultfooter_variables, wp_polls_template_resultfooter2_variables. These can be used to register new variables on the admin side.
### Version 2.75.5
* NEW: New filter for templates: wp_polls_template_resultheader_markup, wp_polls_template_resultbody_markup, wp_polls_template_resultbody2_markup, wp_polls_template_resultfooter_markup, wp_polls_template_resultfooter2_markup. Props @Jaska.
......
......@@ -445,15 +445,18 @@ function display_pollvote($poll_id, $display_loading = true) {
$template_question = removeslashes(get_option('poll_template_voteheader'));
$template_question = apply_filters( 'wp_polls_template_voteheader_markup', $template_question, $poll_question, array(
'%POLL_QUESTION%' => $poll_question_text,
'%POLL_ID%' => $poll_question_id,
'%POLL_TOTALVOTES%' => $poll_question_totalvotes,
'%POLL_TOTALVOTERS%' => $poll_question_totalvoters,
'%POLL_START_DATE%' => $poll_start_date,
'%POLL_END_DATE%' => $poll_end_date,
'%POLL_MULTIPLE_ANS_MAX%' => $poll_multiple_ans > 0 ? $poll_multiple_ans : 1
) );
$template_question_variables = array(
'%POLL_QUESTION%' => $poll_question_text,
'%POLL_ID%' => $poll_question_id,
'%POLL_TOTALVOTES%' => $poll_question_totalvotes,
'%POLL_TOTALVOTERS%' => $poll_question_totalvoters,
'%POLL_START_DATE%' => $poll_start_date,
'%POLL_END_DATE%' => $poll_end_date,
'%POLL_MULTIPLE_ANS_MAX%' => $poll_multiple_ans > 0 ? $poll_multiple_ans : 1
);
$template_question_variables = apply_filters( 'wp_polls_template_voteheader_variables', $template_question_variables );
$template_question = apply_filters( 'wp_polls_template_voteheader_markup', $template_question, $poll_question, $template_question_variables );
// Get Poll Answers Data
list($order_by, $sort_order) = _polls_get_ans_sort();
......@@ -479,15 +482,18 @@ function display_pollvote($poll_id, $display_loading = true) {
$poll_multiple_answer_percentage = $poll_question_totalvoters > 0 ? round( ( $poll_answer_votes / $poll_question_totalvoters ) * 100 ) : 0;
$template_answer = removeslashes( get_option( 'poll_template_votebody' ) );
$template_answer = apply_filters( 'wp_polls_template_votebody_markup', $template_answer, $poll_answer, array(
'%POLL_ID%' => $poll_question_id,
'%POLL_ANSWER_ID%' => $poll_answer_id,
'%POLL_ANSWER%' => $poll_answer_text,
'%POLL_ANSWER_VOTES%' => number_format_i18n( $poll_answer_votes ),
'%POLL_ANSWER_PERCENTAGE%' => $poll_answer_percentage,
$template_answer_variables = array(
'%POLL_ID%' => $poll_question_id,
'%POLL_ANSWER_ID%' => $poll_answer_id,
'%POLL_ANSWER%' => $poll_answer_text,
'%POLL_ANSWER_VOTES%' => number_format_i18n( $poll_answer_votes ),
'%POLL_ANSWER_PERCENTAGE%' => $poll_answer_percentage,
'%POLL_MULTIPLE_ANSWER_PERCENTAGE%' => $poll_multiple_answer_percentage,
'%POLL_CHECKBOX_RADIO%' => $poll_multiple_ans > 0 ? 'checkbox' : 'radio'
) );
'%POLL_CHECKBOX_RADIO%' => $poll_multiple_ans > 0 ? 'checkbox' : 'radio',
);
$template_answer_variables = apply_filters( 'wp_polls_template_votebody_variables', $template_answer_variables );
$template_answer = apply_filters( 'wp_polls_template_votebody_markup', $template_answer, $poll_answer, $template_answer_variables );
// Print Out Voting Form Body Template
$temp_pollvote .= "\t\t$template_answer\n";
......@@ -505,13 +511,16 @@ function display_pollvote($poll_id, $display_loading = true) {
// Voting Form Footer Variables
$template_footer = removeslashes(get_option('poll_template_votefooter'));
$template_footer = apply_filters( 'wp_polls_template_votefooter_markup', $template_footer, $poll_question, array(
$template_footer_variables = array(
'%POLL_ID%' => $poll_question_id,
'%POLL_RESULT_URL%' => $poll_result_url,
'%POLL_START_DATE%' => $poll_start_date,
'%POLL_END_DATE%' => $poll_end_date,
'%POLL_MULTIPLE_ANS_MAX%' => $poll_multiple_ans > 0 ? $poll_multiple_ans : 1
) );
);
$template_footer_variables = apply_filters( 'wp_polls_template_votefooter_variables', $template_footer_variables );
$template_footer = apply_filters( 'wp_polls_template_votefooter_markup', $template_footer, $poll_question, $template_footer_variables );
// Print Out Voting Form Footer Template
$temp_pollvote .= "\t\t$template_footer\n";
......@@ -585,7 +594,8 @@ function display_pollresult( $poll_id, $user_voted = array(), $display_loading =
'%POLL_END_DATE%' => $poll_end_date
);
$template_question = apply_filters('wp_polls_template_resultheader_markup', $template_question, $poll_question, $template_variables);
$template_variables = apply_filters('wp_polls_template_resultheader_variables', $template_variables );
$template_question = apply_filters('wp_polls_template_resultheader_markup', $template_question, $poll_question, $template_variables );
if($poll_multiple_ans > 0) {
$template_question = str_replace( '%POLL_MULTIPLE_ANS_MAX%', $poll_multiple_ans, $template_question );
......@@ -645,6 +655,8 @@ function display_pollresult( $poll_id, $user_voted = array(), $display_loading =
'%POLL_MULTIPLE_ANSWER_PERCENTAGE%' => $poll_multiple_answer_percentage,
'%POLL_ANSWER_IMAGEWIDTH%' => $poll_answer_imagewidth
);
$template_variables = apply_filters('wp_polls_template_resultbody_variables', $template_variables);
// Let User See What Options They Voted
if ( in_array( $poll_answer_id, $user_voted, true ) ) {
// Results Body Variables
......@@ -689,6 +701,8 @@ function display_pollresult( $poll_id, $user_voted = array(), $display_loading =
'%POLL_LEAST_VOTES%' => number_format_i18n( $poll_least_votes ),
'%POLL_LEAST_PERCENTAGE%' => $poll_least_percentage
);
$template_variables = apply_filters('wp_polls_template_resultfooter_variables', $template_variables );
if ( ! empty( $user_voted ) || $poll_question_active === 0 || ! check_allowtovote() ) {
$template_footer = removeslashes( get_option( 'poll_template_resultfooter' ) );
$template_footer = apply_filters('wp_polls_template_resultfooter_markup', $template_footer, $poll_question, $template_variables);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment