| Current Path : /home/krobertfnz/www/wp-content/plugins/wpmudev-updates/includes/endpoints/ |
| Current File : /home/krobertfnz/www/wp-content/plugins/wpmudev-updates/includes/endpoints/class-free-plugins.php |
<?php
/**
* Plugins functionality REST endpoint.
*
* @link http://wpmudev.com
* @since 5.0.0
* @author Hendrawan Kuncoro <hendrawan.kuncoro@incsub.com>
* @package WPMUDEV\Dashboard\Endpoints
*/
namespace WPMUDEV\Dashboard\Endpoints;
// If this file is called directly, abort.
defined( 'WPINC' ) || die;
use WP_REST_Request;
use WP_REST_Response;
use WP_REST_Server;
use WPMUDEV_Dashboard;
/**
* Class Plugins
*/
class Free_Plugins extends Endpoint {
/**
* API endpoint for the current endpoint.
*
* @since 5.0.0
* @var string $endpoint
*/
private string $endpoint = '/free-plugins';
/**
* Register the routes for handling settings functionality.
*
* @since 5.0.0
*
* @return void
*/
public function register_routes() {
// Plugin list.
register_rest_route(
$this->get_namespace(),
$this->endpoint,
array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'permissions_check' ),
),
)
);
}
/**
* Get the list of installed WPMU DEV free plugins (wp.org stuff)
*
* @since 5.0.0
*
* @param WP_REST_Request $request Request object.
*
* @return WP_REST_Response
*/
public function get_items( WP_REST_Request $request ): WP_REST_Response {
$free_plugins = WPMUDEV_Dashboard::$site->get_installed_free_projects();
return $this->get_response( $free_plugins );
}
}