LLMS_Analytics_Enrollments_Widget
Source Source
File: includes/admin/reporting/widgets/class.llms.analytics.widget.enrollments.php
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | class LLMS_Analytics_Enrollments_Widget extends LLMS_Analytics_Widget { public $charts = true; protected function get_chart_data() { return array ( 'type' => 'count' , // Type of field. 'header' => array ( 'id' => 'enrollments' , 'label' => __( '# of Enrollments' , 'lifterlms' ), 'type' => 'number' , ), ); } public function set_query() { global $wpdb ; $dates = $this ->get_posted_dates(); $student_ids = '' ; $students = $this ->get_posted_students(); if ( $students ) { $student_ids .= 'AND user_id IN ( ' . implode( ', ' , $students ) . ' )' ; } $product_ids = '' ; $products = $this ->get_posted_posts(); if ( $products ) { $product_ids .= 'AND post_id IN ( ' . implode( ', ' , $products ) . ' )' ; } $this ->query_function = 'get_results' ; $this ->output_type = OBJECT; $this ->query = "SELECT updated_date AS date FROM { $wpdb ->prefix}lifterlms_user_postmeta WHERE meta_key = '_status' AND ( meta_value = 'Enrolled' OR meta_value = 'enrolled' ) AND updated_date BETWEEN CAST( %s AS DATETIME ) AND CAST( %s AS DATETIME ) { $student_ids } { $product_ids } ;"; $this ->query_vars = array ( $this ->format_date( $dates [ 'start' ], 'start' ), $this ->format_date( $dates [ 'end' ], 'end' ), ); } protected function format_response() { if ( ! $this ->is_error() ) { return count ( $this ->get_results() ); } } } |
Expand full source code Collapse full source code View on GitHub
Methods Methods
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |