Torna a Blog

KF Most Read Plugin

Siamo lieti di annunciare il lancio del primo plugin per Wordpress targato KiFuLab. Si tratta di un plugin per tracciare e restituire il numero di letture di un singolo post. La particolarità di KF most read consiste nella possibilità estrarre la lista dei post più visitati entro un periodo di tempo definibile dall’utente.

Come funziona il plugin?

KF most read consiste in un solo piccolo file (4KB). L’installazione avviene come per tutti i plugin di Wordpress (copia dentro wp-content/plugins e attivazione da pannello di controllo). Una volta installato, bisognerà inserire all’interno del template la chiamata alla funzione principale del template: kf_get_posts_by_hits.

Download plugin

KF most read 1.2

16 Commenti
  • Filippo Civiletti

    Grandi ragazzi, siete i numeri uno! (Y)

  • Javier.

    Could this plugin be widgetized?

    Thanks a lot for your help!!

  • cicciodarkast

    E si!! sono finiti i tempi di Joomla alias Paleojoomla!!

  • baron

    Works great, thank you

  • biagio semilia

    ebbbravi!

  • Arif Uddin

    Hi… i’ve used ur plugin in a project and found it pretty easy and cool.

    just one thing i want to tell you…

    I saw that u have implemented this plugin for a constant table name… ‘wp_kf_most_read’. what is i use a different prefix.. that is… Use wp1_ instead of wp_…. i know that for most of the of blog wp_ is ok… but still it can be changed… i have to change the code for my project to work ur plugin…

    its a little change required…
    replace the line —> $sql = “CREATE TABLE `wp_kf_most_read` (
    by —> $sql = “CREATE TABLE `”. $table_name .”` (

    Once again… great work man…

  • fulippo

    Hi Arif,

    thanks for your advice. We are planning to release a new version of the plugin as soon as possible. We will include a widget and make some general improvements including a dynamic table name for the sql that creates the table.

  • Mustardamus

    Hey,
    great slim plugin, fits perfect in my latest project. Anyway, it only worked because I applied a fix.

    In the function “kf_register_post_hits” you referred to the variable “$post_id” without ever setting it. A simple “$post_id = $post->ID” (line 5 of the pasted code) will do it:

    function kf_register_post_hits(&$the_content){
    global $post, $wpdb;
    if(($post->post_status == ‘publish’) && (int)$post->ID){
    if(!empty($_SESSION)){
    $post_id = $post->ID;
    if(is_single() && !in_array($post_id, $_SESSION['kf_session_manager']['kf_most_read']['posts'])){
    $_SESSION['kf_session_manager']['kf_most_read']['posts'][] = $post_id;
    $sql= “INSERT INTO {$wpdb->prefix}kf_most_read(post_ID, hit_ts) values(‘$post_id’,”.time().”);\n”;
    $wpdb->query($sql);
    }
    }
    else{
    $_SESSION['kf_session_manager']['kf_most_read']['posts'] = array();
    }
    }
    return $the_content;
    }

    I hope you will fix it in future releases.

    Thanks,
    Basti

  • Marco

    Per vedere il punteggio associato al post basta cambiare la funzione kf_get_posts_by_hits con il seguente echo da sostituire a quello di default (If you wont to view the score you can change the function kf_get_posts_by_hits whith):

    echo ‘‘.$post['Title'].’ (‘.$p->totHits.’)’.chr(13);

  • fulippo

    @Marco: sinceramente non capisco come questa riga di codice possa funzionare. Potresti essere più preciso o postare un esempio più corposo?
    Prima usi $post ($post['Title']) e poi $p ($p->totHits). Perchè?

  • godaddy coupons

    Thanks for making this awesome plugin

  • Giraldi Maggio

    I get this message right after installation:

    session_start() [function.session-start]: open(..\..\php5\temp\sess_lnrg6r3s67782n4qd2bssgm477, O_RDWR) failed: No such file or directory (2) in …\wp-content\plugins\kf-most-read\kf_most_read.php on line 29

    Why is this?

  • Giraldi Maggio

    Thanks for the quick reply.

    I think I was getting the session_start() error because I was testing it offline (locally)… Once I uploaded it, the problem disappeared.

    However, the function doesn’t seem to be getting any result. The output is always empty.

    Am I missing something?

    Cheers!

  • jim

    the plugin has been working fine, but suddenly it does not display anything, but there is code at the bottom of the page. i think our database was corrupted, but do you know? have you seen this before?

    erors on page:
    WordPress database error Can’t open file: ‘wp_kf_most_read.MYI’ (errno: 130) for query SELECT count(mr.post_ID) as totHits, p.ID, p.post_title from wp_posts p JOIN wp_kf_most_read mr on mr.post_ID = p.ID where mr.hit_ts >= ‘1266373956′ GROUP BY mr.post_ID order by totHits desc, ID ASC LIMIT 5 made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, PHP_Code_Widget->widget, eval, kf_get_posts_by_hits WordPress database error Can’t open file: ‘wp_kf_most_read.MYI’ (errno: 130) for query SELECT count(mr.post_ID) as totHits, p.ID, p.post_title from wp_posts p JOIN wp_kf_most_read mr on mr.post_ID = p.ID where mr.hit_ts >= ‘1265855556′ GROUP BY mr.post_ID order by totHits desc, ID ASC LIMIT 5 made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, PHP_Code_Widget->widget, eval, kf_get_posts_by_hits WordPress database error Can’t open file: ‘wp_kf_most_read.MYI’ (errno: 130) for query SELECT count(mr.post_ID) as totHits, p.ID, p.post_title from wp_posts p JOIN wp_kf_most_read mr on mr.post_ID = p.ID where mr.hit_ts >= ‘1263868356′ GROUP BY mr.post_ID order by totHits desc, ID ASC LIMIT 5 made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, PHP_Code_Widget->widget, eval, kf_get_posts_by_hits

  • jim

    l’alimentabile sta funzionando benissimo, ma non visualizza improvvisamente nulla, ma ci è codice in calce alla pagina. penso che la nostra base di dati siate stato corrotto, ma sappiate? avete veduto questo prima?
    erors on page:
    WordPress database error Can’t open file: ‘wp_kf_most_read.MYI’ (errno: 130) for query SELECT count(mr.post_ID) as totHits, p.ID, p.post_title from wp_posts p JOIN wp_kf_most_read mr on mr.post_ID = p.ID where mr.hit_ts >= ‘1266373956′ GROUP BY mr.post_ID order by totHits desc, ID ASC LIMIT 5 made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, PHP_Code_Widget->widget, eval, kf_get_posts_by_hits WordPress database error Can’t open file: ‘wp_kf_most_read.MYI’ (errno: 130) for query SELECT count(mr.post_ID) as totHits, p.ID, p.post_title from wp_posts p JOIN wp_kf_most_read mr on mr.post_ID = p.ID where mr.hit_ts >= ‘1265855556′ GROUP BY mr.post_ID order by totHits desc, ID ASC LIMIT 5 made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, PHP_Code_Widget->widget, eval, kf_get_posts_by_hits WordPress database error Can’t open file: ‘wp_kf_most_read.MYI’ (errno: 130) for query SELECT count(mr.post_ID) as totHits, p.ID, p.post_title from wp_posts p JOIN wp_kf_most_read mr on mr.post_ID = p.ID where mr.hit_ts >= ‘1263868356′ GROUP BY mr.post_ID order by totHits desc, ID ASC LIMIT 5 made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, PHP_Code_Widget->widget, eval, kf_get_posts_by_hits

  • Fulippo

    @Jim: Those errors are not related to the plugin itself. The error in fact seems to be related to some kind of table corruption.

    Try googling “mysql errno: 130″ and you will find many solutions to you problem.

    http://www.google.com/#hl=it&q=mysql+errno%3A+130

Lascia un commento