PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.5.1
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.5.1
6.5.1 6.5.0 6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 All 154 releases
← All changes | public/class-poll-maker-ays-public.php +114 -93 6.4.3 → 6.5.1 View file →
@@ -206,13 +206,9 @@
206 206 }
207 207
208 208 public function show_chart_js() {
209 209 wp_enqueue_script( $this->plugin_name . '-charts-google', plugin_dir_url(__FILE__) . 'js/google-chart.js', array('jquery'), $this->version, true);
210 - }
211 - // public function show_column_chart_js() {
212 - // // wp_enqueue_script( $this->plugin_name . '-column-chart', 'https://www.gstatic.com/charts/loader.js', array('jquery'), $this->version, true);
213 - // wp_enqueue_script( $this->plugin_name . '-column-chart', plugin_dir_url(__FILE__) . 'js/poll-maker-chart-loader.js', array('jquery'), $this->version, true);
214 - // }
210 + }
215 211
216 212 // Categories shortcode
217 213 public function ays_poll_generate_categories_method($attr) {
218 214 ob_start();
@@ -370,9 +366,8 @@
370 366
371 367 $chart_style = false;
372 368 if (isset( $result_option_res['show_result_view']) && ( $result_option_res['show_result_view'] == 'pie_chart' || $result_option_res['show_result_view'] == 'column_chart' )) {
373 369 $this->show_chart_js();
374 - // $this->show_column_chart_js();
375 370 $chart_style = true;
376 371 }
377 372
378 373 if ($polls == null) {
@@ -919,14 +914,9 @@
919 914 );
920 915
921 916 $bg_color = $options['bg_color'];
922 917 $bg_image = isset($options['bg_image']) && $options['bg_image'] != '' ? esc_url($options['bg_image']): '';
923 - // if ($bg_image != '') {
924 - // if ( !(filter_var($bg_image, FILTER_VALIDATE_URL) && wp_http_validate_url($bg_image)) ) {
925 - // // invalid URL, handle accordingly
926 - // $bg_image = '';
927 - // }
928 - // }
918 +
929 919 if( $bg_image != "" ){
930 920 $check_if_current_image_exists = Poll_Maker_Ays_Admin::ays_poll_check_if_current_image_exists($bg_image);
931 921
932 922 if( !$check_if_current_image_exists ){
@@ -1292,8 +1282,14 @@
1292 1282
1293 1283 // Poll title font size mobile
1294 1284 $poll_title_font_size_mobile = (isset($options['poll_title_font_size_mobile']) && $options['poll_title_font_size_mobile'] != "") ? absint(intval(esc_attr($options['poll_title_font_size_mobile']))) : "20";
1295 1285
1286 + // Poll title font weight
1287 + $poll_title_font_weight = (isset($options['poll_title_font_weight']) && $options['poll_title_font_weight'] != "") ? esc_attr($options['poll_title_font_weight']) : "normal";
1288 +
1289 + // Poll title font weight mobile
1290 + $poll_title_font_weight_mobile = (isset($options['poll_title_font_weight_mobile']) && $options['poll_title_font_weight_mobile'] != "") ? esc_attr($options['poll_title_font_weight_mobile']) : $poll_title_font_weight;
1291 +
1296 1292 // Poll title alignment
1297 1293 $poll_title_alignment = ( isset($options['poll_title_alignment']) && $options['poll_title_alignment'] != "" ) ? esc_attr($options['poll_title_alignment']) : "center";
1298 1294
1299 1295 // Poll title alignment mobile
@@ -1298,8 +1294,11 @@
1298 1294
1299 1295 // Poll title alignment mobile
1300 1296 $poll_title_alignment_mobile = ( isset($options['poll_title_alignment_mobile']) && $options['poll_title_alignment_mobile'] != "" ) ? esc_attr($options['poll_title_alignment_mobile']) : $poll_title_alignment;
1301 1297
1298 + // Poll title text transform
1299 + $poll_title_text_transform = ( isset($options['poll_title_text_transform']) && $options['poll_title_text_transform'] != "" ) ? esc_attr($options['poll_title_text_transform']) : "none";
1300 +
1302 1301 // ===== Poll text type options start =====
1303 1302 $poll_view_type_text = isset($poll['view_type']) && $poll['view_type'] != "" ? $poll['view_type'] : "short_text";
1304 1303
1305 1304 $poll_text_type_length_enable = (isset($options['poll_text_type_length_enable']) && $options['poll_text_type_length_enable'] == "on") ? true : false;
@@ -1670,11 +1669,13 @@
1670 1669 }
1671 1670
1672 1671 #".$this_poll_id.".box-apm .apm-title-box div{
1673 1672 font-size: ".$poll_title_font_size."px;
1673 + font-weight: ".$poll_title_font_weight.";
1674 1674 word-break: break-word;
1675 1675 word-wrap: break-word;
1676 1676 text-align: ".$poll_title_alignment.";
1677 + text-transform: ".$poll_title_text_transform.";
1677 1678 }
1678 1679
1679 1680 #".$this_poll_id.".box-apm .ays-poll-answer-container-list{
1680 1681 margin-bottom: ".$poll_answer_margin."px;
@@ -1929,9 +1930,11 @@
1929 1930
1930 1931 $content .= "
1931 1932 #".$this_poll_id.".box-apm .apm-title-box div{
1932 1933 font-size: ".$poll_title_font_size_mobile."px;
1934 + font-weight: ".$poll_title_font_weight_mobile.";
1933 1935 text-align: ".$poll_title_alignment_mobile.";
1936 + text-transform: ".$poll_title_text_transform.";
1934 1937 word-break: break-word;
1935 1938 word-wrap: break-word;
1936 1939 }
1937 1940
@@ -2464,19 +2467,10 @@
2464 2467
2465 2468 $poll_answer_percentages = array();
2466 2469 $poll_answer_votes = array();
2467 2470 foreach ( $poll['answers'] as $index => $answer ) {
2468 - // if($fake_votes){
2469 - // if(intval( $answer['votes'] ) + intval( $answer['fake_votes'] ) < 0){
2470 - // $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2471 - // }
2472 - // else{
2473 - // $poll_answer_votes[$answer['id']] = intval( $answer['votes'] ) + intval( $answer['fake_votes'] );
2474 - // }
2475 - // }
2476 - // else{
2477 - $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2478 - // }
2471 +
2472 + $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2479 2473 }
2480 2474
2481 2475 $poll_answer_votes_sum = array_sum( $poll_answer_votes );
2482 2476 $poll_answer_percentages = array();
@@ -2485,13 +2479,10 @@
2485 2479 $poll_answer_percentages[$index] = round( ( $answer_vote_count * 100 ) / $poll_answer_votes_sum, 1);
2486 2480 }else{
2487 2481 $poll_answer_percentages[$index] = 0;
2488 2482 }
2489 - }
2483 + }
2490 2484
2491 - // $show_votes_count = isset($options['show_votes_count']) && $options['show_votes_count'] == 1 ? true : false;
2492 - // $show_answer_percent = isset($options['show_res_percent']) && $options['show_res_percent'] == 1 ? true : false;
2493 -
2494 2485 if($poll_allow_multivote){
2495 2486 $content .= "<input type='hidden' id='multivot_answer_count' value='".$multivote_answer_count."'/>";
2496 2487 $content .= $poll_multivote_min_count_content;
2497 2488 }
@@ -2567,29 +2558,14 @@
2567 2558 $answer_votes_count_before_voting = "";
2568 2559 switch ( $show_votes_before_voting_by ) {
2569 2560 case 'by_percentage':
2570 2561 $answer_votes_count_before_voting = $poll_answer_percentages[$answer['id']] . "%";
2571 - // if( $show_votes_count ){
2572 - // $answer_votes_count_before_voting .= " (". intval( $answer['votes'] ) .")";
2573 - // }
2574 2562 break;
2575 2563 default:
2576 2564 $real_votes = isset($answer['votes']) && $answer['votes'] != "" ? intval( $answer['votes'] ) : 0;
2577 - // $fake_votes_all = isset($answer['fake_votes']) && $answer['fake_votes'] != "0" ? intval( $answer['fake_votes'] ) : 0;
2578 - // if($fake_votes){
2579 - // if($real_votes + $fake_votes_all < 0){
2580 - // $answer_votes_count_before_voting = $real_votes;
2581 - // }
2582 - // else{
2583 - // $answer_votes_count_before_voting = $real_votes + $fake_votes_all;
2584 - // }
2585 - // }
2586 - // else{
2587 - $answer_votes_count_before_voting = $real_votes;
2588 - // }
2589 - // if( $show_answer_percent ){
2590 - // $answer_votes_count_before_voting .= " (". $poll_answer_percentages[$answer['id']] . "%" .")";
2591 - // }
2565 +
2566 + $answer_votes_count_before_voting = $real_votes;
2567 +
2592 2568 break;
2593 2569 }
2594 2570
2595 2571 $content .= "
@@ -3058,9 +3034,11 @@
3058 3034 return $poll;
3059 3035 }
3060 3036
3061 3037 private static function get_user_ip() {
3062 - $ipaddress = '';
3038 +
3039 + $ipaddress = false;
3040 +
3063 3041 if (getenv('HTTP_CLIENT_IP')) {
3064 3042 $ipaddress = getenv('HTTP_CLIENT_IP');
3065 3043 } else if (getenv('HTTP_X_FORWARDED_FOR')) {
3066 3044 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
@@ -3069,15 +3047,20 @@
3069 3047 } else if (getenv('HTTP_FORWARDED_FOR')) {
3070 3048 $ipaddress = getenv('HTTP_FORWARDED_FOR');
3071 3049 } else if (getenv('HTTP_FORWARDED')) {
3072 3050 $ipaddress = getenv('HTTP_FORWARDED');
3073 - } else if (getenv('REMOTE_ADDR')) {
3074 - $ipaddress = getenv('REMOTE_ADDR');
3075 - } else {
3076 - $ipaddress = 'UNKNOWN';
3077 3051 }
3078 3052
3079 - return $ipaddress;
3053 + if ( $ipaddress !== false && filter_var( $ipaddress, FILTER_VALIDATE_IP ) !== false ) {
3054 + return $ipaddress;
3055 + }
3056 +
3057 + $remote_address = getenv('REMOTE_ADDR');
3058 + if ( $remote_address !== false && filter_var( $remote_address, FILTER_VALIDATE_IP ) !== false ) {
3059 + return $remote_address;
3060 + }
3061 +
3062 + return 'UNKNOWN';
3080 3063 }
3081 3064
3082 3065 public static function get_user_ip_validated(){
3083 3066 $headers_to_check = array(
@@ -3161,8 +3144,28 @@
3161 3144
3162 3145 return $result;
3163 3146 }
3164 3147
3148 + public static function get_poll_category_by_ids($ids){
3149 + global $wpdb;
3150 +
3151 + $ids = array_map('intval', explode(',', $ids));
3152 + $ids = array_filter($ids);
3153 +
3154 + if (empty($ids)) {
3155 + return [];
3156 + }
3157 +
3158 + $ids_sql = implode(',', $ids);
3159 +
3160 + $sql = "SELECT *
3161 + FROM {$wpdb->prefix}ayspoll_categories
3162 + WHERE id IN ($ids_sql)
3163 + ORDER BY FIELD(id, $ids_sql)";
3164 +
3165 + return $wpdb->get_results($sql, ARRAY_A);
3166 + }
3167 +
3165 3168 public function get_poll_status($id) {
3166 3169 global $wpdb;
3167 3170 $poll_id = absint(intval($id));
3168 3171 $poll_table = $wpdb->prefix . 'ayspoll_polls';
@@ -3271,8 +3274,22 @@
3271 3274 $poll_answers_count = isset($poll['answers']) ? count($poll['answers']) : 0;
3272 3275 $added_answer_id = array();
3273 3276
3274 3277 $poll_title = (isset($poll['title']) && $poll['title'] != '') ? stripslashes( sanitize_text_field( $poll['title'] ) ) : '';
3278 +
3279 + // Poll category title
3280 + $poll_category_title = "";
3281 +
3282 + $poll_cats = isset( $poll['categories'] ) ? trim( $poll['categories'], ',' ) : '';
3283 + $poll_category_ids = $poll_cats !== '' ? sanitize_text_field( $poll_cats ) : '';
3284 +
3285 + if ( $poll_category_ids != '' ) {
3286 + $categories = self::get_poll_category_by_ids( $poll_category_ids );
3287 + $category_names = wp_list_pluck( $categories, 'title' );
3288 +
3289 + $poll_category_title = implode( ', ', $category_names );
3290 + }
3291 +
3275 3292 $poll_vote_reason_text = "";
3276 3293 $poll_vote_reason = false;
3277 3294 $show_answers_numbering = (isset($options['show_answers_numbering']) && sanitize_text_field( $options['show_answers_numbering'] ) != '') ? sanitize_text_field( $options['show_answers_numbering'] ) : 'none';
3278 3295 if (isset($options['poll_vote_reason']) && $options['poll_vote_reason'] == "on" && isset($_POST['ays-poll-reason-text'])) {
@@ -3484,8 +3501,9 @@
3484 3501 $current_poll_author_email = '';
3485 3502 $current_poll_author_nickname = '';
3486 3503 $current_poll_author_display_name = '';
3487 3504 $current_poll_author_website_url = '';
3505 + $current_poll_author_registered = '';
3488 3506 if( !empty($options['author']) ){
3489 3507 if( !is_array($options['author']) ){
3490 3508 $options['author'] = json_decode($options['author'], true);
3491 3509 }
@@ -3498,8 +3516,9 @@
3498 3516 $current_poll_author_email = ( isset( $current_poll_user_data->data->user_email ) && $current_poll_user_data->data->user_email != '' ) ? sanitize_text_field( $current_poll_user_data->data->user_email ) : "";
3499 3517 $current_poll_author_nickname = ( isset( $current_poll_user_data->data->user_nicename ) && $current_poll_user_data->data->user_nicename != '' ) ? sanitize_text_field( $current_poll_user_data->data->user_nicename ) : "";
3500 3518 $current_poll_author_display_name = ( isset( $current_poll_user_data->data->display_name ) && $current_poll_user_data->data->display_name != '' ) ? sanitize_text_field( $current_poll_user_data->data->display_name ) : "";
3501 3519 $current_poll_author_website_url = ( isset( $current_poll_user_data->data->user_url ) && $current_poll_user_data->data->user_url != '' ) ? sanitize_text_field( $current_poll_user_data->data->user_url ) : "";
3520 + $current_poll_author_registered = ( isset( $current_poll_user_data->data->user_registered ) && $current_poll_user_data->data->user_registered != '' ) ? sanitize_text_field( $current_poll_user_data->data->user_registered ) : "";
3502 3521 }
3503 3522 }
3504 3523
3505 3524 // Get Current date
@@ -3623,50 +3642,52 @@
3623 3642 $form_apm_email = (isset($_POST['apm_email']) && $_POST['apm_email'] != "") ? esc_attr($_POST['apm_email']) : "";
3624 3643 $form_apm_phone = (isset($_POST['apm_phone']) && $_POST['apm_phone'] != "") ? esc_attr($_POST['apm_phone']) : "";
3625 3644
3626 3645 $message_data = array(
3627 - 'user_name' => $form_apm_name,
3628 - 'user_email' => $form_apm_email,
3629 - 'user_phone' => $form_apm_phone,
3630 - 'poll_title' => $poll_title,
3631 - 'poll_id' => $poll_id,
3632 - 'users_first_name' => $user_first_name,
3633 - 'users_last_name' => $user_last_name,
3634 - 'creation_date' => $creation_date,
3635 - 'current_date' => $poll_current_date,
3636 - 'current_time' => $poll_current_time,
3637 - 'current_day' => $poll_current_day,
3638 - 'current_month' => $poll_current_month,
3639 - 'current_poll_page_link' => $current_poll_page_link_html,
3640 - 'current_poll_author' => $current_poll_author,
3641 - 'current_poll_author_email' => $current_poll_author_email,
3642 - 'current_poll_author_nickname' => $current_poll_author_nickname,
3643 - 'current_poll_author_display_name' => $current_poll_author_display_name,
3644 - 'current_poll_author_website_url' => $current_poll_author_website_url,
3645 - 'admin_email' => $super_admin_email,
3646 - 'user_nickname' => $user_nickname,
3647 - 'user_first_name' => $user_first_name,
3648 - 'user_display_name' => $user_display_name,
3649 - 'user_wordpress_email' => $user_wordpress_email,
3650 - 'user_wordpress_roles' => $user_wordpress_roles,
3651 - 'poll_pass_count' => $pass_count,
3652 - 'passed_poll_count_per_user' => $passed_poll_count_per_user,
3653 - 'user_wordpress_website' => $user_wordpress_website,
3654 - 'user_ip_address' => $user_ip_address,
3655 - 'user_id' => $current_user_id,
3656 - 'user_registered' => $user_registered,
3657 - 'post_title' => $post_title,
3658 - 'post_author_email' => $post_author_email,
3659 - 'post_author_display_name' => $post_author_display_name,
3660 - 'post_author_nickname' => $post_author_nickname,
3661 - 'post_author_first_name' => $post_author_first_name,
3662 - 'post_author_last_name' => $post_author_last_name,
3663 - 'post_author_website_url' => $post_author_website_url,
3664 - 'post_author_roles' => $post_author_roles,
3665 - 'post_id' => $post_id,
3666 - 'site_title' => $get_site_title,
3667 - 'site_description' => $get_site_description,
3668 - 'home_page_url' => $home_page_url,
3646 + 'user_name' => $form_apm_name,
3647 + 'user_email' => $form_apm_email,
3648 + 'user_phone' => $form_apm_phone,
3649 + 'poll_title' => $poll_title,
3650 + 'poll_category_title' => $poll_category_title,
3651 + 'poll_id' => $poll_id,
3652 + 'users_first_name' => $user_first_name,
3653 + 'users_last_name' => $user_last_name,
3654 + 'creation_date' => $creation_date,
3655 + 'current_date' => $poll_current_date,
3656 + 'current_time' => $poll_current_time,
3657 + 'current_day' => $poll_current_day,
3658 + 'current_month' => $poll_current_month,
3659 + 'current_poll_page_link' => $current_poll_page_link_html,
3660 + 'current_poll_author' => $current_poll_author,
3661 + 'current_poll_author_email' => $current_poll_author_email,
3662 + 'current_poll_author_nickname' => $current_poll_author_nickname,
3663 + 'current_poll_author_display_name' => $current_poll_author_display_name,
3664 + 'current_poll_author_website_url' => $current_poll_author_website_url,
3665 + 'current_poll_author_registered' => $current_poll_author_registered,
3666 + 'admin_email' => $super_admin_email,
3667 + 'user_nickname' => $user_nickname,
3668 + 'user_first_name' => $user_first_name,
3669 + 'user_display_name' => $user_display_name,
3670 + 'user_wordpress_email' => $user_wordpress_email,
3671 + 'user_wordpress_roles' => $user_wordpress_roles,
3672 + 'poll_pass_count' => $pass_count,
3673 + 'passed_poll_count_per_user' => $passed_poll_count_per_user,
3674 + 'user_wordpress_website' => $user_wordpress_website,
3675 + 'user_ip_address' => $user_ip_address,
3676 + 'user_id' => $current_user_id,
3677 + 'user_registered' => $user_registered,
3678 + 'post_title' => $post_title,
3679 + 'post_author_email' => $post_author_email,
3680 + 'post_author_display_name' => $post_author_display_name,
3681 + 'post_author_nickname' => $post_author_nickname,
3682 + 'post_author_first_name' => $post_author_first_name,
3683 + 'post_author_last_name' => $post_author_last_name,
3684 + 'post_author_website_url' => $post_author_website_url,
3685 + 'post_author_roles' => $post_author_roles,
3686 + 'post_id' => $post_id,
3687 + 'site_title' => $get_site_title,
3688 + 'site_description' => $get_site_description,
3689 + 'home_page_url' => $home_page_url,
3669 3690 );
3670 3691
3671 3692 $user_ip = esc_sql($user_ips);
3672 3693