auto-patch 638-dev-dev01-2024-05-14T20_44_36
This commit is contained in:
@@ -47,7 +47,7 @@ class WC_REST_WCCOM_Site_Installer_Error_Codes {
|
||||
self::NOT_AUTHENTICATED => 'Authentication required',
|
||||
self::NO_ACCESS_TOKEN => 'No access token provided',
|
||||
self::NO_SIGNATURE => 'No signature provided',
|
||||
self::SITE_NOT_CONNECTED => 'Site not connected to Woo.com',
|
||||
self::SITE_NOT_CONNECTED => 'Site not connected to WooCommerce.com',
|
||||
self::INVALID_TOKEN => 'Invalid access token provided',
|
||||
self::REQUEST_VERIFICATION_FAILED => 'Request verification by signature failed',
|
||||
self::USER_NOT_FOUND => 'Token owning user not found',
|
||||
@@ -60,8 +60,8 @@ class WC_REST_WCCOM_Site_Installer_Error_Codes {
|
||||
self::INSTALLATION_ALREADY_RUNNING => 'The installation of the plugin is already running',
|
||||
self::INSTALLATION_FAILED => 'The installation of the plugin failed',
|
||||
self::FILESYSTEM_REQUIREMENTS_NOT_MET => 'The filesystem requirements are not met',
|
||||
self::FAILED_GETTING_PRODUCT_INFO => 'Failed to retrieve product info from Woo.com',
|
||||
self::INVALID_PRODUCT_INFO_RESPONSE => 'Invalid product info response from Woo.com',
|
||||
self::FAILED_GETTING_PRODUCT_INFO => 'Failed to retrieve product info from WooCommerce.com',
|
||||
self::INVALID_PRODUCT_INFO_RESPONSE => 'Invalid product info response from WooCommerce.com',
|
||||
self::WCCOM_PRODUCT_MISSING_SUBSCRIPTION => 'Product subscription is missing',
|
||||
self::WCCOM_PRODUCT_MISSING_PACKAGE => 'Could not find product package',
|
||||
self::MISSING_DOWNLOAD_PATH => 'Download path is missing',
|
||||
|
||||
@@ -95,7 +95,7 @@ class WC_REST_WCCOM_Site_Installer_Controller extends WC_REST_WCCOM_Site_Control
|
||||
}
|
||||
|
||||
/**
|
||||
* Install Woo.com products.
|
||||
* Install WooCommerce.com products.
|
||||
*
|
||||
* @since 7.7.0
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
|
||||
@@ -66,7 +66,7 @@ class WC_REST_WCCOM_Site_SSR_Controller extends WC_REST_WCCOM_Site_Controller {
|
||||
$data = $ssr_controller->get_items( $request );
|
||||
$data = $data->get_data();
|
||||
|
||||
// Submit SSR data to Woo.com.
|
||||
// Submit SSR data to WooCommerce.com.
|
||||
$request = WC_Helper_API::post(
|
||||
'ssr',
|
||||
array(
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* WCCOM Site Status REST API Controller
|
||||
*
|
||||
* Handle requests to /status.
|
||||
*
|
||||
* @package WooCommerce\WCCom\API
|
||||
* @since 8.7.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* REST API WCCOM Site Status Controller Class.
|
||||
*
|
||||
* @extends WC_REST_WCCOM_Site_Status_Controller
|
||||
*/
|
||||
class WC_REST_WCCOM_Site_Status_Controller extends WC_REST_WCCOM_Site_Controller {
|
||||
|
||||
|
||||
/**
|
||||
* Route base.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rest_base = 'status';
|
||||
|
||||
/**
|
||||
* Register the routes for Site Status Controller.
|
||||
*
|
||||
* @since 8.7.0
|
||||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'handle_status_request' ),
|
||||
'permission_callback' => array( $this, 'check_permission' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether user has permission to access controller's endpoints.
|
||||
*
|
||||
* @since 8.7.0
|
||||
* @param WP_USER $user User object.
|
||||
* @return bool
|
||||
*/
|
||||
public function user_has_permission( $user ): bool {
|
||||
return user_can( $user, 'install_plugins' ) && user_can( $user, 'activate_plugins' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status details of the site.
|
||||
*
|
||||
* @since 8.7.0
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return WP_REST_Response
|
||||
*/
|
||||
public function handle_status_request( $request ) {
|
||||
|
||||
return rest_ensure_response(
|
||||
array(
|
||||
'success' => true,
|
||||
'data' => array(
|
||||
'wc_version' => WC()->version,
|
||||
'woo_update_manager_installed' => WC_Woo_Update_Manager_Plugin::is_plugin_installed(),
|
||||
'woo_update_manager_active' => WC_Woo_Update_Manager_Plugin::is_plugin_active(),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user