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
ajax-polling lesterchan polls wordpress wordpress-plugin wp-polls

WP-Polls

Contributors: GamerZ
Donate link: https://lesterchan.net/site/donation/
Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
Requires at least: 4.9.6
Tested up to: 6.3
Stable tag: 2.77.2

Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.

Description

WP-Polls is extremely customizable via templates and css styles and there are tons of options for you to choose to ensure that WP-Polls runs the way you wanted. It now supports multiple selection of answers.

Development

https://github.com/lesterchan/wp-polls

Credits

Donations

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.77.2

Version 2.77.1

Version 2.77.0

Version 2.76.0

Version 2.75.6

Version 2.75.5

Version 2.75.4

Version 2.75.3

Versiob 2.75.2

Version 2.75.1

Version 2.75

Version 2.74.1

Version 2.74

Version 2.73.8

Version 2.73.7

Version 2.73.6

Version 2.73.5

Version 2.73.4

Version 2.73.3

Version 2.73.2

Version 2.73.1

Version 2.73

Version 2.72

Version 2.71

Version 2.70

Screenshots

  1. Admin - All Poll
  2. Admin - Manage Polls
  3. Admin - Poll Options
  4. Admin - Poll Templates
  5. Admin - Poll Widget
  6. Admin - Uninstall Poll
  7. Poll - Single Poll Answer
  8. Poll - Mutiple Poll Answers
  9. Poll - Results
  10. Poll - Archive

Frequently Asked Questions

General Usage (Without Widget)

<?php if ( function_exists( 'vote_poll' ) && ! in_pollarchive() ): ?>
    <li>
        <h2>Polls</h2>
        <ul>
            <li><?php get_poll();?></li>
        </ul>
        <?php display_polls_archive_link(); ?>
    </li>
<?php endif; ?>

General Usage (With Widget)

  1. Go to WP-Admin -> Appearance -> Widgets.
  2. You can add the Polls Widget by clicking on the 'Add' link besides it.
  3. After adding, you can configure the Polls Widget by clicking on the 'Edit' link besides it.
  4. Click 'Save Changes'.
  5. Scroll down for instructions on how to create a Polls Archive.

How To Add A Polls Archive?

  1. Go to WP-Admin -> Pages -> Add New.
  2. Type any title you like in the post's title area.
  3. If you ARE using nice permalinks, after typing the title, WordPress will generate the permalink to the page. You will see an 'Edit' link just beside the permalink.
  4. Click 'Edit' and type in pollsarchive in the text field and click 'Save'.
  5. Type [page_polls] in the post's content area.
  6. Click 'Publish'.

Why doesn't my poll's answers add up to 100%?

How Does WP-Polls Load CSS?

Why In Internet Explorer (IE) The poll's Text Appear Jagged?

How Do I Have Individual Colors For Each Poll's Bar?

.wp-polls-ul li:nth-child(01) .pollbar{ background:#8FA0C5}
.wp-polls-ul li:nth-child(02) .pollbar{ background:#FF8}
.wp-polls-ul li:nth-child(03) .pollbar{ background:#ff8a3b}
.wp-polls-ul li:nth-child(04) .pollbar{ background:#a61e2a}
.wp-polls-ul li:nth-child(05) .pollbar{ background:#4ebbff}
.wp-polls-ul li:nth-child(06) .pollbar{ background:#fbca54}
.wp-polls-ul li:nth-child(07) .pollbar{ background:#aad34f}
.wp-polls-ul li:nth-child(08) .pollbar{ background:#66cc9a}
.wp-polls-ul li:nth-child(09) .pollbar{ background:#98CBCB}
.wp-polls-ul li:nth-child(10) .pollbar{ background:#a67c52}
.wp-polls-ul li .pollbar{ transition: background 0.7s ease-in-out }
.wp-polls-ul li .pollbar:hover{ background:#F00 }

To Display Total Polls

<?php if ( function_exists( 'get_pollquestions' ) ): ?>
    <?php get_pollquestions(); ?>
<?php endif; ?> 

To Display Total Poll Answers

<?php if ( function_exists( 'get_pollanswers' ) ): ?>
    <?php get_pollanswers(); ?>
<?php endif; ?> 

To Display Total Poll Votes

<?php if ( function_exists( 'get_pollvotes' ) ): ?>
    <?php get_pollvotes(); ?>
<?php endif; ?> 

To Display Poll Votes by ID

<?php if ( function_exists( 'get_pollvotes_by_id' ) ): ?>
    <?php get_pollvotes_by_id($poll_id); ?>
<?php endif; ?>

To Display Total Poll Voters

<?php if ( function_exists( 'get_pollvoters' ) ): ?>
    <?php get_pollvoters(); ?>
<?php endif; ?> 

To Display Poll Time by ID and date format

<?php if ( function_exists( 'get_polltime' ) ): ?>
    <?php get_polltime( $poll_id, $date_format ); ?>
<?php endif; ?>

Translating the template

The plugin templates can be translated via template variables. There are these filters for the custom template variables

wp_polls_template_votebody_variables
wp_polls_template_votefooter
wp_polls_template_resultheader_variables
wp_polls_template_resultbody_variables
wp_polls_template_resultfooter_variables

Add filter to your theme and register custom variable where you will add your translation. Good practice is to name them for example with prefix STR_ in the example STR_TOTAL_VOTERS.

    /**
     * Localize wp_polls_template_resultfooter_variables.
     *
     * @param array $variables An array of template variables.
     * @return array $variables Modified template variables.
     */
    function wp_polls_template_resultfooter_variables( $variables ) {

        // Add strings.
        $variables['%STR_TOTAL_VOTERS%'] = __( 'Total voters', 'theme-textdomain' );

        return $variables;
    }

// Trigger the filter
add_filter( 'wp_polls_template_resultfooter_variables', 'wp_polls_template_resultfooter_variables' , 10, 1 );

In the admin side just call the custom variable like so and the variable has been translated in the front-end. %STR_TOTAL_VOTERS%'