| @@ -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'])) { |
| @@ -3629,8 +3646,9 @@ | ||
| 3629 | 3646 | 'user_name' => $form_apm_name, |
| 3630 | 3647 | 'user_email' => $form_apm_email, |
| 3631 | 3648 | 'user_phone' => $form_apm_phone, |
| 3632 | 3649 | 'poll_title' => $poll_title, |
| 3650 | + 'poll_category_title' => $poll_category_title, | |
| 3633 | 3651 | 'poll_id' => $poll_id, |
| 3634 | 3652 | 'users_first_name' => $user_first_name, |
| 3635 | 3653 | 'users_last_name' => $user_last_name, |
| 3636 | 3654 | 'creation_date' => $creation_date, |