PluginProbe
Survey Maker by AYS / 5.2.4.1
Survey Maker by AYS v5.2.4.1
5.2.4.1 5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 All 154 releases
← All changes | public/class-survey-maker-public.php +224 -89 5.2.3.1 → 5.2.4.1 View file →
@@ -133,8 +133,9 @@
133 133
134 134 wp_localize_script( $this->plugin_name . '-plugin', 'aysSurveyMakerAjaxPublic', array(
135 135 'ajaxUrl' => admin_url('admin-ajax.php'),
136 136 'warningIcon' => SURVEY_MAKER_PUBLIC_URL . "/images/warning.svg",
137 + 'ajaxNonce' => wp_create_nonce( 'ays_survey_ajax_nonce' ),
137 138 'autofill_nonce' => wp_create_nonce('survey_maker_autofill_nonce')
138 139 ) );
139 140 wp_localize_script( $this->plugin_name, 'aysSurveyLangObj', array(
140 141 'notAnsweredText' => __( 'You have not answered this question', "survey-maker" ),
@@ -159,8 +160,9 @@
159 160 public function enqueue_scripts_popups() {
160 161 wp_enqueue_script( $this->plugin_name . '-popups', plugin_dir_url( __FILE__ ) . 'js/survey-maker-public-popups.js', array( 'jquery' ), $this->version, false );
161 162 wp_localize_script( $this->plugin_name . '-popups', 'aysSurveyMakerPopupsAjaxPublic', array(
162 163 'ajaxUrl' => admin_url('admin-ajax.php'),
164 + 'ajaxNonce' => wp_create_nonce( 'ays_survey_ajax_nonce' ),
163 165 ) );
164 166 }
165 167
166 168 public function ays_survey_ajax(){
@@ -165,8 +167,14 @@
165 167
166 168 public function ays_survey_ajax(){
167 169 global $wpdb;
168 170
171 + if ( 'POST' !== strtoupper( isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : '' ) ) {
172 + wp_send_json_error( array( 'message' => __( 'Invalid request method.', 'survey-maker' ) ), 405 );
173 + }
174 +
175 + check_ajax_referer( 'ays_survey_ajax_nonce', '_ajax_nonce' );
176 +
169 177 $results = array(
170 178 "status" => false
171 179 );
172 180 $function = isset($_REQUEST['function']) ? $_REQUEST['function'] : null;
@@ -188,16 +196,14 @@
188 196 }
189 197
190 198 ob_end_clean();
191 199 $ob_get_clean = ob_get_clean();
192 - echo json_encode( $results );
193 - wp_die();
200 + wp_send_json( $results );
194 201 }
195 202
196 203 ob_end_clean();
197 204 $ob_get_clean = ob_get_clean();
198 - echo json_encode( $results );
199 - wp_die();
205 + wp_send_json( $results );
200 206 }
201 207
202 208 public function ays_finish_survey( $data ){
203 209 $unique_id = isset($data['unique_id']) ? $data['unique_id'] : null;
@@ -223,14 +229,25 @@
223 229
224 230 $answered_questions = isset( $data[ $name_prefix . 'answers-' . $unique_id ] ) && !empty( $data[ $name_prefix . 'answers-' . $unique_id ] ) ? $data[ $name_prefix . 'answers-' . $unique_id ] : array();
225 231 $questions_data = isset( $data[ $name_prefix . 'questions-' . $unique_id ] ) && !empty( $data[ $name_prefix . 'questions-' . $unique_id ] ) ? $data[ $name_prefix . 'questions-' . $unique_id ] : array();
226 232
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();
233 + $survey_additional_wp_data = array();
234 + if ( isset( $data[ $valid_name_prefix . 'additional_wp_data' ] ) && is_string( $data[ $valid_name_prefix . 'additional_wp_data' ] ) && '' !== $data[ $valid_name_prefix . 'additional_wp_data' ] ) {
235 + $decoded_additional_wp_data = base64_decode( wp_unslash( $data[ $valid_name_prefix . 'additional_wp_data' ] ), true );
236 + if ( false !== $decoded_additional_wp_data ) {
237 + $decoded_additional_wp_data = json_decode( $decoded_additional_wp_data, true );
238 + if ( is_array( $decoded_additional_wp_data ) ) {
239 + $survey_additional_wp_data = $decoded_additional_wp_data;
240 + }
241 + }
242 + }
228 243
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'] ) : "";
244 + $survey_current_page_link = isset( $data['ays-survey-current_page_link'] ) && $data['ays-survey-current_page_link'] != '' ? sanitize_url( $data['ays-survey-current_page_link'] ) : "";
230 245
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>";
246 + $survey_current_page_title = isset( $data['ays-survey-current_page_title'] ) && $data['ays-survey-current_page_title'] != '' ? sanitize_text_field( $data['ays-survey-current_page_title'] ) : "";
232 247
248 + $survey_current_page_link_html = "<a href='". esc_sql( $survey_current_page_link ) ."' target='_blank' class='ays-survey-current-page-link-a-tag'>". __( "Survey link", "survey-maker" ) ."</a>";
249 +
233 250 // Survey modified date
234 251 $survey_modified_date = (isset($survey->date_modified) && $survey->date_modified != '') ? esc_attr( $survey->date_modified ) : "";
235 252 if( $survey_modified_date != "" ){
236 253 $survey_modified_date = date_i18n( get_option( 'date_format' ), strtotime( $survey_modified_date ) );
@@ -369,8 +386,9 @@
369 386 $current_survey_author_email = '';
370 387 $current_survey_author_nickname = '';
371 388 $current_survey_author_display_name = '';
372 389 $current_survey_author_website_url = '';
390 + $current_survey_author_registered = '';
373 391 if ( isset( $current_survey_user_data ) && $current_survey_user_data ) {
374 392 // Get survey author name
375 393 $current_survey_author = ( isset( $current_survey_user_data->data->display_name ) && $current_survey_user_data->data->display_name != '' ) ? sanitize_text_field( $current_survey_user_data->data->display_name ) : "";
376 394 // Get survey author email
@@ -380,10 +398,16 @@
380 398 // Get survey author display name
381 399 $current_survey_author_display_name = ( isset( $current_survey_user_data->data->display_name ) && $current_survey_user_data->data->display_name != '' ) ? sanitize_text_field( $current_survey_user_data->data->display_name ) : "";
382 400 // Get survey author Website URL
383 401 $current_survey_author_website_url = ( isset( $current_survey_user_data->data->user_url ) && $current_survey_user_data->data->user_url != '' ) ? sanitize_text_field( $current_survey_user_data->data->user_url ) : "";
402 + // Get survey author Website URL
403 + $current_survey_author_registered = ( isset( $current_survey_user_data->data->user_registered ) && $current_survey_user_data->data->user_registered != '' ) ? sanitize_text_field( $current_survey_user_data->data->user_registered ) : "";
384 404 }
385 405
406 + if ( ! empty( $current_survey_author_website_url ) ) {
407 + $current_survey_author_website_url = '<a href="'. $current_survey_author_website_url .'" target="_blank">'. $current_survey_author_website_url .'</a>';
408 + }
409 +
386 410 $super_admin_email = "";
387 411 $wp_all_admins = get_users('role=Administrator');
388 412 if(!empty($wp_all_admins)){
389 413 $super_admin_email = isset($wp_all_admins[0]) ? $wp_all_admins[0]->data->user_email : '';
@@ -397,97 +421,121 @@
397 421 $survey_current_post_author_last_name = '';
398 422 $survey_current_post_author_website_url = '';
399 423 $survey_current_post_author_roles = '';
400 424 $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'] : '';
425 + if ( ! empty( $survey_additional_wp_data ) ) {
426 + $sanitize_additional_text = static function( $value ) {
427 + return is_scalar( $value ) ? esc_html( sanitize_text_field( wp_unslash( (string) $value ) ) ) : '';
428 + };
429 +
430 + $survey_post_type = isset( $survey_additional_wp_data['survey_post_type'] ) && is_scalar( $survey_additional_wp_data['survey_post_type'] ) ? sanitize_key( wp_unslash( (string) $survey_additional_wp_data['survey_post_type'] ) ) : '';
431 + if ( 'post' === $survey_post_type ) {
432 + $survey_current_post_id = isset( $survey_additional_wp_data['survey_post_id'] ) && is_scalar( $survey_additional_wp_data['survey_post_id'] ) ? absint( $survey_additional_wp_data['survey_post_id'] ) : '';
404 433 }
405 434
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']) : '';
435 + $survey_current_post_author_email = isset( $survey_additional_wp_data['survey_post_author_email'] ) && is_scalar( $survey_additional_wp_data['survey_post_author_email'] ) ? esc_html( sanitize_email( wp_unslash( (string) $survey_additional_wp_data['survey_post_author_email'] ) ) ) : '';
436 + $survey_current_post_author_nickname = isset( $survey_additional_wp_data['survey_current_post_author_nickname'] ) ? $sanitize_additional_text( $survey_additional_wp_data['survey_current_post_author_nickname'] ) : '';
437 + $survey_current_post_author_display_name = isset( $survey_additional_wp_data['survey_current_post_author_display_name'] ) ? $sanitize_additional_text( $survey_additional_wp_data['survey_current_post_author_display_name'] ) : '';
438 + $survey_current_post_author_first_name = isset( $survey_additional_wp_data['survey_current_post_author_first_name'] ) ? $sanitize_additional_text( $survey_additional_wp_data['survey_current_post_author_first_name'] ) : '';
439 + $survey_current_post_author_last_name = isset( $survey_additional_wp_data['survey_current_post_author_last_name'] ) ? $sanitize_additional_text( $survey_additional_wp_data['survey_current_post_author_last_name'] ) : '';
440 + $survey_current_post_author_website_url = isset( $survey_additional_wp_data['survey_current_post_author_website_url'] ) && is_scalar( $survey_additional_wp_data['survey_current_post_author_website_url'] ) ? esc_url_raw( wp_unslash( (string) $survey_additional_wp_data['survey_current_post_author_website_url'] ) ) : '';
441 + $survey_current_post_author_roles = isset( $survey_additional_wp_data['survey_current_post_author_roles'] ) ? $survey_additional_wp_data['survey_current_post_author_roles'] : '';
442 + $survey_current_post_title = isset( $survey_additional_wp_data['survey_current_post_title'] ) ? $sanitize_additional_text( $survey_additional_wp_data['survey_current_post_title'] ) : '';
414 443 }
415 444
416 445 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>';
446 + $survey_current_post_author_website_url = '<a href="' . esc_url( $survey_current_post_author_website_url ) . '" target="_blank" rel="noopener noreferrer">' . esc_html( $survey_current_post_author_website_url ) . '</a>';
418 447 }
419 448
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 - }
449 + if ( is_array( $survey_current_post_author_roles ) ) {
450 + $survey_current_post_author_roles = array_filter( $survey_current_post_author_roles, 'is_scalar' );
451 + $survey_current_post_author_roles = array_map( static function( $role ) {
452 + return sanitize_text_field( wp_unslash( (string) $role ) );
453 + }, $survey_current_post_author_roles );
454 + $survey_current_post_author_roles = implode( ', ', $survey_current_post_author_roles );
424 455 }
456 + $survey_current_post_author_roles = is_scalar( $survey_current_post_author_roles ) ? esc_html( sanitize_text_field( wp_unslash( (string) $survey_current_post_author_roles ) ) ) : '';
425 457
426 458 $get_site_title = get_bloginfo('name');
427 459 $get_site_description = get_bloginfo('description');
428 460
461 + // Survey category title
462 + $survey_category_title = "";
463 +
464 + $survey_cats = $survey->category_ids;
465 + $survey_category_ids = isset( $survey_cats ) && $survey_cats != "" ? sanitize_text_field( $survey_cats ) : '';
466 +
467 + if ( $survey_category_ids != '' ) {
468 + $categories = self::get_survey_category_by_ids($survey_category_ids);
469 + $category_names = wp_list_pluck( $categories, 'title' );
470 +
471 + $survey_category_title = implode( ', ', $category_names );
472 + }
473 +
429 474 $detectedDevice = Survey_Maker_Data::ays_survey_detected_device_chart();
430 475
431 476 $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,
477 + 'survey_title' => stripslashes($survey->title),
478 + 'survey_category_title' => $survey_category_title,
479 + 'survey_id' => stripslashes($survey->id),
480 + 'post_id' => $survey_current_post_id,
481 + 'user_name' => $user_name,
482 + 'user_email' => $user_email,
483 + 'user_wordpress_email' => $user_wordpress_email,
484 + 'user_id' => $user_id,
485 + 'user_registered' => $user_registered,
486 + 'questions_count' => $survey_question_count,
487 + 'current_date' => $survey_current_date,
488 + 'current_time' => $survey_current_time_only,
489 + 'current_day' => $survey_current_day,
490 + 'current_month' => $survey_current_month,
491 + 'unique_code' => $result_unique_code,
492 + 'sections_count' => $survey_sections_count,
493 + 'users_count' => $survey_passed_users_count,
494 + 'users_first_name' => $user_first_name,
495 + 'users_last_name' => $user_last_name,
496 + 'users_nick_name' => $user_nick_name,
497 + 'users_display_name' => $user_display_name,
498 + 'users_ip_address' => $user_ip_address,
499 + 'user_wordpress_roles' => $user_wordpress_roles,
500 + 'user_website_url' => $user_website_url,
501 + 'creation_date' => date_i18n( get_option( 'date_format' ), strtotime( sanitize_text_field( $survey->date_created ) ) ),
502 + 'modified_date' => $survey_modified_date,
503 + 'current_survey_author' => $current_survey_author,
504 + 'current_survey_author_email' => $current_survey_author_email,
505 + 'current_survey_author_nickname' => $current_survey_author_nickname,
506 + 'current_survey_author_display_name' => $current_survey_author_display_name,
507 + 'current_survey_author_website_url' => $current_survey_author_website_url,
508 + 'current_survey_author_registered' => $current_survey_author_registered,
509 + 'current_survey_page_link' => $survey_current_page_link_html,
510 + 'current_survey_page_title' => $survey_current_page_title,
511 + 'admin_email' => $super_admin_email,
512 + 'home_page_url' => $wp_home_page_url,
513 + 'post_author_email' => $survey_current_post_author_email,
514 + 'post_author_nickname' => $survey_current_post_author_nickname,
515 + 'post_author_display_name' => $survey_current_post_author_display_name,
516 + 'post_author_first_name' => $survey_current_post_author_first_name,
517 + 'post_author_last_name' => $survey_current_post_author_last_name,
518 + 'post_author_website_url' => $survey_current_post_author_website_url,
519 + 'post_author_roles' => $survey_current_post_author_roles,
520 + 'post_title' => $survey_current_post_title,
521 + 'site_title' => $get_site_title,
522 + 'site_description' => $get_site_description,
475 523 );
476 524
477 525 $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,
526 + 'questions_data' => $questions_data,
527 + 'answered_questions' => $answered_questions,
528 + 'survey' => $survey,
529 + 'questions_ids' => $survey->question_ids,
530 + 'user_id' => $user_id,
531 + 'user_ip' => $user_ip,
532 + 'user_name' => $user_name,
533 + 'user_email' => $user_email,
534 + 'start_date' => current_time( 'mysql' ),
535 + 'end_date' => current_time( 'mysql' ),
536 + 'unique_code' => $result_unique_code,
537 + 'detectedDevice' => $detectedDevice,
490 538 );
491 539 $check_limitations = false;
492 540 if(isset($options['survey_limit_users']) && $options['survey_limit_users']){
493 541 $limit_users_by = isset($options['survey_limit_users_by']) && $options['survey_limit_users_by'] != "" ? $options['survey_limit_users_by'] : "";
@@ -1056,9 +1104,9 @@
1056 1104 if ( $this->options[ $this->name_prefix . 'allow_html_in_section_description' ] ) {
1057 1105
1058 1106 $survey_allowed_html = Survey_Maker_Data::ays_survey_custom_allowed_html();
1059 1107
1060 - $sections[$section_key]['description'] = (isset($section['description']) && $section['description'] != '') ? nl2br( wp_kses( $section['description'] ), $survey_allowed_html ) : '';
1108 + $sections[$section_key]['description'] = (isset($section['description']) && $section['description'] != '') ? nl2br( wp_kses( $section['description'], $survey_allowed_html ) ) : '';
1061 1109 } else {
1062 1110 $sections[$section_key]['description'] = (isset($section['description']) && $section['description'] != '') ? nl2br( esc_html( $section['description'] ) ) : '';
1063 1111 }
1064 1112
@@ -1248,8 +1296,11 @@
1248 1296 $ays_survey_protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
1249 1297 $current_survey_page_link = esc_url( $ays_survey_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1250 1298 $content[] = '<input type="hidden" name="'. $this->html_name_prefix .'current_page_link" value="'. $current_survey_page_link .'">';
1251 1299
1300 + $current_survey_page_title = get_the_title();
1301 + $content[] = '<input type="hidden" name="'. $this->html_name_prefix .'current_page_title" value="'. $current_survey_page_title .'">';
1302 +
1252 1303 if( !$limit && !$is_expired ){
1253 1304 $content[] = $this->create_sections( $sections );
1254 1305 }else{
1255 1306 if( $is_expired && !$limit ){
@@ -2967,8 +3018,9 @@
2967 3018
2968 3019 $content[] = '
2969 3020 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' {
2970 3021 width: ' . $width . ';
3022 + box-sizing: border-box;
2971 3023 }
2972 3024
2973 3025 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section-header {
2974 3026 border-top-color: ' . $this->options[ $this->name_prefix . 'color' ] . ' !important;
@@ -3698,8 +3750,28 @@
3698 3750 }
3699 3751 return $output;
3700 3752 }
3701 3753
3754 + public static function get_survey_category_by_ids($ids){
3755 + global $wpdb;
3756 +
3757 + $ids = array_map('intval', explode(',', $ids));
3758 + $ids = array_filter($ids);
3759 +
3760 + if (empty($ids)) {
3761 + return [];
3762 + }
3763 +
3764 + $ids_sql = implode(',', $ids);
3765 +
3766 + $sql = "SELECT *
3767 + FROM {$wpdb->prefix}ayssurvey_survey_categories
3768 + WHERE id IN ($ids_sql)
3769 + ORDER BY FIELD(id, $ids_sql)";
3770 +
3771 + return $wpdb->get_results($sql, ARRAY_A);
3772 + }
3773 +
3702 3774 public function ays_survey_popup_set_cookie(){
3703 3775 if( isset( $_REQUEST['id'] ) && $_REQUEST['id'] != '' ){
3704 3776 $id = sanitize_text_field( $_REQUEST['id'] );
3705 3777 }else{
@@ -3796,9 +3868,9 @@
3796 3868 $question_border_radius = $this->options[ $this->name_prefix . 'question_border_radius_mobile' ];
3797 3869 $content .= '
3798 3870 @media screen and (max-width: 640px){
3799 3871 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' {
3800 - max-width: '. $mobile_max_width .';
3872 + max-width: min('. $mobile_max_width .', calc(100vw - 20px));
3801 3873 }
3802 3874
3803 3875 #' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' {
3804 3876 width: ' . $mobile_width . ';
@@ -4083,18 +4155,28 @@
4083 4155 // Title border radius mobile
4084 4156 $survey_popup_title_border_radius_mobile = (isset($options["popup_title_border_radius_mobile"]) && $options["popup_title_border_radius_mobile"] != "") ? absint ( intval( $options["popup_title_border_radius_mobile"] ) ) : 0;
4085 4157
4086 4158 // Width
4087 - $popup_survey_width = (isset($options['width']) && $options['width'] != '') ? absint ( intval( $options['width'] ) ) : 800;
4159 + $popup_survey_width = (isset($options['width']) && $options['width'] != '') ? absint ( intval( $options['width'] ) ) : '';
4160 + // Width by percentage or pixels
4161 + $popup_survey_width_by = (isset($options['width_by_percentage_px']) && $options['width_by_percentage_px'] != '' && $popup_survey_width != '') ? stripslashes ( esc_attr( $options['width_by_percentage_px'] ) ) : 'pixels';
4162 +
4088 4163 // Mobile width
4089 4164 $options['width_mobile'] = isset($options['width_mobile']) ? $options['width_mobile'] : $popup_survey_width;
4090 - $popup_survey_width_mobile = (isset($options['width_mobile']) && $options['width_mobile'] != '') ? absint ( intval( $options['width_mobile'] ) ) : 800;
4165 + $popup_survey_width_mobile = (isset($options['width_mobile']) && $options['width_mobile'] != '') ? absint ( intval( $options['width_mobile'] ) ) : '';
4166 + // Mobile width by percentage or pixels
4167 + $popup_survey_width_mobile_by = (isset($options['width_mobile_by_percentage_px']) && $options['width_mobile_by_percentage_px'] != '' && $popup_survey_width_mobile != '') ? stripslashes ( esc_attr( $options['width_mobile_by_percentage_px'] ) ) : 'pixels';
4091 4168
4092 4169 // Height
4093 - $popup_survey_height = (isset($options['height']) && $options['height'] != '') ? absint ( intval( $options['height'] ) ) : 450;
4170 + $popup_survey_height = (isset($options['height']) && $options['height'] != '') ? absint ( intval( $options['height'] ) ) : '';
4171 + // Height by percentage or pixels
4172 + $popup_survey_height_by = (isset($options['height_by_percentage_px']) && $options['height_by_percentage_px'] != '' && $popup_survey_height != '') ? stripslashes ( esc_attr( $options['height_by_percentage_px'] ) ) : 'pixels';
4173 +
4094 4174 // Height mobile
4095 4175 $options['height_mobile'] = isset($options['height_mobile']) ? $options['height_mobile'] : $popup_survey_height;
4096 - $popup_survey_height_mobile = (isset($options['height_mobile']) && $options['height_mobile'] != '') ? absint ( intval( $options['height_mobile'] ) ) : 450;
4176 + $popup_survey_height_mobile = (isset($options['height_mobile']) && $options['height_mobile'] != '') ? absint ( intval( $options['height_mobile'] ) ) : '';
4177 + // Mobile height by percentage or pixels
4178 + $popup_survey_height_mobile_by = (isset($options['height_mobile_by_percentage_px']) && $options['height_mobile_by_percentage_px'] != '' && $popup_survey_height_mobile != '') ? stripslashes ( esc_attr( $options['height_mobile_by_percentage_px'] ) ) : 'pixels';
4097 4179
4098 4180 // Popup Position
4099 4181 $popup_position = (isset($options['popup_position']) && $options['popup_position'] != 'center-center') ? $options['popup_position'] : 'center-center';
4100 4182
@@ -4149,8 +4231,11 @@
4149 4231
4150 4232 // Popup selector
4151 4233 $popup_selector = (isset($options["popup_selector"]) && $options["popup_selector"] != "") ? stripslashes( esc_attr($options["popup_selector"])) : "";
4152 4234
4235 + // Popup animation
4236 + $popup_animation = (isset($options["popup_animation"]) && $options["popup_animation"] != "") ? esc_attr($options["popup_animation"]) : "none";
4237 +
4153 4238 // Close by pressing the ESC
4154 4239 $survey_popup_enable_close_by_esc = (isset($options["popup_enable_close_by_esc"]) && $options["popup_enable_close_by_esc"] != '') ? $options["popup_enable_close_by_esc"] : 'off';
4155 4240
4156 4241
@@ -4222,13 +4307,15 @@
4222 4307 $display_popup_on_load = '';
4223 4308 break;
4224 4309 }
4225 4310
4311 + $popup_animation_class = in_array($popup_animation, array('fade', 'slide-down', 'slide-up', 'zoom-in', 'bounce'), true) && $popup_trigger_type != 'on_click' ? 'ays-popup-animation-' . $popup_animation : '';
4312 +
4226 4313 if( ! isset( $_COOKIE[ 'ays_survey_popup_cookie_name_' . $popup['id'] ] ) && ! isset( $_COOKIE[ 'ays_survey_popup_hide_after_click_close_' . $popup['id'] ] ) ){
4227 4314 if ($show_popup) {
4228 4315 $shortcode2 = '[ays_survey id="'. $popup['survey_id'] .'"]';
4229 4316 // $popup_survey_view = "<div class='ays-survey-popup-survey-window ays-survey-popup-modal-".$popup['id']."' data-id='".$popup['id']."'>
4230 - $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."'>
4317 + $popup_survey_view = "<div class='ays-survey-popup-survey-window ays-survey-popup-modal-".$popup['id']." ".$display_popup_on_load." ".$popup_animation_class."' data-id='".$popup['id']."' data-close-popup='".$survey_enable_popup_close_after_finish."'>
4231 4318 <div class='ays-survey-popup-btn-close'>
4232 4319 <img class='ays-survey-popup-btn-close-icon' src='". SURVEY_MAKER_PUBLIC_URL ."/images/cross.svg'>
4233 4320 </div>";
4234 4321 $popup_survey_view .= "<div class='ays-survey-popup-content'>";
@@ -4356,13 +4443,17 @@
4356 4443 }
4357 4444
4358 4445 $hide_popup_on_mobile_class = $survey_popup_hide_title_on_mobile ? 'display: none;' : '';
4359 4446
4447 + $popup_width_css = ($popup_survey_width > 0 ? $popup_survey_width . ($popup_survey_width_by == 'percentage' ? '%' : 'px') : '100%');
4448 + $popup_height_css = ($popup_survey_height > 0 ? $popup_survey_height . ($popup_survey_height_by == 'percentage' ? '%' : 'px') : '100%');
4449 +
4360 4450 $popup_survey_view .= '
4361 4451 <style>
4362 4452 .ays-survey-popup-modal-' . $popup['id'] . ' {
4363 - width: ' . $popup_survey_width . 'px;
4364 - height: ' . $popup_survey_height . 'px;
4453 + width: ' . $popup_width_css . ';
4454 + box-sizing: border-box;
4455 + height: ' . $popup_height_css . ';
4365 4456 background-color: ' . $popup_bg_color . ';
4366 4457 top: ' . $ays_survey_popup_conteiner_pos_top . ';
4367 4458 left: ' . $ays_survey_popup_conteiner_pos_left . ';
4368 4459 right: ' . $ays_survey_popup_conteiner_pos_right . ';
@@ -4385,10 +4476,11 @@
4385 4476 }
4386 4477
4387 4478 @media screen and (max-width: 640px){
4388 4479 div.ays-survey-popup-modal-' . $popup['id'] . ' {
4389 - width: ' . $popup_survey_width_mobile . 'px;
4390 - height: ' . $popup_survey_height_mobile . 'px;
4480 + width: ' . ($popup_survey_width_mobile > 0 ? $popup_survey_width_mobile . ($popup_survey_width_mobile_by == 'percentage' ? '%' : 'px') : '100%') . ';
4481 + max-width: calc(100vw - 20px);
4482 + height: ' . ($popup_survey_height_mobile > 0 ? $popup_survey_height_mobile . ($popup_survey_height_mobile_by == 'percentage' ? '%' : 'px') : '100%') . ';
4391 4483 background-color: ' . $popup_bg_color_mobile . ';
4392 4484 }
4393 4485 .ays-survey-popup-modal-' . $popup['id'] . ' .ays-survey-popup-title-content{
4394 4486 font-size: '.$survey_popup_title_mobile_font_size.'px;
@@ -4404,8 +4496,50 @@
4404 4496
4405 4497 </style>
4406 4498 ';
4407 4499
4500 + $popup_survey_view .= '<style type="text/css">';
4501 + $popup_survey_view .= "
4502 + @keyframes ays-popup-fade-in {
4503 + from { opacity: 0; }
4504 + to { opacity: 1; }
4505 + }
4506 + @keyframes ays-popup-slide-down {
4507 + from { opacity: 0; transform: translateY(-50px); }
4508 + to { opacity: 1; transform: translateY(0); }
4509 + }
4510 + @keyframes ays-popup-slide-up {
4511 + from { opacity: 0; transform: translateY(50px); }
4512 + to { opacity: 1; transform: translateY(0); }
4513 + }
4514 + @keyframes ays-popup-zoom-in {
4515 + from { opacity: 0; transform: scale(0.8); }
4516 + to { opacity: 1; transform: scale(1); }
4517 + }
4518 + @keyframes ays-popup-bounce {
4519 + 0% { opacity: 0; transform: scale(0.3); }
4520 + 50% { opacity: 1; transform: scale(1.05); }
4521 + 70% { transform: scale(0.9); }
4522 + 100% { transform: scale(1); }
4523 + }
4524 + .ays-survey-popup-survey-window.ays-popup-animation-fade {
4525 + animation: ays-popup-fade-in 0.3s ease-in-out;
4526 + }
4527 + .ays-survey-popup-survey-window.ays-popup-animation-slide-down {
4528 + animation: ays-popup-slide-down 0.4s ease-out;
4529 + }
4530 + .ays-survey-popup-survey-window.ays-popup-animation-slide-up {
4531 + animation: ays-popup-slide-up 0.4s ease-out;
4532 + }
4533 + .ays-survey-popup-survey-window.ays-popup-animation-zoom-in {
4534 + animation: ays-popup-zoom-in 0.3s ease-out;
4535 + }
4536 + .ays-survey-popup-survey-window.ays-popup-animation-bounce {
4537 + animation: ays-popup-bounce 0.5s ease-out;
4538 + }
4539 + ";
4540 + $popup_survey_view .= '</style>';
4541 +
4408 4542 $popup_survey_view .= '<script type="text/javascript">';
4409 4543
4410 4544 $popup_survey_view .= "
4411 4545 if(typeof aysSurveyPopupsOptions === 'undefined'){
@@ -4419,8 +4553,9 @@
4419 4553 'popup_close_after_finish_delay' => $survey_popup_close_after_finish_delay,
4420 4554 'popup_selector' => $popup_selector,
4421 4555 'popupEnableCloseByEsc' => $survey_popup_enable_close_by_esc,
4422 4556 'closePopupOverlayOutsideClick' => $close_popup_overlay_outside_click,
4557 + 'popup_animation' => $popup_animation,
4423 4558
4424 4559 ) ) ) . "';";
4425 4560 $popup_survey_view .= '</script>';
4426 4561 $popup_survey_view .= '</div>';