refining dashboard
This commit is contained in:
parent
e904e0faec
commit
b26f4cf578
|
|
@ -1,17 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
function register_admin_dashboard_widget()
|
function register_admin_dashboard_widget()
|
||||||
{
|
{
|
||||||
wp_add_dashboard_widget('admin_dashboard_widget', 'THE DASHBOARD TITLE', 'admin_dashboard_widget_callback');
|
wp_add_dashboard_widget('admin_dashboard_widget', 'Consulter les statistiques', 'admin_dashboard_widget_callback');
|
||||||
}
|
}
|
||||||
add_action('wp_dashboard_setup', 'register_admin_dashboard_widget');
|
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()
|
function myprefix_register_options_page()
|
||||||
{
|
{
|
||||||
|
|
@ -27,6 +20,23 @@ function myprefix_register_options_page()
|
||||||
}
|
}
|
||||||
add_action('admin_menu', 'myprefix_register_options_page');
|
add_action('admin_menu', 'myprefix_register_options_page');
|
||||||
|
|
||||||
|
function admin_dashboard_widget_callback()
|
||||||
|
{
|
||||||
|
$url = menu_page_url('session-datas-options', false);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="dashboard-widget">
|
||||||
|
<img class="dashboard-widget__preview-picture" src="<?php echo get_template_directory_uri() . '/resources/img/dashboard/data_visual.png' ?>" alt="">
|
||||||
|
<h3 class="dashboard-widget__title">Statistiques</h3>
|
||||||
|
<p>Pour consulter les statistiques des jeux sur la page de session datas</p>
|
||||||
|
<a class="dashboard-widget__cta" href="<?php echo $url ?>">Consulter</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "My Options" page html.
|
* The "My Options" page html.
|
||||||
*/
|
*/
|
||||||
|
|
@ -52,76 +62,122 @@ function my_options_page_html()
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$table_name = "wp_app_users_statistics";
|
$table_name = "wp_app_users_statistics";
|
||||||
|
|
||||||
$users_locales = $wpdb->get_results("
|
|
||||||
SELECT user_locale, COUNT(user_locale) as count
|
$level_post_ids = $wpdb->get_col("
|
||||||
FROM $table_name
|
SELECT DISTINCT level_post_id
|
||||||
GROUP BY user_locale
|
FROM $table_name
|
||||||
");
|
");
|
||||||
|
|
||||||
$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">
|
<div class="page-sessions-datas">
|
||||||
<h1 class="page-title"><?php echo esc_html(get_admin_page_title()); ?></h1>
|
<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 foreach ($level_post_ids as $level_post_id) : ?>
|
||||||
<?php endif; ?>
|
<?php $levelPost = get_post($level_post_id); ?>
|
||||||
|
|
||||||
</div>
|
<section class="game_stats">
|
||||||
|
<?php
|
||||||
|
$users_locales = $wpdb->get_results("
|
||||||
|
SELECT user_locale, COUNT(user_locale) as count
|
||||||
|
FROM $table_name
|
||||||
|
WHERE level_post_id = $level_post_id
|
||||||
|
GROUP BY user_locale
|
||||||
|
");
|
||||||
|
|
||||||
<div class="notes-distribution">
|
$users_countries = $wpdb->get_results("
|
||||||
<h3>Répartition des notes</h3>
|
SELECT user_country, COUNT(user_country) as count
|
||||||
<ul>
|
FROM $table_name
|
||||||
<?php foreach ($notes_repartition as $note) : ?>
|
WHERE level_post_id = $level_post_id
|
||||||
<li><span class="data-label"><?php echo $note->level_score ?></span> : <?php echo $note->count ?></li>
|
GROUP BY user_country
|
||||||
<?php endforeach; ?>
|
");
|
||||||
</ul>
|
|
||||||
</div>
|
$notes_repartition = $wpdb->get_results("
|
||||||
|
SELECT level_score, COUNT(level_score) as count
|
||||||
|
FROM $table_name
|
||||||
|
WHERE level_post_id = $level_post_id
|
||||||
|
GROUP BY level_score
|
||||||
|
");
|
||||||
|
|
||||||
|
$average_level_score = $wpdb->get_var("
|
||||||
|
SELECT AVG(level_score) as average
|
||||||
|
FROM $table_name
|
||||||
|
WHERE level_post_id = $level_post_id
|
||||||
|
");
|
||||||
|
$completeLevelsScores = $wpdb->get_results("
|
||||||
|
SELECT level_score
|
||||||
|
FROM $table_name
|
||||||
|
WHERE level_post_id = $level_post_id
|
||||||
|
");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2 class="game_stats__game-title"><?php echo $levelPost->post_title ?></h2>
|
||||||
|
<div class="stats-container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="game_stats__statistics-section game-statistics">
|
||||||
|
<div class="game_stats__average-score block-data-score">
|
||||||
|
<h3>Score moyen</h3>
|
||||||
|
|
||||||
|
<?php if ($average_level_score) : ?>
|
||||||
|
<div class="average-score">
|
||||||
|
<svg viewBox="0 -1 40 40" class="circular-chart">
|
||||||
|
<path class="circle" stroke-dasharray="70, 800" d="M18 2.0845
|
||||||
|
a 15.9155 15.9155 0 0 1 0 31.831
|
||||||
|
a 15.9155 15.9155 0 0 1 0 -31.831" />
|
||||||
|
</svg>
|
||||||
|
<p class="text"><?php echo round($average_level_score, 1) ?></p>
|
||||||
|
<!-- <div class="donut-average"></div> -->
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="game_stats__scores-distribution ">
|
||||||
|
<h3>Répartition des scores</h3>
|
||||||
|
<canvas id="graphic-score-repartition"></canvas>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($notes_repartition as $note) : ?>
|
||||||
|
<li class="score-data" score="<?php echo $note->level_score ?>" count="<?php echo $note->count ?>"><span class="data-label"><?php echo $note->level_score ?></span> : <span class="data-value"><?php echo $note->count ?></span> <span class="joueurs">joueurs</span></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="game_stats__statistics-section geopraphy-statistics">
|
||||||
|
<h3 class=" section-title">Langue et Géographie</h3>
|
||||||
|
<div class="data-grid">
|
||||||
|
|
||||||
|
<div class="lang">
|
||||||
|
<h4>Répartition des langues</h4>
|
||||||
|
<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">
|
||||||
|
<h4>Répartition des pays</h4>
|
||||||
|
<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 ?> joueurs</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
</section>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
</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>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user