xperience.ro

blogging as hobby

09.11.2009

kStats plugin WordPress – patching v0.4.1

plugin-uri, wordpress

De aproximativ 2 saptamani folosesc plugin-ul kStats reloaded pentru WordPress si sincer imi place. Simplu si la obiect, isi face treaba de minune, adica detalii si statistici despre vizitatorii blogului. Nu ofera nici prea multe informatii dar nici prea putine, ci doar atatea cate ai nevoie. Din ce tara sunt vizitatorii, cum au ajuns pe blogul tau, cati au fost intr-o zi, ce au citit, chestii de genul acesta.

Totusi plugin-ul este la inceput si evident are destule bug-uri. Unul dintre ele ar fi acela ca nu prea tine minte informatiile din ziua precedenta (daca aveti versiunea 0.4.0 e ok, daca aveti 0.4.2 trebuie sa aplicati un patch). Si pentru ca m-am conversat destul de mult cu autorul plugin-ului Mark Watero am primit de la acesta si un patch pentru remedierea problemei. In caz ca mai sunt si altii care il folosesc si au aceeasi problema, nu trebuie decat sa luati patch-ul de mai jos, il salvati cu extensia .php, il copiati in directorul wp-content/plugins din blog, il activati ca pe orice plugin dupa care il puteti sterge. Restul face el singur la activare. Cititi tot articolul pentru a gasi plugin-ul (din motive obscure nu merge sa-l atasez ca fisier, sorry)…

< ?php /*
Plugin Name:  kStats 0.4.1 patch
Description:  Patches the database upgrades necessary for 0.4.1 to run
Version:      1.0
Author:       Mark Waterous
Author URI:   http://mark.watero.us/
*/

global $wpdb;

define( 'KSTATS_TABLE_TOTALS',    $wpdb->prefix . 'kstats_totals' );

kstats_patch_upgrade();

register_activation_hook( __FILE__, 'kstats_patch_upgrade' );

if ( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' ) 
	add_action( 'admin_notices', 'kstats_patch_run' );

function kstats_patch_run() {
	echo '
The kStats Patch has run successfully. You may now deactivate the patch plugin and delete the file from your server.
'; } function kstats_patch_upgrade() { global $wpdb; $query[] = sprintf( "SHOW COLUMNS FROM `%s`", KSTATS_TABLE_TOTALS ); $results = $wpdb->get_results( end( $query ), ARRAY_A ); $kstats_up_enum = ( $results[0]['Type'] != "enum('totals','monthly','daily')" ) ? TRUE : FALSE; $kstats_up_fields = ( $results[2]['Field'] != 'visitors' ) ? TRUE : FALSE; if ( $kstats_up_enum === TRUE ) { $query[] = sprintf( "ALTER TABLE `%s` CHANGE `type` `type` ENUM( 'totals', 'monthly', 'daily' ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL", KSTATS_TABLE_TOTALS ); // bye Charts! $wpdb->query( end( $query ) ); } if ( $kstats_up_fields === TRUE ) { // Change our column names to actually reference the data they're holding, in this way future columns can be appended, like Bounce Rate, etc $query[] = sprintf( "ALTER TABLE `%s` CHANGE `total` `visitors` INT(10) UNSIGNED NOT NULL, CHANGE `last` `pageviews` INT(10) UNSIGNED NOT NULL, CHANGE `this` `spiders` INT(10) UNSIGNED NOT NULL, CHANGE `yesterday` `feeds` INT(10) UNSIGNED NOT NULL", KSTATS_TABLE_TOTALS ); $wpdb->query( end( $query ) ); } $query[] = sprintf( "SELECT name, visitors, pageviews, spiders, feeds FROM `%s` WHERE type = ''", KSTATS_TABLE_TOTALS ); $results = $wpdb->get_results( end( $query ), ARRAY_A ); if ( ! is_null( $results ) ) { foreach ( $results as $row ) { if ( strlen( $row['name'] ) == 7 ) $query_parts[] = sprintf( "( 'monthly', '%s', '%d', '%d', '%d', '%d' )", $row['name'], $row['visitors'], $row['pageviews'], $row['spiders'], $row['feeds'] ); else if ( strlen( $row['name'] ) == 10 ) $query_parts[] = sprintf( "( 'daily', '%s', '%d', '%d', '%d', '%d' )", $row['name'], $row['visitors'], $row['pageviews'], $row['spiders'], $row['feeds'] ); } $query[] = sprintf( "REPLACE INTO `%s` VALUES %s", KSTATS_TABLE_TOTALS, implode( ', ', $query_parts ) ); $wpdb->query( end( $query ) ); $query[] = sprintf( "DELETE FROM `%s` WHERE type = ''", KSTATS_TABLE_TOTALS ); $wpdb->query( end( $query ) ); } }




Reclame Google

Intrebare intrebatoare

Ce faci de 1 Mai?

View Results

Loading ... Loading ...

Arhiva


Etichete

1 mai 9am Apple apple iphone Articole Bancuri bebelusi blog blogging bmw bucuresti cfr Clipuri clipuri amuzante clipuri youtube clubbing concursuri concursuri online craiova dacia dacia logan dacia sandero design blog dj pagal droguri emil boc facebook fotbal free proxy list Funny Clips Funny Pics gigi becali google Internet iphone jay bliss kudos beach kudos beach mamaia love events mamaia marea neagra medieval melodia zilei mircea geoana monica columbeanu muzica nights.ro ninsoare nokia Noutati nunta pagal petreceri romania rosario internullo socks4 socks5 Software spam traian basescu wordpress wordpress plugins yahoo youtube zapada