PluginProbe
Survey Maker by AYS / 5.2.2.3
Survey Maker by AYS v5.2.2.3
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.2.3, at public/class-survey-maker-public.php

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