PluginProbe
Survey Maker by AYS / 5.2.3.3
Survey Maker by AYS v5.2.3.3
5.2.4.1 5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 All 154 releases
survey-maker / public / class-survey-maker-public.php

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

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