PluginProbe
Survey Maker by AYS / 5.2.0.8
Survey Maker by AYS v5.2.0.8
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.0.8, at public/class-survey-maker-public.php

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