Mark Ghosh. Configure... Author: Ajay D'Souza Author URI: http://ajaydsouza.com/ */ //if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?"); if (!function_exists('add_action')) { $wp_root = '../../..'; if (file_exists($wp_root.'/wp-load.php')) { require_once($wp_root.'/wp-load.php'); } else { require_once($wp_root.'/wp-config.php'); } } $tptn_db_version = "1.0"; function ald_tptn_init() { load_plugin_textdomain('myald_tptn_plugin', PLUGINDIR.'/'.dirname(plugin_basename(__FILE__))); } add_action('init', 'ald_tptn_init'); define('ALD_TPTN_DIR', dirname(__FILE__)); /********************************************************************* * Main Function (Do not edit) * ********************************************************************/ // Update post views add_action('wp_head','tptn_add_viewed_count'); function tptn_add_viewed_count() { global $post, $wpdb, $single; $table_name = $wpdb->prefix . "top_ten"; if(is_single() || is_page()) { $id = intval($post->ID); $output = ''; echo $output; } } function tptn_pc_content($content) { global $single, $post; $tptn_settings = tptn_read_options(); $id = intval($post->ID); if(($single)&&($tptn_settings['add_to_content'])) { $output = ''; return $content.$output; } else { return $content; } } add_filter('the_content', 'tptn_pc_content'); function echo_tptn_post_count() { global $post; $id = intval($post->ID); $output = ''; echo $output; } // Function to show popular posts function tptn_show_pop_posts() { global $wpdb, $siteurl, $tableposts, $id; $table_name = $wpdb->prefix . "top_ten"; $tptn_settings = tptn_read_options(); $limit = $tptn_settings['limit']; $sql = "SELECT postnumber, cntaccess , ID, post_type "; $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ; if ($tptn_settings['exclude_pages']) $sql .= "AND post_type = 'post' "; $sql .= "ORDER BY cntaccess DESC LIMIT $limit"; $results = $wpdb->get_results($sql); echo '
'; } // Create a WordPress Widget for Popular Posts function widget_tptn_pop($args) { global $wpdb, $siteurl, $tableposts, $id; extract($args); // extracts before_widget,before_title,after_title,after_widget $table_name = $wpdb->prefix . "top_ten"; $tptn_settings = tptn_read_options(); $limit = $tptn_settings['limit']; $sql = "SELECT postnumber, cntaccess , ID, post_type "; $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ; if ($tptn_settings['exclude_pages']) $sql .= "AND post_type = 'post' "; $sql .= "ORDER BY cntaccess DESC LIMIT $limit"; $results = $wpdb->get_results($sql); $title = (($tptn_settings['title']) ? strip_tags($tptn_settings['title']) : __('Popular Posts')); echo $before_widget; echo $before_title.$title.$after_title; echo '