PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.4.9
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.4.9
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 / pb_templates / poll_maker_elementor.php

poll_maker_elementor.php in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 6.4.9, at pb_templates/poll_maker_elementor.php

100 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4 class Widget_Poll_Maker_Elementor extends Widget_Base {
5 /*
6 public function init() {
7
8 // Register Widget Styles
9 add_action( 'elementor/frontend/after_enqueue_styles', array( $this, 'widget_styles' ) );
10
11 }*/
12
13 public function get_name() {
14 return 'poll-maker';
15 }
16 public function get_title() {
17 return esc_html__( 'Poll Maker', 'poll-maker' );
18 }
19 public function get_icon() {
20 // Icon name from the Elementor font file, as per http://dtbaker.net/web-development/creating-your-own-custom-elementor-widgets/
21 // return 'fas fa-poll ays_fa_poll';
22 return 'ays_fa_power_off_poll';
23 }
24 public function get_categories() {
25 return array( 'general' );
26 }
27
28 protected function _register_controls() {
29 $this->start_controls_section(
30 'section_poll_maker',
31 array(
32 'label' => esc_html__( 'Poll Maker', 'poll-maker' ),
33 )
34 );
35
36 $this->add_control(
37 'poll_title',
38 array(
39 'label' =>esc_html__( 'Poll Title', 'poll-maker' ),
40 'type' => Controls_Manager::TEXT,
41 'default' => '',
42 'title' =>esc_html__( 'Enter the poll title', 'poll-maker' ),
43 'placeholder' =>esc_html__( 'Enter the poll title', 'poll-maker' ),
44 )
45 );
46 $this->add_control(
47 'poll_title_alignment',
48 array(
49 'label' =>esc_html__( 'Title Alignment', 'poll-maker' ),
50 'type' => Controls_Manager::SELECT,
51 'default' => 'left',
52 'options' => array(
53 'left' => 'Left',
54 'right' => 'Right',
55 'center' => 'Center'
56 )
57 )
58 );
59 $this->add_control(
60 'poll_selector',
61 array(
62 'label' =>esc_html__( 'Select Poll', 'poll-maker' ),
63 'type' => Controls_Manager::SELECT,
64 'default' => $this->get_default_poll(),
65 'options' => $this->get_active_polls()
66 )
67 );
68
69 $this->end_controls_section();
70 }
71 protected function render( $instance = array() ) {
72 $settings = $this->get_settings_for_display();
73 echo ( isset( $settings['poll_title'] ) && ! empty( $settings['poll_title'] ) ) ? "<h2 style='text-align: ". esc_attr( $settings['poll_title_alignment'] ) ."'>". esc_html($settings['poll_title']) ."</h2>" : "";
74 echo do_shortcode("[ays_poll id=". esc_attr( $settings['poll_selector'] ) ."]");
75 }
76
77 public function get_active_polls(){
78 global $wpdb;
79 $polls_table = esc_sql($wpdb->prefix . 'ayspoll_polls');
80 $sql = "SELECT id,title FROM ".$polls_table;
81 $results = $wpdb->get_results( $sql, ARRAY_A );
82 $options = array();
83 foreach ( $results as $result ){
84 $options[$result['id']] = $result['title'];
85 }
86 return $options;
87 }
88
89 public function get_default_poll(){
90 global $wpdb;
91 $polls_table = esc_sql($wpdb->prefix . 'ayspoll_polls');
92 $sql = "SELECT id FROM ".$polls_table;
93 $id = $wpdb->get_var( $sql );
94
95 return intval($id);
96 }
97
98 protected function content_template() {}
99 public function render_plain_content( $instance = array() ) {}
100 }