introducing data session option page
This commit is contained in:
parent
681a02bbea
commit
7d32ebca46
128
includes/dashboard.php
Normal file
128
includes/dashboard.php
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
function register_admin_dashboard_widget()
|
||||
{
|
||||
wp_add_dashboard_widget('admin_dashboard_widget', 'THE DASHBOARD TITLE', 'admin_dashboard_widget_callback');
|
||||
}
|
||||
add_action('wp_dashboard_setup', 'register_admin_dashboard_widget');
|
||||
|
||||
function admin_dashboard_widget_callback()
|
||||
{
|
||||
echo "<h2>Deligraph</h2>";
|
||||
echo "<p>Deligraph is a tool that helps you to manage your social media.</p>";
|
||||
echo "<p>For more information, please visit <a href='http://www.deligraph.com'>www.deligraph.com</a>.</p>";
|
||||
}
|
||||
|
||||
|
||||
function myprefix_register_options_page()
|
||||
{
|
||||
add_menu_page(
|
||||
'Session Datas',
|
||||
'Session Datas',
|
||||
'manage_options',
|
||||
'session-datas-options',
|
||||
'my_options_page_html',
|
||||
'dashicons-chart-area'
|
||||
|
||||
);
|
||||
}
|
||||
add_action('admin_menu', 'myprefix_register_options_page');
|
||||
|
||||
/**
|
||||
* The "My Options" page html.
|
||||
*/
|
||||
function my_options_page_html()
|
||||
{
|
||||
if (!current_user_can('manage_options')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($_GET['settings-updated'])) {
|
||||
add_settings_error(
|
||||
'my_options_mesages',
|
||||
'my_options_message',
|
||||
esc_html__('Settings Saved', 'text_domain'),
|
||||
'updated'
|
||||
);
|
||||
}
|
||||
|
||||
settings_errors('my_options_mesages');
|
||||
|
||||
?>
|
||||
<?php
|
||||
global $wpdb;
|
||||
$table_name = "wp_app_users_statistics";
|
||||
|
||||
$users_locales = $wpdb->get_results("
|
||||
SELECT user_locale, COUNT(user_locale) as count
|
||||
FROM $table_name
|
||||
GROUP BY user_locale
|
||||
");
|
||||
|
||||
$users_countries = $wpdb->get_results("
|
||||
SELECT user_country, COUNT(user_country) as count
|
||||
FROM $table_name
|
||||
GROUP BY user_country
|
||||
");
|
||||
|
||||
$notes_repartition = $wpdb->get_results("
|
||||
SELECT level_score, COUNT(level_score) as count
|
||||
FROM $table_name
|
||||
GROUP BY level_score
|
||||
");
|
||||
|
||||
write_log($users_countries);
|
||||
|
||||
$average_level_score = $wpdb->get_var("
|
||||
SELECT AVG(level_score) as average
|
||||
FROM $table_name
|
||||
");
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1 class="page-title"><?php echo esc_html(get_admin_page_title()); ?></h1>
|
||||
<section class="game">
|
||||
<h2 class="section-title">Données de jeu</h2>
|
||||
<div class="score">
|
||||
<h3>Score moyen</h3>
|
||||
<?php if ($average_level_score) : ?>
|
||||
|
||||
<p><?php echo round($average_level_score, 1) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="notes-distribution">
|
||||
<h3>Répartition des notes</h3>
|
||||
<ul>
|
||||
<?php foreach ($notes_repartition as $note) : ?>
|
||||
<li><span class="data-label"><?php echo $note->level_score ?></span> : <?php echo $note->count ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<section class="geography">
|
||||
<h2 class="section-title">Langue et Géographie</h2>
|
||||
<div class="lang">
|
||||
<h3>Répartition des langues</h3>
|
||||
<ul>
|
||||
<?php foreach ($users_locales as $users_locale) : ?>
|
||||
<li><span class="data-label"><?php echo $users_locale->user_locale ?></span> : <?php echo $users_locale->count ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="countries">
|
||||
<h3>Répartition des pays</h3>
|
||||
<ul>
|
||||
<?php foreach ($users_countries as $user_country) : ?>
|
||||
<li><span class="data-label"><?php echo $user_country->user_country ?></span> : <?php echo $user_country->count ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user