PluginProbe
Survey Maker by AYS / 5.2.3.0
Survey Maker by AYS v5.2.3.0
5.2.4.1 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 All 154 releases
survey-maker / public / class-survey-maker-public.php

class-survey-maker-public.php in Survey Maker by AYS 5.2.3.0, at public/class-survey-maker-public.php

4,456 lines 271.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The public-facing functionality of the plugin.
5 *
6 * @link https://ays-pro.com/
7 * @since 1.0.0
8 *
9 * @package Survey_Maker
10 * @subpackage Survey_Maker/public
11 */
12
13 /**
14 * The public-facing functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the public-facing stylesheet and JavaScript.
18 *
19 * @package Survey_Maker
20 * @subpackage Survey_Maker/public
21 * @author Survey Maker team <[email protected]>
22 */
23 class Survey_Maker_Public {
24
25 /**
26 * The ID of this plugin.
27 *
28 * @since 1.0.0
29 * @access private
30 * @var string $plugin_name The ID of this plugin.
31 */
32 private $plugin_name;
33
34 /**
35 * The version of this plugin.
36 *
37 * @since 1.0.0
38 * @access private
39 * @var string $version The current version of this plugin.
40 */
41 private $version;
42
43 private $html_class_prefix = 'ays-survey-';
44 private $html_name_prefix = 'ays-survey-';
45 private $name_prefix = 'survey_';
46 private $unique_id;
47 private $unique_id_in_class;
48 private $options;
49 private $settings;
50 protected $default_texts;
51 private $buttons_texts;
52 private $lazy_loading;
53 private $message_variable_data;
54
55 /**
56 * Initialize the class and set its properties.
57 *
58 * @since 1.0.0
59 * @param string $plugin_name The name of the plugin.
60 * @param string $version The version of this plugin.
61 */
62 public function __construct( $plugin_name, $version ) {
63
64 $this->plugin_name = $plugin_name;
65 $this->version = $version;
66 $this->settings = new Survey_Maker_Settings_Actions($this->plugin_name);
67
68 add_shortcode('ays_survey', array($this, 'ays_generate_survey_method'));
69 add_shortcode('ays_survey_popup', array($this, 'ays_generate_survey_popup_method'));
70 }
71
72 /**
73 * Register the stylesheets for the public-facing side of the site.
74 *
75 * @since 1.0.0
76 */
77 public function enqueue_styles() {
78
79 /**
80 * This function is provided for demonstration purposes only.
81 *
82 * An instance of this class should be passed to the run() function
83 * defined in Survey_Maker_Loader as all of the hooks are defined
84 * in that particular class.
85 *
86 * The Survey_Maker_Loader will then create the relationship
87 * between the defined hooks and the functions defined in this
88 * class.
89 */
90
91 wp_enqueue_style( $this->plugin_name . "-font-awesome", plugin_dir_url( __FILE__ ) . 'css/survey-maker-font-awesome.min.css', array(), $this->version, 'all' );
92 wp_enqueue_style( $this->plugin_name . "-transition", plugin_dir_url( __FILE__ ) . 'css/transition.min.css', array(), $this->version, 'all' );
93 wp_enqueue_style( $this->plugin_name . "-dropdown", plugin_dir_url( __FILE__ ) . 'css/dropdown.min.css', array(), $this->version, 'all' );
94 wp_enqueue_style( $this->plugin_name . '-select2', plugin_dir_url(__FILE__) . 'css/survey-maker-select2.min.css', array(), $this->version, 'all');
95 wp_enqueue_style( $this->plugin_name . "-loaders", plugin_dir_url( __FILE__ ) . 'css/loaders.css', array(), $this->version, 'all' );
96 wp_enqueue_style( $this->plugin_name . '-timepicker', plugin_dir_url( __FILE__ ) . '/css/survey-maker-timepicker.css', array(), $this->version, 'all');
97
98 }
99
100 public function enqueue_styles_early(){
101 wp_enqueue_style( $this->plugin_name . '-min', plugin_dir_url( __FILE__ ) . 'css/survey-maker-public-min.css', array(), $this->version, 'all' );
102 }
103
104 /**
105 * Register the JavaScript for the public-facing side of the site.
106 *
107 * @since 1.0.0
108 */
109 public function enqueue_scripts() {
110
111 /**
112 * This function is provided for demonstration purposes only.
113 *
114 * An instance of this class should be passed to the run() function
115 * defined in Survey_Maker_Loader as all of the hooks are defined
116 * in that particular class.
117 *
118 * The Survey_Maker_Loader will then create the relationship
119 * between the defined hooks and the functions defined in this
120 * class.
121 */
122 $is_elementor_exists = Survey_Maker_Data::ays_survey_is_elementor();
123 if( !$is_elementor_exists ){
124 wp_enqueue_script( $this->plugin_name . '-autosize', plugin_dir_url( __FILE__ ) . 'js/survey-maker-autosize.js', array( 'jquery' ), $this->version, false );
125 wp_enqueue_script( $this->plugin_name . '-transition', plugin_dir_url( __FILE__ ) . 'js/transition.min.js', array( 'jquery' ), $this->version, false );
126 wp_enqueue_script( $this->plugin_name . '-dropdown', plugin_dir_url( __FILE__ ) . 'js/dropdown.min.js', array( 'jquery' ), $this->version, false );
127 wp_enqueue_script( $this->plugin_name . '-select2js', plugin_dir_url(__FILE__) . 'js/survey-maker-select2.min.js', array('jquery'), $this->version, false);
128 wp_enqueue_script( $this->plugin_name . '-plugin', plugin_dir_url( __FILE__ ) . 'js/survey-maker-public-plugin.js', array( 'jquery' ), $this->version, false );
129 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/survey-maker-public.js', array( 'jquery' ), $this->version, false );
130 wp_enqueue_script( $this->plugin_name . '-sweetalert-js', SURVEY_MAKER_PUBLIC_URL . '/js/survey-maker-sweetalert2.all.min.js', array('jquery'), $this->version, true );
131 wp_enqueue_script( $this->plugin_name . '-ajax', plugin_dir_url( __FILE__ ) . 'js/survey-maker-public-ajax.js', array( 'jquery' ), $this->version, false );
132 wp_enqueue_script( $this->plugin_name . "-timepicker", plugin_dir_url(__FILE__) . '/js/survey-maker-timepicker.js', array( 'jquery' ), $this->version, false );
133
134 wp_localize_script( $this->plugin_name . '-plugin', 'aysSurveyMakerAjaxPublic', array(
135 'ajaxUrl' => admin_url('admin-ajax.php'),
136 'warningIcon' => SURVEY_MAKER_PUBLIC_URL . "/images/warning.svg",
137 'autofill_nonce' => wp_create_nonce('survey_maker_autofill_nonce')
138 ) );
139 wp_localize_script( $this->plugin_name, 'aysSurveyLangObj', array(
140 'notAnsweredText' => __( 'You have not answered this question', "survey-maker" ),
141 'areYouSure' => __( 'Do you want to finish the quiz? Are you sure?', "survey-maker" ),
142 'sorry' => __( 'Sorry', "survey-maker" ),
143 'unableStoreData' => __( 'We are unable to store your data', "survey-maker" ),
144 'connectionLost' => __( 'Connection is lost', "survey-maker" ),
145 'checkConnection' => __( 'Please check your connection and try again', "survey-maker" ),
146 'selectPlaceholder' => __( 'Select an answer', "survey-maker" ),
147 'shareDialog' => __( 'Share Dialog', "survey-maker" ),
148 'passwordIsWrong' => __( 'Password is wrong!', "survey-maker" ),
149 'choose' => __( 'Choose', "survey-maker" ),
150 'redirectAfter' => $this->default_texts['redirectingAfter'],
151 'emailValidationError' => $this->default_texts['emailValidationError'],
152 'requiredError' => __( 'This is a required question', "survey-maker" ),
153 'minimumVotes' => __( 'Min votes count should be', "survey-maker" ),
154 'maximumVotes' => __( 'Max votes count should be', "survey-maker" ),
155 ) );
156 }
157 }
158
159 public function enqueue_scripts_popups() {
160 wp_enqueue_script( $this->plugin_name . '-popups', plugin_dir_url( __FILE__ ) . 'js/survey-maker-public-popups.js', array( 'jquery' ), $this->version, false );
161 wp_localize_script( $this->plugin_name . '-popups', 'aysSurveyMakerPopupsAjaxPublic', array(
162 'ajaxUrl' => admin_url('admin-ajax.php'),
163 ) );
164 }
165
166 public function ays_survey_ajax(){
167 global $wpdb;
168
169 $results = array(
170 "status" => false
171 );
172 $function = isset($_REQUEST['function']) ? $_REQUEST['function'] : null;
173 if($function !== null){
174 $data = $_REQUEST;
175 $results = array();
176 unset($data['action']);
177 unset($data['function']);
178 switch ($function) {
179 case 'ays_finish_survey':
180 $results = $this->ays_finish_survey( $data );
181 break;
182 case 'ays_survey_get_user_information':
183 $results = $this->ays_survey_get_user_information( $data );
184 break;
185 case 'ays_survey_popup_set_cookie':
186 $results = $this->ays_survey_popup_set_cookie( $data );
187 break;
188 }
189
190 ob_end_clean();
191 $ob_get_clean = ob_get_clean();
192 echo json_encode( $results );
193 wp_die();
194 }
195
196 ob_end_clean();
197 $ob_get_clean = ob_get_clean();
198 echo json_encode( $results );
199 wp_die();
200 }
201
202 public function ays_finish_survey( $data ){
203 $unique_id = isset($data['unique_id']) ? $data['unique_id'] : null;
204 if($unique_id === null){
205 return array("status" => false, "message" => "No no no" );
206 } else {
207 global $wpdb;
208 $name_prefix = 'ays-survey-';
209 $valid_name_prefix = 'survey_';
210 $survey_id = isset( $data[ $name_prefix . 'id-' . $unique_id ] ) ? absint( intval( $data[ $name_prefix . 'id-' . $unique_id ] ) ) : null;
211
212 if($survey_id === null){
213 return array("status" => false, "message" => "No no no" );
214 }else{
215 $survey = Survey_Maker_Data::get_survey_by_id( $survey_id );
216
217 $user_id = get_current_user_id();
218
219 $attr = array(
220 'id' => $survey_id
221 );
222 $options = Survey_Maker_Data::get_survey_validated_data_from_array( $survey, $attr );
223
224 $answered_questions = isset( $data[ $name_prefix . 'answers-' . $unique_id ] ) && !empty( $data[ $name_prefix . 'answers-' . $unique_id ] ) ? $data[ $name_prefix . 'answers-' . $unique_id ] : array();
225 $questions_data = isset( $data[ $name_prefix . 'questions-' . $unique_id ] ) && !empty( $data[ $name_prefix . 'questions-' . $unique_id ] ) ? $data[ $name_prefix . 'questions-' . $unique_id ] : array();
226
227 $survey_additional_wp_data = isset($data[ $valid_name_prefix . 'additional_wp_data' ]) && $data[ $valid_name_prefix . 'additional_wp_data' ] != '' ? json_decode(base64_decode($data[ $valid_name_prefix . 'additional_wp_data' ]) , true) : array();
228
229 $survey_current_page_link = isset( $data['ays_'.$valid_name_prefix.'_current_page_link'] ) && $data['ays_'.$valid_name_prefix.'_current_page_link'] != '' ? sanitize_url( $data['ays_'.$valid_name_prefix.'_current_page_link'] ) : "";
230
231 $survey_current_page_link_html = "<a href='". esc_sql( $survey_current_page_link ) ."' target='_blank' class='ays-survey-current-page-link-a-tag'>". __( "Survey link", "survey-maker" ) ."</a>";
232
233 // Survey modified date
234 $survey_modified_date = (isset($survey->date_modified) && $survey->date_modified != '') ? esc_attr( $survey->date_modified ) : "";
235 if( $survey_modified_date != "" ){
236 $survey_modified_date = date_i18n( get_option( 'date_format' ), strtotime( $survey_modified_date ) );
237 }
238
239 $user_email = '';
240 if( isset( $data[ $name_prefix . 'user-email-' . $unique_id ] ) && !empty( $data[ $name_prefix . 'user-email-' . $unique_id ] ) ){
241 if( is_array( $data[ $name_prefix . 'user-email-' . $unique_id ] ) ){
242 $user_emails_arr = $data[ $name_prefix . 'user-email-' . $unique_id ];
243 $user_email = $answered_questions[ $user_emails_arr[ count( $user_emails_arr ) - 1 ] ];
244 }else{
245 $user_email = $answered_questions[ $data[ $name_prefix . 'user-email-' . $unique_id ] ];
246 }
247 }
248 if( is_array( $user_email ) ){
249 if( isset( $user_email['answer'] ) && !empty( $user_email['answer'] ) ){
250 $user_email = $user_email['answer'];
251 }else{
252 $user_email = '';
253 }
254 }
255 $user_email = is_scalar( $user_email ) ? sanitize_email( $user_email ) : '';
256
257 $user_name = '';
258 if( isset( $data[ $name_prefix . 'user-name-' . $unique_id ] ) && !empty( $data[ $name_prefix . 'user-name-' . $unique_id ] ) ){
259 if( is_array( $data[ $name_prefix . 'user-name-' . $unique_id ] ) ){
260 $user_names_arr = $data[ $name_prefix . 'user-name-' . $unique_id ];
261 $user_name = $answered_questions[ $user_names_arr[ count( $user_names_arr ) - 1 ] ];
262 }else{
263 $user_name = $answered_questions[ $data[ $name_prefix . 'user-name-' . $unique_id ] ];
264 }
265 }
266 if( is_array( $user_name ) ){
267 if( isset( $user_name['answer'] ) && !empty( $user_name['answer'] ) ){
268 $user_name = $user_name['answer'];
269 }else{
270 $user_name = '';
271 }
272 }
273 $user_name = is_scalar( $user_name ) ? sanitize_text_field( $user_name ) : '';
274
275 $result_unique_code = strtoupper( uniqid() );
276
277 $setting_options = Survey_Maker_Data::get_setting_data( 'options' );
278
279 // Do not store IP adressess
280 $settings_options[ $valid_name_prefix . 'disable_user_ip' ] = (isset($setting_options[ $valid_name_prefix . 'disable_user_ip' ]) && $setting_options[ $valid_name_prefix . 'disable_user_ip' ] == 'on') ? stripslashes( $setting_options[ $valid_name_prefix . 'disable_user_ip' ] ): 'off';
281 $survey_disable_user_ip = (isset($setting_options[ $valid_name_prefix . 'disable_user_ip' ]) && $setting_options[ $valid_name_prefix . 'disable_user_ip' ] == 'on') ? true : false;
282
283 // Do not store User Names
284 $settings_options[ $valid_name_prefix . 'disable_user_name' ] = (isset($setting_options[ $valid_name_prefix . 'disable_user_name' ]) && $setting_options[ $valid_name_prefix . 'disable_user_name' ] == 'on') ? stripslashes( $setting_options[ $valid_name_prefix . 'disable_user_name' ] ): 'off';
285 $survey_disable_user_name = (isset($setting_options[ $valid_name_prefix . 'disable_user_name' ]) && $setting_options[ $valid_name_prefix . 'disable_user_name' ] == 'on') ? true : false;
286
287 // Do not store User Emails
288 $settings_options[ $valid_name_prefix . 'disable_user_email' ] = (isset($setting_options[ $valid_name_prefix . 'disable_user_email' ]) && $setting_options[ $valid_name_prefix . 'disable_user_email' ] == 'on') ? stripslashes( $setting_options[ $valid_name_prefix . 'disable_user_email' ] ): 'off';
289 $survey_disable_user_email = (isset($setting_options[ $valid_name_prefix . 'disable_user_email' ]) && $setting_options[ $valid_name_prefix . 'disable_user_email' ] == 'on') ? true : false;
290
291 $survey_question_count = Survey_Maker_Data::get_survey_questions_count($survey_id);
292 $survey_sections_count = Survey_Maker_Data::get_survey_sections_count($survey_id);
293 $survey_passed_users_count = Survey_Maker_Data::ays_survey_get_passed_users_count($survey_id);
294
295 $user_ip = '';
296 if($survey_disable_user_ip){
297 $user_ip = '';
298 }else{
299 $user_ip = Survey_Maker_Data::get_user_ip_validated();
300 $user_ip = ($user_ip != 'UNKNOWN') ? $user_ip : '';
301 }
302
303 if ( $survey_disable_user_name ) {
304 $user_name = '';
305 $user_id = '';
306 }
307
308 if ( $survey_disable_user_email ) {
309 $user_email = '';
310 $user_id = '';
311 }
312
313 $survey_user_information = Survey_Maker_Data::get_user_profile_data();
314 // Get user first name
315 $user_first_name = (isset( $survey_user_information['user_first_name'] ) && $survey_user_information['user_first_name'] != "") ? $survey_user_information['user_first_name'] : '';
316
317 // Get user last name
318 $user_last_name = (isset( $survey_user_information['user_last_name'] ) && $survey_user_information['user_last_name'] != "") ? $survey_user_information['user_last_name'] : '';
319
320 // Get user nick name
321 $user_nick_name = (isset( $survey_user_information['user_nickname'] ) && $survey_user_information['user_nickname'] != "") ? $survey_user_information['user_nickname'] : '';
322
323 // Get display name
324 $user_display_name = (isset( $survey_user_information['user_display_name'] ) && $survey_user_information['user_display_name'] != "") ? $survey_user_information['user_display_name'] : '';
325
326 // User Wordpress role
327 $user_wordpress_roles = (isset( $survey_user_information['user_wordpress_roles'] ) && $survey_user_information['user_wordpress_roles'] != "") ? $survey_user_information['user_wordpress_roles'] : '';
328
329 // User Website URL
330 $user_website_url = (isset( $survey_user_information['user_website_url'] ) && $survey_user_information['user_website_url'] != "") ? $survey_user_information['user_website_url'] : '';
331
332 if ( ! empty( $user_website_url ) ) {
333 $user_website_url = '<a href="'. $user_website_url .'" target="_blank">'. $user_website_url .'</a>';
334 }
335
336 // User Registered
337 $user_data = wp_get_current_user();
338 $user_registered = '';
339 if ( is_user_logged_in() ) {
340 $user_registered = $user_data->user_registered;
341 }
342
343 // User ip address
344 $user_ip_address = (isset( $survey_user_information['user_ip_address'] ) && $survey_user_information['user_ip_address'] != "") ? $survey_user_information['user_ip_address'] : '';
345
346 // User wordpress email
347 $user_wordpress_email = (isset( $survey_user_information['user_wordpress_email'] ) && $survey_user_information['user_wordpress_email'] != "") ? esc_attr($survey_user_information['user_wordpress_email']) : '';
348
349 // Current date
350 $survey_current_date = date_i18n( 'M d, Y', strtotime( sanitize_text_field( $_REQUEST['end_date'] ) ) );
351
352 // WP home page url
353 $home_main_url = home_url();
354 $wp_home_page_url = '<a href="'.$home_main_url.'" target="_blank">'.$home_main_url.'</a>';
355
356 // Current time
357 $survey_current_time = explode( ' ', current_time( 'mysql' ) );
358 $survey_current_time_only = ($survey_current_time[1]) ? $survey_current_time[1] : '';
359
360 // Current day
361 $survey_current_day = date_i18n( 'l', strtotime( sanitize_text_field( $_REQUEST['end_date'] ) ) );
362
363 // Current month
364 $survey_current_month = date_i18n( 'F', strtotime( sanitize_text_field( $_REQUEST['end_date'] ) ) );
365
366 // Get survey author
367 $current_survey_user_data = get_userdata( $survey->author_id );
368 $current_survey_author = '';
369 $current_survey_author_email = '';
370 $current_survey_author_nickname = '';
371 $current_survey_author_display_name = '';
372 $current_survey_author_website_url = '';
373 if ( isset( $current_survey_user_data ) && $current_survey_user_data ) {
374 // Get survey author name
375 $current_survey_author = ( isset( $current_survey_user_data->data->display_name ) && $current_survey_user_data->data->display_name != '' ) ? sanitize_text_field( $current_survey_user_data->data->display_name ) : "";
376 // Get survey author email
377 $current_survey_author_email = ( isset( $current_survey_user_data->data->user_email ) && $current_survey_user_data->data->user_email != '' ) ? sanitize_text_field( $current_survey_user_data->data->user_email ) : "";
378 // Get survey author nickname
379 $current_survey_author_nickname = ( isset( $current_survey_user_data->data->user_nicename ) && $current_survey_user_data->data->user_nicename != '' ) ? sanitize_text_field( $current_survey_user_data->data->user_nicename ) : "";
380 // Get survey author display name
381 $current_survey_author_display_name = ( isset( $current_survey_user_data->data->display_name ) && $current_survey_user_data->data->display_name != '' ) ? sanitize_text_field( $current_survey_user_data->data->display_name ) : "";
382 // Get survey author Website URL
383 $current_survey_author_website_url = ( isset( $current_survey_user_data->data->user_url ) && $current_survey_user_data->data->user_url != '' ) ? sanitize_text_field( $current_survey_user_data->data->user_url ) : "";
384 }
385
386 $super_admin_email = "";
387 $wp_all_admins = get_users('role=Administrator');
388 if(!empty($wp_all_admins)){
389 $super_admin_email = isset($wp_all_admins[0]) ? $wp_all_admins[0]->data->user_email : '';
390 }
391
392 $survey_current_post_id = '';
393 $survey_current_post_author_email = '';
394 $survey_current_post_author_nickname = '';
395 $survey_current_post_author_display_name = '';
396 $survey_current_post_author_first_name = '';
397 $survey_current_post_author_last_name = '';
398 $survey_current_post_author_website_url = '';
399 $survey_current_post_author_roles = '';
400 $survey_current_post_title = '';
401 if(!empty($survey_additional_wp_data)){
402 if(isset($survey_additional_wp_data['survey_post_type']) && $survey_additional_wp_data['survey_post_type'] == 'post'){
403 $survey_current_post_id = isset($survey_additional_wp_data['survey_post_id']) && $survey_additional_wp_data['survey_post_id'] != '' ? $survey_additional_wp_data['survey_post_id'] : '';
404 }
405
406 $survey_current_post_author_email = isset($survey_additional_wp_data['survey_post_author_email']) && $survey_additional_wp_data['survey_post_author_email'] != '' ? esc_attr($survey_additional_wp_data['survey_post_author_email']) : '';
407 $survey_current_post_author_nickname = isset($survey_additional_wp_data['survey_current_post_author_nickname']) && $survey_additional_wp_data['survey_current_post_author_nickname'] != '' ? esc_attr($survey_additional_wp_data['survey_current_post_author_nickname']) : '';
408 $survey_current_post_author_display_name = isset($survey_additional_wp_data['survey_current_post_author_display_name']) && $survey_additional_wp_data['survey_current_post_author_display_name'] != '' ? esc_attr($survey_additional_wp_data['survey_current_post_author_display_name']) : '';
409 $survey_current_post_author_first_name = isset($survey_additional_wp_data['survey_current_post_author_first_name']) && $survey_additional_wp_data['survey_current_post_author_first_name'] != '' ? esc_attr($survey_additional_wp_data['survey_current_post_author_first_name']) : '';
410 $survey_current_post_author_last_name = isset($survey_additional_wp_data['survey_current_post_author_last_name']) && $survey_additional_wp_data['survey_current_post_author_last_name'] != '' ? esc_attr($survey_additional_wp_data['survey_current_post_author_last_name']) : '';
411 $survey_current_post_author_website_url = isset($survey_additional_wp_data['survey_current_post_author_website_url']) && $survey_additional_wp_data['survey_current_post_author_website_url'] != '' ? esc_attr($survey_additional_wp_data['survey_current_post_author_website_url']) : '';
412 $survey_current_post_author_roles = isset($survey_additional_wp_data['survey_current_post_author_roles']) && $survey_additional_wp_data['survey_current_post_author_roles'] != '' ? $survey_additional_wp_data['survey_current_post_author_roles'] : '';
413 $survey_current_post_title = isset($survey_additional_wp_data['survey_current_post_title']) && $survey_additional_wp_data['survey_current_post_title'] != '' ? esc_attr($survey_additional_wp_data['survey_current_post_title']) : '';
414 }
415
416 if ( ! empty( $survey_current_post_author_website_url ) ) {
417 $survey_current_post_author_website_url = '<a href="'.$survey_current_post_author_website_url.'" target="_blank">'.$survey_current_post_author_website_url.'</a>';
418 }
419
420 if ( ! empty( $survey_current_post_author_roles ) && $survey_current_post_author_roles != "" ) {
421 if ( is_array( $survey_current_post_author_roles ) ) {
422 $survey_current_post_author_roles = implode( ", ", $survey_current_post_author_roles );
423 }
424 }
425
426 $get_site_title = get_bloginfo('name');
427 $get_site_description = get_bloginfo('description');
428
429 $detectedDevice = Survey_Maker_Data::ays_survey_detected_device_chart();
430
431 $message_data = array(
432 'survey_title' => stripslashes($survey->title),
433 'survey_id' => stripslashes($survey->id),
434 'post_id' => $survey_current_post_id,
435 'user_name' => $user_name,
436 'user_email' => $user_email,
437 'user_wordpress_email' => $user_wordpress_email,
438 'user_id' => $user_id,
439 'user_registered' => $user_registered,
440 'questions_count' => $survey_question_count,
441 'current_date' => $survey_current_date,
442 'current_time' => $survey_current_time_only,
443 'current_day' => $survey_current_day,
444 'current_month' => $survey_current_month,
445 'unique_code' => $result_unique_code,
446 'sections_count' => $survey_sections_count,
447 'users_count' => $survey_passed_users_count,
448 'users_first_name' => $user_first_name,
449 'users_last_name' => $user_last_name,
450 'users_nick_name' => $user_nick_name,
451 'users_display_name' => $user_display_name,
452 'users_ip_address' => $user_ip_address,
453 'user_wordpress_roles' => $user_wordpress_roles,
454 'user_website_url' => $user_website_url,
455 'creation_date' => date_i18n( get_option( 'date_format' ), strtotime( sanitize_text_field( $survey->date_created ) ) ),
456 'modified_date' => $survey_modified_date,
457 'current_survey_author' => $current_survey_author,
458 'current_survey_author_email' => $current_survey_author_email,
459 'current_survey_author_nickname' => $current_survey_author_nickname,
460 'current_survey_author_display_name' => $current_survey_author_display_name,
461 'current_survey_author_website_url' => $current_survey_author_website_url,
462 'current_survey_page_link' => $survey_current_page_link_html,
463 'admin_email' => $super_admin_email,
464 'home_page_url' => $wp_home_page_url,
465 'post_author_email' => $survey_current_post_author_email,
466 'post_author_nickname' => $survey_current_post_author_nickname,
467 'post_author_display_name' => $survey_current_post_author_display_name,
468 'post_author_first_name' => $survey_current_post_author_first_name,
469 'post_author_last_name' => $survey_current_post_author_last_name,
470 'post_author_website_url' => $survey_current_post_author_website_url,
471 'post_author_roles' => $survey_current_post_author_roles,
472 'post_title' => $survey_current_post_title,
473 'site_title' => $get_site_title,
474 'site_description' => $get_site_description,
475 );
476
477 $send_data = array(
478 'questions_data' => $questions_data,
479 'answered_questions' => $answered_questions,
480 'survey' => $survey,
481 'questions_ids' => $survey->question_ids,
482 'user_id' => $user_id,
483 'user_ip' => $user_ip,
484 'user_name' => $user_name,
485 'user_email' => $user_email,
486 'start_date' => current_time( 'mysql' ),
487 'end_date' => current_time( 'mysql' ),
488 'unique_code' => $result_unique_code,
489 'detectedDevice' => $detectedDevice,
490 );
491 $check_limitations = false;
492 if(isset($options['survey_limit_users']) && $options['survey_limit_users']){
493 $limit_users_by = isset($options['survey_limit_users_by']) && $options['survey_limit_users_by'] != "" ? $options['survey_limit_users_by'] : "";
494 $limit_users_attr = array(
495 'id' => $survey_id,
496 'name' => 'ays_survey_cookie_',
497 'title' => $survey->title,
498 );
499 $check_limitations = $this->ays_survey_check_limitations($limit_users_by, $limit_users_attr);
500 }
501 $result = $this->add_results_to_db( $send_data );
502
503 // Get submission count
504 $survey_submission_count_and_ids = Survey_Maker_Data::get_submission_count_and_ids_for_summary($survey_id);
505 $survey_submission_count = isset($survey_submission_count_and_ids['submission_count']) && $survey_submission_count_and_ids['submission_count'] != '' ? esc_attr($survey_submission_count_and_ids['submission_count']) : '';
506 $message_data['submission_count'] = $survey_submission_count;
507
508
509 $thank_you_message = trim( $options[ $valid_name_prefix . 'final_result_text' ] );
510 if( $thank_you_message == '' ){
511 $thank_you_message = __( "Thank you for completing this survey.", "survey-maker" );
512 }
513
514 $thank_you_message = Survey_Maker_Data::replace_message_variables($thank_you_message, $message_data);
515
516 $thank_you_message = Survey_Maker_Data::ays_autoembed( $thank_you_message );
517
518 $heading_for_share_buttons = '';
519 if( isset($options['survey_social_buttons']) && $options['survey_social_buttons'] ){
520 $heading_for_share_buttons = $options[ $this->name_prefix . 'social_buttons_heading' ];
521 $heading_for_share_buttons = Survey_Maker_Data::replace_message_variables($heading_for_share_buttons, $message_data);
522 $heading_for_share_buttons = Survey_Maker_Data::ays_autoembed( $heading_for_share_buttons );
523 }
524
525 return array(
526 'status' => $result,
527 "message" => $thank_you_message,
528 "limited" => $check_limitations,
529 "socialHeading" => $heading_for_share_buttons
530 );
531 }
532 }
533
534 return array("status" => false, "message" => "No no no" );
535 }
536
537 protected function add_results_to_db( $data ){
538 global $wpdb;
539
540 $questions_table = ( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "questions";
541 $answers_table = ( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
542 $submissions_table = ( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "submissions";
543 $submissions_questions_table = ( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "submissions_questions";
544
545 $survey = $data['survey'];
546 $questions_ids = $data['questions_ids'];
547 $user_id = $data['user_id'];
548 $user_ip = $data['user_ip'];
549 $user_name = $data['user_name'];
550 $user_email = $data['user_email'];
551 $start_date = $data['start_date'];
552 $end_date = $data['end_date'];
553 $answered_questions = $data['answered_questions'];
554 $questions_data = $data['questions_data'];
555 $duration = strtotime($end_date) - strtotime($start_date);
556 $unique_code = $data['unique_code'];
557 $detectedDevice = $data['detectedDevice'];
558
559 $question_ids_array = $questions_ids != '' ? explode(',', $questions_ids) : array();
560 $questions_count = count( $question_ids_array );
561
562 $options = array(
563 'device' => $detectedDevice,
564 );
565
566 $results_submissions = $wpdb->insert(
567 $submissions_table,
568 array(
569 'survey_id' => absint( intval( $survey->id ) ),
570 'questions_ids' => $questions_ids,
571 'user_id' => $user_id,
572 'user_ip' => $user_ip,
573 'user_name' => $user_name,
574 'user_email' => $user_email,
575 'start_date' => $start_date,
576 'end_date' => $end_date,
577 'submission_date' => $end_date,
578 'duration' => $duration,
579 'questions_count' => $questions_count,
580 'unique_code' => $unique_code,
581 'options' => json_encode($options)
582 ),
583 array(
584 '%d', // survey_id
585 '%s', // questions_ids
586 '%d', // user_id
587 '%s', // user_ip
588 '%s', // user_name
589 '%s', // user_email
590 '%s', // start_date
591 '%s', // end_date
592 '%s', // submission_date
593 '%s', // duration
594 '%s', // questions_count
595 '%s', // unique_code
596 '%s' // options
597 )
598 );
599
600 $submission_id = $wpdb->insert_id;
601
602 $results_submissions_questions = 0;
603 foreach ($question_ids_array as $key => $qid) {
604 $questions_options = array(
605
606 );
607
608 $user_answer = '';
609 $user_variant = '';
610 $section_id = $questions_data[$qid]['section'];
611
612 $question_answer = '';
613 if( isset( $answered_questions[$qid] ) ){
614 if( isset( $answered_questions[$qid]['other'] ) ){
615 $user_variant = sanitize_text_field( $answered_questions[$qid]['other'] );
616 unset( $answered_questions[$qid]['other'] );
617 }
618
619 if( is_array( $answered_questions[$qid] ) ){
620 if( isset( $answered_questions[$qid]['answer'] ) && !empty( $answered_questions[$qid]['answer'] ) ){
621 $question_answer = $answered_questions[$qid]['answer'];
622 }else{
623 $question_answer = '';
624 }
625 }else{
626 $question_answer = $answered_questions[$qid];
627 }
628 }
629 $answer_id = $question_answer;
630
631 $question_type = (isset($questions_data[$qid]['questionType']) && $questions_data[$qid]['questionType'] != '') ? stripslashes ( sanitize_text_field( $questions_data[$qid]['questionType'] ) ) : 'radio';
632 switch ( $question_type ) {
633 case "radio":
634 $user_answer = '';
635 if($question_answer != ""){
636 $user_variant = '';
637 }
638 break;
639 case "checkbox":
640 if( is_array( $question_answer ) ){
641 if( !in_array( '0', $question_answer ) ){
642 $user_variant = '';
643 }
644 $user_answer = implode(',', array_map( 'absint', $question_answer ));
645 }else{
646 $user_answer = absint( $question_answer );
647 if( '0' != $question_answer ){
648 $user_variant = '';
649 }
650 }
651 $answer_id = 0;
652 break;
653 case "select":
654 $user_answer = '';
655 break;
656 case "text":
657 $user_answer = is_scalar( $question_answer ) ? sanitize_textarea_field( $question_answer ) : '';
658 $answer_id = 0;
659 break;
660 case "star":
661 $user_answer = is_scalar( $question_answer ) ? sanitize_text_field( $question_answer ) : '';
662 $answer_id = 0;
663 break;
664 case "short_text":
665 $user_answer = is_scalar( $question_answer ) ? sanitize_text_field( $question_answer ) : '';
666 $answer_id = 0;
667 break;
668 case "number":
669 case "phone":
670 case "date":
671 $user_answer = is_scalar( $question_answer ) ? sanitize_text_field( $question_answer ) : '';
672 $answer_id = 0;
673 break;
674 case "time":
675 $user_answer = is_scalar( $question_answer ) ? sanitize_text_field( $question_answer ) : '';
676 $answer_id = 0;
677 break;
678 case "date_time":
679 if( is_array( $question_answer ) ){
680 $question_answer_date = isset( $question_answer['date'] ) && is_scalar( $question_answer['date'] ) && $question_answer['date'] != '' ? stripslashes( sanitize_text_field( $question_answer['date'] ) ) : '-';
681 $question_answer_time = isset( $question_answer['time'] ) && is_scalar( $question_answer['time'] ) && $question_answer['time'] != '' ? stripslashes( sanitize_text_field( $question_answer['time'] ) ) : '-';
682 $user_answer = $question_answer_date != '-' || $question_answer_time != '-' ? $question_answer_date . ' ' . $question_answer_time : '';
683 }
684 else{
685 $user_answer = is_scalar( $question_answer ) ? sanitize_text_field( $question_answer ) : '';
686 }
687 $answer_id = 0;
688 break;
689 case "name":
690 $user_answer = is_scalar( $question_answer ) ? sanitize_text_field( $question_answer ) : '';
691 $answer_id = 0;
692 break;
693 case "email":
694 $user_answer = is_scalar( $question_answer ) ? sanitize_email( $question_answer ) : '';
695 $answer_id = 0;
696 break;
697 default:
698 $user_answer = '';
699 break;
700 }
701
702 $results_submissions_quests = $wpdb->insert(
703 $submissions_questions_table,
704 array(
705 'submission_id' => intval( $submission_id ),
706 'question_id' => intval( $qid ),
707 'section_id' => intval( $section_id ),
708 'survey_id' => intval( $survey->id ),
709 'user_id' => $user_id,
710 'answer_id' => intval( $answer_id ),
711 'user_answer' => $user_answer,
712 'user_variant' => $user_variant,
713 'user_explanation' => '',
714 'type' => $question_type,
715 'options' => json_encode( $questions_options )
716 ),
717 array(
718 '%d', // submission_id
719 '%d', // question_id
720 '%d', // section_id
721 '%d', // survey_id
722 '%d', // user_id
723 '%d', // answer_id
724 '%s', // user_answer
725 '%s', // user_variant
726 '%s', // user_explanation
727 '%s', // type
728 '%s', // options
729 )
730 );
731 }
732
733 if ($results_submissions >= 0) {
734 return true;
735 }
736
737 return false;
738 }
739
740 public function ays_generate_survey_method( $attr ){
741 $id = (isset($attr['id'])) ? absint(intval($attr['id'])) : null;
742 $this->default_texts = Survey_Maker_Data::ays_set_default_texts( $this->plugin_name, array() );
743
744 if (is_null($id)) {
745 $content = "<p class='wrong_shortcode_text' style='color:red;'>" . $this->default_texts['wrongShortcode'] . "</p>";
746 return $content;
747 }
748
749 $this->enqueue_styles();
750 $this->enqueue_scripts();
751
752 $content = $this->show_survey($id, $attr);
753 return str_replace( array( "\r\n", "\n", "\r" ), '', $content );
754 }
755
756 public function show_survey( $id, $attr ){
757
758 $survey = Survey_Maker_Data::get_survey_by_id( $id );
759
760 if ( is_null( $survey ) ) {
761 return "<p class='wrong_shortcode_text' style='color:red;'>" . $this->default_texts['wrongShortcode'] . "</p>";
762 }
763
764 $status = isset( $survey->status ) && $survey->status != '' ? sanitize_text_field($survey->status) : '';
765
766 if ( $status == 'trashed' ) {
767 return "<p class='wrong_shortcode_text' style='color:red;'>" . $this->default_texts['wrongShortcode'] . "</p>";
768 }
769 elseif( $status == 'draft' ){
770 return '';
771 }
772
773 $unique_id = uniqid();
774 $this->unique_id = $unique_id;
775 $this->unique_id_in_class = $id . "-" . $unique_id;;
776
777 /*******************************************************************************************************/
778
779 $settings_options = $this->settings->ays_get_setting('options');
780 if($settings_options){
781 $settings_options = json_decode( $settings_options, true );
782 }else{
783 $settings_options = array();
784 }
785
786 // $this->buttons_texts = Survey_Maker_Data::ays_set_survey_texts( $this->plugin_name, $this->options );
787
788 $this->message_variable_data = Survey_Maker_Data::ays_set_survey_message_variables_data( $id, $survey, $settings_options );
789
790 $this->options = Survey_Maker_Data::get_survey_validated_data_from_array( $survey, $attr );
791
792 $this->buttons_texts = Survey_Maker_Data::ays_set_survey_texts( $this->plugin_name, $this->options );
793
794
795 $user_id = get_current_user_id();
796
797 /*******************************************************************************************************/
798
799 /*
800 ==========================================
801 General settings
802 ==========================================
803 */
804
805 // Textarea height (public)
806 $this->options[ $this->name_prefix . 'textarea_height' ] = (isset($settings_options['survey_textarea_height']) && $settings_options['survey_textarea_height'] != '' && $settings_options['survey_textarea_height'] != 0) ? absint( sanitize_text_field($settings_options['survey_textarea_height']) ) : 100;
807
808 // Lazy loading for images
809 $this->options[ $this->name_prefix . 'lazy_loading_for_images' ] = (isset($settings_options['survey_lazy_loading_for_images']) && $settings_options['survey_lazy_loading_for_images'] == 'on') ? true : false;
810 $this->lazy_loading = '';
811 if($this->options[ $this->name_prefix . 'lazy_loading_for_images' ]){
812 $this->lazy_loading = Survey_Maker_Data::survey_lazy_loading_for_images($this->options[ $this->name_prefix . 'lazy_loading_for_images' ]);
813 }
814 /*******************************************************************************************************/
815
816
817 $options = isset( $survey->options ) && $survey->options != '' ? json_decode( $survey->options, true ) : array();
818
819 $sections_ids = isset( $survey->section_ids ) && $survey->section_ids != '' ? $survey->section_ids : '';
820 $question_ids = isset( $survey->question_ids ) && $survey->question_ids != '' ? $survey->question_ids : '';
821
822 if( $sections_ids != '' ){
823 $section_ids_array = explode( ',', $sections_ids );
824 }else{
825 $section_ids_array = array();
826 }
827
828 /*******************************************************************************************************/
829 /* Limit users */
830 /*******************************************************************************************************/
831 $limit = false;
832 $limit_message = false;
833 $limit_users_attr = array(
834 'id' => $id,
835 'name' => 'ays_survey_cookie_',
836 'title' => $survey->title,
837 );
838 if( $this->options[ $this->name_prefix . 'limit_users' ] ){
839 switch( $this->options[ $this->name_prefix . 'limit_users_by' ] ){
840 case 'ip':
841 $limit_by = Survey_Maker_Data::get_limit_user_by_ip( $id );
842 $remove_cookie = Survey_Maker_Data::ays_survey_remove_cookie( $limit_users_attr );
843 break;
844 case 'user_id':
845 $limit_by = Survey_Maker_Data::get_limit_user_by_id( $id, $user_id );
846 $remove_cookie = Survey_Maker_Data::ays_survey_remove_cookie( $limit_users_attr );
847 if( ! is_user_logged_in() ){
848 $limit_by = 0;
849 }
850 break;
851 case 'cookie':
852 $check_cookie = Survey_Maker_Data::ays_survey_check_cookie( $limit_users_attr );
853 if ( !$check_cookie ) {
854 $limit_by = 0;
855 }else{
856 $limit_by = Survey_Maker_Data::get_limit_cookie_count( $limit_users_attr );
857 }
858 break;
859 case 'ip_cookie':
860 $check_cookie = Survey_Maker_Data::ays_survey_check_cookie( $limit_users_attr );
861 $check_user_by_ip = Survey_Maker_Data::get_user_by_ip( $id );
862 if($check_cookie || $check_user_by_ip > 0){
863 $limit_by = $check_user_by_ip;
864 }elseif(! $check_cookie || $check_user_by_ip <= 0){
865 $limit_by = 0;
866 }
867 break;
868
869 }
870
871 if( $limit_by > 0 ){
872 $limit = true;
873 $limit_message = $this->options[ $this->name_prefix . 'limitation_message' ];
874 $limit_message = Survey_Maker_Data::replace_message_variables($this->options[ $this->name_prefix . 'limitation_message' ], $this->message_variable_data);
875
876 if( $limit_message == '' ){
877 $limit_message = __( "You've already responded", "survey-maker" );
878 }
879 }
880 }
881
882 $logged_in_limit = false;
883 $logged_in_limit_message = false;
884 if( $this->options[ $this->name_prefix . 'enable_logged_users' ] ){
885 if( ! is_user_logged_in() ){
886 // $limit = true;
887 // $limit_message = $this->options[ $this->name_prefix . 'logged_in_message' ];
888
889 // if( $limit_message == '' ){
890 // $limit_message = "<h4 style='margin-top:0;'>" . __( "Sign in to continue", "survey-maker" ) . "</h4>";
891 // $limit_message .= "<p>" . __( "To fill out this form, you must be signed in. Your identity will remain anonymous.", "survey-maker" ) . "</p>";
892 // }
893
894 $logged_in_limit = true;
895 $logged_in_limit_message = $this->options[ $this->name_prefix . 'logged_in_message' ];
896 $logged_in_limit_message = Survey_Maker_Data::replace_message_variables($logged_in_limit_message, $this->message_variable_data);
897
898 if( $logged_in_limit_message == '' ){
899 $logged_in_limit_message = "<h4 style='margin-top:0;text-align:center;'>" . __( "Sign in to continue", "survey-maker" ) . "</h4>";
900 $logged_in_limit_message .= "<p style='margin-top:0;text-align:center;'>" . __( "To fill out this form, you must be signed in. Your identity will remain anonymous.", "survey-maker" ) . "</p>";
901 }
902 }
903
904 // Show login form for not logged in users
905 $survey_login_form = "";
906 if($this->options[ $this->name_prefix . 'show_login_form' ]){
907 $ays_survey_login_button_text = $this->buttons_texts[ 'loginButton' ];
908 $args = array(
909 'echo' => false,
910 'id_username' => 'user_login',
911 'id_password' => 'user_pass',
912 'id_remember' => 'rememberme',
913 'id_submit' => 'wp-submit',
914 'label_log_in' => $ays_survey_login_button_text,
915 );
916 $survey_login_form = "<div class='ays_survey_login_form'>" . wp_login_form( $args ) . "</div>";
917 }
918
919 if($logged_in_limit){
920 if(!is_user_logged_in()){
921 $logged_in_limit_message .= $survey_login_form;
922 }
923 }
924 }
925
926 // Limitation tackers of quiz
927 $tackers_message = "<div><p class='".$this->name_prefix."expired-survey-message'>" . __( "This survey has expired!", "survey-maker" ) . "</p></div>";
928 $takers_count = Survey_Maker_Data::get_survey_takers_count($id);
929
930 if($this->options[ $this->name_prefix . 'enable_takers_count' ]){
931 if($this->options[ $this->name_prefix . 'takers_count' ] <= $takers_count ){
932 $limit = true;
933 $limit_message = $tackers_message;
934 }
935 }
936
937
938 $survey_loader = $this->options[ $this->name_prefix . 'loader' ];
939 $survey_loader_text = '';
940 if(isset($this->options['options'])){
941 $survey_loader_text = isset($this->options['options'][ $this->name_prefix . 'loader_text' ]) && $this->options['options'][ $this->name_prefix . 'loader_text' ] != "" ? stripslashes(esc_attr($this->options['options'][ $this->name_prefix . 'loader_text' ])) : '';
942 }
943
944 // Loader Gif
945 $survey_loader_gif = (isset($this->options[ $this->name_prefix . 'loader_gif' ]) && $this->options[ $this->name_prefix . 'loader_gif' ] != '') ? $this->options[ $this->name_prefix . 'loader_gif' ] : '';
946 $survey_loader_gif_width = (isset($this->options[ $this->name_prefix . 'loader_gif_width' ]) && $this->options[ $this->name_prefix . 'loader_gif_width' ] != '') ? stripslashes( $this->options[ $this->name_prefix . 'loader_gif_width' ] ) : '';
947
948 switch( $survey_loader ){
949 case 'default':
950 $survey_loader_html = "<div data-class='lds-ellipsis' data-role='loader' class='ays-loader'><div></div><div></div><div></div><div></div></div>";
951 break;
952 case 'circle':
953 $survey_loader_html = "<div data-class='lds-circle' data-role='loader' class='ays-loader'></div>";
954 break;
955 case 'dual_ring':
956 $survey_loader_html = "<div data-class='lds-dual-ring' data-role='loader' class='ays-loader'></div>";
957 break;
958 case 'facebook':
959 $survey_loader_html = "<div data-class='lds-facebook' data-role='loader' class='ays-loader'><div></div><div></div><div></div></div>";
960 break;
961 case 'hourglass':
962 $survey_loader_html = "<div data-class='lds-hourglass' data-role='loader' class='ays-loader'></div>";
963 break;
964 case 'ripple':
965 $survey_loader_html = "<div data-class='lds-ripple' data-role='loader' class='ays-loader'><div></div><div></div></div>";
966 break;
967 case 'snake':
968 $survey_loader_html = '<div class="ays-survey-loader ays-survey-loader-snake" data-class="ays-survey-loader-snake" data-role="loader"><div></div><div></div><div></div><div></div><div></div><div></div></div>';
969 break;
970 case 'text':
971 $survey_loader_html = '<div class="ays-survey-loader ays-survey-loader-with-text" data-class="ays-survey-loader-text" data-role="loader">'.$survey_loader_text.'</div>';
972 break;
973 case 'custom_gif':
974 $survey_loader_html = '<div class="ays-survey-loader ays-survey-loader-with-custom-gif" data-class="ays-survey-loader-cistom-gif" data-role="loader"><img src="'.$survey_loader_gif.'" '.$this->lazy_loading.' style="width: '.$survey_loader_gif_width.'px;object-fit:cover;"></div>';
975 break;
976 default:
977 $survey_loader_html = "<div data-class='lds-ellipsis' data-role='loader' class='ays-loader'><div></div><div></div><div></div><div></div></div>";
978 break;
979 }
980
981 $this->options[ $this->name_prefix . 'loader_html' ] = $survey_loader_html;
982
983 /*
984 * Schedule quiz
985 * Check is quiz expired
986 */
987
988 $is_expired = false;
989 $active_date_check = false;
990 $startDate_atr = '';
991 $endDate_atr = '';
992 $current_time = strtotime( current_time( "Y:m:d H:i:s" ) );
993 $startDate = strtotime( $this->options[ $this->name_prefix . 'schedule_active' ] );
994 $endDate = strtotime( $this->options[ $this->name_prefix . 'schedule_deactive' ] );
995
996 $expired_survey_message = __('The survey has expired.', "survey-maker");
997
998 if ( $this->options[ $this->name_prefix . 'enable_schedule' ] ) {
999 $active_date_check = true;
1000
1001 if ( $this->options[ $this->name_prefix . 'schedule_active' ] ) {
1002 $startDate_atr = $startDate - $current_time;
1003 }elseif ( $this->options[ $this->name_prefix . 'schedule_deactive' ] ) {
1004 $endDate_atr = $endDate - $current_time;
1005 }
1006
1007 if ($startDate > $current_time) {
1008 if($this->options[ $this->name_prefix . 'dont_show_survey_container' ]){
1009 $hide_survey_and_popup = '
1010 <style>
1011 .' . $this->html_class_prefix . 'popup-survey-window[data-survey-id="' . $id . '"]{
1012 display:none !important;
1013 }
1014 </style>';
1015 return $hide_survey_and_popup;
1016 }
1017 $is_expired = true;
1018 $expired_survey_message = $this->options[ $this->name_prefix . 'schedule_pre_start_message' ];
1019 }elseif ($endDate < $current_time) {
1020 if($this->options[ $this->name_prefix . 'dont_show_survey_container' ]){
1021 $hide_survey_and_popup = '
1022 <style>
1023 .' . $this->html_class_prefix . 'popup-survey-window[data-survey-id="' . $id . '"]{
1024 display:none !important;
1025 }
1026 </style>';
1027 return $hide_survey_and_popup;
1028 }
1029 $is_expired = true;
1030 $expired_survey_message = $this->options[ $this->name_prefix . 'schedule_expiration_message' ];
1031 }
1032 }
1033
1034 if( !$limit ){
1035 $sections = Survey_Maker_Data::get_sections_by_survey_id( $sections_ids );
1036 $sections_count = count( $sections );
1037
1038
1039 $question_types_placeholders = array(
1040 "radio" => '',
1041 "checkbox" => '',
1042 "select" => '',
1043 "yesorno" => '',
1044 "text" => __("Your answer", "survey-maker"),
1045 "short_text" => __("Your answer", "survey-maker"),
1046 "number" => __("Your answer", "survey-maker"),
1047 "email" => __("Your email", "survey-maker"),
1048 "name" => __("Your name", "survey-maker"),
1049 );
1050
1051 $multiple_sections = $sections_count > 1 ? true : false;
1052
1053 foreach ($sections as $section_key => $section) {
1054 $sections[$section_key]['title'] = (isset($section['title']) && $section['title'] != '') ? stripslashes( esc_html( $section['title'] ) ) : '';
1055
1056 if ( $this->options[ $this->name_prefix . 'allow_html_in_section_description' ] ) {
1057
1058 $survey_allowed_html = Survey_Maker_Data::ays_survey_custom_allowed_html();
1059
1060 $sections[$section_key]['description'] = (isset($section['description']) && $section['description'] != '') ? nl2br( wp_kses( $section['description'] ), $survey_allowed_html ) : '';
1061 } else {
1062 $sections[$section_key]['description'] = (isset($section['description']) && $section['description'] != '') ? nl2br( esc_html( $section['description'] ) ) : '';
1063 }
1064
1065 $section_questions = Survey_Maker_Data::get_questions_by_section_id( intval( $section['id'] ), $question_ids );
1066
1067 foreach ($section_questions as $question_key => $question) {
1068 $section_questions[$question_key]['question'] = (isset($question['question']) && $question['question'] != '') ? nl2br( $question['question'] ) : '';
1069 $section_questions[$question_key]['image'] = (isset($question['image']) && $question['image'] != '') ? $question['image'] : '';
1070 $section_questions[$question_key]['type'] = (isset($question['type']) && $question['type'] != '') ? $question['type'] : 'radio';
1071 $section_questions[$question_key]['user_variant'] = (isset($question['user_variant']) && $question['user_variant'] == 'on') ? true : false;
1072
1073 $opts = json_decode( $question['options'], true );
1074 $opts['required'] = (isset($opts['required']) && $opts['required'] == 'on') ? true : false;
1075 $opts['enable_max_selection_count'] = (isset($opts['enable_max_selection_count']) && $opts['enable_max_selection_count'] == 'on') ? true : false;
1076 $opts['max_selection_count'] = (isset($opts['max_selection_count']) && $opts['max_selection_count'] != '') ? intval( $opts['max_selection_count'] ) : null;
1077 $opts['min_selection_count'] = (isset($opts['min_selection_count']) && $opts['min_selection_count'] != '') ? intval( $opts['min_selection_count'] ) : null;
1078 // Text Limitations
1079 $opts['enable_word_limitation'] = (isset($opts['enable_word_limitation']) && $opts['enable_word_limitation'] == 'on') ? true : false;
1080 $opts['limit_by'] = (isset($opts['limit_by']) && $opts['limit_by'] != '') ? sanitize_text_field($opts['limit_by']) : '';
1081 $opts['limit_length'] = (isset($opts['limit_length']) && $opts['limit_length'] != '') ? intval( $opts['limit_length'] ) : '';
1082 $opts['limit_counter'] = (isset($opts['limit_counter']) && $opts['limit_counter'] == 'on') ? true : false;
1083
1084 // Number Limitations
1085 $opts['enable_number_limitation'] = (isset($opts['enable_number_limitation']) && $opts['enable_number_limitation'] == 'on') ? true : false;
1086 $opts['number_min_selection'] = (isset($opts['number_min_selection']) && $opts['number_min_selection'] != '') ? sanitize_text_field($opts['number_min_selection']) : '';
1087 $opts['number_max_selection'] = (isset($opts['number_max_selection']) && $opts['number_max_selection'] != '') ? sanitize_text_field($opts['number_max_selection']) : '';
1088 $opts['number_error_message'] = (isset($opts['number_error_message']) && $opts['number_error_message'] != '') ? sanitize_text_field($opts['number_error_message']) : '';
1089 $opts['enable_number_error_message'] = (isset($opts['enable_number_error_message']) && $opts['enable_number_error_message'] == 'on') ? true : false;
1090 $opts['number_limit_length'] = (isset($opts['number_limit_length']) && $opts['number_limit_length'] != '') ? intval( $opts['number_limit_length'] ) : '';
1091 $opts['enable_number_limit_counter'] = (isset($opts['enable_number_limit_counter']) && $opts['enable_number_limit_counter'] == 'on') ? true : false;
1092 // Input types placeholders
1093 $opts['placeholder'] = (isset($opts['survey_input_type_placeholder'])) ? stripslashes(esc_attr($opts['survey_input_type_placeholder'])) : $question_types_placeholders[$section_questions[$question_key]['type']];
1094 $opts['image_caption'] = (isset($opts['image_caption'])) ? stripslashes(esc_attr($opts['image_caption'])) : '';
1095 $opts['image_caption_enable'] = (isset($opts['image_caption_enable']) && $opts['image_caption_enable'] == 'on') ? true : false;
1096
1097 //Admin note
1098 $opts['enable_admin_note'] = ( isset( $opts['enable_admin_note'] ) && $opts['enable_admin_note'] == 'on' ) ? true : false;
1099 $opts['admin_note'] = isset( $opts['admin_note'] ) && $opts['admin_note'] != '' ? stripslashes( esc_attr( $opts['admin_note'] ) ) : '';
1100
1101 $opts['enable_value_prefix'] = (isset($opts['enable_value_prefix']) && $opts['enable_value_prefix'] == 'on') ? true : false;
1102 $opts['value_prefix'] = isset( $opts['value_prefix'] ) && $opts['value_prefix'] != '' ? stripslashes( esc_attr( $opts['value_prefix'] ) ) : '';
1103 $opts['enable_value_suffix'] = (isset($opts['enable_value_suffix']) && $opts['enable_value_suffix'] == 'on') ? true : false;
1104 $opts['value_suffix'] = isset( $opts['value_suffix'] ) && $opts['value_suffix'] != '' ? stripslashes( esc_attr( $opts['value_suffix'] ) ) : '';
1105
1106 if( $section_questions[$question_key]['type'] == 'checkbox' ){
1107 $this->options[ 'survey_checkbox_options' ][$question['id']]['enable_max_selection_count'] = $opts['enable_max_selection_count'];
1108 $this->options[ 'survey_checkbox_options' ][$question['id']]['max_selection_count'] = $opts['max_selection_count'];
1109 $this->options[ 'survey_checkbox_options' ][$question['id']]['min_selection_count'] = $opts['min_selection_count'];
1110 }
1111
1112 if( $section_questions[$question_key]['type'] == 'text' || $section_questions[$question_key]['type'] == 'short_text'){
1113 $this->options[ 'survey_text_limit_options' ][$question['id']]['enable_word_limitation'] = $opts['enable_word_limitation'];
1114 $this->options[ 'survey_text_limit_options' ][$question['id']]['limit_by'] = $opts['limit_by'];
1115 $this->options[ 'survey_text_limit_options' ][$question['id']]['limit_length'] = $opts['limit_length'];
1116 $this->options[ 'survey_text_limit_options' ][$question['id']]['limit_counter'] = $opts['limit_counter'];
1117 }
1118
1119 if( $section_questions[$question_key]['type'] == 'number' || $section_questions[$question_key]['type'] == 'phone'){
1120 $this->options[ 'survey_number_limit_options' ][$question['id']]['enable_number_limitation'] = $opts['enable_number_limitation'];
1121 $this->options[ 'survey_number_limit_options' ][$question['id']]['number_min_selection'] = $opts['number_min_selection'];
1122 $this->options[ 'survey_number_limit_options' ][$question['id']]['number_max_selection'] = $opts['number_max_selection'];
1123 $this->options[ 'survey_number_limit_options' ][$question['id']]['number_error_message'] = $opts['number_error_message'];
1124 $this->options[ 'survey_number_limit_options' ][$question['id']]['enable_number_error_message'] = $opts['enable_number_error_message'];
1125 $this->options[ 'survey_number_limit_options' ][$question['id']]['number_limit_length'] = $opts['number_limit_length'];
1126 $this->options[ 'survey_number_limit_options' ][$question['id']]['enable_number_limit_counter'] = $opts['enable_number_limit_counter'];
1127 }
1128
1129 $q_answers = Survey_Maker_Data::get_answers_by_question_id( intval( $question['id'] ) );
1130
1131 foreach ($q_answers as $answer_key => $answer) {
1132 $answer_content = (isset($answer['answer']) && $answer['answer'] != '') ? $answer['answer'] : '';
1133
1134 if( $this->options[ $this->name_prefix . 'allow_html_in_answers' ] === false ){
1135 $answer_content = htmlentities( $answer_content );
1136 }
1137
1138 $q_answers[$answer_key]['answer'] = stripslashes( $answer_content );
1139 $q_answers[$answer_key]['image'] = (isset($answer['image']) && $answer['image'] != '') ? $answer['image'] : '';
1140 $q_answers[$answer_key]['placeholder'] = (isset($answer['placeholder']) && $answer['placeholder'] != '') ? $answer['placeholder'] : '';
1141 }
1142
1143 $section_questions[$question_key]['answers'] = $q_answers;
1144
1145 $section_questions[$question_key]['options'] = $opts;
1146 }
1147
1148 $sections[$section_key]['questions'] = $section_questions;
1149 }
1150 }
1151
1152 if( $logged_in_limit ){
1153 $limit = true;
1154 $limit_message = $logged_in_limit_message;
1155 }
1156
1157 $blocked_content_class = '';
1158 if( ( $limit || $is_expired ) && !$logged_in_limit ){
1159 $blocked_content_class = " " . $this->html_class_prefix . "blocked-content ";
1160 }
1161
1162 $content = array();
1163 $content[] = '<div class="' . $this->html_class_prefix . 'container ' . $blocked_content_class . $this->options[ $this->name_prefix . 'custom_class' ] . '" id="' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . '" data-id="' . $unique_id . '" data-theme="'.$this->options[ $this->name_prefix . 'theme' ].'">';
1164
1165 if(Survey_Maker_Data::ays_survey_is_elementor() || Survey_Maker_Data::ays_survey_is_editor()){
1166
1167 $content[] = '<div style="display: flex; justify-content: center;font-size: 15px; text-align: center;gap: 4px">';
1168 $content[] = '<div><i class="ays_fa ays_fa_info_circle"></i></div>';
1169 $content[] = '<div>'. esc_attr( __( "You're in the preview mode. Note: All elements work correctly on the front end." , "survey-maker") ).'</div>';
1170 $content[] = '</div>';
1171 }
1172
1173 if($this->options[ $this->name_prefix . 'enable_survey_start_loader' ] && !Survey_Maker_Data::ays_survey_is_elementor()){
1174 $content[] = Survey_Maker_Data::survey_get_loader($this->options[ $this->name_prefix . 'before_start_loader' ]);
1175 }
1176 $survey_full_screen_button_pos = $this->options[ $this->name_prefix . 'show_title' ] ? "" : $this->html_class_prefix . "full-screen-and-no-title";
1177 $survey_no_cover_photo_class = "";
1178 if( $this->options[ $this->name_prefix . 'full_screen_mode' ] ){
1179 $survey_cover_photo_class = "";
1180 if( $this->options[ $this->name_prefix . 'cover_photo' ] != "" ){
1181 $survey_cover_photo_class = $this->html_class_prefix . "cover-photo-title-wrap";
1182 $survey_no_cover_photo_class = $this->html_class_prefix . "no-cover-photo";
1183 }
1184 $content[] = '<div class="' . $this->html_class_prefix . 'full-screen-and-title ' . $survey_full_screen_button_pos . ' ' . $survey_cover_photo_class . '">';
1185 }
1186
1187 if( $this->options[ $this->name_prefix . 'show_title' ] && $this->options[ $this->name_prefix . 'cover_photo' ] != "" ){
1188 $content[] = '<div class="' . $this->html_class_prefix . 'title-wrap">';
1189 if( $this->options[ $this->name_prefix . 'full_screen_mode' ] ){
1190 $content[] = '<div class="' . $this->html_class_prefix . 'cover-photo-title-wrap ' . $survey_no_cover_photo_class . '">';
1191 }else{
1192 $content[] = '<div class="' . $this->html_class_prefix . 'cover-photo-title-wrap">';
1193 }
1194 $content[] = '<span class="' . $this->html_class_prefix . 'title">' . $survey->title . '</span>';
1195 $content[] = '</div>';
1196 $content[] = '</div>';
1197 }else if( $this->options[ $this->name_prefix . 'cover_photo' ] != "" ){
1198 $content[] = '<div class="' . $this->html_class_prefix . 'title-wrap">';
1199 if( $this->options[ $this->name_prefix . 'full_screen_mode' ] ){
1200 $content[] = '<div class="' . $this->html_class_prefix . 'cover-photo-title-wrap ' . $survey_no_cover_photo_class . '"></div>';
1201 }else{
1202 $content[] = '<div class="' . $this->html_class_prefix . 'cover-photo-title-wrap"></div>';
1203 }
1204 $content[] = '</div>';
1205 }else if($this->options[ $this->name_prefix . 'show_title' ]){
1206 $content[] = '<div class="' . $this->html_class_prefix . 'title-wrap">';
1207 $content[] = '<span class="' . $this->html_class_prefix . 'title">' . $survey->title . '</span>';
1208 $content[] = '</div>';
1209 }
1210
1211 if( $this->options[ $this->name_prefix . 'full_screen_mode' ] && !$limit){
1212 $content[] = '<div class="ays-survey-full-screen-mode">
1213 <a class="ays-survey-full-screen-container" title="'.__("Full screen" , "survey-maker").'" >
1214 <svg xmlns="http://www.w3.org/2000/svg" height="24" fill="#fff" viewBox="0 0 24 24" tabindex="0" width="24" class="ays-survey-close-full-screen">
1215 <path d="M0 0h24v24H0z" fill="none"/>
1216 <path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>
1217 </svg>
1218 <svg xmlns="http://www.w3.org/2000/svg" height="24" fill="#fff" viewBox="0 0 24 24" tabindex="0" width="24" class="ays-survey-open-full-screen">
1219 <path d="M0 0h24v24H0z" fill="none"/>
1220 <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
1221 </svg>
1222 </a>
1223 </div>';
1224 }
1225 if( $this->options[ $this->name_prefix . 'full_screen_mode' ] ){
1226 $content[] = '</div>';
1227 }
1228
1229
1230 if( $this->options[ $this->name_prefix . 'enable_logged_users' ] ){
1231 if( ! is_user_logged_in() && $this->options[ $this->name_prefix . 'show_login_form'] ){
1232 $content[] = $this->create_restricted_content( $limit_message );
1233 $content[] = $this->get_styles();
1234 $content[] = $this->get_custom_css();
1235
1236 $content[] = $this->get_encoded_options( $limit );
1237
1238 $content[] = '</div>';
1239
1240 $content = implode( '', $content );
1241 return $content;
1242 }
1243 }
1244
1245 $content[] = '<form class="' . $this->html_class_prefix . 'form" method="post">';
1246 $content[] = '<input type="hidden" name="'. $this->html_name_prefix .'id-' . $unique_id . '" value="'. $id .'">';
1247 // Get survey current page
1248 $ays_survey_protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
1249 $current_survey_page_link = esc_url( $ays_survey_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1250 $content[] = '<input type="hidden" name="'. $this->html_name_prefix .'current_page_link" value="'. $current_survey_page_link .'">';
1251
1252 if( !$limit && !$is_expired ){
1253 $content[] = $this->create_sections( $sections );
1254 }else{
1255 if( $is_expired && !$limit ){
1256 $limit_message = $expired_survey_message;
1257 }
1258 else if($is_expired && $limit){
1259 $limit_message = $expired_survey_message;
1260 }
1261
1262 $content[] = $this->create_restricted_content( $limit_message );
1263 }
1264
1265 $content[] = '</form>';
1266
1267 $content[] = $this->get_styles();
1268 $content[] = $this->get_custom_css();
1269
1270 $content[] = $this->get_encoded_options( $limit );
1271
1272 $content[] = '</div>';
1273
1274 $content = implode( '', $content );
1275 return $content;
1276 }
1277
1278 public function create_sections( $sections ){
1279
1280 $content = array();
1281 $content[] = '<div class="' . $this->html_class_prefix . 'sections">';
1282
1283 if(isset($this->options[ $this->name_prefix .'enable_password']) && $this->options[ $this->name_prefix .'enable_password'] ){
1284 $ays_survey_show_password_flag = true;
1285
1286 $password_type = 'general';
1287 $general_psw_input = $this->options[$this->name_prefix .'password_survey'];
1288 // $active_psw = $this->options['options'][ $this->name_prefix .'generated_passwords'][ $this->name_prefix .'active_passwords'];
1289
1290 if( $password_type == 'general' && $general_psw_input == '' ){
1291 $ays_survey_show_password_flag = false;
1292 }else{
1293 $ays_survey_show_password_flag = true;
1294 }
1295
1296 if($ays_survey_show_password_flag){
1297 $if_generated = isset($this->options[ $this->name_prefix .'password_type']) && $this->options[ $this->name_prefix .'password_type'] == 'generated_password' ? 'name="' . $this->html_class_prefix . 'password"' : '';
1298 $content[] = '<div class="' . $this->html_class_prefix . 'section">';
1299
1300 $content[] = '<div class="' . $this->html_class_prefix . 'section-content">';
1301
1302 $content[] = '<div style="margin-bottom:10px;">';
1303 $content[] = '<div>';
1304 $content[] = $this->options[ $this->name_prefix .'password_message'];
1305 $content[] = '</div>';
1306 $content[] = '</div>';
1307 $content[] = '<div style="margin-bottom:10px;">';
1308 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box">';
1309 $content[] = '<input class="' . $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'password ' . $this->html_class_prefix . 'question-input ' .
1310 $this->html_class_prefix . 'input" type="password" autocomplete="off" tabindex="0" placeholder="Please enter password" '.$if_generated.'/>';
1311 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline" style="margin:0;"></div>';
1312 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation" style="margin:0;"></div>';
1313 $content[] = '</div>';
1314 $content[] = '</div>';
1315
1316 $content[] = '<div class="' . $this->html_class_prefix . 'check-password-block">';
1317
1318 $content[] = '<div class="' . $this->html_class_prefix . 'section-buttons">';
1319 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-container" tabindex="0">';
1320 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-content">';
1321
1322 $content[] = '<input type="button" class="' . $this->html_class_prefix . 'section-button ays-check-survey-password" value="Check" />';
1323
1324 $content[] = '</div>';
1325 $content[] = '</div>';
1326 $content[] = '</div>';
1327
1328 $content[] = '</div>';
1329 $content[] = '</div>';
1330
1331 $content[] = '</div>';
1332 }
1333 }
1334
1335 if( $this->options[ $this->name_prefix . 'enable_start_page'] === true ){
1336 $content[] = '<div class="' . $this->html_class_prefix . 'section ' . $this->html_class_prefix . 'section-start-page">';
1337
1338 $content[] = '<div class="' . $this->html_class_prefix . 'section-content ' . $this->options[ $this->name_prefix .'start_page_custom_class'] . '">';
1339
1340 $content[] = '<div class="' . $this->html_class_prefix . 'section-header">';
1341
1342 $content[] = '<div class="' . $this->html_class_prefix . 'section-title-row">';
1343 $content[] = '<span class="' . $this->html_class_prefix . 'section-title">' . stripslashes( $this->options[ $this->name_prefix .'start_page_title'] ) . '</span>';
1344 $content[] = '</div>';
1345 $survey_start_page_description_content = stripslashes( $this->options[ $this->name_prefix .'start_page_description']);
1346 $survey_start_page_description_content = $survey_start_page_description_content;
1347
1348 $content[] = '<div class="' . $this->html_class_prefix . 'section-desc">' . $survey_start_page_description_content . '</div>';
1349
1350 $content[] = '<div class="' . $this->html_class_prefix . 'section-buttons">';
1351
1352 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-container" tabindex="0">';
1353 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-content">';
1354 $content[] = '<input type="button" class="' . $this->html_class_prefix . 'section-button ' . $this->html_class_prefix . 'start-button" value="'. $this->buttons_texts[ 'startButton' ] .'" />';
1355 $content[] = '</div>';
1356 $content[] = '</div>';
1357
1358 $content[] = '</div>';
1359
1360 $content[] = '</div>';
1361
1362 $content[] = '</div>';
1363
1364 $content[] = '</div>';
1365 }
1366
1367 $survey_current_post_id = get_the_ID();
1368 $author_id = get_the_author_meta('ID');
1369 $survey_current_post_author_email = get_the_author_meta('email');
1370 $survey_current_post_author_nickname = get_the_author_meta('user_nicename');
1371 $survey_current_post_author_display_name = get_the_author_meta( 'display_name', $author_id );
1372 $survey_current_post_author_first_name = get_the_author_meta( 'first_name', $author_id );
1373 $survey_current_post_author_last_name = get_the_author_meta( 'last_name', $author_id );
1374 $survey_current_post_author_website_url = get_the_author_meta( 'url', $author_id );
1375 $survey_current_post_author_roles = get_the_author_meta( 'roles', $author_id );
1376
1377 $survey_current_post_title = get_the_title();
1378
1379 $survey_additional_wp_data = array(
1380 'survey_post_type' => get_post_type(),
1381 'survey_post_id' => $survey_current_post_id,
1382 'survey_post_author_email' => $survey_current_post_author_email,
1383 'survey_current_post_author_nickname' => $survey_current_post_author_nickname,
1384 'survey_current_post_author_display_name' => $survey_current_post_author_display_name,
1385 'survey_current_post_author_first_name' => $survey_current_post_author_first_name,
1386 'survey_current_post_author_last_name' => $survey_current_post_author_last_name,
1387 'survey_current_post_author_website_url' => $survey_current_post_author_website_url,
1388 'survey_current_post_author_roles' => $survey_current_post_author_roles,
1389 'survey_current_post_title' => $survey_current_post_title,
1390 );
1391
1392 $additional_data = base64_encode(json_encode($survey_additional_wp_data));
1393
1394 $sections_count = count( $sections );
1395 foreach ( $sections as $key => $section ) {
1396 $first = $key == 0 ? true : false;
1397 $last = $key + 1 == $sections_count ? true : false;
1398 $section_numbering = $key+1;
1399 $content[] = $this->create_section( $section, $last, $first , $sections_count , $section_numbering);
1400 }
1401
1402 $minimal_theme_header = $this->options[ $this->name_prefix . 'is_minimal' ] ? 'ays-survey-minimal-theme-header' : "";
1403 $modern_theme_header = $this->options[ $this->name_prefix . 'is_modern' ] ? 'ays-survey-modern-theme-header' : "";
1404
1405 $content[] = '<div class="' . $this->html_class_prefix . 'section ' . $this->html_class_prefix . 'results-content">';
1406 $content[] = '<div class="' . $this->html_class_prefix . 'section-header ' . $minimal_theme_header . ' ' . $modern_theme_header . '">';
1407
1408 $content[] = '<div class="' . $this->html_class_prefix . 'results">';
1409 $content[] = '<input type="hidden" value="'.esc_attr($additional_data).'" name="' . $this->name_prefix . 'additional_wp_data' . '">';
1410 $content[] = '<div class="' . $this->html_class_prefix . 'loader">' . $this->options[ $this->name_prefix . 'loader_html' ] . '</div>';
1411 $content[] = '<div class="' . $this->html_class_prefix . 'thank-you-page">';
1412
1413 if( $this->options[ $this->name_prefix . 'enable_restart_button' ] ){
1414 $content[] = '<div class="' . $this->html_class_prefix . 'section-buttons">';
1415 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-container" tabindex="0">';
1416 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-content">';
1417 $content[] = '<button type="button" class="' . $this->html_class_prefix . 'section-button ' . $this->html_class_prefix . 'restart-button">'. $this->buttons_texts[ 'restartButton' ] .'</button>';
1418 $content[] = '</div>';
1419 $content[] = '</div>';
1420 $content[] = '</div>';
1421 }
1422
1423 if( $this->options[ $this->name_prefix . 'enable_exit_button' ] ){
1424 if( $this->options[ $this->name_prefix . 'exit_redirect_url' ] != '' && filter_var( $this->options[ $this->name_prefix . 'exit_redirect_url' ], FILTER_VALIDATE_URL) !== false ){
1425
1426 $content[] = '<div class="' . $this->html_class_prefix . 'section-buttons">';
1427 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-container" tabindex="0">';
1428 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-content">';
1429 $content[] = '<a href="' . $this->options[ $this->name_prefix . 'exit_redirect_url' ] . '" class="' . $this->html_class_prefix . 'section-button">'. $this->buttons_texts[ 'exitButton' ] .'</a>';
1430 $content[] = '</div>';
1431 $content[] = '</div>';
1432 $content[] = '</div>';
1433 }
1434 }
1435
1436 if( $this->options[ $this->name_prefix . 'social_buttons' ] ){
1437 $actual_link = "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
1438 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === "on"){
1439 $actual_link = "https" . $actual_link;
1440 }else{
1441 $actual_link = "http" . $actual_link;
1442 }
1443 $content[] = "<div class='ays-survey-social-shares'>";
1444 $content[] .= "<div class='ays-survey-social-shares-heading'>";
1445 // $content[] .= $this->options[ $this->name_prefix . 'social_buttons_heading' ];
1446 $content[] .= "</div>";
1447
1448
1449 if ( $this->options[ $this->name_prefix . 'social_button_ln' ] ) {
1450 $content[] = "<a class='ays-survey-share-btn ays-survey-share-btn-linkedin ays-survey-share-btn-all'
1451 href='https://www.linkedin.com/shareArticle?mini=true&url=" . $actual_link . "'
1452 title='Share on LinkedIn'>
1453 <span class='ays-survey-share-btn-icon'></span>
1454 <span class='ays-share-btn-text'>LinkedIn</span>
1455 </a>";
1456 }
1457 if ( $this->options[ $this->name_prefix . 'social_button_fb' ] ) {
1458 $content[] = "<a class='ays-survey-share-btn ays-survey-share-btn-facebook ays-survey-share-btn-all'
1459 href='https://www.facebook.com/sharer/sharer.php?u=" . $actual_link . "'
1460 title='Share on Facebook'>
1461 <span class='ays-survey-share-btn-icon'></span>
1462 <span class='ays-share-btn-text'>Facebook</span>
1463 </a>";
1464 }
1465 if ( $this->options[ $this->name_prefix . 'social_button_tr' ] ) {
1466 $content[] = "<a class='ays-survey-share-btn ays-survey-share-btn-twitter ays-survey-share-btn-all'
1467 href='https://twitter.com/share?url=" . $actual_link . "'
1468 title='Share on X'>
1469 <span class='ays-survey-share-btn-icon'></span>
1470 <span class='ays-share-btn-text'>X</span>
1471 </a>";
1472 }
1473 if ( $this->options[ $this->name_prefix . 'social_button_vk' ] ) {
1474 $content[] = "<a class='ays-survey-share-btn ays-survey-share-btn-vkontakte ays-survey-share-btn-all'
1475 href='https://vk.com/share.php?url=" . $actual_link . "'
1476 title='Share on VKontakte'>
1477 <span class='ays-survey-share-btn-icon'></span>
1478 <span class='ays-share-btn-text'>VKontakte</span>
1479 </a>";
1480 }
1481 $content[] = "</div>";
1482 }
1483
1484
1485 $content[] = '</div>';
1486 $content[] = '</div>';
1487
1488 $content[] = '</div>';
1489 $content[] = '</div>';
1490
1491 $content[] = '</div>';
1492
1493 $content = implode( '', $content );
1494
1495 return $content;
1496 }
1497
1498 public function create_section( $section, $last, $first, $section_count, $section_numbering ){
1499
1500 $content = array();
1501 $show_question_numbering = $this->options[ $this->name_prefix . 'auto_numbering_questions' ];
1502 $this->options[ $this->name_prefix . 'question_numbering_array' ] = Survey_Maker_Data::ays_survey_numbering_all( $show_question_numbering );
1503 $content[] = '<div class="' . $this->html_class_prefix . 'section" data-page-number="'.$section_numbering.'">';
1504 $minimal_theme_header = $this->options[ $this->name_prefix . 'is_minimal' ] ? 'ays-survey-minimal-theme-header' : "";
1505 $modern_theme_header = $this->options[ $this->name_prefix . 'is_modern' ] ? 'ays-survey-modern-theme-header' : "";
1506
1507 if( $this->options[ $this->name_prefix . 'show_section_header' ] ){
1508 $show_section_header = true;
1509 if( $section['title'] == '' && $section['description'] == '' ){
1510 $show_section_header = false;
1511 }
1512 if( $this->options[ $this->name_prefix . 'show_sections_questions_count' ] ){
1513 $show_section_header = true;
1514 }
1515 if( $show_section_header ){
1516 $content[] = '<div class="' . $this->html_class_prefix . 'section-header ' . $minimal_theme_header . ' '.$modern_theme_header.'">';
1517
1518 $content[] = '<div class="' . $this->html_class_prefix . 'section-title-row">';
1519 $content[] = '<div class="' . $this->html_class_prefix . 'section-title-row-main">';
1520 $content[] = '<span class="' . $this->html_class_prefix . 'section-title">' . stripslashes( $section['title'] ) . '</span>';
1521 $content[] = '</div>';
1522 $content[] = '</div>';
1523
1524 $content[] = '<div class="' . $this->html_class_prefix . 'section-desc">' . stripslashes( $section['description'] ) . '</div>';
1525 if( $this->options[ $this->name_prefix . 'show_sections_questions_count' ] ){
1526 $content[] = '<div class="' . $this->html_class_prefix . 'section-questions-count" title="'. esc_attr__('Questions Count', 'survey-maker') .'">' . count( $section['questions'] ) . '</div>';
1527 }
1528
1529 $content[] = '</div>';
1530 }
1531 }
1532
1533 $content[] = '<div class="' . $this->html_class_prefix . 'section-content">';
1534
1535 $content[] = '<div class="' . $this->html_class_prefix . 'section-questions">';
1536
1537 if( $this->options[ $this->name_prefix . 'enable_randomize_questions' ] ){
1538 shuffle( $section['questions'] );
1539 }
1540
1541 $loop_count = 1;
1542
1543 $other_answer_count = 0;
1544 $check_question_type_for_next_button = 0;
1545 $allowed_question_to_disable_next_button = array(
1546 'radio',
1547 'select',
1548 'yesorno'
1549 );
1550
1551 foreach ( $section['questions'] as $key => $question ) {
1552 $numbering = "";
1553 if(isset($this->options[ $this->name_prefix . 'question_numbering_array' ]) && !empty($this->options[ $this->name_prefix . 'question_numbering_array' ])){
1554 $numbering = $this->options[ $this->name_prefix . 'question_numbering_array' ][$key]." ";
1555 }
1556 $content[] = $this->create_question( $question , $numbering, $loop_count );
1557 $loop_count++;
1558
1559 if( isset($question['user_variant']) && $question['user_variant'] ){
1560 $other_answer_count++;
1561 }
1562
1563 if( isset($question['type']) && !in_array($question['type'], $allowed_question_to_disable_next_button) ){
1564 $check_question_type_for_next_button++;
1565 }
1566 }
1567 $content[] = '</div>';
1568
1569 $content[] = '</div>';
1570
1571 $footer_class_with_bar = "";
1572 $footer_class_with_terms = "";
1573 $enable_terms_and_conditions = $this->options[ $this->name_prefix . 'enable_terms_and_conditions' ];
1574 $terms_and_conditions_data = $this->options[ $this->name_prefix . 'terms_and_conditions_data' ];
1575 if($this->options[ $this->name_prefix . 'enable_progress_bar' ] == "on"){
1576 $footer_class_with_bar = "ays-survey-footer-with-live-bar";
1577 }
1578
1579 $enable_terms_and_conditions_required_message = $this->options['enable_terms_and_conditions_required_message'];
1580 if($enable_terms_and_conditions){
1581
1582 $footer_class_with_terms = "ays-survey-footer-with-terms-and-conds";
1583 }
1584
1585 $content[] = '<div class="' . $this->html_class_prefix . 'section-footer '.$footer_class_with_bar.' '.$footer_class_with_terms.'">';
1586
1587 if( $last ){
1588 if( $enable_terms_and_conditions ) {
1589 $content[] = '<div data-required="true" data-all-terms-check="true" data-type="checkbox" class="' . $this->html_class_prefix . 'section-terms-and-conditions-container">';
1590 $content[] = '<div class="' . $this->html_class_prefix . 'section-terms-and-conditions-content">';
1591 $padding_for_bussines = $this->options[ $this->name_prefix . 'is_business' ] ? 'style="padding:0 10px 3px;"' : '';
1592 foreach ($terms_and_conditions_data as $tc_text => $tc_text_value) {
1593 if( $tc_text_value['messages'] != '' ){
1594 $content[] = '<div class="' . $this->html_class_prefix . 'terms-and-conditions-content-box" '.$padding_for_bussines.'>';
1595 $content[] = '<label class="' . $this->html_class_prefix . 'answer-label ' . $this->html_class_prefix . 'answer-label-terms-conditions">';
1596 if($this->options[ $this->name_prefix . 'is_business' ]){
1597 $content[] = '<input type="checkbox" class="' . $this->html_class_prefix . 'is-checked-terms-and-conditions ' . $this->html_class_prefix . 'business-theme-answers">';
1598 $content[] = '<span class="' . $this->html_name_prefix . 'maker-checkmark ' . $this->html_name_prefix . 'maker-checkmark-checkbox" style="top:18px"></span>';
1599 }else{
1600 $content[] = '<input type="checkbox" class="' . $this->html_class_prefix . 'is-checked-terms-and-conditions">';
1601 }
1602 $content[] = '<div class="' . $this->html_class_prefix . 'answer-label-content">';
1603 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content">';
1604 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-ink"></div>';
1605 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-1">';
1606 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-2">';
1607 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-3"></div>';
1608 $content[] = '</div>';
1609 $content[] = '</div>';
1610 $content[] = '</div>';
1611 $content[] = '<div class="' . $this->html_class_prefix . 'section-terms-and-conditions">';
1612 $content[] = '<span class="">' . stripslashes(($tc_text_value['messages'])) . '</span>';
1613 $content[] = '</div>';
1614 $content[] = '</div>';
1615 $content[] = '</label>';
1616
1617 $content[] = '</div>';
1618 }
1619 }
1620 $content[] = '</div>';
1621 if($enable_terms_and_conditions_required_message){
1622 $content[] = '<div class="' . $this->html_class_prefix . 'section-terms-and-conditions-required-message-content" style="display:none;">';
1623 $content[] = '<p class="' . $this->html_class_prefix . 'section-terms-and-conditions-required-message">';
1624 $content[] = '<span class="">' . __('By clicking on the checkbox, you agree to our Terms and Conditions', "survey-maker") . '</span>';
1625 $content[] = '</p>';
1626 $content[] = '</div>';
1627 }
1628 $content[] = '</div>';
1629 }
1630 }
1631 $content[] = '<div class="' . $this->html_class_prefix . 'section-buttons">';
1632
1633 if( ! $first ){
1634 if( $this->options[ $this->name_prefix . 'enable_previous_button' ] ){
1635 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-container" tabindex="0">';
1636 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-content">';
1637 $content[] = '<input type="button" class="' . $this->html_class_prefix . 'section-button ' . $this->html_class_prefix . 'prev-button" value="'. $this->buttons_texts[ 'previousButton' ] .'" />';
1638 $content[] = '</div>';
1639 $content[] = '</div>';
1640 }
1641 }
1642
1643 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-container" tabindex="0">';
1644 $content[] = '<div class="' . $this->html_class_prefix . 'section-button-content">';
1645 if( $last ){
1646 $content[] = '<input type="button" class="' . $this->html_class_prefix . 'section-button ' . $this->html_class_prefix . 'finish-button" value="'. $this->buttons_texts[ 'finishButton' ] .'" />';
1647 }else{
1648 $disalble_next_button_class = $this->checkNextButtonVisibility($other_answer_count, $check_question_type_for_next_button) ? 'display_none_important' : '';
1649 $content[] = '<input type="button" class="' . $this->html_class_prefix . 'section-button ' . $this->html_class_prefix . 'next-button '.$disalble_next_button_class.'" value="'. $this->buttons_texts[ 'nextButton' ] .'" />';
1650 }
1651 $content[] = '</div>';
1652 $content[] = '</div>';
1653 $content[] = '</div>';
1654
1655 if($this->options[ $this->name_prefix . 'enable_progress_bar' ] == "on"){
1656 $page_fill_percent = (1*100)/$section_count;
1657 $content[] = "<div class='" . $this->html_class_prefix . "live-bar-main'>";
1658 if(!($this->options[ $this->name_prefix . 'hide_section_bar' ])){
1659 $content[] = "<div class='" . $this->html_class_prefix . "live-bar-wrap'>
1660 <div class='" . $this->html_class_prefix . "live-bar-fill' style='width: ".$page_fill_percent."%;'></div>
1661 </div>";
1662 }
1663 if(!($this->options[ $this->name_prefix . 'hide_section_pagination_text' ])){
1664 $content[] = "<div class='" . $this->html_class_prefix . "live-bar-status'>
1665 <span class='" . $this->html_class_prefix . "live-bar-status-text'>".sprintf(__("%s %s of %s" , "survey-maker") , $this->options[ $this->name_prefix . 'progress_bar_text' ] , "<span class='" . $this->html_class_prefix . "live-bar-changeable-text'>1</span>" , $section_count)."</span>
1666 </div>";
1667 }
1668 $content[] = "</div>";
1669 }
1670
1671 $content[] = '</div>';
1672
1673 $content[] = '</div>';
1674
1675 $content = implode( '', $content );
1676
1677 return $content;
1678 }
1679
1680 public function create_question( $question , $numbering, $loop_count ){
1681
1682 $question_type = $question['type'];
1683 $answers = $question['answers'];
1684 $answers_html = array();
1685 $is_required = isset( $question['options']['required'] ) && $question['options']['required'] == 'on' ? true : false;
1686 $image_caption = isset($question['options']['image_caption']) ? $question['options']['image_caption'] : '';
1687 $image_caption_enable = $question['options']['image_caption_enable'];
1688 $is_minimum = "false";
1689 if($question_type == 'checkbox'){
1690 if(isset($question['options']['enable_max_selection_count']) && $question['options']['enable_max_selection_count'])
1691 $is_minimum = isset($question['options']['min_selection_count']) && $question['options']['min_selection_count'] != "" ? "true" : "false";
1692 }
1693
1694 // Admin note
1695 $enable_admin_note = $question['options']['enable_admin_note'];
1696 $admin_note = $question['options']['admin_note'];
1697
1698 // Logo Image URL
1699 $survey_logo_url_validate = "javascript:void(0)";
1700 $survey_logo_url = isset($this->options['options'][ $this->name_prefix . 'logo_url' ]) && $this->options['options'][ $this->name_prefix . 'logo_url' ] != "" ? $this->options['options'][ $this->name_prefix . 'logo_url' ] : "";
1701 $survey_logo_url_check = isset($this->options['options'][ $this->name_prefix . 'enable_logo_url' ]) && $this->options['options'][ $this->name_prefix . 'enable_logo_url' ] == "on" ? true : false;
1702 $survey_logo_url_check_new_tab = isset($this->options['options'][ $this->name_prefix . 'logo_url_new_tab' ]) && $this->options['options'][ $this->name_prefix . 'logo_url_new_tab' ] == "on" ? true : false;
1703 $survey_logo_target = "";
1704 if($survey_logo_url_check){
1705 $survey_logo_url_validate = filter_var($survey_logo_url, FILTER_VALIDATE_URL) ? $survey_logo_url : $survey_logo_url_validate;
1706 if(filter_var($survey_logo_url, FILTER_VALIDATE_URL) && $survey_logo_url_check_new_tab){
1707 $survey_logo_target = "target='_blank'";
1708 }
1709 }
1710 //
1711 if( $this->options[ $this->name_prefix . 'enable_randomize_answers' ] ){
1712 shuffle( $question['answers'] );
1713 shuffle( $answers );
1714 }
1715
1716 $other_answer = $question['user_variant'];
1717 if( $other_answer ){
1718 $answers[] = array(
1719 'id' => '0',
1720 'question_id' => $question['id'],
1721 'answer' => '',
1722 'image' => '',
1723 'ordering' => count( $answers ) + 1,
1724 'placeholder' => '',
1725 'is_other' => true,
1726 );
1727 }
1728
1729 $answers['is_first_question'] = $loop_count;
1730 $question['answers']['is_first_question'] = $loop_count;
1731 $is_lazy_loading = ($loop_count > 1) ? $this->lazy_loading : "";
1732 $show_answers_numbering = $this->options[ $this->name_prefix . 'auto_numbering' ];
1733 $this->options[ $this->name_prefix . 'numbering_array' ] = Survey_Maker_Data::ays_survey_numbering_all( $show_answers_numbering );
1734
1735 $minimal_theme_question = $this->options[ $this->name_prefix . 'is_minimal' ] ? 'ays-survey-minimal-theme-question' : "";
1736 $modern_theme_question = $this->options[ $this->name_prefix . 'is_modern' ] ? 'ays-survey-modern-theme-question' : "";
1737
1738 $has_answer_image = false;
1739 foreach ($answers as $key => $answer) {
1740 if(isset( $answer['image'] ) && $answer['image'] != ""){
1741 $has_answer_image = true;
1742 }
1743 }
1744
1745 $question_types = array(
1746 "radio",
1747 "checkbox",
1748 "select",
1749 "star",
1750 "date",
1751 "time",
1752 "date_time",
1753 "text",
1754 "short_text",
1755 "number",
1756 "phone",
1757 "email",
1758 "name",
1759 );
1760
1761 $question_types_getting_answers_array = array(
1762 "radio",
1763 "checkbox",
1764 );
1765
1766 if( !in_array( $question_type, $question_types ) ){
1767 $question_type = "radio";
1768 }
1769
1770
1771 $question_type_function = 'ays_survey_question_type_' . strtoupper( $question_type ) . '_html';
1772
1773 $transmitting_array = in_array( $question_type, $question_types_getting_answers_array ) ? $answers : $question;
1774
1775 $answers_html[] = $this->$question_type_function( $transmitting_array );
1776
1777 $answers_html = implode( '', $answers_html );
1778
1779 $answer_grid = '';
1780 if( $has_answer_image || $this->options[ $this->name_prefix . 'answers_view' ] == 'grid' ){
1781 $answer_grid = $this->html_class_prefix . 'question-answers-grid';
1782 }
1783 $data_required = $is_required ? "true" : "false";
1784
1785 $is_required_field = $is_required ? '<sup class="' . $this->html_class_prefix . 'question-required-icon">*</sup>' : "";
1786
1787
1788 $question_title = Survey_Maker_Data::survey_sanitize_specific_content($question['question']);
1789 if($numbering){
1790 preg_match('/<([a-z]+[1-9]*)\b[^>]*>(.*?)<\/\1>/', $question_title, $matches );
1791 if(empty($matches)){
1792 $question_title = $numbering . $question_title;
1793 }else{
1794 $question_title_numbering_1 = $numbering . $matches[2];
1795 $question_title_numbering_2 = str_replace( $matches[2], $question_title_numbering_1, $matches[0] );
1796 $question_title = str_replace( $matches[0], $question_title_numbering_2, $question_title );
1797 }
1798 }
1799
1800 if ( $is_required_field != "" ) {
1801 preg_match('/<([a-z]+[1-9]*)\b[^>]*>(.*?)<\/\1>/', $question_title, $matches );
1802 if(empty($matches)){
1803 $question_title = $question_title . $is_required_field;
1804 }else{
1805 $question_title_numbering_1 = $matches[2] . $is_required_field;
1806 $question_title_numbering_2 = str_replace( $matches[2], $question_title_numbering_1, $matches[0] );
1807 $question_title = str_replace( $matches[0], $question_title_numbering_2, $question_title );
1808 }
1809 }
1810
1811 $content = array();
1812 $content[] = '<div class="' . $this->html_class_prefix . 'question ' . $minimal_theme_question . ' '.$modern_theme_question . '" data-required="' . $data_required . '" data-type="' . $question_type . '" data-is-min="'.$is_minimum.'">';
1813
1814 $content[] = '<div class="' . $this->html_class_prefix . 'question-header">';
1815
1816 $content[] = '<div class="' . $this->html_class_prefix . 'question-header-content">';
1817
1818 $content[] = '<div class="' . $this->html_class_prefix . 'question-title">' . Survey_Maker_Data::ays_autoembed( $question_title );
1819
1820 $content[] = '</div>';
1821
1822 $content[] = '</div>';
1823
1824 if( isset( $question['image'] ) && $question['image'] != "" ){
1825 $content[] = '<div class="' . $this->html_class_prefix . 'question-image-container">';
1826 $surve_question_image_alt_text = Survey_Maker_Data::ays_survey_get_image_id_by_url($question['image']);
1827 $content[] = '<img class="' . $this->html_class_prefix . 'question-image" src="' . $question['image'] . '" alt="' . $surve_question_image_alt_text . '" '.$is_lazy_loading.' />';
1828 if($image_caption_enable){
1829 $content[] = '<div class="' . $this->html_class_prefix . 'question-image-caption">';
1830 $content[] = '<span>'.$image_caption.'</span>';
1831 $content[] = '</div>';
1832 }
1833 $content[] = '</div>';
1834 }
1835
1836 $content[] = '</div>';
1837
1838 $content[] = '<div class="' . $this->html_class_prefix . 'question-content">';
1839
1840 $content[] = '<div class="' . $this->html_class_prefix . 'question-answers ' . $answer_grid . '">';
1841
1842 $content[] = $answers_html;
1843
1844 $content[] = '<input type="hidden" name="' . $this->html_name_prefix . 'questions-' . $this->unique_id . '[' . $question['id'] . '][section]" value="' . $question['section_id'] . '">';
1845 $content[] = '<input type="hidden" name="' . $this->html_name_prefix . 'questions-' . $this->unique_id . '[' . $question['id'] . '][questionType]" value="' . $question_type . '">';
1846 $content[] = '<input type="hidden" class="' . $this->html_class_prefix . 'question-id" name="' . $this->html_name_prefix . 'questions-' . $this->unique_id . '[' . $question['id'] . '][questionId]" value="' . $question['id'] . '">';
1847
1848 if( $this->options[ $this->name_prefix . 'enable_clear_answer' ] ){
1849 $content[] = '<div class="' . $this->html_class_prefix . 'answer-clear-selection-container ' . $this->html_class_prefix . 'visibility-none transition fade">';
1850 $content[] = '<div class="' . $this->html_class_prefix . 'simple-button-container">';
1851 $content[] = '<div class="' . $this->html_class_prefix . 'button-content">';
1852 $content[] = '<span class="' . $this->html_class_prefix . 'answer-clear-selection-text ' . $this->html_class_prefix . 'button" tabindex="0">' . $this->buttons_texts[ 'clearButton' ] . '</span>';
1853 $content[] = '</div>';
1854 $content[] = '</div>';
1855 $content[] = '</div>';
1856 }
1857
1858 $content[] = '</div>';
1859
1860 $content[] = '</div>';
1861
1862 if( $enable_admin_note && $admin_note != "" ){
1863 $content[] = "<div class='" . $this->html_class_prefix . "admin-note-main'>
1864 <div class='" . $this->html_class_prefix . "admin-note-inner'><span class='" . $this->html_class_prefix . "admin-note-text'>" . $admin_note . "</span></div>
1865 </div>";
1866 }
1867
1868 $content[] = '<div class="' . $this->html_class_prefix . 'question-footer">';
1869 if($is_minimum == 'true'){
1870 $content[] = '<div class="' . $this->html_class_prefix . 'votes-count-validation-error" role="alert"></div>';
1871 }
1872 $content[] = '<div class="' . $this->html_class_prefix . 'question-validation-error" role="alert"></div>';
1873 if(isset($this->options[ $this->name_prefix . 'logo' ]) && $this->options[ $this->name_prefix . 'logo' ] != ""){
1874 $content[] = '<div class="' . $this->html_class_prefix . 'image-logo-url">
1875 <a href="'.$survey_logo_url_validate.'" '.$survey_logo_target.' style="display: inline-block;">
1876 <img title="'.$this->options[ $this->name_prefix . 'logo_title' ].'" src="'.$this->options[ $this->name_prefix . 'logo' ].'" class="' . $this->html_class_prefix . 'image-logo-url-img">
1877 </a>
1878 </div>';
1879 }
1880 $content[] = '</div>';
1881
1882 $content[] = '</div>';
1883
1884 $content = implode( '', $content );
1885
1886 return $content;
1887 }
1888
1889 public function ays_survey_question_type_RADIO_html( $answers ){
1890
1891 $content = array();
1892
1893 $has_answer_image = false;
1894 foreach ($answers as $key => $answer) {
1895 if(isset( $answer['image'] ) && $answer['image'] != ""){
1896 $has_answer_image = true;
1897 }
1898 }
1899
1900 $answer_grid = '';
1901 $answer_label_grid = '';
1902 if( $has_answer_image || $this->options[ $this->name_prefix . 'answers_view' ] == 'grid' ){
1903 $answer_grid = $this->html_class_prefix . 'answer-grid';
1904 $answer_label_grid = $this->html_class_prefix . 'answer-label-grid';
1905 }
1906
1907 $is_first_question = $answers['is_first_question'];
1908 $is_lazy_loading = ($is_first_question > 1) ? $this->lazy_loading : "";
1909 unset($answers['is_first_question']);
1910
1911 foreach ($answers as $key => $answer) {
1912
1913 $is_other = false;
1914 if( isset( $answer['is_other'] ) && $answer['is_other'] == true ){
1915 $is_other = true;
1916 }
1917
1918 $answer_label_other = '';
1919 $other_answer_box_width = '';
1920 if( $is_other ){
1921 $answer_label_other = $this->html_class_prefix . 'answer-label-other';
1922 $other_answer_box_width = $this->html_class_prefix . 'other-answer-container';
1923 }
1924
1925 $content[] = '<div class="' . $this->html_class_prefix . 'answer ' . $answer_grid . ' '.$other_answer_box_width.'">';
1926
1927 $content[] = '<label class="' . $this->html_class_prefix . 'answer-label ' . $answer_label_grid . ' ' . $answer_label_other . '" tabindex="0">';
1928
1929 if( $this->options[$this->name_prefix . 'is_minimal'] ){
1930 if( isset( $answer['image'] ) && $answer['image'] != "" ){
1931 $content[] = '<div class="' . $this->html_class_prefix . 'answer-image-container">';
1932 $content[] = '<img class="' . $this->html_class_prefix . 'answer-image" '. $is_lazy_loading .' src="' . $answer['image'] . '" alt="' . stripslashes( $answer['answer'] ) . '" />';
1933 $content[] = '</div>';
1934 }
1935 if (!$is_other) {
1936 $content[] = '<input class="" type="radio" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $answer['question_id'] . '][answer]" value="' . $answer['id'] . '">';
1937 } else {
1938 $content[] = '<input class="" type="radio" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $answer['question_id'] . '][answer]" data-logicjump="' . $answer['question_id'] . '" value="' . $answer['id'] . '">';
1939 }
1940 }
1941 else{
1942
1943 $content[] = '<input class="" type="radio" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $answer['question_id'] . '][answer]" value="' . $answer['id'] . '" autocomplete="off">';
1944
1945 if( isset( $answer['image'] ) && $answer['image'] != "" ){
1946 $content[] = '<div class="' . $this->html_class_prefix . 'answer-image-container">';
1947 $content[] = '<img class="' . $this->html_class_prefix . 'answer-image" src="' . $answer['image'] . '" alt="' . stripslashes( $answer['answer'] ) . '" '. $is_lazy_loading .' />';
1948 $content[] = '</div>';
1949 }
1950 }
1951
1952 $content[] = '<div class="' . $this->html_class_prefix . 'answer-label-content">';
1953
1954 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content">';
1955 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-ink"></div>';
1956 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-1">';
1957 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-2">';
1958 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-3"></div>';
1959 $content[] = '</div>';
1960 $content[] = '</div>';
1961 $content[] = '</div>';
1962
1963 if( $is_other ){
1964 $content[] = '<span class="">' . __( 'Other', "survey-maker" ) . ':</span>';
1965 }else{
1966 if( ! empty( $this->options[ $this->name_prefix . 'numbering_array' ] ) ){
1967 $numebering_answer = $this->options[ $this->name_prefix . 'numbering_array' ][$key] . ' ';
1968 }else{
1969 $numebering_answer = '';
1970 }
1971 $content[] = '<span class="">' .$numebering_answer . $answer['answer'] . '</span>';
1972 }
1973
1974 $content[] = '</div>';
1975 $content[] = '</label>';
1976
1977 if( $is_other ){
1978
1979 $content[] = '<div class="' . $this->html_class_prefix . 'answer-other-text">';
1980 $content[] = '<input id="' . $this->html_class_prefix . 'answer-other-input-' . $answer['question_id'] . '" class="' . $this->html_class_prefix . 'answer-other-input ' .
1981 $this->html_class_prefix . 'remove-default-border ' .
1982 $this->html_class_prefix . 'question-input ' .
1983 $this->html_class_prefix . 'input
1984 ' . $this->html_class_prefix . 'answer-text-inputs"
1985 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $answer['question_id'] . '][other]"
1986 type="text" autocomplete="off" tabindex="0" />';
1987 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline" style="margin:0;"></div>';
1988 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation" style="margin:0;"></div>';
1989 $content[] = '</div>';
1990
1991 }
1992
1993 $content[] = '</div>';
1994 }
1995
1996 $content = implode( '', $content );
1997
1998 return $content;
1999 }
2000
2001 public function ays_survey_question_type_CHECKBOX_html( $answers ){
2002 $content = array();
2003 $has_answer_image = false;
2004 foreach ($answers as $key => $answer) {
2005 if(isset( $answer['image'] ) && $answer['image'] != ""){
2006 $has_answer_image = true;
2007 }
2008 }
2009
2010 $answer_grid = '';
2011 $answer_label_grid = '';
2012 if( $has_answer_image || $this->options[ $this->name_prefix . 'answers_view' ] == 'grid' ){
2013 $answer_grid = $this->html_class_prefix . 'answer-grid';
2014 $answer_label_grid = $this->html_class_prefix . 'answer-label-grid';
2015 }
2016
2017 $is_first_question = $answers['is_first_question'];
2018 $is_lazy_loading = ($is_first_question > 1) ? $this->lazy_loading : "";
2019 unset($answers['is_first_question']);
2020 foreach ($answers as $key => $answer) {
2021
2022 $is_other = false;
2023 if( isset( $answer['is_other'] ) && $answer['is_other'] == true ){
2024 $is_other = true;
2025 }
2026
2027 $answer_label_other = '';
2028 $other_answer_box_width = '';
2029 if( $is_other ){
2030 $answer_label_other = $this->html_class_prefix . 'answer-label-other';
2031 $other_answer_box_width = $this->html_class_prefix . 'other-answer-container';
2032 }
2033
2034 $content[] = '<div class="' . $this->html_class_prefix . 'answer ' . $answer_grid . ' '.$other_answer_box_width.'">';
2035
2036 $content[] = '<label class="' . $this->html_class_prefix . 'answer-label ' . $answer_label_grid . ' ' . $answer_label_other . '" tabindex="0">';
2037
2038 if( $this->options[$this->name_prefix . 'is_minimal'] ){
2039 if( isset( $answer['image'] ) && $answer['image'] != "" ){
2040 $content[] = '<div class="' . $this->html_class_prefix . 'answer-image-container">';
2041 $content[] = '<img class="' . $this->html_class_prefix . 'answer-image" '. $is_lazy_loading .' src="' . $answer['image'] . '" alt="' . stripslashes( $answer['answer'] ) . '" />';
2042 $content[] = '</div>';
2043 }
2044
2045 $content[] = '<input class="" type="checkbox" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $answer['question_id'] . '][answer][]" value="' . $answer['id'] . '">';
2046 }
2047 else{
2048 $content[] = '<input class="" type="checkbox" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $answer['question_id'] . '][answer][]" value="' . $answer['id'] . '" autocomplete="off">';
2049
2050 if( isset( $answer['image'] ) && $answer['image'] != "" ){
2051 $content[] = '<div class="' . $this->html_class_prefix . 'answer-image-container">';
2052 $content[] = '<img class="' . $this->html_class_prefix . 'answer-image" src="' . $answer['image'] . '" '. $is_lazy_loading .' alt="' . stripslashes( $answer['answer'] ) . '" />';
2053 $content[] = '</div>';
2054 }
2055 }
2056
2057 $content[] = '<div class="' . $this->html_class_prefix . 'answer-label-content">';
2058
2059 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content">';
2060 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-ink"></div>';
2061 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-1">';
2062 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-2">';
2063 $content[] = '<div class="' . $this->html_class_prefix . 'answer-icon-content-3"></div>';
2064 $content[] = '</div>';
2065 $content[] = '</div>';
2066 $content[] = '</div>';
2067
2068 if( $is_other ){
2069 $content[] = '<span class="">' . __( 'Other', "survey-maker" ) . ':</span>';
2070 }else{
2071 if( ! empty( $this->options[ $this->name_prefix . 'numbering_array' ] ) ){
2072 $numebering_answer = $this->options[ $this->name_prefix . 'numbering_array' ][$key] . ' ';
2073 }else{
2074 $numebering_answer = '';
2075 }
2076 $content[] = '<span class="">' . $numebering_answer . $answer['answer'] . '</span>';
2077 }
2078
2079 $content[] = '</div>';
2080 $content[] = '</label>';
2081
2082 if( $is_other ){
2083
2084 $content[] = '<div class="' . $this->html_class_prefix . 'answer-other-text">';
2085 $content[] = '<input id="' . $this->html_class_prefix . 'answer-other-input-' . $answer['question_id'] . '" class="' . $this->html_class_prefix . 'answer-other-input ' .
2086 $this->html_class_prefix . 'remove-default-border ' .
2087 $this->html_class_prefix . 'question-input ' .
2088 $this->html_class_prefix . 'input
2089 ' . $this->html_class_prefix . 'answer-text-inputs"
2090 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $answer['question_id'] . '][other]"
2091 type="text" autocomplete="off" tabindex="0" />';
2092 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline" style="margin:0;"></div>';
2093 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation" style="margin:0;"></div>';
2094 $content[] = '</div>';
2095
2096 }
2097
2098 $content[] = '</div>';
2099 }
2100
2101 $content = implode( '', $content );
2102
2103 return $content;
2104 }
2105
2106 public function ays_survey_question_type_SELECT_html( $question ){
2107 $content = array();
2108
2109 $is_first_question = $question['answers']['is_first_question'];
2110 $is_lazy_loading = ($is_first_question > 1) ? $this->lazy_loading : "";
2111 unset($question['answers']['is_first_question']);
2112 $select_class = $this->html_class_prefix . 'question-select-conteiner-minimal';
2113 if( $this->options[$this->name_prefix . 'is_minimal']){
2114 $content[] = '<div class="' . $this->html_class_prefix . 'answer">';
2115 $content[] = '<div class="' . $this->html_class_prefix . 'question-type-select-box">';
2116 $content[] = '<div class="' . $this->html_class_prefix . 'question-select-conteiner">';
2117 $content[] = '<select class="' . $select_class . '"
2118 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . ']">';
2119 foreach ( $question['answers'] as $key => $answer ) {
2120
2121 $content[] = "<option value='" . $answer['id'] . "' >";
2122 if( ! empty( $this->options[ $this->name_prefix . 'numbering_array' ] ) ){
2123 $numebering_answer = $this->options[ $this->name_prefix . 'numbering_array' ][$key] . ' ';
2124 }else{
2125 $numebering_answer = '';
2126 }
2127 $content[] = $numebering_answer . stripslashes( $answer['answer'] );
2128 $content[] = '</option>';
2129 }
2130 $content[] = '</select>';
2131 $content[] = '</div>';
2132 $content[] = '</div>';
2133 $content[] = '</div>';
2134 }
2135 else{
2136 $content[] = '<div class="' . $this->html_class_prefix . 'answer">';
2137
2138 $content[] = '<div class="' . $this->html_class_prefix . 'question-type-select-box">';
2139 $content[] = '<div class="' . $this->html_class_prefix . 'question-select-conteiner">';
2140
2141 $content[] = '<div class="' . $this->html_class_prefix . 'question-select ui selection icon dropdown">';
2142
2143 $content[] = '<input type="hidden" class="' . $this->html_name_prefix . 'detect-selected-question-dropdown" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . ']">';
2144
2145 $content[] = '<i class="dropdown icon"></i>';
2146 $content[] = '<div class="default text">'.__('Choose', "survey-maker").'</div>';
2147
2148 $content[] = '<div class="menu">';
2149
2150 foreach ( $question['answers'] as $key => $answer ) {
2151 $content[] = '<div class="item" data-value="'. $answer['id'] .'">';
2152
2153 if( isset( $answer['image'] ) && $answer['image'] != "" ){
2154 $content[] = '<img class="' . $this->html_class_prefix . 'answer-image" src="' . $answer['image'] . '" alt="' . stripslashes( $answer['answer'] ) . '" '. $is_lazy_loading .' />';
2155 }
2156
2157 if( ! empty( $this->options[ $this->name_prefix . 'numbering_array' ] ) ){
2158 $numebering_answer = $this->options[ $this->name_prefix . 'numbering_array' ][$key] . ' ';
2159 }else{
2160 $numebering_answer = '';
2161 }
2162
2163 $content[] = $numebering_answer . stripslashes( $answer['answer'] );
2164
2165 $content[] = '</div>';
2166 }
2167
2168 $content[] = '</div>';
2169 $content[] = '</div>';
2170
2171 $content[] = '</div>';
2172 $content[] = '</div>';
2173
2174 $content[] = '</div>';
2175 }
2176
2177 $content = implode( '', $content );
2178
2179 return $content;
2180 }
2181
2182
2183 public function ays_survey_question_type_STAR_html( $question ){
2184 $content = array();
2185
2186 //checked Input
2187 $enable_url_parameter = isset($question['options']['enable_url_parameter']) && $question['options']['enable_url_parameter'] == true ? true : false;
2188 $url_parameter = $enable_url_parameter && isset($question['options']['url_parameter']) && $question['options']['url_parameter'] != "" ? $question['options']['url_parameter'] : '';
2189 $selected_input = isset($_GET[$url_parameter]) && $_GET[$url_parameter] ? $_GET[$url_parameter] : '';
2190
2191 $star_label_1 = (isset($question['options']['star_1']) && $question['options']['star_1'] != '') ? $question['options']['star_1'] : '';
2192 $star_label_2 = (isset($question['options']['star_2']) && $question['options']['star_2'] != '') ? $question['options']['star_2'] : '';
2193 $star_scale_length = (isset($question['options']['star_scale_length']) && $question['options']['star_scale_length'] != '') ? absint( $question['options']['star_scale_length'] ) : 5;
2194
2195 $content[] = '<div class="' . $this->html_class_prefix . 'answer-star">';
2196
2197 $content[] = '<label class="' . $this->html_class_prefix . 'answer-star-label">';
2198 $content[] = '<div class="' . $this->html_class_prefix . 'answer-star-radio-label" dir="auto"></div>';
2199 $content[] = '<div class="' . $this->html_class_prefix . 'answer-star-radio">';
2200 $content[] = $star_label_1;
2201 $content[] = '</div>';
2202 $content[] = '</label>';
2203
2204 for ($i=1; $i <= $star_scale_length; $i++) {
2205 $is_selected = $i == $selected_input ? "checked" : "";
2206 $active_answer = $i == $selected_input ? "active-answer" : "";
2207 $selected_stars = ($i <= $selected_input) && ($selected_input <= $star_scale_length) ? "fa-star" : "fa-star-o";
2208
2209 $content[] = '<label class="' . $this->html_class_prefix . 'answer-label ' . $active_answer . '">';
2210 $content[] = '<div class="' . $this->html_class_prefix . 'answer-star-radio-label" dir="auto"></div>';
2211 $content[] = '<div class="' . $this->html_class_prefix . 'answer-star-radio" tabindex="0">';
2212
2213 $content[] = '<input type="radio" value="'.$i.'" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]"' . $is_selected . '>';
2214
2215 $content[] = '<i class="fa ' . $selected_stars . ' ' . $this->html_class_prefix . 'star-icon"></i>';
2216
2217 $content[] = '</div>';
2218 $content[] = '</label>';
2219 }
2220
2221 $content[] = '<label class="' . $this->html_class_prefix . 'answer-star-label">';
2222 $content[] = '<div class="' . $this->html_class_prefix . 'answer-star-radio-label" dir="auto"></div>';
2223 $content[] = '<div class="' . $this->html_class_prefix . 'answer-star-radio">';
2224 $content[] = $star_label_2;
2225 $content[] = '</div>';
2226 $content[] = '</label>';
2227
2228 $content[] = '</div>';
2229
2230 $content = implode( '', $content );
2231
2232 return $content;
2233 }
2234
2235 public function ays_survey_question_type_TEXT_html( $question ){
2236 $content = array();
2237 // Input types placeholders
2238 $survey_input_type_placeholder = isset($question['options']['placeholder']) && $question['options']['placeholder'] != "" ? $question['options']['placeholder'] : '';
2239
2240 $enable_word_limit = isset($question['options']['enable_word_limitation']) && $question['options']['enable_word_limitation'] == "on" ? true : false;
2241 $show_limit = isset($question['options']['limit_counter']) && $question['options']['limit_counter'] == "on" ? true : false;
2242 $limit_length = isset($question['options']['limit_length']) && $question['options']['limit_length'] != "" ? $question['options']['limit_length'] : "";
2243 $limit_by = "Character";
2244 $limit_checker = false;
2245 $survey_question_limit_length_class = '';
2246 if($enable_word_limit ){
2247 if($show_limit){
2248 $limit_checker = true;
2249 }
2250 $survey_question_limit_length_class = $this->html_class_prefix . 'check-word-limit ';
2251 }
2252 if($question['options']['limit_by'] && $question['options']['limit_by'] == "word"){
2253 $limit_by = "Word";
2254 }
2255 if(intval($limit_length) > 0){
2256 $limit_by .= "s ";
2257 }
2258 $limit_by .= __("left", "survey-maker");
2259 if(intval($limit_length) <= 0){
2260 $limit_by = '';
2261 }
2262
2263 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2264 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-input-textarea ' . $this->html_class_prefix . 'question-input';
2265 if( $minimal_theme ){
2266 $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input";
2267 }
2268
2269
2270 $content[] = '<div class="' . $this->html_class_prefix . 'answer">';
2271
2272 $content[] = '<div class="' . $this->html_class_prefix . 'question-box ' . $this->html_class_prefix . 'question-type-text-box">';
2273 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box">';
2274
2275 $content[] = '<textarea class="
2276 ' . $minimal_class . '
2277 ' .
2278 $this->html_class_prefix . 'remove-default-border ' .
2279 $this->html_class_prefix . 'question-input-textarea ' .
2280 $survey_question_limit_length_class .
2281 $this->html_class_prefix . 'question-input ' .
2282 $this->html_class_prefix . 'input
2283 ' . $this->html_class_prefix . 'answer-text-inputs" type="text" style="min-height: 24px;"
2284 placeholder="'. __( $survey_input_type_placeholder, "survey-maker" ) .'"
2285 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]" autocomplete="off">';
2286 $content[] = '</textarea>';
2287
2288 if( ! $minimal_theme ){
2289 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2290 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2291 }
2292
2293 $content[] = '</div>';
2294 if($limit_checker){
2295 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-conteiner">';
2296 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-message">';
2297 $content[] .= '<span class="'.$this->html_class_prefix.'question-text-message-span">'. $limit_length . '</span> ' . $limit_by;
2298 $content[] .= '</div>';
2299 $content[] .= '</div>';
2300 }
2301 $content[] = '</div>';
2302
2303 $content[] = '</div>';
2304
2305 $content = implode( '', $content );
2306
2307 return $content;
2308 }
2309
2310 public function ays_survey_question_type_SHORT_TEXT_html( $question ){
2311 $content = array();
2312 // Input types placeholders
2313 $survey_input_type_placeholder = isset($question['options']['placeholder']) && $question['options']['placeholder'] != "" ? $question['options']['placeholder'] : '';
2314
2315 $enable_value_prefix = $question['options']['enable_value_prefix'];
2316 $value_prefix = $enable_value_prefix ? stripslashes(sanitize_text_field($question['options']['value_prefix'])) : '';
2317
2318 $enable_value_suffix = $question['options']['enable_value_suffix'];
2319 $value_suffix = $enable_value_suffix ? stripslashes(sanitize_text_field($question['options']['value_suffix'])) : '';
2320
2321 $answer_box_prefix_suffix_css_class = "";
2322 $answer_container_prefix_suffix_css_class = "";
2323 if( $value_prefix != "" || $value_suffix != "" ){
2324 $answer_box_prefix_suffix_css_class = $this->html_class_prefix . 'question-box-text-types-prefix-suffix';
2325 }
2326 $answer_container_prefix_suffix_css_class = $this->html_class_prefix . 'answer-box-text-types-prefix-suffix';
2327
2328 $enable_word_limit = isset($question['options']['enable_word_limitation']) && $question['options']['enable_word_limitation'] ? true : false;
2329 $show_limit = isset($question['options']['limit_counter']) && $question['options']['limit_counter'] == "on" ? true : false;
2330 $limit_length = isset($question['options']['limit_length']) && $question['options']['limit_length'] != "" ? $question['options']['limit_length'] : "";
2331 $limit_by = "Character";
2332 $limit_checker = false;
2333 $survey_question_limit_length_class = '';
2334 if($enable_word_limit ){
2335 if($show_limit){
2336 $limit_checker = true;
2337 }
2338 $survey_question_limit_length_class = $this->html_class_prefix . 'check-word-limit ';
2339 }
2340 if($question['options']['limit_by'] && $question['options']['limit_by'] == "word"){
2341 $limit_by = "Word";
2342 }
2343 if(intval($limit_length) > 0){
2344 $limit_by .= "s ";
2345 }
2346 $limit_by .= __("left", "survey-maker");
2347 if(intval($limit_length) <= 0){
2348 $limit_by = '';
2349 }
2350
2351 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2352 $minimal_class = $this->html_class_prefix . 'remove-default-border ' .$this->html_class_prefix . 'question-input';
2353 if( $minimal_theme ){
2354 $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input";
2355 }
2356
2357 $content[] = '<div class="' . $this->html_class_prefix . 'answer '. $answer_container_prefix_suffix_css_class .'">';
2358
2359 $content[] = '<div class="' . $this->html_class_prefix . 'question-box '. $answer_box_prefix_suffix_css_class .'">';
2360 if( $value_prefix != "" ){
2361 $content[] = '<div class="' . $this->html_class_prefix . 'question-answer-prefix">' . $value_prefix . '</div>';
2362 }
2363
2364 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box">';
2365
2366 $content[] = '<input class="
2367 ' . $minimal_class . '
2368 ' .
2369 $this->html_class_prefix . 'remove-default-border ' .
2370 $this->html_class_prefix . 'question-input ' .
2371 $survey_question_limit_length_class .
2372 $this->html_class_prefix . 'input
2373 ' . $this->html_class_prefix . 'answer-text-inputs" type="text" style="min-height: 24px;"
2374 placeholder="'. __( $survey_input_type_placeholder, "survey-maker" ) .'"
2375 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]" autocomplete="off">';
2376
2377 if( ! $minimal_theme ){
2378 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2379 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2380 }
2381
2382 $content[] = '</div>';
2383 if( $value_suffix != "" ){
2384 $content[] = '<div class="' . $this->html_class_prefix . 'question-answer-suffix">' . $value_suffix . '</div>';
2385 }
2386
2387 $content[] = '</div>';
2388
2389 if($limit_checker){
2390 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-conteiner">';
2391 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-message">';
2392 $content[] .= '<span class="'.$this->html_class_prefix.'question-text-message-span">'. $limit_length . '</span> ' . $limit_by;
2393 $content[] .= '</div>';
2394 $content[] .= '</div>';
2395 }
2396
2397 $content[] = '</div>';
2398
2399 $content = implode( '', $content );
2400
2401 return $content;
2402 }
2403
2404 public function ays_survey_question_type_NUMBER_html( $question ){
2405 $content = array();
2406 // Input types placeholders
2407 $survey_input_type_placeholder = isset($question['options']['placeholder']) && $question['options']['placeholder'] != "" ? $question['options']['placeholder'] : '';
2408
2409 $enable_value_prefix = $question['options']['enable_value_prefix'];
2410 $value_prefix = $enable_value_prefix ? stripslashes(sanitize_text_field($question['options']['value_prefix'])) : '';
2411
2412 $enable_value_suffix = $question['options']['enable_value_suffix'];
2413 $value_suffix = $enable_value_suffix ? stripslashes(sanitize_text_field($question['options']['value_suffix'])) : '';
2414
2415 $answer_box_prefix_suffix_css_class = "";
2416 $answer_container_prefix_suffix_css_class = "";
2417 if( $value_prefix != "" || $value_suffix != "" ){
2418 $answer_box_prefix_suffix_css_class = $this->html_class_prefix . 'question-box-text-types-prefix-suffix';
2419 }
2420 $answer_container_prefix_suffix_css_class = $this->html_class_prefix . 'answer-box-text-types-prefix-suffix';
2421
2422 $enable_number_limit = isset($question['options']['enable_number_limitation']) && $question['options']['enable_number_limitation'] == "on" ? true : false;
2423 $enable_number_limit_message = isset($question['options']['enable_number_error_message']) && $question['options']['enable_number_error_message'] == "on" ? true : false;
2424 $number_limit_message = isset($question['options']['number_error_message']) && $question['options']['number_error_message'] != "" ? stripslashes(esc_attr($question['options']['number_error_message'])) : "";
2425
2426 $show_limit = isset($question['options']['enable_number_limit_counter']) && $question['options']['enable_number_limit_counter'] == "on" ? true : false;
2427 $limit_length = isset($question['options']['number_limit_length']) && $question['options']['number_limit_length'] != "" ? $question['options']['number_limit_length'] : "";
2428 $limit_by = "Character";
2429 $limit_checker = false;
2430 // $survey_question_limit_length_class = '';
2431
2432 $number_limit_class = "";
2433 if($enable_number_limit){
2434 if($show_limit){
2435 $limit_checker = true;
2436 }
2437 $number_limit_class = $this->html_class_prefix . 'check-number-limit ';
2438 }
2439
2440 if(intval($limit_length) > 0){
2441 $limit_by .= "s ";
2442 }
2443
2444 $limit_by .= __("left", "survey-maker");
2445 if(intval($limit_length) <= 0){
2446 $limit_by = '';
2447 }
2448
2449 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2450 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-input';
2451 if( $minimal_theme ){
2452 $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input";
2453 }
2454
2455 $content[] = '<div class="' . $this->html_class_prefix . 'answer '. $answer_container_prefix_suffix_css_class .'">';
2456
2457 $content[] = '<div class="' . $this->html_class_prefix . 'question-box '. $answer_box_prefix_suffix_css_class .'">';
2458 if( $value_prefix != "" ){
2459 $content[] = '<div class="' . $this->html_class_prefix . 'question-answer-prefix">' . $value_prefix . '</div>';
2460 }
2461
2462 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box">';
2463
2464 $content[] = '<input class="
2465 ' . $minimal_class . '
2466 ' .
2467 $this->html_class_prefix . 'remove-default-border ' .
2468 $this->html_class_prefix . 'question-input ' .
2469 $number_limit_class .
2470 $this->html_class_prefix . 'input" type="number" step="any" style="min-height: 24px;"
2471 placeholder="'. __( $survey_input_type_placeholder, "survey-maker" ) .'"
2472 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]" autocomplete="off">';
2473 if( ! $minimal_theme ){
2474 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2475 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2476 }
2477
2478 $content[] = '</div>';
2479
2480 if( $value_suffix != "" ){
2481 $content[] = '<div class="' . $this->html_class_prefix . 'question-answer-suffix">' . $value_suffix . '</div>';
2482 }
2483
2484 $content[] = '</div>';
2485
2486 if($enable_number_limit_message){
2487 $content[] = '<div class="' . $this->html_class_prefix . 'number-limit-message-box ' . $this->html_class_prefix . 'question-text-error-message" style="display: none;">';
2488 $content[] = '<span class="' . $this->html_class_prefix . 'number-limit-message-text">';
2489 $content[] = $number_limit_message;
2490 $content[] = '</span>';
2491 $content[] = '</div>';
2492 }
2493 if($limit_checker){
2494 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-conteiner">';
2495 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-message">';
2496 $content[] .= '<span class="'.$this->html_class_prefix.'question-text-message-span">'. $limit_length . '</span> ' . $limit_by;
2497 $content[] .= '</div>';
2498 $content[] .= '</div>';
2499 }
2500
2501 $content[] = '</div>';
2502
2503 $content = implode( '', $content );
2504
2505 return $content;
2506 }
2507
2508
2509 public function ays_survey_question_type_PHONE_html( $question ){
2510 $content = array();
2511 // Input types placeholders
2512 $survey_input_type_placeholder = isset($question['options']['placeholder']) && $question['options']['placeholder'] != "" ? $question['options']['placeholder'] : '';
2513
2514 $enable_value_prefix = $question['options']['enable_value_prefix'];
2515 $value_prefix = $enable_value_prefix ? stripslashes(sanitize_text_field($question['options']['value_prefix'])) : '';
2516
2517 $enable_value_suffix = $question['options']['enable_value_suffix'];
2518 $value_suffix = $enable_value_suffix ? stripslashes(sanitize_text_field($question['options']['value_suffix'])) : '';
2519
2520 $answer_box_prefix_suffix_css_class = "";
2521 $answer_container_prefix_suffix_css_class = "";
2522 if( $value_prefix != "" || $value_suffix != "" ){
2523 $answer_box_prefix_suffix_css_class = $this->html_class_prefix . 'question-box-text-types-prefix-suffix';
2524 }
2525 $answer_container_prefix_suffix_css_class = $this->html_class_prefix . 'answer-box-text-types-prefix-suffix';
2526
2527 //Input types value
2528 $enable_url_parameter = isset($question['options']['enable_url_parameter']) && $question['options']['enable_url_parameter'] == true ? true : false;
2529 $url_parameter = $enable_url_parameter && isset($question['options']['url_parameter']) && $question['options']['url_parameter'] != "" ? $question['options']['url_parameter'] : '';
2530 $survey_input_type_value = isset($_GET[$url_parameter]) && $_GET[$url_parameter] ? $_GET[$url_parameter] : '';
2531
2532 $enable_number_limit = isset($question['options']['enable_number_limitation']) && $question['options']['enable_number_limitation'] == "on" ? true : false;
2533 $enable_number_limit_message = isset($question['options']['enable_number_error_message']) && $question['options']['enable_number_error_message'] == "on" ? true : false;
2534 $number_limit_message = isset($question['options']['number_error_message']) && $question['options']['number_error_message'] != "" ? stripslashes(esc_attr($question['options']['number_error_message'])) : "";
2535 $show_limit = isset($question['options']['enable_number_limit_counter']) && $question['options']['enable_number_limit_counter'] == "on" ? true : false;
2536 $limit_length = isset($question['options']['number_limit_length']) && $question['options']['number_limit_length'] != "" ? $question['options']['number_limit_length'] : "";
2537 $limit_by = "Character";
2538 $limit_checker = false;
2539
2540 $number_limit_class = $this->html_class_prefix . 'is-phone-type ';
2541 if($enable_number_limit){
2542 if($show_limit){
2543 $limit_checker = true;
2544 }
2545
2546 $number_limit_class .= $this->html_class_prefix . 'check-number-limit ';
2547 }
2548
2549 if(intval($limit_length) > 0){
2550 $limit_by .= "s ";
2551 }
2552
2553 $limit_by .= __("left", "survey-maker");
2554 if(intval($limit_length) <= 0){
2555 $limit_by = '';
2556 }
2557
2558 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2559 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-input';
2560 if( $minimal_theme ){
2561 $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input";
2562 }
2563
2564 $content[] = '<div class="' . $this->html_class_prefix . 'answer '. $answer_container_prefix_suffix_css_class .'">';
2565
2566 $content[] = '<div class="' . $this->html_class_prefix . 'question-box ' . $this->html_class_prefix . 'question-box-text-types-short '. $answer_box_prefix_suffix_css_class .'">';
2567 if( $value_prefix != "" ){
2568 $content[] = '<div class="' . $this->html_class_prefix . 'question-answer-prefix">' . $value_prefix . '</div>';
2569 }
2570
2571 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box">';
2572
2573 $content[] = '<input class="' . $minimal_class . ' '.$number_limit_class.' ' . $this->html_class_prefix . 'answer-text-inputs ' . $this->html_class_prefix . 'answer-text-inputs-default" type="text" tabindex="0" step="any" style="min-height: 24px;"
2574 placeholder="'. __( $survey_input_type_placeholder, "survey-maker" ) .'"
2575 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]"
2576 value="' . __( $survey_input_type_value, "survey-maker" ) . '">';
2577
2578 if( ! $minimal_theme ){
2579 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2580 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2581 }
2582
2583 $content[] = '</div>';
2584
2585 if( $value_suffix != "" ){
2586 $content[] = '<div class="' . $this->html_class_prefix . 'question-answer-suffix">' . $value_suffix . '</div>';
2587 }
2588
2589 $content[] = '</div>';
2590
2591 if($enable_number_limit_message){
2592 $content[] = '<div class="' . $this->html_class_prefix . 'number-limit-message-box ' . $this->html_class_prefix . 'question-text-error-message" style="display: none;">';
2593 $content[] = '<span class="' . $this->html_class_prefix . 'number-limit-message-text">';
2594 $content[] = $number_limit_message;
2595 $content[] = '</span>';
2596 $content[] = '</div>';
2597 }
2598
2599 if($limit_checker){
2600 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-conteiner">';
2601 $content[] .= '<div class="'.$this->html_class_prefix.'question-text-message">';
2602 $content[] .= '<span class="'.$this->html_class_prefix.'question-text-message-span">'. $limit_length . '</span> ' . $limit_by;
2603 $content[] .= '</div>';
2604 $content[] .= '</div>';
2605 }
2606
2607 $content[] = '</div>';
2608
2609 $content = implode( '', $content );
2610
2611 return $content;
2612 }
2613
2614 public function ays_survey_question_type_DATE_html( $question ){
2615 $content = array();
2616
2617 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2618 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-date-input ' . $this->html_class_prefix . 'question-input';
2619 if( $minimal_theme ){
2620 $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input " . $this->html_class_prefix."minimal-theme-input-date";
2621 }
2622
2623 $content[] = '<div class="' . $this->html_class_prefix . 'answer">';
2624
2625 $content[] = '<div class="' . $this->html_class_prefix . 'question-box ' . $this->html_class_prefix . 'question-date-box">';
2626 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box ' . $this->html_class_prefix . 'question-date-input-box">';
2627
2628 $content[] = '<input type="date" class="' . $minimal_class . ' ' . $this->html_class_prefix . 'input" type="text" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]" tabindex="0">';
2629
2630 $content[] = '</div>';
2631 $content[] = '</div>';
2632
2633 $content[] = '</div>';
2634
2635 $content = implode( '', $content );
2636
2637 return $content;
2638 }
2639
2640 public function ays_survey_question_type_TIME_html( $question ){
2641 $content = array();
2642
2643 // $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2644 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-date-input ' . $this->html_class_prefix . 'question-input';
2645 // if( $minimal_theme ){
2646 // $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input " . $this->html_class_prefix."minimal-theme-input-date";
2647 // }
2648
2649 $content[] = '<div class="' . $this->html_class_prefix . 'answer">';
2650
2651 $content[] = '<div class="' . $this->html_class_prefix . 'question-box ' . $this->html_class_prefix . 'question-time-box">';
2652 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box ' . $this->html_class_prefix . 'question-time-input-box">';
2653
2654 $content[] = '<input class="' . $minimal_class . ' ' . $this->html_class_prefix . 'input ays-survey-timepicker" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]" placeholder="00:00" tabindex="0">';
2655
2656 // if( ! $minimal_theme ){
2657 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2658 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2659 // }
2660
2661 $content[] = '</div>';
2662 $content[] = '</div>';
2663
2664 $content[] = '</div>';
2665
2666 $content = implode( '', $content );
2667
2668 return $content;
2669 }
2670
2671 public function ays_survey_question_type_DATE_TIME_html( $question ){
2672 $content = array();
2673
2674 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-date-input ' . $this->html_class_prefix . 'question-input';
2675
2676 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2677 $minimal_date_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-date-input ' . $this->html_class_prefix . 'question-input';
2678 if( $minimal_theme ){
2679 $minimal_date_class = $this->html_class_prefix . "minimal-theme-textarea-input " . $this->html_class_prefix."minimal-theme-input-date";
2680 }
2681
2682 $content[] = '<div class="' . $this->html_class_prefix . 'answer ' . $this->html_class_prefix . 'date-and-time-answer">';
2683
2684 $content[] = '<div class="' . $this->html_class_prefix . 'question-box ' . $this->html_class_prefix . 'question-date-time-box">';
2685 $content[] = '<div class="' . $this->html_class_prefix . 'date-time-inner-box">';
2686 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box ' . $this->html_class_prefix . 'question-date-input-box">';
2687
2688 $content[] = '<input type="date" class="' . $minimal_date_class . ' ' . $this->html_class_prefix . 'input" type="text"
2689 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer][date]">';
2690
2691 if( ! $minimal_theme ){
2692 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2693 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2694 }
2695
2696 $content[] = '</div>';
2697 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box ' . $this->html_class_prefix . 'question-time-input-box">';
2698
2699 $content[] = '<input class="' . $minimal_class . ' ' . $this->html_class_prefix . 'input ays-survey-timepicker" name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer][time]" placeholder="00:00" tabindex="0">';
2700
2701 // if( ! $minimal_theme ){
2702 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2703 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2704 // }
2705
2706 $content[] = '</div>';
2707 $content[] = '</div>';
2708 $content[] = '</div>';
2709
2710 $content[] = '</div>';
2711
2712 $content = implode( '', $content );
2713
2714 return $content;
2715 }
2716
2717
2718 public function ays_survey_question_type_EMAIL_html( $question ){
2719 $content = array();
2720 // Input types placeholders
2721 $survey_input_type_placeholder = isset($question['options']['placeholder']) && $question['options']['placeholder'] != "" ? $question['options']['placeholder'] : '';
2722
2723 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2724 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-email-input ' . $this->html_class_prefix . 'question-input';
2725 if( $minimal_theme ){
2726 $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input " . $this->html_class_prefix . "question-email-input";
2727 }
2728
2729 $content[] = '<div class="' . $this->html_class_prefix . 'answer">';
2730
2731 $content[] = '<div class="' . $this->html_class_prefix . 'question-box">';
2732 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box">';
2733
2734 $content[] = '<input class="
2735 ' . $minimal_class . '
2736 ' .
2737 $this->html_class_prefix . 'remove-default-border ' .
2738 $this->html_class_prefix . 'question-email-input ' .
2739 $this->html_class_prefix . 'question-input ' .
2740 $this->html_class_prefix . 'input" type="text" style="min-height: 24px;"
2741 placeholder="'. __( $survey_input_type_placeholder, "survey-maker" ) .'"
2742 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]" autocomplete="off">';
2743 if( true ){
2744 $content[] = '<input type="hidden" name="' . $this->html_name_prefix . 'user-email-' . $this->unique_id . '" value="' . $question['id'] . '" >';
2745 }
2746
2747 if( ! $minimal_theme ){
2748 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2749 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2750 }
2751
2752 $content[] = '</div>';
2753 $content[] = '</div>';
2754
2755 $content[] = '</div>';
2756
2757 $content = implode( '', $content );
2758
2759 return $content;
2760 }
2761
2762 public function ays_survey_question_type_NAME_html( $question ){
2763 $content = array();
2764 // Input types placeholders
2765 $survey_input_type_placeholder = isset($question['options']['placeholder']) && $question['options']['placeholder'] != "" ? $question['options']['placeholder'] : '';
2766
2767 $minimal_theme = $this->options[ $this->name_prefix . 'is_minimal' ] ? true : false;
2768 $minimal_class = $this->html_class_prefix . 'remove-default-border ' . $this->html_class_prefix . 'question-input';
2769 if( $minimal_theme ){
2770 $minimal_class = $this->html_class_prefix . "minimal-theme-textarea-input";
2771 }
2772
2773 $content[] = '<div class="' . $this->html_class_prefix . 'answer">';
2774
2775 $content[] = '<div class="' . $this->html_class_prefix . 'question-box">';
2776 $content[] = '<div class="' . $this->html_class_prefix . 'question-input-box">';
2777
2778 $content[] = '<input class="
2779 ' . $minimal_class . '
2780 ' .
2781 $this->html_class_prefix . 'remove-default-border ' .
2782 $this->html_class_prefix . 'question-input ' .
2783 $this->html_class_prefix . 'input
2784 ' . $this->html_class_prefix . 'answer-text-inputs" type="text" style="min-height: 24px;"
2785 placeholder="'. __( $survey_input_type_placeholder, "survey-maker" ) .'"
2786 name="' . $this->html_name_prefix . 'answers-' . $this->unique_id . '[' . $question['id'] . '][answer]" autocomplete="off">';
2787
2788 if( true ){
2789 $content[] = '<input type="hidden" name="' . $this->html_name_prefix . 'user-name-' . $this->unique_id . '" value="' . $question['id'] . '" >';
2790 }
2791
2792 if( ! $minimal_theme ){
2793 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline"></div>';
2794 $content[] = '<div class="' . $this->html_class_prefix . 'input-underline-animation"></div>';
2795 }
2796
2797 $content[] = '</div>';
2798 $content[] = '</div>';
2799
2800 $content[] = '</div>';
2801
2802 $content = implode( '', $content );
2803
2804 return $content;
2805 }
2806
2807 public function create_restricted_content( $limit_message ){
2808
2809 $content = array();
2810 $content[] = '<div class="' . $this->html_class_prefix . 'section ' . $this->html_class_prefix . 'restricted-content active-section">';
2811
2812 $content[] = '<div class="' . $this->html_class_prefix . 'section-header">';
2813
2814 $content[] = $limit_message;
2815
2816 $content[] = '</div>';
2817
2818 $content[] = '</div>';
2819
2820 $content = implode( '', $content );
2821
2822 return $content;
2823 }
2824
2825 public function get_styles(){
2826
2827 $content = array();
2828 $content[] = '<style type="text/css">';
2829
2830
2831 $question_image_width = '100%';
2832 if( $this->options[ $this->name_prefix . 'question_image_width' ] != '' ){
2833 $question_image_width = $this->options[ $this->name_prefix . 'question_image_width' ] . 'px';
2834 }
2835
2836 $question_image_height = 'auto';
2837 if( $this->options[ $this->name_prefix . 'question_image_height' ] != '' ){
2838 $question_image_height = $this->options[ $this->name_prefix . 'question_image_height' ] . 'px';
2839 }
2840
2841 $survey_title_box_shadow_class = '';
2842 if( isset($this->options[ $this->name_prefix . 'title_box_shadow_enable' ]) && $this->options[ $this->name_prefix . 'title_box_shadow_enable' ] ){
2843 $survey_title_text_shadow_params = $this->options[ $this->name_prefix . 'title_text_shadow_x_offset' ].'px '.$this->options[ $this->name_prefix . 'title_text_shadow_y_offset' ].'px '.$this->options[ $this->name_prefix . 'title_text_shadow_z_offset' ].'px';
2844 $survey_title_box_shadow_class = 'text-shadow : '.$survey_title_text_shadow_params.' '.$this->options[ $this->name_prefix . 'title_box_shadow_color' ].';';
2845 }
2846
2847 $survey_pagination_positioning = isset($this->options[ $this->name_prefix . 'pagination_positioning' ]) ? $this->options[ $this->name_prefix . 'pagination_positioning' ] : 'none';
2848 $pagination_positioning = "row";
2849 $pagination_number_height = "";
2850 switch ($survey_pagination_positioning) {
2851 case 'none':
2852 $pagination_positioning = "row";
2853 break;
2854 case 'reverse':
2855 $pagination_positioning = "row-reverse";
2856 break;
2857 case 'column':
2858 $pagination_positioning = "column";
2859 $pagination_number_height = "line-height: 1;";
2860 break;
2861 case 'column_reverse':
2862 $pagination_positioning = "column-reverse";
2863 $pagination_number_height = "line-height: 1;";
2864 break;
2865 default:
2866 $pagination_positioning = "row";
2867 $pagination_number_height = "";
2868 break;
2869 }
2870
2871 $filtered_survey_color = Survey_Maker_Data::rgb2hex( $this->options[ $this->name_prefix . 'color' ] );
2872
2873 $width = $this->options[ $this->name_prefix . 'width' ];
2874 $width_by = $this->options[ $this->name_prefix . 'width_by_percentage_px' ];
2875
2876 $mobile_width = $this->options[ $this->name_prefix . 'mobile_width' ];
2877 $mobile_width_by = $this->options[ $this->name_prefix . 'mobile_width_by_percent_px' ];
2878 $mobile_max_width = $this->options[ $this->name_prefix . 'mobile_max_width' ];
2879
2880 if( absint( $width ) == 0 ){
2881 $width = '100';
2882 $width_by = 'percentage';
2883 }
2884
2885 if( absint( $mobile_width ) == 0 ){
2886 $mobile_width = '100';
2887 $mobile_width_by = 'percentage';
2888 }
2889
2890 if( absint( $mobile_max_width ) > 0 ){
2891 $mobile_max_width .= '%';
2892 }else{
2893 $mobile_max_width = '95%';
2894 }
2895
2896 switch( $width_by ){
2897 case 'percentage':
2898 $width .= '%';
2899 break;
2900 case 'pixels':
2901 $width .= 'px';
2902 break;
2903 default:
2904 $width .= '%';
2905 break;
2906 }
2907
2908 switch( $mobile_width_by ){
2909 case 'percentage':
2910 $mobile_width .= '%';
2911 break;
2912 case 'pixels':
2913 $mobile_width .= 'px';
2914 break;
2915 default:
2916 $mobile_width .= '%';
2917 break;
2918 }
2919
2920 switch($this->options[ $this->name_prefix . 'logo_image_position' ]){
2921 case "right":
2922 $survey_logo_image_position = "right: 5px;";
2923 break;
2924 case "left":
2925 $survey_logo_image_position = "left: 5px;";
2926 break;
2927 case "center":
2928 $survey_logo_image_position = "left: 50%;";
2929 break;
2930 default:
2931 $survey_logo_image_position = "right: 5px;";
2932 break;
2933 }
2934
2935 switch($this->options[ $this->name_prefix . 'start_page_button_pos' ]){
2936 case "left":
2937 $survey_start_page_button_pos = 'justify-content: flex-start;';
2938 break;
2939 case "center":
2940 $survey_start_page_button_pos = 'justify-content: center;';
2941 break;
2942 case "right":
2943 $survey_start_page_button_pos = 'justify-content: flex-end;';
2944 break;
2945 }
2946
2947 $answers_list_width = "width:initial;";
2948 $answers_list_direction = "";
2949 if($this->options[ $this->name_prefix . 'answers_view_alignment' ] == 'center' && $this->options[ $this->name_prefix . 'answers_view' ] == 'list'){
2950 $answers_list_width = "width:50%;";
2951 $answers_list_direction = "flex-direction: column;";
2952 }
2953
2954 $other_answer_box_width = "";
2955 if($this->options[ $this->name_prefix . 'answers_view_alignment' ] == 'flex-start' && $this->options[ $this->name_prefix . 'answers_view' ] == 'list'){
2956 $other_answer_box_width = "width: 100%;";
2957 }
2958
2959 $answers_grid_min_width = '';
2960 if($this->options[ $this->name_prefix . 'answers_view_alignment' ] == 'flex-start' && $this->options[ $this->name_prefix . 'answers_view' ] == 'grid'){
2961 $answers_grid_min_width = "min-width: 50%;";
2962 }
2963
2964 // Question padding
2965 $question_padding = $this->options[ $this->name_prefix . 'question_padding' ];
2966 $question_border_radius = $this->options[ $this->name_prefix . 'question_border_radius' ];
2967
2968 $content[] = '
2969 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' {
2970 width: ' . $width . ';
2971 }
2972
2973 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-header {
2974 border-top-color: ' . $this->options[ $this->name_prefix . 'color' ] . ' !important;
2975 }
2976
2977 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question {
2978 border-left-color: ' . $this->options[ $this->name_prefix . 'color' ] . ' !important;
2979 }
2980
2981 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-header,
2982 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-terms-and-conditions-container,
2983 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question {
2984 background-color: ' . $this->options[ $this->name_prefix . 'background_color' ] . ';
2985 }
2986
2987 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section.' . $this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-header {
2988 background-color: ' . $this->options[ $this->name_prefix . 'start_page_background_color' ] . ';
2989 color: ' . $this->options[ $this->name_prefix . 'start_page_text_color' ] . ';
2990 }
2991
2992 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section.' . $this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-header *,
2993 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section.' . $this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-header .' . $this->html_class_prefix . 'section-title-row {
2994 color: ' . $this->options[ $this->name_prefix . 'start_page_text_color' ] . ';
2995 }
2996
2997 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section.' . $this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-header .' . $this->html_class_prefix . 'section-title-row {
2998 justify-content: ' . $this->options[ $this->name_prefix . 'start_page_title_pos' ] . ';
2999 }
3000
3001 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-buttons {
3002 display: flex;
3003 '.$survey_start_page_button_pos.'
3004 }
3005
3006 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question {
3007 ' . ( $this->options[ $this->name_prefix . 'logo' ] != '' ? 'padding: '.$question_padding.'px '.$question_padding.'px 0 '.$question_padding.'px;' : 'padding: '.$question_padding.'px;' ) . '
3008 ' . ( $this->options[ $this->name_prefix . 'logo' ] != '' ? 'padding-bottom: 50px;' : '' ) . '
3009 border-radius: ' . $question_border_radius . 'px;
3010 }
3011
3012 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input.' . $this->html_class_prefix . 'question-input {
3013 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size' ] . 'px;
3014 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing' ] . 'px;
3015 font-weight: normal;
3016 }
3017
3018 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' textarea.' . $this->html_class_prefix . 'question-input {
3019 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing' ] . 'px;
3020 }
3021
3022 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input.' . $this->html_class_prefix . 'question-input ~ .' . $this->html_class_prefix . 'input-underline,
3023 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input.' . $this->html_class_prefix . 'question-input ~ .' . $this->html_class_prefix . 'input-underline-animation,
3024 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'simple-button-container,
3025 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container,
3026 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label-content > span,
3027 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select.dropdown div.item,
3028 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'thank-you-page,
3029 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'loader-with-text,
3030 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'restricted-message,
3031 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-desc,
3032 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-questions-count,
3033 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-terms-and-conditions-container,
3034 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-title,
3035 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-title-row,
3036 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'thank-you-page > div p {
3037 color: ' . $this->options[ $this->name_prefix . 'text_color' ] . ';
3038 font-weight: normal;
3039 }';
3040 $content[] = '
3041 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label input[type="checkbox"] ~ .' . $this->html_class_prefix . 'answer-label-content .' . $this->html_class_prefix . 'answer-icon-content .' . $this->html_class_prefix . 'answer-icon-content-3,
3042 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label input[type="radio"] ~ .' . $this->html_class_prefix . 'answer-label-content .' . $this->html_class_prefix . 'answer-icon-content .' . $this->html_class_prefix . 'answer-icon-content-3,
3043 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label input[type="checkbox"]:checked ~ .' . $this->html_class_prefix . 'answer-label-content .' . $this->html_class_prefix . 'answer-icon-content .' . $this->html_class_prefix . 'answer-icon-content-2,
3044 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label input[type="radio"]:checked ~ .' . $this->html_class_prefix . 'answer-label-content .' . $this->html_class_prefix . 'answer-icon-content .' . $this->html_class_prefix . 'answer-icon-content-2,
3045 #'.$this->html_class_prefix.'container-'.$this->unique_id_in_class.' .'.$this->html_class_prefix.'answer-label .'.$this->html_class_prefix.'answer-image-container{
3046 border-color:' . ( $this->options[ $this->name_prefix . 'is_modern' ] ? $this->options[ $this->name_prefix . 'buttons_bg_color' ] : $this->options[ $this->name_prefix . 'color' ] ) . ';
3047 }
3048
3049 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label input[type="checkbox"] ~ .' . $this->html_class_prefix . 'answer-label-content .' . $this->html_class_prefix . 'answer-icon-content .' . $this->html_class_prefix . 'answer-icon-content-2,
3050 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label input[type="radio"] ~ .' . $this->html_class_prefix . 'answer-label-content .' . $this->html_class_prefix . 'answer-icon-content .' . $this->html_class_prefix . 'answer-icon-content-2 {
3051 border-color: ' . ( $this->options[ $this->name_prefix . 'is_modern' ] ? $this->options[ $this->name_prefix . 'buttons_bg_color' ] : $this->options[ $this->name_prefix . 'text_color' ] ) . ';
3052 }
3053
3054 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' textarea.' . $this->html_class_prefix . 'question-input:focus ~ .' . $this->html_class_prefix . 'input-underline-animation,
3055 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input.' . $this->html_class_prefix . 'input:focus ~ .' . $this->html_class_prefix . 'input-underline-animation {
3056 background-color: ' . ( $this->options[ $this->name_prefix . 'is_modern' ] ? $this->options[ $this->name_prefix . 'text_color' ] : $this->options[ $this->name_prefix . 'color' ] ) . ';
3057 }
3058
3059 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3060 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content a.' . $this->html_class_prefix . 'section-button,
3061 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content input.' . $this->html_class_prefix . 'section-button {
3062 color: ' . $this->options[ $this->name_prefix . 'buttons_text_color' ] . ';
3063 }
3064
3065 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label:hover .' . $this->html_class_prefix . 'answer-icon-ink{
3066 background-color: ' . Survey_Maker_Data::hex2rgba( $filtered_survey_color, 0.04 ) . ';
3067 }
3068
3069 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3070 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content input.' . $this->html_class_prefix . 'section-button,
3071 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:focus .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3072 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:focus .' . $this->html_class_prefix . 'section-button-content input.' . $this->html_class_prefix . 'section-button {
3073 color: ' . Survey_Maker_Data::hex2rgba( $this->options[ $this->name_prefix . 'buttons_text_color' ], 0.7) . ';
3074 background-color: ' . Survey_Maker_Data::hex2rgba( $this->options[ $this->name_prefix . 'buttons_bg_color' ] ) . ';
3075 }
3076
3077 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-required-icon,
3078 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-title {
3079 font-size: ' . $this->options[ $this->name_prefix . 'question_font_size' ] . 'px;
3080 line-height: 1.5;
3081 }
3082
3083 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . '
3084 .' . $this->html_class_prefix . 'sections
3085 .' . $this->html_class_prefix . 'question
3086 .' . $this->html_class_prefix . 'question-header
3087 .' . $this->html_class_prefix . 'question-header-content
3088 .' . $this->html_class_prefix . 'question-title p{
3089 margin: 0;
3090 color: ' . $this->options[ $this->name_prefix . 'text_color' ] . ';
3091 }';
3092 $content[] = '
3093 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-title{
3094 padding-top: 10px;
3095 text-align: ' . $this->options[ $this->name_prefix . 'question_title_alignment' ] . ';
3096 }
3097
3098 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-image {
3099 width: ' . $question_image_width . ';
3100 height: ' . $question_image_height . ';
3101 object-fit: ' . $this->options[ $this->name_prefix . 'question_image_sizing' ] . ';
3102 }
3103
3104 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-image-caption {
3105 text-align: ' . $this->options[ $this->name_prefix . 'question_caption_text_alignment' ] . ';
3106 }
3107
3108 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label-content > span {
3109 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size' ] . 'px;
3110 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing' ] . 'px;
3111 word-break: break-word;
3112 }
3113
3114 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer {
3115 padding: ' . $this->options[ $this->name_prefix . 'answers_padding' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_padding' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_padding' ] . 'px 0;
3116 margin: ' . $this->options[ $this->name_prefix . 'answers_gap' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_gap' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_gap' ] . 'px 0;
3117 }
3118
3119 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-image {
3120 object-fit: ' . $this->options[ $this->name_prefix . 'answers_object_fit' ] . ';
3121 }
3122
3123 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content .' . $this->html_class_prefix . 'section-button {
3124 font-size: ' . $this->options[ $this->name_prefix . 'buttons_font_size' ] . 'px;
3125 padding-left: ' . $this->options[ $this->name_prefix . 'buttons_left_right_padding' ] . 'px;
3126 padding-right: ' . $this->options[ $this->name_prefix . 'buttons_left_right_padding' ] . 'px;
3127 padding-top: ' . $this->options[ $this->name_prefix . 'buttons_top_bottom_padding' ] . 'px;
3128 padding-bottom: ' . $this->options[ $this->name_prefix . 'buttons_top_bottom_padding' ] . 'px;
3129 background-color: ' . $this->options[ $this->name_prefix . 'buttons_bg_color' ] . ';
3130 letter-spacing: ' . $this->options[ $this->name_prefix . 'buttons_text_letter_spacing' ] . 'px;
3131 height: initial;
3132 color: #333 !important;
3133 }
3134
3135 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content .' . $this->html_class_prefix . 'section-button:hover {
3136 color: rgba(51,51,51,0.7) !important;
3137 }
3138
3139 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container {
3140 border-radius: ' . $this->options[ $this->name_prefix . 'buttons_border_radius' ] . 'px;
3141 background-color: ' . $this->options[ $this->name_prefix . 'background_color' ] . ';
3142 }
3143
3144 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select.dropdown div.text,
3145 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select.dropdown div.item {
3146 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size' ] . 'px !important;
3147 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing' ] . 'px;
3148 font-weight: normal;
3149 }
3150
3151 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-star .' . $this->html_class_prefix . 'answer-star-radio,
3152 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-star .' . $this->html_class_prefix . 'answer-star-radio-label,
3153 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select.dropdown div.item {
3154 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size' ] . 'px !important;
3155 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing' ] . 'px;
3156 color: ' . $this->options[ $this->name_prefix . 'text_color' ] . ';
3157 }
3158
3159 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' label.' . $this->html_class_prefix . 'individual-submission-conatiner-star-label-stars div:nth-child(2) > i.fa.fa_star_o::before{
3160 content: "\f006";
3161 }
3162
3163
3164 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label .' . $this->html_class_prefix . 'answer-star-radio input {
3165 display: none ;
3166 }
3167
3168 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .lds-ripple[data-role="loader"] div{
3169 border-color: ' . $this->options[ $this->name_prefix . 'loader_color' ] . ';
3170 }
3171 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .lds-dual-ring[data-role="loader"]::after,
3172 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .lds-hourglass[data-role="loader"]::after{
3173 border-color: ' . $this->options[ $this->name_prefix . 'loader_color' ] . ' transparent ' . $this->options[ $this->name_prefix . 'loader_color' ] . ' transparent;
3174 }
3175
3176 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .lds-default[data-role="loader"] div,
3177 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .lds-ellipsis[data-role="loader"] div,
3178 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .lds-facebook[data-role="loader"] div,
3179 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .lds-circle[data-role="loader"] {
3180 background-color: ' . $this->options[ $this->name_prefix . 'loader_color' ] . ';
3181 }
3182
3183 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .ays-survey-loader-snake[data-role="loader"]{
3184 color:' . $this->options[ $this->name_prefix . 'loader_color' ] . ';
3185 }
3186
3187 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' textarea.' . $this->html_class_prefix . 'question-input {
3188 min-height: ' . $this->options[ $this->name_prefix . 'textarea_height' ] . 'px !important;
3189 }
3190
3191 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .'.$this->name_prefix.'expired-survey-message {
3192 color: ' . $this->options[ $this->name_prefix . 'text_color' ] . ';
3193 }';
3194 $content[] = '
3195 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'simple-button-container .' . $this->html_class_prefix . 'button-content .' . $this->html_class_prefix . 'button{
3196 color: ' . $this->options[ $this->name_prefix . 'buttons_text_color' ] . ';
3197 background-color: ' . $this->options[ $this->name_prefix . 'buttons_bg_color' ] . ';
3198 }
3199
3200 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'full-screen-mode .' . $this->html_class_prefix . 'close-full-screen,
3201 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'full-screen-mode .' . $this->html_class_prefix . 'open-full-screen{
3202 fill: ' . $this->options[ $this->name_prefix . 'full_screen_button_color' ] . ';
3203 }
3204
3205 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-wrap{
3206 background-color: ' . $this->options[ $this->name_prefix . 'color' ] . ';
3207 border-color: ' . $this->options[ $this->name_prefix . 'color' ] . ';
3208 }
3209
3210 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-fill{
3211 background-color: ' . $this->options[ $this->name_prefix . 'background_color' ] . ';
3212 }
3213
3214 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-status .' . $this->html_class_prefix . 'live-bar-status-text{
3215 font-size: ' . $this->options[ $this->name_prefix . 'progress_bar_text_font_size' ] . 'px;
3216 color: ' . $this->options[ $this->name_prefix . 'pagination_text_color' ] . ';
3217 padding: 0 10px;
3218 letter-spacing: ' . $this->options[ $this->name_prefix . 'progress_bar_text_letter_spacing' ] . 'px;
3219 line-height: 30px;
3220 font-weight: normal;
3221 text-transform: '.$this->options[ $this->name_prefix . 'progress_bar_text_transform' ].';
3222 }
3223
3224 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'title{
3225 text-align: ' . $this->options[ $this->name_prefix . 'title_alignment' ] . ';
3226 font-size: ' . $this->options[ $this->name_prefix . 'title_font_size' ] . 'px;
3227 letter-spacing: ' . $this->options[ $this->name_prefix . 'title_letter_spacing' ] . 'px;
3228 '. $survey_title_box_shadow_class .'
3229 }
3230
3231 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'section-title-row-main{
3232 text-align: ' . $this->options[ $this->name_prefix . 'section_title_alignment' ] . ';
3233 font-size: ' . $this->options[ $this->name_prefix . 'section_title_font_size' ] . 'px;
3234 letter-spacing: ' . $this->options[ $this->name_prefix . 'section_title_letter_spacing' ] . 'px;
3235 width: 100%;
3236 line-height: 1.5;
3237 }
3238
3239 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'answer-label .' . $this->html_class_prefix . 'answer-image-container{
3240 height: ' . $this->options[ $this->name_prefix . 'answers_image_size' ] . 'px;
3241 }
3242
3243 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'section-desc{
3244 text-align: ' . $this->options[ $this->name_prefix . 'section_description_alignment' ] . ';
3245 font-size: ' . $this->options[ $this->name_prefix . 'section_description_font_size' ] . 'px;
3246 letter-spacing: ' . $this->options[ $this->name_prefix . 'section_description_letter_spacing' ] . 'px;
3247 line-height: 1;
3248 }';
3249 $content[] = '
3250 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'cover-photo-title-wrap{
3251 height: ' . $this->options[ $this->name_prefix . 'cover_photo_height' ] . 'px;
3252 background-position: ' . implode(" ", explode("_" , $this->options[ $this->name_prefix . 'cover_photo_position' ])) .';
3253 background-size: ' . $this->options[ $this->name_prefix . 'cover_photo_object_fit' ] .';
3254 }
3255
3256 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'image-logo-url{
3257 '.$survey_logo_image_position.'
3258 }
3259
3260 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'question-text-message,
3261 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'number-limit-message-box{
3262 color: ' . $this->options[ $this->name_prefix . 'text_color' ] . ';
3263 text-align: left;
3264 font-size: 12px;
3265 padding-top: 10px;
3266 }
3267
3268 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'question-text-error-message {
3269 color: #ff0000;
3270 }
3271
3272 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'admin-note-inner span{
3273 color: #000;
3274 text-transform: none;
3275 font-size: 11px;
3276 }
3277
3278 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-main{
3279 flex-direction: '.$pagination_positioning.';
3280 }
3281
3282 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons{
3283 margin-top: ' . $this->options[ $this->name_prefix . 'buttons_top_distance' ] . 'px;
3284 text-align: ' . $this->options[ $this->name_prefix . 'buttons_alignment' ] . ';
3285 }
3286
3287 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'results .' . $this->html_class_prefix . 'section-buttons{
3288 margin-top: 0;
3289 }
3290
3291 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question-content .' . $this->html_class_prefix . 'question-answers:not(.' . $this->html_class_prefix . 'question-answers-grid){
3292 align-items: ' . $this->options[ $this->name_prefix . 'answers_view_alignment' ] . ';
3293 }
3294
3295 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question-content .' . $this->html_class_prefix . 'question-answers-grid{
3296 justify-content: ' . $this->options[ $this->name_prefix . 'answers_view_alignment' ] . ';
3297 }
3298
3299 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'answer{
3300 '.$answers_list_width.'
3301 '.$answers_list_direction.'
3302 '.$answers_grid_min_width.'
3303 }
3304
3305 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question[data-type="date"] .' . $this->html_class_prefix . 'answer{
3306 width: 100%;
3307 }
3308
3309 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'answer.' . $this->html_class_prefix . 'other-answer-container{
3310 '.$other_answer_box_width.'
3311 }
3312
3313 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question[data-type="short_text"] .' . $this->html_class_prefix . 'answer,
3314 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question[data-type="text"] .' . $this->html_class_prefix . 'answer,
3315 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question[data-type="email"] .' . $this->html_class_prefix . 'answer,
3316 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question[data-type="name"] .' . $this->html_class_prefix . 'answer,
3317 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question[data-type="number"] .' . $this->html_class_prefix . 'answer,
3318 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question[data-type="phone"] .' . $this->html_class_prefix . 'answer{
3319 width: 100%;
3320 }
3321
3322 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'question-image-caption span{
3323 color: '.$this->options[ $this->name_prefix . 'question_caption_text_color' ].';
3324 font-size: '.$this->options[ $this->name_prefix . 'question_caption_font_size' ].'px;
3325 text-transform: '.$this->options[ $this->name_prefix . 'question_caption_text_transform' ].';
3326 letter-spacing: '.$this->options[ $this->name_prefix . 'question_caption_letter_spacing' ].'px;
3327 }
3328
3329 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . '.' . $this->html_class_prefix . 'container .' . $this->html_class_prefix . 'restricted-content.' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'section-header p,
3330 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . '.' . $this->html_class_prefix . 'container .' . $this->html_class_prefix . 'restricted-content .' . $this->html_class_prefix . 'section-header *{
3331 color: ' . $this->options[ $this->name_prefix . 'text_color' ] . ';
3332 }
3333
3334 ';
3335
3336 if($this->options[ $this->name_prefix . 'enable_survey_start_loader' ]){
3337 $content[] = '#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . '.' . $this->html_class_prefix . 'container {
3338 min-height: 250px;
3339 }';
3340 }
3341
3342 if( $this->options[ $this->name_prefix . 'is_minimal' ] ){
3343 $content[] =
3344 '#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'minimal-theme-header {
3345 box-shadow: unset;
3346 border: 0;
3347 }
3348
3349 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question.' . $this->html_class_prefix . 'minimal-theme-question {
3350 border: 0;
3351 }
3352
3353 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label-content .' . $this->html_class_prefix . 'answer-icon-content {
3354 display: none;
3355 }
3356
3357 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label input {
3358 display: block ;
3359 cursor: pointer;
3360 outline: none;
3361 }
3362
3363 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label {
3364 justify-content: initial;
3365 }
3366
3367 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label .' . $this->html_class_prefix . 'answer-star-radio input {
3368 display: none ;
3369 }
3370
3371 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-matrix-scale-main .' . $this->html_class_prefix . 'answer-matrix-scale-container .' . $this->html_class_prefix . 'answer-matrix-scale-row .' . $this->html_class_prefix . 'answer-matrix-scale-column-content,
3372 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-slider-list-main .' . $this->html_class_prefix . 'answer-slider-list-container .' . $this->html_class_prefix . 'answer-slider-list-row .' . $this->html_class_prefix . 'answer-slider-list-column-content,
3373 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-star-list-main .' . $this->html_class_prefix . 'answer-star-list-container .' . $this->html_class_prefix . 'answer-star-list-row .' . $this->html_class_prefix . 'answer-matrix-scale-column-content {
3374 width: initial;
3375 }
3376
3377 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input[type=range].' . $this->html_class_prefix . 'range-type-input {
3378 -webkit-appearance: auto;
3379 appearance: auto;
3380 }
3381
3382 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input[type=range].' . $this->html_class_prefix . 'range-type-input {
3383 -moz-appearance: auto;
3384 appearance: auto;
3385 }
3386
3387 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .'.$this->html_class_prefix.'minimal-theme-textarea-input {
3388 border: 1px solid !important;
3389 transition: 0;
3390 width: 100%;
3391 }
3392
3393 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select-conteiner-minimal {
3394 width: 230px;
3395 padding: 5px !important;
3396 outline: none;
3397 }
3398
3399 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .'.$this->html_class_prefix.'question-date-input-box {
3400 width: 230px;
3401 height: 40px;
3402 }
3403
3404 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .'.$this->html_class_prefix.'question-date-input-box input {
3405 width: 100%;
3406 height: 100%;
3407 box-sizing: border-box;
3408 font-size: 15px;
3409 padding: 10px;
3410 }';
3411 }
3412
3413 if( $this->options[ $this->name_prefix . 'is_modern' ] ){
3414 $content[] =
3415 '#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-questions > .' . $this->html_class_prefix . 'question.' . $this->html_class_prefix . 'modern-theme-question{
3416 border: none;
3417 margin: 15px 0 0;
3418 padding: '. ((isset($this->options[ $this->name_prefix . 'logo' ]) && $this->options[ $this->name_prefix . 'logo' ] != "") ? '0 0 50px 0': '1px 12px').';
3419 }
3420
3421 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-questions > .' . $this->html_class_prefix . 'question.' . $this->html_class_prefix . 'modern-theme-question:not(:last-child){
3422 border-radius: unset;
3423 }
3424 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-footer{
3425 margin-top:11px 12pxpx;
3426 }
3427
3428 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-questions > div.' . $this->html_class_prefix . 'question.' . $this->html_class_prefix . 'modern-theme-question:last-child{
3429 border-bottom-left-radius: 5px;
3430 border-bottom-right-radius: 5px;
3431 border-top-left-radius: 0;
3432 border-top-right-radius: 0;
3433 }
3434
3435 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'modern-theme-header{
3436 border-bottom-left-radius: 0;
3437 border-bottom-right-radius: 0;
3438 border-top-left-radius: 5px;
3439 border-top-right-radius: 5px;
3440 border: none;
3441 box-shadow: none;
3442 margin: 0;
3443 }
3444
3445 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-questions > .' . $this->html_class_prefix . 'question.' . $this->html_class_prefix . 'modern-theme-question .' . $this->html_class_prefix . 'question-header{
3446 margin: 7px 0;
3447 }
3448
3449 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-questions > .' . $this->html_class_prefix . 'question.' . $this->html_class_prefix . 'modern-theme-question .' . $this->html_class_prefix .'question-content > .' . $this->html_class_prefix . 'question-answers > .' . $this->html_class_prefix . 'answer {
3450 padding: 5px 0;
3451 margin: 0px;
3452 }
3453
3454 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'modern-theme-header > .' . $this->html_class_prefix . 'results .' . $this->html_class_prefix . 'thank-you-page .' . $this->html_class_prefix . 'submission-summary-question-container,
3455 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'modern-theme-header > .' . $this->html_class_prefix . 'results .' . $this->html_class_prefix . 'thank-you-page .' . $this->html_class_prefix . 'submission-summary-section-header{
3456 border: none;
3457 }
3458
3459 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-title {
3460 font-weight: bold;
3461 margin: 0 !important;
3462 text-align: ' . $this->options[ $this->name_prefix . 'question_title_alignment' ] . ';
3463 }
3464
3465 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3466 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content a.' . $this->html_class_prefix . 'section-button,
3467 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content input.' . $this->html_class_prefix . 'section-button,
3468 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'results-content .' . $this->html_class_prefix . 'thank-you-summary-submission-main-container button.' . $this->html_class_prefix . 'single-submission-results-export,
3469 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'submission-questions-answers > .' . $this->html_class_prefix . 'each-question-answer.' . $this->html_class_prefix . 'answer .ays_text_answer{
3470 color: ' . $this->options[ $this->name_prefix . 'color' ] . ';
3471 }
3472
3473 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3474 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content input.' . $this->html_class_prefix . 'section-button,
3475 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3476 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content a.' . $this->html_class_prefix . 'section-button,
3477 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'results-content .' . $this->html_class_prefix . 'thank-you-summary-submission-main-container button.' . $this->html_class_prefix . 'single-submission-results-export{
3478 background-color: ' . Survey_Maker_Data::hex2rgba( $this->options[ $this->name_prefix . 'buttons_bg_color' ], 0.8 ) . ';
3479 color: '.$this->options[ $this->name_prefix . 'buttons_text_color' ].';
3480 }
3481
3482 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-wrap {
3483 background-color: ' . ( $this->options[ $this->name_prefix . 'is_minimal' ] ? $this->options[ $this->name_prefix . 'text_color' ] : $this->options[ $this->name_prefix . 'buttons_bg_color' ] ) . ';
3484 border-color: ' . ( $this->options[ $this->name_prefix . 'is_minimal' ] ? $this->options[ $this->name_prefix . 'text_color' ] : $this->options[ $this->name_prefix . 'buttons_bg_color' ] ) . ';
3485 }
3486
3487 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-fill {
3488 background-color: ' . ( $this->options[ $this->name_prefix . 'is_minimal' ] ? $this->options[ $this->name_prefix . 'text_color' ] : $this->options[ $this->name_prefix . 'buttons_text_color' ] ) . ';
3489 }
3490
3491 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-questions > .' . $this->html_class_prefix . 'question.' . $this->html_class_prefix . 'modern-theme-question .' . $this->html_class_prefix .'question-input{
3492 background-color: unset;
3493 }
3494
3495 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3496 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:hover .' . $this->html_class_prefix . 'section-button-content input.' . $this->html_class_prefix . 'section-button,
3497 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:focus .' . $this->html_class_prefix . 'section-button-content button.' . $this->html_class_prefix . 'section-button,
3498 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container:focus .' . $this->html_class_prefix . 'section-button-content input.' . $this->html_class_prefix . 'section-button {
3499 color: ' . Survey_Maker_Data::hex2rgba( $this->options[ $this->name_prefix . 'buttons_text_color' ], 0.7) . ';
3500 background-color: ' . Survey_Maker_Data::hex2rgba( $this->options[ $this->name_prefix . 'buttons_bg_color' ], 0.8 ) . ';
3501 }
3502
3503 ';
3504 }
3505
3506 $content[] = $this->get_css_mobile_part($mobile_max_width, $mobile_width, $pagination_number_height);
3507
3508 if( isset($this->options[ $this->name_prefix . 'cover_photo' ]) && $this->options[ $this->name_prefix . 'cover_photo' ] != "" ){
3509 $content[] =
3510 '#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .'.$this->html_class_prefix.'cover-photo-title-wrap {
3511 background-image: url('.$this->options[ $this->name_prefix . 'cover_photo' ].');
3512 background-repeat: no-repeat;
3513 }
3514
3515 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .'.$this->html_class_prefix.'cover-photo-title-wrap .'.$this->html_class_prefix.'title {
3516 display: flex;
3517 align-items: flex-end;
3518 height: 100%;
3519 }
3520 ';
3521
3522 $title_alignment_with_cover_photo_css = 'flex-start';
3523 switch( $this->options[ $this->name_prefix . 'title_alignment' ] ){
3524 case "left":
3525 $title_alignment_with_cover_photo_css = 'flex-start';
3526 break;
3527 case "right":
3528 $title_alignment_with_cover_photo_css = 'flex-end';
3529 break;
3530 case "center":
3531 $title_alignment_with_cover_photo_css = 'center';
3532 break;
3533 default:
3534 $title_alignment_with_cover_photo_css = 'flex-start';
3535 break;
3536 }
3537
3538 $content[] =
3539 '#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .'.$this->html_class_prefix.'cover-photo-title-wrap .'.$this->html_class_prefix.'title {
3540 justify-content: ' . $title_alignment_with_cover_photo_css . ';
3541 }';
3542
3543 }
3544
3545 $content[] = '</style>';
3546
3547 $content = implode( '', $content );
3548
3549 return $content;
3550 }
3551
3552 public function get_custom_css(){
3553
3554 $content = array();
3555
3556 if( $this->options[ $this->name_prefix . 'custom_css' ] != '' ){
3557
3558 $content[] = '<style type="text/css">';
3559
3560 $content[] = $this->options[ $this->name_prefix . 'custom_css' ];
3561
3562 $content[] = '</style>';
3563
3564 }
3565
3566 $content = implode( '', $content );
3567
3568 return $content;
3569 }
3570
3571 public function get_encoded_options( $limit ){
3572
3573 $content = array();
3574
3575 if( isset( $this->options[ $this->name_prefix . 'submit_redirect_delay' ] ) ){
3576 $this->options[ $this->name_prefix . 'submit_redirect_seconds'] = Survey_Maker_Data::secondsToWords( intval( $this->options[ $this->name_prefix . 'submit_redirect_delay' ] ) );
3577 }
3578
3579 // Animation Top (px)
3580 $setting_options = Survey_Maker_Data::get_setting_data( 'options' );
3581 $survey_animation_top = ( isset($setting_options[ 'survey_animation_top' ]) && $setting_options[ 'survey_animation_top' ] != '' ) ? intval( $setting_options[ 'survey_animation_top' ] ) : '';
3582 $setting_options['survey_enable_animation_top'] = isset($setting_options['survey_enable_animation_top']) ? $setting_options['survey_enable_animation_top'] : 'on';
3583 $survey_enable_animation_top = ( isset($setting_options[ 'survey_enable_animation_top' ]) && $setting_options[ 'survey_enable_animation_top' ] == 'on' ) ? true : false;
3584
3585 $this->options['is_user_logged_in'] = is_user_logged_in();
3586
3587 $this->options[ $this->name_prefix . 'animation_top'] = $survey_animation_top;
3588 $this->options[ $this->name_prefix . 'enable_animation_top'] = $survey_enable_animation_top;
3589
3590 $options = array();
3591 if( ! $limit ){
3592 foreach( $this->options as $k => $q ){
3593 if( strpos( $k, 'email' ) !== false ){
3594 unset( $this->options[ $k ] );
3595 }
3596 }
3597 $options = $this->options;
3598 }else{
3599 if($this->options[ $this->name_prefix . 'redirect_delay' ] && $this->options[ $this->name_prefix . 'redirect_delay' ] != ''){
3600 if($this->options[ $this->name_prefix . 'redirect_url' ] && $this->options[ $this->name_prefix . 'redirect_url' ] != ''){
3601 if($this->options[ $this->name_prefix . 'limit_users' ]){
3602 $options = array(
3603 $this->name_prefix . 'submit_redirect_seconds' => Survey_Maker_Data::secondsToWords( intval( $this->options[ $this->name_prefix . 'submit_redirect_delay' ] ) ),
3604 $this->name_prefix . 'submit_redirect_delay' => intval( $this->options[ $this->name_prefix . 'submit_redirect_delay' ] ),
3605 $this->name_prefix . 'submit_redirect_url' => $this->options[ $this->name_prefix . 'submit_redirect_url' ],
3606 $this->name_prefix . 'limit_users' => $this->options[ $this->name_prefix . 'limit_users' ],
3607 $this->name_prefix . 'redirect_url' => $this->options[ $this->name_prefix . 'redirect_url' ],
3608 $this->name_prefix . 'redirect_delay' => intval( $this->options[ $this->name_prefix . 'redirect_delay' ] ),
3609 $this->name_prefix . 'redirect_delay_seconds' => Survey_Maker_Data::secondsToWords( intval( $this->options[ $this->name_prefix . 'redirect_delay' ] ) ),
3610 );
3611 }
3612 }
3613 }
3614
3615 $options[ $this->name_prefix . 'enable_survey_start_loader' ] = $this->options[ $this->name_prefix . 'enable_survey_start_loader' ];
3616 }
3617
3618 $content[] = '<script type="text/javascript">';
3619
3620 $content[] = "
3621 if(typeof aysSurveyOptions === 'undefined'){
3622 var aysSurveyOptions = [];
3623 }
3624 aysSurveyOptions['" . $this->unique_id . "'] = '" . base64_encode( json_encode( $options ) ) . "';";
3625
3626 $content[] = '</script>';
3627
3628 $content = implode( '', $content );
3629
3630 return $content;
3631 }
3632
3633 protected function ays_survey_check_limitations($limit_by, $limit_users_data){
3634 $is_limited = false;
3635 switch($limit_by){
3636 case 'cookie':
3637
3638 // PRO FEATURE
3639 // $started_user_count = Survey_Maker_Data::get_limit_cookie_count( $limit_users_attr );
3640 // if( $quiz_max_pass_count > $started_user_count){
3641 // $limit_users_attr['increase_count'] = true;
3642 // }
3643 $check_cookie = Survey_Maker_Data::ays_survey_check_cookie( $limit_users_data );
3644 $return_false_status_arr = array(
3645 "status" => false,
3646 "message" => __( 'You already passed this survey.', "survey-maker" ),
3647 "limited" => true
3648 );
3649
3650 // PRO FEATURE
3651 // if( $quiz_max_pass_count <= $started_user_count){
3652 // echo json_encode( $return_false_status_arr );
3653 // wp_die();
3654 // }
3655
3656 if( ! $check_cookie ){
3657 $set_cookie = Survey_Maker_Data::ays_survey_set_cookie( $limit_users_data );
3658 $is_limited = true;
3659 }
3660 else{
3661 echo json_encode( $return_false_status_arr );
3662 wp_die();
3663 }
3664 break;
3665 case 'ip_cookie':
3666 $check_user_by_ip = Survey_Maker_Data::get_user_by_ip( $limit_users_data['id'] );
3667
3668 $started_user_count = Survey_Maker_Data::get_limit_cookie_count( $limit_users_data );
3669 $check_cookie = Survey_Maker_Data::ays_survey_check_cookie( $limit_users_data );
3670
3671 if ( ! $check_cookie || $check_user_by_ip <= 0 ) {
3672 if ( ! $check_cookie ) {
3673 $set_cookie = Survey_Maker_Data::ays_survey_set_cookie( $limit_users_data );
3674 }
3675 }
3676 $is_limited = true;
3677 break;
3678
3679 }
3680 return $is_limited;
3681 }
3682
3683 public function ays_survey_get_user_information() {
3684 $output = array();
3685 if(isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'survey_maker_autofill_nonce')){
3686 if(is_user_logged_in()) {
3687 $user = wp_get_current_user();
3688
3689 $output = array(
3690 'data' => array(
3691 'display_name' => $user->display_name,
3692 'user_email' => $user->user_email,
3693 )
3694 );
3695 } else {
3696 $output = array();
3697 }
3698 }
3699 return $output;
3700 }
3701
3702 public function ays_survey_popup_set_cookie(){
3703 if( isset( $_REQUEST['id'] ) && $_REQUEST['id'] != '' ){
3704 $id = sanitize_text_field( $_REQUEST['id'] );
3705 }else{
3706 $id = null;
3707 }
3708 if( $id === null ){
3709 return array(
3710 'status' => false
3711 );
3712 }
3713
3714 $cookie_name = 'ays_survey_popup_cookie_name_'.$id;
3715 $cookie_value = 'ays_survey_popup_cookie_value_'.$id;
3716 $cookie_expiration = time() + (12 * 30 * 24 * 60 * 60);
3717 setcookie($cookie_name, $cookie_value, $cookie_expiration, '/');
3718 return array(
3719 'status' => true
3720 );
3721 }
3722
3723 public function get_css_mobile_part($mobile_max_width, $mobile_width, $pagination_number_height) {
3724 $content = '';
3725
3726 $question_image_width_mobile = '100%';
3727 if( $this->options[ $this->name_prefix . 'question_image_width_mobile' ] != '' ){
3728 $question_image_width_mobile = $this->options[ $this->name_prefix . 'question_image_width_mobile' ] . 'px';
3729 }
3730
3731 $question_image_height_mobile = 'auto';
3732 if( $this->options[ $this->name_prefix . 'question_image_height_mobile' ] != '' ){
3733 $question_image_height_mobile = $this->options[ $this->name_prefix . 'question_image_height_mobile' ] . 'px';
3734 }
3735 else{
3736 if($this->options[ $this->name_prefix . 'question_image_height' ] != ''){
3737 $question_image_height_mobile = $this->options[ $this->name_prefix . 'question_image_height' ] . 'px';
3738 }
3739 }
3740
3741 switch($this->options[ $this->name_prefix . 'logo_image_position_mobile' ]){
3742 case "right":
3743 $survey_logo_image_position_mobile = "right: 5px;";
3744 break;
3745 case "left":
3746 $survey_logo_image_position_mobile = "left: 5px;";
3747 break;
3748 case "center":
3749 $survey_logo_image_position_mobile = "left: 50%;";
3750 break;
3751 default:
3752 $survey_logo_image_position_mobile = "right: 5px;";
3753 break;
3754 }
3755
3756
3757 switch($this->options[ $this->name_prefix . 'start_page_button_pos_mobile' ]){
3758 case "left":
3759 $survey_start_page_button_pos_mobile = 'justify-content: flex-start;';
3760 break;
3761 case "center":
3762 $survey_start_page_button_pos_mobile = 'justify-content: center;';
3763 break;
3764 case "right":
3765 $survey_start_page_button_pos_mobile = 'justify-content: flex-end;';
3766 break;
3767 }
3768
3769 $survey_pagination_positioning_mobile = isset($this->options[ $this->name_prefix . 'pagination_positioning_mobile' ]) ? $this->options[ $this->name_prefix . 'pagination_positioning_mobile' ] : 'none';
3770 $pagination_positioning_mobile = "row";
3771 // $pagination_number_height = "";
3772 switch ($survey_pagination_positioning_mobile) {
3773 case 'none':
3774 $pagination_positioning_mobile = "row";
3775 break;
3776 case 'reverse':
3777 $pagination_positioning_mobile = "row-reverse";
3778 break;
3779 case 'column':
3780 $pagination_positioning_mobile = "column";
3781 // $pagination_number_height = "line-height: 1;";
3782 break;
3783 case 'column_reverse':
3784 $pagination_positioning_mobile = "column-reverse";
3785 // $pagination_number_height = "line-height: 1;";
3786 break;
3787 default:
3788 $pagination_positioning_mobile = "row";
3789 // $pagination_number_height = "";
3790 break;
3791 }
3792
3793 // Question padding mobile
3794 $question_padding = $this->options[ $this->name_prefix . 'question_padding_mobile' ];
3795 $question_caption_text_display = !$this->options[ $this->name_prefix . 'question_caption_hide_on_mobile' ] ? 'block' : 'none';
3796 $question_border_radius = $this->options[ $this->name_prefix . 'question_border_radius_mobile' ];
3797 $content .= '
3798 @media screen and (max-width: 640px){
3799 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' {
3800 max-width: '. $mobile_max_width .';
3801 }
3802
3803 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' {
3804 width: ' . $mobile_width . ';
3805 }
3806
3807 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-box{
3808 width: 100%;
3809 }
3810
3811 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-main{
3812 flex-wrap: wrap;
3813 flex-direction: '.$pagination_positioning_mobile.';
3814 }
3815
3816 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'footer-with-live-bar{
3817 flex-direction: column-reverse;
3818 }
3819
3820 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-main{
3821 margin-bottom: 10px;
3822 }
3823
3824 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-required-icon,
3825 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-title {
3826 font-size: ' . $this->options[ $this->name_prefix . 'question_font_size_mobile' ] . 'px;
3827 }
3828
3829 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question {
3830 ' . ( $this->options[ $this->name_prefix . 'logo' ] != '' ? 'padding: '.$question_padding.'px '.$question_padding.'px 0 '.$question_padding.'px;' : 'padding: '.$question_padding.'px;' ) . '
3831 border-radius: ' . $question_border_radius . 'px;
3832 }
3833
3834 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons {
3835 margin-top: ' . $this->options[ $this->name_prefix . 'buttons_top_distance_mobile' ] . 'px;
3836 text-align: ' . $this->options[ $this->name_prefix . 'buttons_alignment_mobile' ] . ';
3837 }
3838
3839 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container{
3840 border-radius: ' . $this->options[ $this->name_prefix . 'buttons_border_radius_mobile' ] . 'px;
3841 }
3842
3843 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-buttons .' . $this->html_class_prefix . 'section-button-container .' . $this->html_class_prefix . 'section-button-content .' . $this->html_class_prefix . 'section-button{
3844 font-size: ' . $this->options[ $this->name_prefix . 'buttons_mobile_font_size' ] . 'px;
3845 letter-spacing: ' . $this->options[ $this->name_prefix . 'buttons_text_letter_spacing_mobile' ] . 'px;
3846 line-height: 2.5;
3847 white-space: normal;
3848 word-break: break-word;
3849 }
3850
3851 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'title{
3852 text-align: ' . $this->options[ $this->name_prefix . 'title_alignment_mobile' ] . ';
3853 font-size: ' . $this->options[ $this->name_prefix . 'title_font_size_for_mobile' ] . 'px;
3854 letter-spacing: ' . $this->options[ $this->name_prefix . 'title_letter_spacing_mobile' ] . 'px;
3855 }
3856
3857 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'section-title-row-main{
3858 text-align: ' . $this->options[ $this->name_prefix . 'section_title_alignment_mobile' ] . ';
3859 font-size: ' . $this->options[ $this->name_prefix . 'section_title_font_size_mobile' ] . 'px;
3860 letter-spacing: ' . $this->options[ $this->name_prefix . 'section_title_letter_spacing_mobile' ] . 'px;
3861 }
3862
3863 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'sections .' . $this->html_class_prefix . 'section-desc{
3864 text-align: ' . $this->options[ $this->name_prefix . 'section_description_alignment_mobile' ] . ';
3865 font-size: ' . $this->options[ $this->name_prefix . 'section_description_font_size_mobile' ] . 'px;
3866 letter-spacing: ' . $this->options[ $this->name_prefix . 'section_description_letter_spacing_mobile' ] . 'px;
3867 }
3868
3869 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input.' . $this->html_class_prefix . 'question-input {
3870 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size_on_mobile' ] . 'px;
3871 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing_mobile' ] . 'px;
3872 height: auto;
3873 }
3874
3875 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' textarea.' . $this->html_class_prefix . 'question-input {
3876 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing_mobile' ] . 'px;
3877 }
3878
3879
3880 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer {
3881 padding: ' . $this->options[ $this->name_prefix . 'answers_padding_mobile' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_padding_mobile' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_padding_mobile' ] . 'px 0;
3882 margin: ' . $this->options[ $this->name_prefix . 'answers_gap_mobile' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_gap_mobile' ] . 'px ' . $this->options[ $this->name_prefix . 'answers_gap_mobile' ] . 'px 0;
3883 }
3884
3885 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-label-content > span {
3886 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size_on_mobile' ] . 'px;
3887 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing_mobile' ] . 'px;
3888 line-height: 1;
3889 }
3890
3891 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select.dropdown div.text,
3892 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select.dropdown div.item {
3893 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size_on_mobile' ] . 'px !important;
3894 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing_mobile' ] . 'px;
3895 line-height: 1 !important;
3896 }
3897
3898 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section.' . $this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-header .' . $this->html_class_prefix . 'section-title-row {
3899 justify-content: ' . $this->options[ $this->name_prefix . 'start_page_title_pos_mobile' ] . ';
3900 }
3901
3902 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-select.dropdown div.item {
3903 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size_on_mobile' ] . 'px !important;
3904 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing_mobile' ] . 'px;
3905 line-height: 1 !important;
3906 }
3907
3908 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'question .' . $this->html_class_prefix . 'image-logo-url{
3909 '.$survey_logo_image_position_mobile.'
3910 }
3911
3912 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-status .' . $this->html_class_prefix . 'live-bar-status-text{
3913 font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size_on_mobile' ] . 'px;
3914 letter-spacing: ' . $this->options[ $this->name_prefix . 'answer_letter_spacing_mobile' ] . 'px;
3915 '.$pagination_number_height.'
3916 }
3917
3918 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'cover-photo-title-wrap{
3919 height: ' . $this->options[ $this->name_prefix . 'cover_photo_mobile_height' ] . 'px;
3920 }
3921
3922 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-image-caption span{
3923 color: '.$this->options[ $this->name_prefix . 'question_caption_text_color_mobile' ].' !important;
3924 font-size: '.$this->options[ $this->name_prefix . 'question_caption_font_size_on_mobile' ].'px;
3925 text-transform: '.$this->options[ $this->name_prefix . 'question_caption_text_transform_mobile' ].' !important;
3926 letter-spacing: '.$this->options[ $this->name_prefix . 'question_caption_letter_spacing_mobile' ].'px !important;
3927 display: '.$question_caption_text_display .';
3928 text-align: ' . $this->options[ $this->name_prefix . 'question_caption_text_alignment_on_mobile' ] . ';
3929 }
3930
3931 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-status .' . $this->html_class_prefix . 'live-bar-status-text{
3932 font-size: ' . $this->options[ $this->name_prefix . 'progress_bar_text_font_size_on_mobile' ] . 'px;
3933 color: ' . $this->options[ $this->name_prefix . 'pagination_text_color_mobile' ] . ';
3934 letter-spacing: ' . $this->options[ $this->name_prefix . 'progress_bar_text_letter_spacing_mobile' ] . 'px;
3935 text-transform: '.$this->options[ $this->name_prefix . 'progress_bar_text_transform_mobile' ].';
3936 line-height: 1;
3937 }
3938 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question-image {
3939 width: ' . $question_image_width_mobile . ';
3940 height: ' . $question_image_height_mobile . ';
3941 object-fit: ' . $this->options[ $this->name_prefix . 'question_image_sizing_mobile' ] . ';
3942 }
3943 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'answer-image {
3944 object-fit: ' . $this->options[ $this->name_prefix . 'answers_object_fit_mobile' ] . ';
3945 }
3946 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-buttons {
3947 display: flex;
3948 '.$survey_start_page_button_pos_mobile.'
3949 }
3950 }';
3951 $content .= '
3952 @media screen and (max-width: 580px) {
3953 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . '.' . $this->html_class_prefix . 'container .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'answer-label .' . $this->html_class_prefix . 'answer-image-container{
3954 height: ' . $this->options[ $this->name_prefix . 'answers_image_size_mobile' ] . 'px;
3955 }
3956
3957 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'live-bar-main{
3958 justify-content: center;
3959 }
3960 }';
3961 $content .= '
3962 @media screen and (min-width: 580px) and (max-width: 1024px) {
3963 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . '.' . $this->html_class_prefix . 'container .' . $this->html_class_prefix . 'section .' . $this->html_class_prefix . 'answer-label .' . $this->html_class_prefix . 'answer-image-container{
3964 height: 150px;
3965 }
3966 }';
3967
3968 return $content;
3969 }
3970
3971
3972 public function ays_generate_survey_popup_method( $attr ){
3973
3974 $id = (isset($attr['id'])) ? absint(intval($attr['id'])) : null;
3975 if (is_null($id)) {
3976 return '';
3977 }
3978
3979 $this->enqueue_scripts_popups();
3980
3981 $content = $this->ays_popup_shortcode_content($id, $attr);
3982 return $content ? str_replace( array( "\r\n", "\n", "\r" ), "\n", $content ) : '';
3983 }
3984
3985
3986 public function ays_popup_shortcode_content( $id, $attr ){
3987 global $wpdb;
3988 $post_id = get_the_ID();
3989 $popup_surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys";
3990 $surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "surveys";
3991 $sql = "SELECT p_s.*, s.options as s_options, s.status as survey_status
3992 FROM {$popup_surveys_table} as p_s
3993 LEFT JOIN {$surveys_table} AS s
3994 ON p_s.survey_id = s.id
3995 WHERE p_s.id = {$id}";
3996 $popup = $wpdb->get_row( $sql, "ARRAY_A" );
3997
3998 if( empty( $popup ) ){
3999 return '';
4000 }
4001
4002 $survey_status = (isset($popup['survey_status'] ) && $popup['survey_status'] != '') ? $popup['survey_status'] : 'published';
4003 $is_elementor_exists = Survey_Maker_Data::ays_survey_is_elementor();
4004 if($survey_status == 'published' && !$is_elementor_exists){
4005
4006 $show_all = $popup['show_all'];
4007 switch($show_all){
4008 case 'all':
4009 $show_popup = true;
4010 break;
4011 case 'selected':
4012 $show_popup = false;
4013 break;
4014 case 'except':
4015 $show_popup = true;
4016 break;
4017 default:
4018 $show_popup = true;
4019 $show_all = 'all';
4020 break;
4021 }
4022
4023 $show = array('selected');
4024
4025 $options = array();
4026 $survey_options = array();
4027 if ($popup['options'] != '' || $popup['options'] != null) {
4028 $options = json_decode( $popup['options'], true );
4029 }
4030
4031 if ($popup['s_options'] != '' || $popup['s_options'] != null) {
4032 $survey_options = json_decode( $popup['s_options'], true );
4033 }
4034 // Title
4035 $popup_title = isset( $popup["title"] ) && $popup["title"] != "" ? stripslashes( esc_attr( $popup["title"] ) ) : "";
4036
4037 // Show popup title
4038 $survey_popup_enable_show_title = (isset($options["popup_enable_show_title"]) && $options["popup_enable_show_title"] == "on") ? true : false;
4039
4040 // Popup title font size
4041 $survey_popup_title_font_size = (isset($options['popup_title_font_size']) && $options['popup_title_font_size'] != '') ? absint ( intval( $options['popup_title_font_size'] ) ) : 25;
4042
4043 // Popup title font size on mobile
4044 $survey_popup_title_mobile_font_size = (isset($options['popup_title_mobile_font_size']) && $options['popup_title_mobile_font_size'] != '') ? absint ( intval( $options['popup_title_mobile_font_size'] ) ) : $survey_popup_title_font_size;
4045
4046 // Popup title bg color
4047 $survey_popup_title_bg_color = (isset($options["popup_title_bg_color"]) && $options["popup_title_bg_color"] != "") ? esc_attr ( $options["popup_title_bg_color"] ) : "#000000";
4048 // Popup title bg color mobile
4049 $options["popup_title_bg_color_mobile"] = isset($options["popup_title_bg_color_mobile"]) ? $options["popup_title_bg_color_mobile"] : $survey_popup_title_bg_color;
4050 $survey_popup_title_bg_color_mobile = (isset($options["popup_title_bg_color_mobile"]) && $options["popup_title_bg_color_mobile"] != "") ? esc_attr ( $options["popup_title_bg_color_mobile"] ) : "#000000";
4051
4052 // Popup title text color
4053 $survey_popup_title_text_color = (isset($options["popup_title_text_color"]) && $options["popup_title_text_color"] != "") ? esc_attr ( $options["popup_title_text_color"] ) : "#000000";
4054 // Popup title text color mobile
4055 $options["popup_title_text_color_mobile"] = isset($options["popup_title_text_color_mobile"]) ? $options["popup_title_text_color_mobile"] : $survey_popup_title_text_color;
4056 $survey_popup_title_text_color_mobile = (isset($options["popup_title_text_color_mobile"]) && $options["popup_title_text_color_mobile"] != "") ? esc_attr ( $options["popup_title_text_color_mobile"] ) : "#000000";
4057
4058 // Popup title alignment
4059 $survey_popup_title_alignment = (isset($options["popup_title_alignment"]) && $options["popup_title_alignment"] != "") ? esc_attr ( $options["popup_title_alignment"] ) : "left";
4060
4061 // Popup title alignment on mobile
4062 $options["popup_title_alignment_on_mobile"] = isset($options["popup_title_alignment_on_mobile"]) ? $options["popup_title_alignment_on_mobile"] : $survey_popup_title_alignment;
4063 $survey_popup_title_alignment_on_mobile = (isset($options["popup_title_alignment_on_mobile"]) && $options["popup_title_alignment_on_mobile"] != "") ? esc_attr ( $options["popup_title_alignment_on_mobile"] ) : "left";
4064
4065 // Popup title transform
4066 $survey_popup_title_transform = (isset($options["popup_title_transform"]) && $options["popup_title_transform"] != "") ? esc_attr ( $options["popup_title_transform"] ) : "none";
4067 // Popup title transform mobile
4068 $options["popup_title_transform_mobile"] = isset($options["popup_title_transform_mobile"]) ? $options["popup_title_transform_mobile"] : $survey_popup_title_transform;
4069 $survey_popup_title_transform_mobile = (isset($options["popup_title_transform_mobile"]) && $options["popup_title_transform_mobile"] != "") ? esc_attr ( $options["popup_title_transform_mobile"] ) : "none";
4070
4071 // Popup title letter spacing
4072 $survey_popup_title_letter_spacing = (isset( $options[ "popup_title_letter_spacing" ] ) && $options["popup_title_letter_spacing"] != '' && $options["popup_title_letter_spacing"] != '0') ? esc_attr( $options["popup_title_letter_spacing"] ) : 0;
4073
4074 // Popup title letter spacing mobile
4075 $options['popup_title_letter_spacing_on_mobile' ] = isset($options['popup_title_letter_spacing_on_mobile' ]) ? $options['popup_title_letter_spacing_on_mobile' ] : $survey_popup_title_letter_spacing;
4076 $survey_popup_title_letter_spacing_on_mobile = (isset( $options['popup_title_letter_spacing_on_mobile' ] ) && $options['popup_title_letter_spacing_on_mobile'] != '' && $options['popup_title_letter_spacing_on_mobile'] != '0') ? esc_attr( $options['popup_title_letter_spacing_on_mobile'] ) : 0;
4077
4078 // Hide popup title on mobile
4079 $survey_popup_hide_title_on_mobile = (isset($options["popup_hide_title_on_mobile"]) && $options["popup_hide_title_on_mobile"] == "on") ? true : false;
4080
4081 // Title border radius
4082 $survey_popup_title_border_radius = (isset($options["popup_title_border_radius"]) && $options["popup_title_border_radius"] != "") ? absint ( intval( $options["popup_title_border_radius"] ) ) : 0;
4083 // Title border radius mobile
4084 $survey_popup_title_border_radius_mobile = (isset($options["popup_title_border_radius_mobile"]) && $options["popup_title_border_radius_mobile"] != "") ? absint ( intval( $options["popup_title_border_radius_mobile"] ) ) : 0;
4085
4086 // Width
4087 $popup_survey_width = (isset($options['width']) && $options['width'] != '') ? absint ( intval( $options['width'] ) ) : 800;
4088 // Mobile width
4089 $options['width_mobile'] = isset($options['width_mobile']) ? $options['width_mobile'] : $popup_survey_width;
4090 $popup_survey_width_mobile = (isset($options['width_mobile']) && $options['width_mobile'] != '') ? absint ( intval( $options['width_mobile'] ) ) : 800;
4091
4092 // Height
4093 $popup_survey_height = (isset($options['height']) && $options['height'] != '') ? absint ( intval( $options['height'] ) ) : 450;
4094 // Height mobile
4095 $options['height_mobile'] = isset($options['height_mobile']) ? $options['height_mobile'] : $popup_survey_height;
4096 $popup_survey_height_mobile = (isset($options['height_mobile']) && $options['height_mobile'] != '') ? absint ( intval( $options['height_mobile'] ) ) : 450;
4097
4098 // Popup Position
4099 $popup_position = (isset($options['popup_position']) && $options['popup_position'] != 'center-center') ? $options['popup_position'] : 'center-center';
4100
4101 // Popup Margin
4102 $popup_margin = (isset($options['popup_margin']) && $options['popup_margin'] != '') ? $options['popup_margin'] : '0';
4103
4104 $hide_popup = (isset($options['hide_popup']) && $options['hide_popup'] == 'on') ? $options['hide_popup'] : 'off';
4105
4106 // Hide popup after close
4107 $hide_popup_after_close = (isset($options['hide_popup_after_close']) && $options['hide_popup_after_close'] == 'on') ? esc_attr($options['hide_popup_after_close']) : 'off';
4108
4109 // Hide popup on mobile
4110 $options['hide_popup_on_mobile'] = isset( $options['hide_popup_on_mobile'] ) ? esc_attr($options['hide_popup_on_mobile']) : "off";
4111 $hide_popup_on_mobile = (isset($options['hide_popup_on_mobile']) && $options['hide_popup_on_mobile'] == 'on') ? true : false;
4112
4113 // Hide popup on PC
4114 $options['hide_popup_on_pc'] = isset( $options['hide_popup_on_pc'] ) ? esc_attr($options['hide_popup_on_pc']) : "off";
4115 $hide_popup_on_pc = (isset($options['hide_popup_on_pc']) && $options['hide_popup_on_pc'] == 'on') ? true : false;
4116
4117 // Hide popup on tablet
4118 $options['hide_popup_on_tablet'] = isset( $options['hide_popup_on_tablet'] ) ? esc_attr($options['hide_popup_on_tablet']) : "off";
4119 $hide_popup_on_tablet = (isset($options['hide_popup_on_tablet']) && $options['hide_popup_on_tablet'] == 'on') ? true : false;
4120
4121 // Close by clicking outside the box
4122 $close_popup_overlay_outside_click = (isset($options['close_popup_overlay_outside_click']) && $options['close_popup_overlay_outside_click'] == 'on') ? esc_attr($options['close_popup_overlay_outside_click']) : 'off';
4123
4124 // $survey_bg = (isset($survey_options['survey_background_color']) && $survey_options['survey_background_color'] != '') ? $survey_options['survey_background_color'] : '#ffffff';
4125 // $survey_theme = (isset($survey_options['survey_theme']) && $survey_options['survey_theme'] != '') ? $survey_options['survey_theme'] : 'classic_light';
4126 // $is_minimal = $survey_theme == 'minimal' ? true : false;
4127 // $is_modern = $survey_theme == 'modern' ? true : false;
4128
4129 // if( $is_minimal || $is_modern){
4130 // $survey_bg = '#ffffff';
4131 // }
4132
4133 // $survey_text_color = (isset($survey_options['survey_text_color']) && $survey_options['survey_text_color'] != '') ? $survey_options['survey_text_color'] : '#ffffff';
4134
4135 // // Popup full screen mode
4136 $survey_popup_full_screen = (isset($options["full_screen_mode"]) && $options["full_screen_mode"] == "on") ? true : false;
4137 // // Popup background color
4138 $popup_bg_color = (isset($options['popup_bg_color']) && $options['popup_bg_color'] != '') ? $options['popup_bg_color'] : '#ffffff';
4139
4140 // Popup background color | Mobile
4141 $popup_bg_color_mobile = (isset($options['popup_bg_color_mobile']) && $options['popup_bg_color_mobile'] != '') ? esc_attr($options['popup_bg_color_mobile']) : $popup_bg_color;
4142
4143 // // Popup trigger type
4144 $popup_trigger_type = (isset($options["popup_trigger"]) && $options["popup_trigger"] != "") ? esc_attr($options["popup_trigger"]) : "on_load";
4145
4146 // Popup close after finish
4147 $survey_enable_popup_close_after_finish = (isset($options["enable_popup_close_after_finish"]) && $options["enable_popup_close_after_finish"] == "on") ? true : false;
4148 $survey_popup_close_after_finish_delay = (isset($options[ 'popup_close_after_finish_delay' ]) && $options[ 'popup_close_after_finish_delay' ] != '') ? absint ( intval( $options[ 'popup_close_after_finish_delay' ] ) ) : '';
4149
4150 // Popup selector
4151 $popup_selector = (isset($options["popup_selector"]) && $options["popup_selector"] != "") ? stripslashes( esc_attr($options["popup_selector"])) : "";
4152
4153 // Close by pressing the ESC
4154 $survey_popup_enable_close_by_esc = (isset($options["popup_enable_close_by_esc"]) && $options["popup_enable_close_by_esc"] != '') ? $options["popup_enable_close_by_esc"] : 'off';
4155
4156
4157 // if($show_all != 'all'){
4158 // if($post_id != false){
4159 // $post = get_post( $post_id );
4160 // $this_post_title = strval( $post->ID );
4161 // $except_posts = array();
4162 // $except_post_types = array();
4163 // $postType = $post->post_type;
4164
4165 // if (isset($options['except_posts']) && !empty($options['except_posts'])) {
4166 // $except_posts = $options['except_posts'];
4167 // }
4168
4169 // if (isset($options['except_post_types']) && !empty($options['except_post_types'])) {
4170 // $except_post_types = $options['except_post_types'];
4171 // }
4172
4173 // $except_all_post_types = ( isset( $options['all_posts'] ) && ! empty( $options['all_posts'] ) ) ? $options['all_posts'] : array();
4174
4175 // if ( is_front_page() ) {
4176 // if( isset($options['show_on_home_page']) && $options['show_on_home_page'] == 'on' ){
4177 // $show_popup = true;
4178 // }else{
4179 // $show_popup = false;
4180 // }
4181 // }
4182
4183 // if( in_array( $post_id . "", $except_posts ) ){
4184 // if( in_array( $show_all, $show ) ){
4185 // $show_popup = true;
4186 // }else{
4187 // $show_popup = false;
4188 // }
4189 // }elseif( !in_array( $this_post_title, $except_posts ) && in_array( $postType, $except_all_post_types ) ) {
4190 // if( in_array( $show_all, $show ) ){
4191 // $show_popup = true;
4192 // }else{
4193 // $show_popup = false;
4194 // }
4195 // }
4196 // }
4197 // }
4198
4199 if($hide_popup_on_mobile){
4200 if(Survey_Maker_Data::ays_survey_pb_detect_mobile_device() === true){
4201 $show_popup = false;
4202 }
4203 }
4204 if($hide_popup_on_pc){
4205 if(Survey_Maker_Data::ays_survey_pb_detect_mobile_device() === false && Survey_Maker_Data::ays_survey_pb_detect_tablet_device() === false){
4206 $show_popup = false;
4207 }
4208 }
4209
4210 if($hide_popup_on_tablet){
4211 if(Survey_Maker_Data::ays_survey_pb_detect_tablet_device() === true){
4212 $show_popup = false;
4213 }
4214 }
4215
4216 switch($popup_trigger_type){
4217 case 'on_click':
4218 $display_popup_on_load = 'display_none_not_important';
4219 break;
4220 case 'on_load':
4221 default:
4222 $display_popup_on_load = '';
4223 break;
4224 }
4225
4226 if( ! isset( $_COOKIE[ 'ays_survey_popup_cookie_name_' . $popup['id'] ] ) && ! isset( $_COOKIE[ 'ays_survey_popup_hide_after_click_close_' . $popup['id'] ] ) ){
4227 if ($show_popup) {
4228 $shortcode2 = '[ays_survey id="'. $popup['survey_id'] .'"]';
4229 // $popup_survey_view = "<div class='ays-survey-popup-survey-window ays-survey-popup-modal-".$popup['id']."' data-id='".$popup['id']."'>
4230 $popup_survey_view = "<div class='ays-survey-popup-survey-window ays-survey-popup-modal-".$popup['id']." ".$display_popup_on_load."' data-id='".$popup['id']."' data-close-popup='".$survey_enable_popup_close_after_finish."'>
4231 <div class='ays-survey-popup-btn-close'>
4232 <img class='ays-survey-popup-btn-close-icon' src='". SURVEY_MAKER_PUBLIC_URL ."/images/cross.svg'>
4233 </div>";
4234 $popup_survey_view .= "<div class='ays-survey-popup-content'>";
4235 if($survey_popup_enable_show_title){
4236 $popup_survey_view .= "<div class='ays-survey-popup-title-content'>".$popup_title."</div>";
4237
4238 }
4239 if($survey_popup_full_screen){
4240 $popup_survey_view .= '<div class="ays-survey-popup-full-screen-mode">
4241 <a class="ays-survey-popup-full-screen-container">
4242 <svg xmlns="http://www.w3.org/2000/svg" height="24" fill="#000" viewBox="0 0 24 24" width="24" tabindex="0" class="ays-survey-popup-close-full-screen">
4243 <path d="M0 0h24v24H0z" fill="none"/>
4244 <path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>
4245 </svg>
4246 <svg xmlns="http://www.w3.org/2000/svg" height="24" fill="#000" viewBox="0 0 24 24" width="24" class="ays-survey-popup-open-full-screen">
4247 <path d="M0 0h24v24H0z" fill="none"/>
4248 <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
4249 </svg>
4250 </a>
4251 </div>';
4252 }
4253 $popup_survey_view .= "<div class='ays-survey-popup-main'>".do_shortcode($shortcode2)."</div>
4254 </div>";
4255
4256 $margin_right = '';
4257 $additional_css = '';
4258 switch ( $popup_position ){
4259 case "center-center":
4260 $ays_survey_popup_conteiner_pos_top = '12px';
4261 $ays_survey_popup_conteiner_pos_left = '0';
4262 $ays_survey_popup_conteiner_pos_right = '0';
4263 $ays_survey_popup_conteiner_pos_bottom = '0';
4264 $popup_margin = 'auto';
4265 $additional_css = 'max-height: calc( 100vh - 12px )';
4266 break;
4267 case "left-top":
4268
4269 $ays_survey_popup_conteiner_pos_top = '0';
4270 $ays_survey_popup_conteiner_pos_left = '0';
4271 $ays_survey_popup_conteiner_pos_right = 'unset';
4272 $ays_survey_popup_conteiner_pos_bottom = 'unset';
4273 $popup_margin = 'px';
4274
4275 if( absint( $popup_margin ) < 12 ){
4276 $margin_right = 'margin-top: 12px;';
4277 }
4278 break;
4279 case "top-center":
4280
4281 $ays_survey_popup_conteiner_pos_top = '0';
4282 $ays_survey_popup_conteiner_pos_left = '50%';
4283 $ays_survey_popup_conteiner_pos_right = 'unset';
4284 $ays_survey_popup_conteiner_pos_bottom = 'unset';
4285 $popup_margin = 'px auto';
4286 $additional_css = 'transform: translateX(-50%);';
4287
4288 if( absint( $popup_margin ) < 12 ){
4289 $margin_right = 'margin-top: 12px;';
4290 }
4291 break;
4292 case "right-top":
4293
4294 $ays_survey_popup_conteiner_pos_top = '0';
4295 $ays_survey_popup_conteiner_pos_left = 'unset';
4296 $ays_survey_popup_conteiner_pos_right = '0';
4297 $ays_survey_popup_conteiner_pos_bottom = 'unset';
4298 $popup_margin .= 'px';
4299 if( absint( $popup_margin ) < 12 ){
4300 $margin_right = 'margin-right: 12px;margin-top: 12px;';
4301 }
4302
4303 break;
4304 case "left-center":
4305
4306 $ays_survey_popup_conteiner_pos_top = '0';
4307 $ays_survey_popup_conteiner_pos_left = '0';
4308 $ays_survey_popup_conteiner_pos_right = 'unset';
4309 $ays_survey_popup_conteiner_pos_bottom = '0';
4310 $popup_margin = 'auto ' . $popup_margin . 'px';
4311
4312 break;
4313 case "right-center":
4314
4315 $ays_survey_popup_conteiner_pos_top = '0';
4316 $ays_survey_popup_conteiner_pos_left = 'unset';
4317 $ays_survey_popup_conteiner_pos_right = '0';
4318 $ays_survey_popup_conteiner_pos_bottom = '0';
4319 $popup_margin = 'auto ' . $popup_margin . 'px';
4320
4321 if( absint( $popup_margin ) < 12 ){
4322 $margin_right = 'margin-right: 12px;';
4323 }
4324 break;
4325 case "right-bottom":
4326
4327 $ays_survey_popup_conteiner_pos_top = 'unset';
4328 $ays_survey_popup_conteiner_pos_left = 'unset';
4329 $ays_survey_popup_conteiner_pos_right = '0';
4330 $ays_survey_popup_conteiner_pos_bottom = '0';
4331 $popup_margin = 'px';
4332
4333 if( absint( $popup_margin ) < 12 ){
4334 $margin_right = 'margin-right: 12px;';
4335 }
4336 break;
4337 case "center-bottom":
4338
4339 $ays_survey_popup_conteiner_pos_top = 'unset';
4340 $ays_survey_popup_conteiner_pos_left = '50%';
4341 $ays_survey_popup_conteiner_pos_right = 'unset';
4342 $ays_survey_popup_conteiner_pos_bottom = '0';
4343 $popup_margin = 'px auto';
4344 $additional_css = 'transform: translateX(-50%);';
4345
4346 break;
4347 case "left-bottom":
4348
4349 $ays_survey_popup_conteiner_pos_top = 'unset';
4350 $ays_survey_popup_conteiner_pos_left = '0';
4351 $ays_survey_popup_conteiner_pos_right = 'unset';
4352 $ays_survey_popup_conteiner_pos_bottom = '0';
4353 $popup_margin = 'px';
4354
4355 break;
4356 }
4357
4358 $hide_popup_on_mobile_class = $survey_popup_hide_title_on_mobile ? 'display: none;' : '';
4359
4360 $popup_survey_view .= '
4361 <style>
4362 .ays-survey-popup-modal-' . $popup['id'] . ' {
4363 width: ' . $popup_survey_width . 'px;
4364 height: ' . $popup_survey_height . 'px;
4365 background-color: ' . $popup_bg_color . ';
4366 top: ' . $ays_survey_popup_conteiner_pos_top . ';
4367 left: ' . $ays_survey_popup_conteiner_pos_left . ';
4368 right: ' . $ays_survey_popup_conteiner_pos_right . ';
4369 bottom: ' . $ays_survey_popup_conteiner_pos_bottom . ';
4370 margin: ' . $popup_margin . ';
4371 ' . $margin_right . '
4372 ' . $additional_css . '
4373 }
4374
4375 .ays-survey-popup-modal-' . $popup['id'] . ' .ays-survey-popup-title-content{
4376 background-color: '.$survey_popup_title_bg_color.';
4377 color: '.$survey_popup_title_text_color.';
4378 font-size: '.$survey_popup_title_font_size.'px;
4379 text-align: '.$survey_popup_title_alignment.';
4380 text-transform: '.$survey_popup_title_transform.';
4381 letter-spacing: '.$survey_popup_title_letter_spacing.'px;
4382 line-height: 2;
4383 border-radius: '.$survey_popup_title_border_radius.'px;
4384 padding: 0 10px;
4385 }
4386
4387 @media screen and (max-width: 640px){
4388 div.ays-survey-popup-modal-' . $popup['id'] . ' {
4389 width: ' . $popup_survey_width_mobile . 'px;
4390 height: ' . $popup_survey_height_mobile . 'px;
4391 background-color: ' . $popup_bg_color_mobile . ';
4392 }
4393 .ays-survey-popup-modal-' . $popup['id'] . ' .ays-survey-popup-title-content{
4394 font-size: '.$survey_popup_title_mobile_font_size.'px;
4395 color: '.$survey_popup_title_text_color_mobile.';
4396 background-color: '.$survey_popup_title_bg_color_mobile.';
4397 '.$hide_popup_on_mobile_class.';
4398 letter-spacing: '.$survey_popup_title_letter_spacing_on_mobile.'px;
4399 text-align: '.$survey_popup_title_alignment_on_mobile.';
4400 text-transform: '.$survey_popup_title_transform_mobile.';
4401 border-radius: '.$survey_popup_title_border_radius_mobile.'px;
4402 }
4403 }
4404
4405 </style>
4406 ';
4407
4408 $popup_survey_view .= '<script type="text/javascript">';
4409
4410 $popup_survey_view .= "
4411 if(typeof aysSurveyPopupsOptions === 'undefined'){
4412 var aysSurveyPopupsOptions = [];
4413 }
4414 aysSurveyPopupsOptions['" . $popup['id'] . "'] = '" . base64_encode( json_encode( array(
4415 'hidePopup' => $hide_popup,
4416 'hidePopupAfterClose' => $hide_popup_after_close,
4417 'popup_trigger' => $popup_trigger_type,
4418 'enable_popup_close_after_finish' => $survey_enable_popup_close_after_finish,
4419 'popup_close_after_finish_delay' => $survey_popup_close_after_finish_delay,
4420 'popup_selector' => $popup_selector,
4421 'popupEnableCloseByEsc' => $survey_popup_enable_close_by_esc,
4422 'closePopupOverlayOutsideClick' => $close_popup_overlay_outside_click,
4423
4424 ) ) ) . "';";
4425 $popup_survey_view .= '</script>';
4426 $popup_survey_view .= '</div>';
4427
4428 return $popup_survey_view;
4429 }
4430 }
4431 }
4432 }
4433
4434
4435 public function ays_shortcodes_show_all(){
4436 global $wpdb;
4437 $post_id = get_the_ID();
4438 $popup_surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys";
4439 $surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "surveys";
4440 $sql = "SELECT p_s.*, s.options as s_options, s.status as survey_status
4441 FROM {$popup_surveys_table} as p_s
4442 LEFT JOIN {$surveys_table} AS s
4443 ON p_s.survey_id = s.id
4444 WHERE p_s.status = 'published'";
4445 $result = $wpdb->get_results( $sql, "ARRAY_A" );
4446
4447 foreach($result as $key => $value){
4448 echo do_shortcode('[ays_survey_popup id="'. $value['id'] .'"]');
4449 }
4450 }
4451
4452 public function checkNextButtonVisibility($other_answers_count, $question_type){
4453 return ($other_answers_count === 0 && $question_type === 0 && $this->options[ $this->name_prefix . 'disable_next_button' ]);
4454 }
4455 }
4456