Changeset 1007332
- Timestamp:
- 10/14/2014 02:47:12 PM (11 years ago)
- Location:
- because/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (1 diff)
-
public/assets/css/public.css (modified) (2 diffs)
-
public/assets/js/public.js (modified) (1 diff)
-
public/class-social-polling.php (modified) (4 diffs)
-
public/includes/class-sp_comments.php (modified) (3 diffs)
-
social-polling.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
because/trunk/README.txt
r1000853 r1007332 7 7 Tested up to: 4.0 8 8 <<<<<<< .mine 9 Stable tag: 1.3. 79 Stable tag: 1.3.8 10 10 ======= 11 Stable tag: 1.3. 711 Stable tag: 1.3.8 12 12 >>>>>>> .r969865 13 13 License: GPLv2 or later -
because/trunk/public/assets/css/public.css
r1000853 r1007332 27 27 28 28 } 29 .answer_divs:focus .answer_image, 30 .answer_divs:HOVER .answer_image{ 31 border:5px solid #1e8cbe; 32 33 34 29 #answer_1_wrapper.answer_divs:focus .answer_image, 30 #answer_1_wrapper.answer_divs:HOVER .answer_image{ 31 border:5px solid #1e8cbe; 32 } 33 34 #answer_2_wrapper.answer_divs:focus .answer_image, 35 #answer_2_wrapper.answer_divs:HOVER .answer_image{ 36 border:5px solid #1ebe50; 35 37 } 36 38 … … 426 428 padding: 1em; 427 429 } 430 431 .comment_voted_a{ 432 color: #1e8cbe; 433 } 434 435 .comment_voted_b{ 436 color: #1ebe50; 437 } 428 438 /* 429 439 //---------------------------- -
because/trunk/public/assets/js/public.js
r999351 r1007332 51 51 show_results($post_id); 52 52 53 54 if(data === "You already voted"){ 55 $('#social_polling_see_results_wrapper').html('You Already Voted'); 56 } 57 else{ 58 $('#social_polling_see_results_wrapper').html(''); 59 } 60 61 62 63 53 if(data === "already_voted"){ 54 $('#social_polling_see_results_wrapper').html('You Already Voted'); 55 } 56 else{ 57 $('#social_polling_see_results_wrapper').html(''); 58 $('.sp_comment-list').html(data); 59 } 64 60 65 61 //console.log(data+ajaxurl); 66 67 68 62 69 63 }//success -
because/trunk/public/class-social-polling.php
r999334 r1007332 306 306 if($already_voted): 307 307 //You already voted 308 return 'already_voted'; 308 $response['vote_status'] = 'already_voted'; 309 return $response; 309 310 else: 310 311 //Do the vote … … 313 314 314 315 if($do_vote): 315 return 'voted'; 316 $response['vote_status'] = 'voted'; 317 //modify comments to display 318 $this->add_id_to_comments($data); 319 $response['new_comments'] = $this->update_comments($data); 316 320 else: 317 321 return false; … … 319 323 }//social_polling_vote 320 324 321 325 private function add_id_to_comments($data){ 326 global $wpdb; 327 328 $table = $wpdb->prefix . "postmeta"; 329 $query = "SELECT meta_key FROM $table WHERE post_id='" . $data['poll_id'] . "' AND meta_value='" . $data['vote_value']. "'"; 330 $ans_choice = $wpdb->get_row($query); 331 332 if ($ans_choice->meta_key == "social_polling_answer_one_field" || $ans_choice->meta_key == "_social_polling_answer_one_field"){ 333 $choice = "one"; 334 } 335 else if ($ans_choice->meta_key == "social_polling_answer_two_field" || $ans_choice->meta_key == "_social_polling_answer_two_field"){ 336 $choice = "two"; 337 } 338 339 $table = $wpdb->prefix . "comments"; 340 $comments = $wpdb->get_results("SELECT comment_ID from $table where comment_post_ID='" . $data['poll_id'] . "' AND (comment_author_IP = '".$data['voter_ip']."' || (user_id = '".$data['voter_id']."' && user_id != '0' ))" ); 341 342 foreach($comments as $row){ 343 add_comment_meta($row->comment_ID,'vote_choice',$choice); 344 } 345 346 return; 347 } 348 349 private function update_comments($data){ 350 351 352 $post_id = $data['poll_id']; 353 354 $comment_args['post_id'] = $post_id; 355 356 $comments = get_comments( $comment_args ); 357 358 ob_start(); 359 360 wp_list_comments(array( 361 362 'callback' => 'mytheme_comment', 363 364 'walker' => new zipGun_walker_comment() 365 366 //'per_page' => 10, //Allow comment pagination 367 368 //'reverse_top_level' => $sortby == 'oldest' ? false : true //Show the latest comments at the top of the list 369 370 ), $comments); 371 372 $updated_comments = ob_get_contents(); 373 374 ob_end_clean; 375 376 } 322 377 323 378 public function get_poll_results($post_id){ … … 482 537 endif; 483 538 484 switch($vote ):539 switch($vote[vote_status]): 485 540 case('voted'): 486 echo 'You were voting on Post '.get_post_meta($post_id,'social_polling_question_field',true ); 487 echo 'You voted '.$vote_value; 541 // echo 'You were voting on Post '.get_post_meta($post_id,'social_polling_question_field',true ); 542 // echo 'You voted '.$vote_value; 543 echo $vote['new_comments']; 488 544 break; 489 545 490 546 case('already_voted'): 491 echo 'You already voted';547 echo "already_voted"; 492 548 break; 493 549 -
because/trunk/public/includes/class-sp_comments.php
r966514 r1007332 81 81 add_action('wp_ajax_sp_Comments_Ajax', array( $this,'sp_Comments_Ajax')); 82 82 83 83 add_action('comment_post', array( $this,'check_user_vote')); 84 84 85 85 … … 153 153 }//Contruct 154 154 155 155 // function to check if user has voted in the Polling 156 157 public function check_user_vote($comment_id){ 158 global $wpdb; 159 160 if ( is_user_logged_in() ): 161 $user_id = $this->get_voter(''); 162 else: 163 $user_id = md5($this->get_voter('ip_address')); 164 endif; 165 166 $table = $wpdb->prefix . "social_polling"; 167 $post_id = get_the_ID(); 168 169 // check to see if the user has voted on the current poll 170 $query = "SELECT vote_value FROM $table WHERE poll_id='" . $post_id . "' AND (voter_ip = '".$user_id."' || (voter_id = '".$user_id."' && voter_id != '0' ))"; 171 $vote_val = $wpdb->get_row($query); 172 173 if ($vote_val){ 174 // if the user has voted then check to see which question in the poll the answer is 175 176 $table = $wpdb->prefix . "postmeta"; 177 $query = "SELECT meta_key FROM $table WHERE post_id='" . $post_id . "' AND meta_value='" . $vote_val->vote_value . "'"; 178 $ans_choice = $wpdb->get_row($query); 179 180 181 // add vote identifier to the comment 182 if ($ans_choice->meta_key == "social_polling_answer_one_field" || $ans_choice->meta_key == "_social_polling_answer_one_field"){ 183 add_comment_meta($comment_id,'vote_choice','one'); 184 } 185 elseif ($ans_choice->meta_key == "social_polling_answer_two_field" || $ans_choice->meta_key == "social_polling_answer_two_field"){ 186 add_comment_meta($comment_id,'vote_choice','two'); 187 } 188 } 189 } 156 190 157 191 … … 1510 1544 }//CLASS spComments 1511 1545 1512 1513 1514 1515 1516 1546 add_filter('comment_text', 'comment_vote_choice'); 1547 1548 function comment_vote_choice( $comment_text){ 1549 1550 $comment_ID = get_comment_ID(); 1551 1552 echo "<p"; 1553 1554 $test = get_comment_meta($comment_ID,"vote_choice",true); 1555 1556 if ($test == "one"){ 1557 echo " class='comment_voted_a'"; 1558 } 1559 elseif ($test == "two") { 1560 echo " class='comment_voted_b'"; 1561 } 1562 1563 echo ">$comment_text</p>"; 1564 } 1517 1565 1518 1566 function mytheme_comment($comment, $args, $depth) { -
because/trunk/social-polling.php
r1000853 r1007332 34 34 35 35 <<<<<<< .mine 36 * Version: 1.3. 736 * Version: 1.3.8 37 37 ======= 38 * Version: 1.3. 738 * Version: 1.3.8 39 39 >>>>>>> .r969865 40 40
Note: See TracChangeset
for help on using the changeset viewer.