PluginProbe
Survey Maker by AYS / 5.2.3.9
Survey Maker by AYS v5.2.3.9
5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 5.2.0.9 All 153 releases
survey-maker / pb_templates / survey-maker-elementor.php

survey-maker-elementor.php in Survey Maker by AYS 5.2.3.9, at pb_templates/survey-maker-elementor.php

134 lines 4.8 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_Survey_Maker_Elementor extends Widget_Base {
5 public function get_name() {
6 return 'survey-maker';
7 }
8
9 public function get_title() {
10 return __( 'Survey Maker', 'survey-maker' );
11 }
12
13 public function get_icon() {
14 return 'survey-elementor-widget-logo';
15 }
16
17 public function get_categories() {
18 return array( 'wordpress' );
19 }
20 protected function _register_controls() {
21 $this->start_controls_section(
22 'section_survey_maker',
23 array(
24 'label' => esc_html__( 'Survey Maker', 'survey-maker' ),
25 )
26 );
27 $this->add_control(
28 'important_note',
29 array(
30 'label' => '',
31 'type' => \Elementor\Controls_Manager::RAW_HTML,
32 'raw' => '<i class="survey-elementor-widget-logo"></i> '.esc_html__( 'Survey Maker', 'survey-maker' ),
33 'content_classes' => 'survey-elementor-widget-logo-wrap',
34 )
35 );
36 $this->add_control(
37 'survey_title',
38 array(
39 'label' => __( 'Survey Title', 'survey-maker' ),
40 'type' => Controls_Manager::TEXT,
41 'default' => '',
42 'title' => __( 'Enter the survey title', 'survey-maker' ),
43 'placeholder' => __( 'Enter the survey title', 'survey-maker' ),
44 )
45 );
46 $this->add_control(
47 'survey_title_alignment',
48 array(
49 'label' => __( 'Title Alignment', 'survey-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 'survey_selector',
61 array(
62 'label' => __( 'Select survey', 'survey-maker' ),
63 'type' => Controls_Manager::SELECT,
64 'default' => $this->get_default_survey(),
65 'options' => $this->get_active_surveys()
66 )
67 );
68
69 $this->end_controls_section();
70 }
71
72 protected function render( $instance = array() ) {
73
74 if ( ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
75 echo '<style>
76 .ays-survey-container .ays-survey-section:first-of-type {
77 display: block!important;
78 }
79
80 .ays-survey-container .ays-survey-section-footer,
81 .ays-survey-container .ays-survey-answer,
82 .ays-survey-container textarea.ays-survey-question-input-textarea,
83 .ays-survey-container select,
84 .ays-survey-container input {
85 pointer-events: none!important;
86 overflow: hidden!important;
87 }
88 </style>';
89 }
90
91 $settings = $this->get_settings_for_display();
92 $h_html = "<h2 style='text-align: {$settings['survey_title_alignment']}'>{$settings['survey_title']}</h2>";
93 $survey_selector = $settings['survey_selector'];
94 echo ( isset( $settings['survey_title'] ) && ! empty( $settings['survey_title'] ) ) ? html_entity_decode(esc_html( $h_html )) : "";
95 echo do_shortcode("[ays_survey id=".esc_attr($survey_selector)."]");
96
97 }
98
99 public function get_active_surveys(){
100 global $wpdb;
101 $current_user = get_current_user_id();
102 $surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . 'surveys';
103 $sql = "SELECT id,title FROM {$surveys_table} WHERE status='published'";
104 if( ! current_user_can( 'manage_options' ) ){
105 $sql .= " AND author_id = ". absint( $current_user ) ." ";
106 }
107 $sql .= " ORDER BY id DESC";
108 $results = $wpdb->get_results( $sql, ARRAY_A );
109 $options = array();
110 foreach ( $results as $result ){
111 $options[$result['id']] = $result['title'];
112 }
113 return $options;
114 }
115
116 public function get_default_survey(){
117 global $wpdb;
118 $current_user = get_current_user_id();
119 $surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . 'surveys';
120 $sql = "SELECT id FROM {$surveys_table} WHERE status='published'";
121 if( ! current_user_can( 'manage_options' ) ){
122 $sql .= " AND author_id = ". absint( $current_user ) ." ";
123 }
124 $sql .= " LIMIT 1;";
125 $id = $wpdb->get_var( $sql );
126
127 return intval($id);
128 }
129
130 protected function content_template() {}
131
132 public function render_plain_content( $instance = array() ) {}
133 }
134