PluginProbe
Survey Maker by AYS / 5.2.4.1
Survey Maker by AYS v5.2.4.1
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.4.1, at public/class-survey-maker-public.php

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