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

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

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