PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.3
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / rest-api / v1 / frontend / class-lp-rest-orders-controller.php

class-lp-rest-orders-controller.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7.3, at inc/rest-api/v1/frontend/class-lp-rest-orders-controller.php

50 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class LP_REST_Orders_Controller extends LP_Abstract_REST_Controller {
3 public function __construct() {
4 $this->namespace = 'lp/v1';
5 $this->rest_base = 'orders';
6
7 parent::__construct();
8 }
9
10 public function register_routes() {
11 $this->routes = array(
12 'statistic' => array(
13 array(
14 'methods' => WP_REST_Server::READABLE,
15 'callback' => array( $this, 'statistic' ),
16 'permission_callback' => '__return_true',
17 ),
18 ),
19 );
20
21 parent::register_routes();
22 }
23
24 public function statistic( WP_REST_Request $request ) {
25
26 $response = new LP_REST_Response();
27 $response->data = '';
28
29 $order_statuses = learn_press_get_order_statuses( true, true );
30 $specific_statuses = array( 'lp-completed', 'lp-failed' );
31
32 foreach ( $order_statuses as $status ) {
33 if ( ! in_array( $status, $specific_statuses ) ) {
34 $specific_statuses[] = $status;
35 }
36 }
37
38 try {
39 $response->data = learn_press_get_template_content( 'admin/views/dashboard/html-orders', compact( 'specific_statuses' ), '', LP_PLUGIN_PATH . 'inc/' );
40 $response->status = 'success';
41
42 } catch ( Exception $e ) {
43 $response->message = $e->getMessage();
44 }
45
46 return rest_ensure_response( $response );
47 }
48
49 }
50