overview.php

Viewing 4 posts - 1 through 4 (of 4 total)
#194206

Paul
Member

Is it possible for the Overview.php shown in the admin dashboard to include the total daily downloads stat?

Something like:
<?php
// Get start and end timestamps for the current day
$s = strtotime(date(“Y-m-d 00:00:00”));
$e = time();

// Retrieve daily downloads within the specified date range
$daily_downloads = $wpdb->get_var(“SELECT SUM(meta_value) FROM {$wpdb->prefix}postmeta WHERE meta_key = ‘__wpdm_download_count’ AND UNIX_TIMESTAMP(date) > $s AND UNIX_TIMESTAMP(date) < $e”);

// Output the daily downloads
echo ‘<span class=”badge pull-right”>’ . $daily_downloads . ‘</span>’;
?>
<?php _e( “Daily Downloads” , “download-manager” ); ?>

#194207

Tahasin
Moderator

Hello, Paul

I hope this message finds you well and thanks for contacting us.

Instead of postmeta, you can write a query to fetch the daily download stats like this
SELECT count(*) as todays_downloads FROM wp_ahm_download_stats WHERE year=2024 and month=4 and day=24
or
SELECT count(*) as todays_downloads FROM wp_ahm_download_stats WHERE timestamp > $s and timestamp < $e

Regards

#194256

Paul
Member

Thank you ! Exactly what I wanted.

#194274

Tahasin
Moderator

Glad to hear that. 🤗

If you find my assistance valuable, I would greatly appreciate your support with a 5-star review here

Thank you

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.