query($wpdb->prepare("INSERT INTO ".AH_TRACKING_TABLE. " (date, post_id, ip) VALUES (now(), %d, %s)", $digit, (string )$_SERVER['REMOTE_ADDR'])); die(); } /** * Tracking_Model::get_all() * * @param mixed $limit - for pagination * @return */ public function get_all($limit) { global $wpdb; return $wpdb->get_results("SELECT ip,post_id,date FROM ".AH_TRACKING_TABLE. " ORDER BY date DESC ".$limit); } /** * Tracking_Model::total_entries() * Finds total entries of posts in ah_tracking table and that which are currently still live * * @return */ public function total_entries() { global $wpdb; $total = $wpdb->get_results("SELECT id, post_id FROM ".AH_TRACKING_TABLE); static $i = 1; $new_total = NULL; foreach ($total as $result) { $post = (int)$result->post_id; $post = get_post($post, OBJECT); if ($post === NULL) continue; $new_total = $i++; } return $new_total; } /** * Tracking_Model::update_options() * * Changes option field for ah_tracking * * @param mixed $var */ public function update_options($var) { if (isset($var) && $var === TRUE) { $option = get_option('ah_tracking'); if ($option) { update_option('ah_tracking', TRUE); } else { update_option('ah_tracking', TRUE); } } else { $option = get_option('ah_tracking'); if ($option) { update_option('ah_tracking', FALSE); } else { update_option('ah_tracking', FALSE); } } // end if } } ?>