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 +61 -51 6.4.6 → 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 ){
@@ -1304,8 +1294,11 @@
1304 1294
1305 1295 // Poll title alignment mobile
1306 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;
1307 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 +
1308 1301 // ===== Poll text type options start =====
1309 1302 $poll_view_type_text = isset($poll['view_type']) && $poll['view_type'] != "" ? $poll['view_type'] : "short_text";
1310 1303
1311 1304 $poll_text_type_length_enable = (isset($options['poll_text_type_length_enable']) && $options['poll_text_type_length_enable'] == "on") ? true : false;
@@ -1680,8 +1673,9 @@
1680 1673 font-weight: ".$poll_title_font_weight.";
1681 1674 word-break: break-word;
1682 1675 word-wrap: break-word;
1683 1676 text-align: ".$poll_title_alignment.";
1677 + text-transform: ".$poll_title_text_transform.";
1684 1678 }
1685 1679
1686 1680 #".$this_poll_id.".box-apm .ays-poll-answer-container-list{
1687 1681 margin-bottom: ".$poll_answer_margin."px;
@@ -1938,8 +1932,9 @@
1938 1932 #".$this_poll_id.".box-apm .apm-title-box div{
1939 1933 font-size: ".$poll_title_font_size_mobile."px;
1940 1934 font-weight: ".$poll_title_font_weight_mobile.";
1941 1935 text-align: ".$poll_title_alignment_mobile.";
1936 + text-transform: ".$poll_title_text_transform.";
1942 1937 word-break: break-word;
1943 1938 word-wrap: break-word;
1944 1939 }
1945 1940
@@ -2472,19 +2467,10 @@
2472 2467
2473 2468 $poll_answer_percentages = array();
2474 2469 $poll_answer_votes = array();
2475 2470 foreach ( $poll['answers'] as $index => $answer ) {
2476 - // if($fake_votes){
2477 - // if(intval( $answer['votes'] ) + intval( $answer['fake_votes'] ) < 0){
2478 - // $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2479 - // }
2480 - // else{
2481 - // $poll_answer_votes[$answer['id']] = intval( $answer['votes'] ) + intval( $answer['fake_votes'] );
2482 - // }
2483 - // }
2484 - // else{
2485 - $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2486 - // }
2471 +
2472 + $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2487 2473 }
2488 2474
2489 2475 $poll_answer_votes_sum = array_sum( $poll_answer_votes );
2490 2476 $poll_answer_percentages = array();
@@ -2493,13 +2479,10 @@
2493 2479 $poll_answer_percentages[$index] = round( ( $answer_vote_count * 100 ) / $poll_answer_votes_sum, 1);
2494 2480 }else{
2495 2481 $poll_answer_percentages[$index] = 0;
2496 2482 }
2497 - }
2483 + }
2498 2484
2499 - // $show_votes_count = isset($options['show_votes_count']) && $options['show_votes_count'] == 1 ? true : false;
2500 - // $show_answer_percent = isset($options['show_res_percent']) && $options['show_res_percent'] == 1 ? true : false;
2501 -
2502 2485 if($poll_allow_multivote){
2503 2486 $content .= "<input type='hidden' id='multivot_answer_count' value='".$multivote_answer_count."'/>";
2504 2487 $content .= $poll_multivote_min_count_content;
2505 2488 }
@@ -2575,29 +2558,14 @@
2575 2558 $answer_votes_count_before_voting = "";
2576 2559 switch ( $show_votes_before_voting_by ) {
2577 2560 case 'by_percentage':
2578 2561 $answer_votes_count_before_voting = $poll_answer_percentages[$answer['id']] . "%";
2579 - // if( $show_votes_count ){
2580 - // $answer_votes_count_before_voting .= " (". intval( $answer['votes'] ) .")";
2581 - // }
2582 2562 break;
2583 2563 default:
2584 2564 $real_votes = isset($answer['votes']) && $answer['votes'] != "" ? intval( $answer['votes'] ) : 0;
2585 - // $fake_votes_all = isset($answer['fake_votes']) && $answer['fake_votes'] != "0" ? intval( $answer['fake_votes'] ) : 0;
2586 - // if($fake_votes){
2587 - // if($real_votes + $fake_votes_all < 0){
2588 - // $answer_votes_count_before_voting = $real_votes;
2589 - // }
2590 - // else{
2591 - // $answer_votes_count_before_voting = $real_votes + $fake_votes_all;
2592 - // }
2593 - // }
2594 - // else{
2595 - $answer_votes_count_before_voting = $real_votes;
2596 - // }
2597 - // if( $show_answer_percent ){
2598 - // $answer_votes_count_before_voting .= " (". $poll_answer_percentages[$answer['id']] . "%" .")";
2599 - // }
2565 +
2566 + $answer_votes_count_before_voting = $real_votes;
2567 +
2600 2568 break;
2601 2569 }
2602 2570
2603 2571 $content .= "
@@ -3066,9 +3034,11 @@
3066 3034 return $poll;
3067 3035 }
3068 3036
3069 3037 private static function get_user_ip() {
3070 - $ipaddress = '';
3038 +
3039 + $ipaddress = false;
3040 +
3071 3041 if (getenv('HTTP_CLIENT_IP')) {
3072 3042 $ipaddress = getenv('HTTP_CLIENT_IP');
3073 3043 } else if (getenv('HTTP_X_FORWARDED_FOR')) {
3074 3044 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
@@ -3077,15 +3047,20 @@
3077 3047 } else if (getenv('HTTP_FORWARDED_FOR')) {
3078 3048 $ipaddress = getenv('HTTP_FORWARDED_FOR');
3079 3049 } else if (getenv('HTTP_FORWARDED')) {
3080 3050 $ipaddress = getenv('HTTP_FORWARDED');
3081 - } else if (getenv('REMOTE_ADDR')) {
3082 - $ipaddress = getenv('REMOTE_ADDR');
3083 - } else {
3084 - $ipaddress = 'UNKNOWN';
3085 3051 }
3086 3052
3087 - 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';
3088 3063 }
3089 3064
3090 3065 public static function get_user_ip_validated(){
3091 3066 $headers_to_check = array(
@@ -3169,8 +3144,28 @@
3169 3144
3170 3145 return $result;
3171 3146 }
3172 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 +
3173 3168 public function get_poll_status($id) {
3174 3169 global $wpdb;
3175 3170 $poll_id = absint(intval($id));
3176 3171 $poll_table = $wpdb->prefix . 'ayspoll_polls';
@@ -3279,8 +3274,22 @@
3279 3274 $poll_answers_count = isset($poll['answers']) ? count($poll['answers']) : 0;
3280 3275 $added_answer_id = array();
3281 3276
3282 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 +
3283 3292 $poll_vote_reason_text = "";
3284 3293 $poll_vote_reason = false;
3285 3294 $show_answers_numbering = (isset($options['show_answers_numbering']) && sanitize_text_field( $options['show_answers_numbering'] ) != '') ? sanitize_text_field( $options['show_answers_numbering'] ) : 'none';
3286 3295 if (isset($options['poll_vote_reason']) && $options['poll_vote_reason'] == "on" && isset($_POST['ays-poll-reason-text'])) {
@@ -3637,8 +3646,9 @@
3637 3646 'user_name' => $form_apm_name,
3638 3647 'user_email' => $form_apm_email,
3639 3648 'user_phone' => $form_apm_phone,
3640 3649 'poll_title' => $poll_title,
3650 + 'poll_category_title' => $poll_category_title,
3641 3651 'poll_id' => $poll_id,
3642 3652 'users_first_name' => $user_first_name,
3643 3653 'users_last_name' => $user_last_name,
3644 3654 'creation_date' => $creation_date,