public function widget($args, $instance)
 {
     echo $args['before_widget'];
     echo $args['before_title'];
     echo apply_filters('widget_title', $instance['title']);
     echo $args['after_title'];
     echo '<form method="post">';
     echo '<p>' . stripslashes(get_option('poll_question')) . '</p>';
     // Si l'utilisateur n'a jamais voté : on affiche le sondage
     if (!isset($_COOKIE['vote'])) {
         $options = Poll_Plugin::get_poll_options();
         if ($options) {
             foreach ($options as $id => $label) {
                 echo '<input type="radio" name="sondage" value="' . $id . '" />' . $label . '<br />';
             }
             echo '<input type="submit" value="Envoyer" />';
         } else {
             echo '<p>Aucune réponse à afficher</p>';
         }
         // Si l'utilisateur a déjà voté : on affiche les résultats des votes
     } else {
         $votes = Poll_Plugin::get_votes();
         if ($votes) {
             echo '<p>Résultats :</p>';
             foreach ($votes as $label => $total) {
                 echo '<p>' . $label . ' : ' . $total . ' vote(s)</p>';
             }
         } else {
             echo '<p>Aucune réponse à afficher</p>';
         }
     }
     echo '</form>';
     echo $args['after_widget'];
 }
Exemple #2
0
<?php

if (Poll_Plugin::isInstalled() && Poll_Question::hasCurrent()) {
    ?>
    <div class="page-header">
        <h3><?php 
    echo $this->input('page-header');
    ?>
</h3>
    </div>
    <?php 
    echo $this->action('current', 'frontend', 'Poll', array('omitJquery' => false, 'omitJqueryUi' => false, 'omitStyles' => false));
}