[ 'label' => esc_html__( 'LearnPress order status', 'learnpress' ), 'callback' => [ $this, 'order_statuses' ], ], 'learn_press_dashboard_plugin_status' => [ 'label' => esc_html__( 'LearnPress status', 'learnpress' ), 'callback' => [ $this, 'plugin_status' ], ], ]; foreach ( $screens as $id => $screen ) { wp_add_dashboard_widget( $id, $screen['label'], $screen['callback'] ); } } /** * Order status widget */ public function order_statuses() { $args = [ 'id_url' => 'order-statistic-dashboard', ]; /** * @uses order_statistic */ $callback = [ 'class' => self::class, 'method' => 'order_statistic', ]; echo TemplateAJAX::load_content_via_ajax( $args, $callback ); } /** * Get order statistic content * * @return stdClass */ public static function order_statistic(): stdClass { // Check permission if ( ! current_user_can( UserModel::ROLE_ADMINISTRATOR ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'learnpress' ) ); } $order_statuses = LP_Order::get_order_statuses(); $lp_order_icons = LP_Order::get_icons_status(); ob_start(); $data = compact( 'order_statuses', 'lp_order_icons' ); Template::instance()->get_admin_template( 'dashboard/html-orders', $data ); $content = new stdClass(); $content->content = sprintf( '