get_results($wpdb->prepare("SELECT name,slug FROM {$wpdb->terms}")); $q = isset($_GET["q"]) ? strtolower($_GET["q"]) : ''; if($q): $terms = &get_terms(get_taxonomies()); // get_terms() should handle the cache (hopefully) $output = array(); foreach ($terms as $term) if(strpos(strtolower($term->name), $q) !== false) echo "{$term->name}|{$term->count}\n"; endif; die(); endif; // echo full post content on 'read more' click -- @todo more testing if(atom_ajax_request('read_more')): atom_ajax_header(); $post_id = isset($_GET["post_id"]) ? intval($_GET["post_id"]) : false; if($post_id): $query = new WP_Query(array('p' => $post_id)); if ($query->have_posts()): $query->the_post(); atom_post_content(array('limit' => 0)); endif; endif; die(); endif; // comment karma rating if(atom_ajax_request('comment_karma') && is_user_logged_in() && atom_get_options('comment_karma')): atom_ajax_header(); global $user_ID; $rate = $_GET['karma'][0]; $comment_id = intval(ltrim($_GET['karma'], '-+')); $comment = get_comment($comment_id); $karma = $comment->comment_karma; if($comment->user_id == $user_ID) // the user shouldn't see these messages unless they hack the html or something exit(_a("You can't vote your own comment :(")); if(get_user_meta($user_ID, "rated_{$comment_id}", true) == true) exit(_a("You can only vote once :)")); $unit = 1; // + $unit if($rate != '+' && $rate != '-') _ae("Invalid vote"); $karma = ($rate == '+') ? ($karma + $unit) : ($karma - $unit); //$query = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->comments} SET comment_karma = comment_karma {$rate} {$unit} WHERE comment_ID = {$comment_id} LIMIT 1")); //$wpdb->update($wpdb->comments, array('comment_karma' => $karma), array('comment_ID' => $comment_id)); $comment->comment_karma = $karma; if(!wp_update_comment((array)$comment)) exit(_a("Failed.")); update_user_meta($user_ID, "rated_{$comment_id}", true); if($comment->user_id): $user_karma = intval(get_user_meta($comment->user_id, "karma", true)); $new_karma = ($rate == '+') ? ($user_karma + $unit) : ($user_karma - $unit); if($new_karma < 0) $new_karma = 0; // no negative karma update_user_meta($comment->user_id, "karma", $new_karma); endif; die(($karma != 0) ? str_replace('-', '−', $karma) : ''); endif; // get a single comment if(atom_ajax_request('get_comment')): atom_ajax_header(); define('RETRIEVING_BURIED_COMMENT', true); $comment_id = abs(intval($_GET['comment_id'])); $comment = get_comment($comment_id); atom_comment($comment, array(), 0); die(); endif; // get a list of comments if(atom_ajax_request('get_comments')): $offset = intval($_GET['offset']); // echo $offset; // global $withcomments; $withcomments = true; global $post; // echo '
';
$comments = get_comments(array(
'type' => 'comment',
'post_id' => $post->ID,
'status' => 'approve',
'offset' => $offset,
'number' => atom_get_options("ajax_comments_count")
));
// print_r($comments);
// print_r($wp_query->comments);
//echo $post->ID; $comments = get_comments();
atom_comments($comments);
// wp_list_comments();
die();
endif;