| @@ -1,55 +1,126 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Template for displaying the Users statistics dashboard tab. | |
| 4 | + * | |
| 5 | + * Data is rendered by assets/src/js/admin/statistics/tab-users.js from the | |
| 6 | + * `dashboard` key of the user-statistics endpoint. | |
| 7 | + * | |
| 8 | + * @since 4.4.2 | |
| 9 | + */ | |
| 2 | 10 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | - exit; // Exit if accessed directly | |
| 5 | -} | |
| 11 | +defined( 'ABSPATH' ) || exit(); | |
| 6 | 12 | |
| 7 | -$sections = array( | |
| 8 | - 'students' => __( 'Students', 'learnpress' ), | |
| 9 | - 'instructors' => __( 'Instructors', 'learnpress' ), | |
| 13 | +$kpi_cards = array( | |
| 14 | + 'users-activated' => __( 'Users activated', 'learnpress' ), | |
| 15 | + 'students' => __( 'Students', 'learnpress' ), | |
| 16 | + 'instructors' => __( 'Instructors', 'learnpress' ), | |
| 17 | + 'not-started' => __( 'Not started', 'learnpress' ), | |
| 18 | + 'in-progress' => __( 'In progress', 'learnpress' ), | |
| 19 | + 'finished' => __( 'Finished', 'learnpress' ), | |
| 10 | 20 | ); |
| 11 | -$section = 'students'; | |
| 12 | -$sections_count = sizeof( $sections ); | |
| 13 | -$count = 0; | |
| 21 | + | |
| 22 | +$funnel_steps = array( | |
| 23 | + 'registered' => __( 'Registered', 'learnpress' ), | |
| 24 | + 'enrolled' => __( 'Enrolled', 'learnpress' ), | |
| 25 | + 'started' => __( 'Started learning', 'learnpress' ), | |
| 26 | + 'completed' => __( 'Completed', 'learnpress' ), | |
| 27 | + 'failed' => __( 'Failed', 'learnpress' ), | |
| 28 | +); | |
| 29 | + | |
| 30 | +// Section config filters — add/remove/relabel cards and lists. @since 4.4.2 | |
| 31 | +$kpi_cards = (array) apply_filters( 'learn-press/statistics/users/kpi-cards', $kpi_cards ); | |
| 32 | +$funnel_steps = (array) apply_filters( 'learn-press/statistics/users/funnel-steps', $funnel_steps ); | |
| 14 | 33 | ?> |
| 34 | +<div class="lp-admin-statistics-tab-content lp-stats-tab-users"> | |
| 35 | + <?php | |
| 36 | + /** | |
| 37 | + * Fires at the top of the Users statistics tab, inside the tab container. | |
| 38 | + * | |
| 39 | + * @since 4.4.2 | |
| 40 | + */ | |
| 41 | + do_action( 'learn-press/statistics/users/before' ); | |
| 15 | 42 | |
| 16 | -<div id="learn-press-statistic" class="learn-press-statistic-users"> | |
| 17 | - <ul class="subsubsub chart-buttons"> | |
| 18 | - <li> | |
| 19 | - <button class="button" data-type="user-last-7-days" | |
| 20 | - disabled="disabled"><?php _e( 'Last 7 Days', 'learnpress' ); ?></button> | |
| 21 | - </li> | |
| 22 | - <li> | |
| 23 | - <button class="button" data-type="user-last-30-days"><?php _e( 'Last 30 Days', 'learnpress' ); ?></button> | |
| 24 | - </li> | |
| 25 | - <li> | |
| 26 | - <button class="button" | |
| 27 | - data-type="user-last-12-months"><?php _e( 'Last 12 Months', 'learnpress' ); ?></button> | |
| 28 | - </li> | |
| 29 | - <li> | |
| 30 | - <button class="button" data-type="user-all"><?php _e( 'All', 'learnpress' ); ?></button> | |
| 31 | - </li> | |
| 32 | - <li> | |
| 33 | - <form id="user-custom-time"> | |
| 34 | - <span><?php _e( 'From', 'learnpress' ); ?></span> | |
| 35 | - <input type="text" placeholder="Y/m/d" name="from" class="date-picker" readonly="readonly"> | |
| 36 | - <span><?php _e( 'To', 'learnpress' ); ?></span> | |
| 37 | - <input type="text" placeholder="Y/m/d" name="to" class="date-picker" readonly="readonly"> | |
| 38 | - <input type="hidden" name="action" value="learnpress_custom_stats"> | |
| 39 | - <button class="button button-primary" data-type="user-custom-time" type="submit" | |
| 40 | - disabled="disabled"><?php _e( 'Go', 'learnpress' ); ?></button> | |
| 41 | - </form> | |
| 42 | - </li> | |
| 43 | - </ul> | |
| 44 | - <div class="clear"></div> | |
| 45 | - <div id="learn-press-chart" class="learn-press-chart"> | |
| 43 | + learn_press_admin_view( 'statistics/parts/filter-bar' ); | |
| 44 | + ?> | |
| 45 | + | |
| 46 | + <div class="lp-stats-dashboard-body"> | |
| 47 | + <div class="lp-stats-kpi-grid"> | |
| 48 | + <?php | |
| 49 | + foreach ( $kpi_cards as $key => $title ) { | |
| 50 | + learn_press_admin_view( | |
| 51 | + 'statistics/parts/kpi-card', | |
| 52 | + array( | |
| 53 | + 'key' => $key, | |
| 54 | + 'title' => $title, | |
| 55 | + ) | |
| 56 | + ); | |
| 57 | + } | |
| 58 | + ?> | |
| 59 | + </div> | |
| 60 | + | |
| 61 | + <div class="lp-stats-overview-grid lp-stats-overview-grid--chart"> | |
| 62 | + <div class="lp-stats-section statistics-content"> | |
| 63 | + <div class="lp-stats-section__header"> | |
| 64 | + <div> | |
| 65 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Learner registration and progress', 'learnpress' ); ?></h3> | |
| 66 | + <p class="lp-stats-section__description"><?php esc_html_e( 'Registration, enrollment, and graduation activity across the learning lifecycle.', 'learnpress' ); ?></p> | |
| 67 | + </div> | |
| 68 | + </div> | |
| 69 | + <div id="user-chart" class="statistics-chart-wrapper"> | |
| 70 | + <?php lp_skeleton_animation_html( 10, 100 ); ?> | |
| 71 | + <canvas id="user-chart-content" style="display: none;"></canvas> | |
| 72 | + </div> | |
| 73 | + </div> | |
| 74 | + | |
| 75 | + <div class="lp-stats-section"> | |
| 76 | + <div class="lp-stats-section__header"> | |
| 77 | + <div> | |
| 78 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Learner funnel', 'learnpress' ); ?></h3> | |
| 79 | + <p class="lp-stats-section__description"><?php esc_html_e( 'Registered users to completed courses.', 'learnpress' ); ?></p> | |
| 80 | + </div> | |
| 81 | + </div> | |
| 82 | + <?php lp_skeleton_animation_html( 5, 100 ); ?> | |
| 83 | + <div class="lp-stats-funnel"> | |
| 84 | + <?php foreach ( $funnel_steps as $step => $label ) : ?> | |
| 85 | + <div class="lp-stats-funnel__step" data-step="<?php echo esc_attr( $step ); ?>"> | |
| 86 | + <span class="lp-stats-funnel__label"><?php echo esc_html( $label ); ?></span> | |
| 87 | + <span class="lp-stats-funnel__track"><span class="lp-stats-funnel__bar" style="width: 0;"></span></span> | |
| 88 | + <span class="lp-stats-funnel__count">–</span> | |
| 89 | + </div> | |
| 90 | + <?php endforeach; ?> | |
| 91 | + </div> | |
| 92 | + </div> | |
| 93 | + </div> | |
| 94 | + | |
| 95 | + <div class="lp-stats-overview-grid lp-stats-overview-grid--tables"> | |
| 96 | + <div class="lp-stats-section"> | |
| 97 | + <div class="lp-stats-section__header"> | |
| 98 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Top students', 'learnpress' ); ?></h3> | |
| 99 | + <button type="button" class="button-link lp-stats-section__action lp-stats-view-all-students"><?php esc_html_e( 'Open report', 'learnpress' ); ?></button> | |
| 100 | + </div> | |
| 101 | + <?php lp_skeleton_animation_html( 5, 100 ); ?> | |
| 102 | + <div class="lp-stats-table-top-students"></div> | |
| 103 | + </div> | |
| 104 | + | |
| 105 | + <div class="lp-stats-section"> | |
| 106 | + <div class="lp-stats-section__header"> | |
| 107 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Top courses by students', 'learnpress' ); ?></h3> | |
| 108 | + <button type="button" class="button-link lp-stats-section__action lp-stats-view-all-courses-by-students"><?php esc_html_e( 'Open report', 'learnpress' ); ?></button> | |
| 109 | + </div> | |
| 110 | + <?php lp_skeleton_animation_html( 5, 100 ); ?> | |
| 111 | + <div class="lp-stats-table-courses-by-students"></div> | |
| 112 | + </div> | |
| 113 | + </div> | |
| 46 | 114 | </div> |
| 47 | 115 | |
| 48 | - <script type="text/javascript"> | |
| 49 | - var LP_Chart_Config = <?php learn_press_config_chart(); ?>; | |
| 50 | - jQuery(document).ready(function ($) { | |
| 51 | - $('#learn-press-chart').LP_Chart_Line(<?php echo json_encode( learn_press_get_chart_users( null, 'days', 7 ) ); ?>, LP_Chart_Config); | |
| 52 | - }); | |
| 53 | - </script> | |
| 116 | + <?php | |
| 117 | + learn_press_admin_view( 'statistics/parts/report-modal' ); | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * Fires at the bottom of the Users statistics tab, inside the tab container. | |
| 121 | + * | |
| 122 | + * @since 4.4.2 | |
| 123 | + */ | |
| 124 | + do_action( 'learn-press/statistics/users/after' ); | |
| 125 | + ?> | |
| 54 | 126 | </div> |
| 55 | - | |