← All changes
|
inc/TemplateHooks/Admin/AdminStatisticsReportTable.php
+36
-1
4.4.4
→
4.4.8
View file →
| @@ -35,9 +35,9 @@ | ||
| 35 | 35 | use Singleton; |
| 36 | 36 | |
| 37 | 37 | const PER_PAGE = 20; |
| 38 | 38 | |
| 39 | - public function init() { | |
| 39 | + public function init(): void { | |
| 40 | 40 | add_filter( 'lp/rest/ajax/allow_callback', array( $this, 'allow_callback' ) ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
| @@ -50,8 +50,43 @@ | ||
| 50 | 50 | $callbacks[] = self::class . ':render_report_table'; |
| 51 | 51 | $callbacks[] = self::class . ':render_report_csv'; |
| 52 | 52 | |
| 53 | 53 | return $callbacks; |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Tabs of the Statistics page. | |
| 58 | + * | |
| 59 | + * @return array | |
| 60 | + */ | |
| 61 | + private static function get_tabs(): array { | |
| 62 | + return array( | |
| 63 | + 'overview' => __( 'Overview', 'learnpress' ), | |
| 64 | + 'orders' => __( 'Orders', 'learnpress' ), | |
| 65 | + 'courses' => __( 'Courses', 'learnpress' ), | |
| 66 | + 'users' => __( 'Users', 'learnpress' ), | |
| 67 | + 'instructors' => __( 'Instructors', 'learnpress' ), | |
| 68 | + ); | |
| 69 | + } | |
| 70 | + | |
| 71 | + public function html_statistics() { | |
| 72 | + $tabs = self::get_tabs(); | |
| 73 | + $tab = isset( $_REQUEST['tab'] ) ? LP_Helper::sanitize_params_submitted( $_REQUEST['tab'] ) : 'overview'; | |
| 74 | + $tab = array_key_exists( $tab, $tabs ) ? $tab : 'overview'; | |
| 75 | + | |
| 76 | + $view = "statistics/{$tab}"; | |
| 77 | + ob_start(); | |
| 78 | + learn_press_admin_view( $view ); | |
| 79 | + $content = ob_get_clean(); | |
| 80 | + | |
| 81 | + echo AdminTemplate::html_on_wp_admin_screen( | |
| 82 | + array( | |
| 83 | + 'tabs' => $tabs, | |
| 84 | + 'content' => $content, | |
| 85 | + 'title' => __( 'Statistics', 'learnpress' ), | |
| 86 | + 'id' => 'learn-press-statistics', | |
| 87 | + ) | |
| 88 | + ); | |
| 54 | 89 | } |
| 55 | 90 | |
| 56 | 91 | /** |
| 57 | 92 | * Row cap for the PHP-merged reports (top_courses / course_performance / |