Example #1
0
function wp_statistics_purge_visitor_hits_action_callback()
{
    global $WP_Statistics, $wpdb;
    // this is how you get access to the database
    require $WP_Statistics->plugin_dir . '/includes/functions/purge-hits.php';
    $manage_cap = wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options'));
    if (current_user_can($manage_cap)) {
        $purge_hits = 10;
        if (array_key_exists('purge-hits', $_POST)) {
            // Get the number of days to purge data before.
            $purge_hits = intval($_POST['purge-hits']);
        }
        if ($purge_hits < 10) {
            _e('Number of hits must be greater than or equal to 10!', 'wp_statistics');
        } else {
            echo wp_statistics_purge_visitor_hits($purge_hits);
        }
    } else {
        _e('Access denied!', 'wp_statistics');
    }
    wp_die();
    // this is required to terminate immediately and return a proper response
}
Example #2
0
function wp_statistics_dbmaint_visitor_event()
{
    global $wpdb, $WP_Statistics;
    require_once plugin_dir_path(__FILE__) . '/includes/functions/purge-hits.php';
    $purge_hits = intval($WP_Statistics->get_option('schedule_dbmaint_visitor_hits', FALSE));
    wp_statistics_purge_visitor_hits($purge_hits);
}