Skip to content

Instantly share code, notes, and snippets.

@pj-dave
Created July 25, 2016 14:41
Show Gist options
  • Save pj-dave/21937c994bf33445bad3b3bfdb7ebe1b to your computer and use it in GitHub Desktop.
Save pj-dave/21937c994bf33445bad3b3bfdb7ebe1b to your computer and use it in GitHub Desktop.
<?php
add_action( 'init', function() {
global $wpdb;
if ( empty( $_GET['pageviews-pvc-export'] ) )
return;
$config = get_option( 'pageviews_config' );
echo $config['account'] . PHP_EOL;
$data = $wpdb->get_results( "SELECT `id`, `count` FROM {$wpdb->prefix}post_views WHERE `period` = 'total';", ARRAY_A );
foreach ( $data as $entry )
printf( "%d:%d\n", $entry['id'], $entry['count'] );
die();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment