prefix . "hitcount"; // Increments the database by one and returns the total number of hits to date. function hitcount_increasehit() { global $wpdb, $hitcount_table_name, $post; $pid = $post->ID; $ptype = $post->post_type; if( ($wpdb->get_var("SELECT hits from $hitcount_table_name WHERE `pid` = '$pid' and `type`='$ptype'"))){ $wpdb->query("UPDATE $hitcount_table_name SET hits = hits + 1 WHERE pid = '$pid' and `type`='$ptype'"); } else { $wpdb->query("insert into $hitcount_table_name (`type`,`pid`,`hits`) values('$ptype',$pid,'1')"); } } function hitcount_gethits(){ global $wpdb,$post,$hitcount_table_name; $pid = $post->ID; $ptype = $post->post_type; $posttable = $wpdb->prefix."posts"; return $wpdb->get_var("SELECT hits FROM $hitcount_table_name, $posttable WHERE `$hitcount_table_name`.pid = $pid and `$hitcount_table_name`.`type` = '$ptype' and `$posttable`.post_title !='' "); } // Prints an error message. function hitcount_readme() { echo '
Something is wrong!
'; } function displayhitcount($content){ global $post; //wordpress post global object global $wpdb,$post,$hitcount_table_name; if(is_single() || is_page()){ hitcount_increasehit(); //echo "single post"; } $hits = hitcount_gethits(); //echo $wpdb->last_query; if($hits==null or empty($hits)) $hits = 0; $position = get_option('hitscount_position'); $label = get_option('hitscount_label'); $label = !empty($label)?$label:"Number of View: "; if($position == 'bottom') $content = $content. $label.$hits; else $content = $label.$hits."
".$content; return $content; } // Installs the plugin. function hitcount_install() { global $wpdb, $hitcount_table_name; if ($wpdb->get_var("SHOW TABLES LIKE '$hitcount_table_name'") != $hitcount_table_name) { $wpdb->query("CREATE TABLE ".$hitcount_table_name." (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,`type` ENUM( 'post', 'page' ) NOT NULL DEFAULT 'post',`pid` INT NOT NULL ,`hits` INT( 11 ) NOT NULL,`create_at` DATETIME NULL ,`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP) TYPE = MYISAM ;"); add_option("hitcount_db_version", "1.0"); } } add_filter('the_content', 'displayhitcount'); add_action('admin_menu', 'my_plugin_menu'); register_activation_hook(__FILE__, "hitcount_install"); /*add_action('admin_menu', 'hitcount_menu'); function hitcount_menu() { add_options_page('My Plugin Options', 'Number of View', 8, 'your-unique-identifier', 'hitcount_options'); add_dashboard_page("number of view details", "Number of View", 8, "./../wp-content/plugins/number-of-view/list.php"); } function hitcount_options() { global $wpdb, $hitcount_table_name; $hitslist = $wpdb->get_results("SELECT * FROM $hitcount_table_name"); echo '
'; foreach($hitslist as $hits){ echo "
"; echo "Post Id: ".$hits->pid." Hits: ".$hits->hits; $post = get_post($hits->pid); echo $post->post_title; } //echo '

Here is where the form would go if I actually had options.

'; echo '
'; } * */ function widget_hitcount_popularpost($args) { global $wpdb, $hitcount_table_name; $options = get_option("widget_hitcount_popularpost"); $posttable = $wpdb->prefix."posts"; extract($args); echo $before_widget; echo $before_title.$options['title'].$after_title; $hitslist = $wpdb->get_results("SELECT * FROM $hitcount_table_name inner join $posttable on `$posttable`.ID = `$hitcount_table_name`.pid WHERE type in ('post','page') and `$posttitle`.post_title !='' ORDER BY hits desc limit ".$options['numpost']); //echo $wpdb->last_query; echo '
'; echo $after_widget; } function widget_hitcount_popularpost_control() { $options = get_option("widget_hitcount_popularpost"); if (!is_array( $options )) { $options = array( 'title' => 'Popular post by view', "numpost" => 5 ); } if ($_POST['widget_hitcount_popularpost-Submit']) { $options['title'] = htmlspecialchars($_POST['widget_hitcount_popularpost-WidgetTitle']); $options['numpost'] = htmlspecialchars($_POST['widget_hitcount_popularpost-Numpost']); update_option("widget_hitcount_popularpost", $options); } ?>


Sekretariat Tim LPSE Kabupaten Lombok Tengah - Jl. Gajah Mada No. 109 Praya - Lombok Tengah
Friday , 18 January 2019
Info Tim LPSE
sahifawplk