PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.3.3
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.3.3
6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 All 152 releases
poll-maker / widgets / poll-maker-ays-widget.php

poll-maker-ays-widget.php in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 6.3.3, at widgets/poll-maker-ays-widget.php

67 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'AYS_POLL_URL' ) ) {
3 define( 'AYS_POLL_URL', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
4 }
5
6 class Poll_Maker_Widget extends WP_Widget {
7 private $plugin_name;
8 public $poll_maker_ays;
9
10 public function __construct() {
11 $this->plugin_name = POLL_MAKER_AYS_NAME;
12 $widget_ops = array(
13 'classname' => 'poll_maker_ays',
14 'description' => 'Poll Maker Widget',
15 );
16 parent::__construct( 'poll_maker_ays', 'Poll Maker Widget', $widget_ops );
17 }
18
19 function form( $instance ) {
20
21 // Check values
22 if ( $instance ) {
23 $poll_id = esc_attr( $instance['poll_maker_ays_id'] );
24 } else {
25 $poll_id = 0;
26 }
27 global $wpdb;
28 $poll_table = esc_sql($wpdb->prefix."ayspoll_polls");
29 $polls = $wpdb->get_results( "SELECT * FROM ".$poll_table, 'ARRAY_A' );
30
31 ?>
32 <p>
33 <select class="widefat" id="<?php echo $this->get_field_id( 'ays-polls' ); ?>"
34 name="<?php echo $this->get_field_name( 'poll_maker_ays_id' ); ?>">
35 <option value="0" selected disabled>Select poll</option>
36 <?php
37 foreach ( $polls as $poll ) { ?>
38 <option value="<?php echo $poll['id']; ?>" <?php echo $poll['id'] == $poll_id ? "selected" : ""; ?> >
39 <?php echo $poll['title']; ?>
40 </option>
41 <?php }
42 ?>
43 </select>
44 </p>
45 <?php
46 }
47
48 function update( $new_instance, $old_instance ) {
49 $instance = $old_instance;
50 // Fields
51 if(isset($new_instance['poll_maker_ays_id'])){
52 $instance['poll_maker_ays_id'] = absint( $new_instance['poll_maker_ays_id'] );
53 }
54
55 return $instance;
56 }
57
58 function widget( $args, $instance ) {
59
60 $id = $instance['poll_maker_ays_id'];
61
62 echo $args['before_widget'];
63 echo do_shortcode("[ays_poll id='".$id."']");
64 echo $args['after_widget'];
65 }
66
67 }