auto-patch 638-dev-dev01-2024-05-14T20_44_36
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Woo.com Product Installation.
|
||||
* WooCommerce.com Product Installation.
|
||||
*
|
||||
* @package WooCommerce\WCCom
|
||||
* @since 3.7.0
|
||||
@@ -11,7 +11,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
/**
|
||||
* WC_WCCOM_Site_Installer Class
|
||||
*
|
||||
* Contains functionalities to install products via Woo.com helper connection.
|
||||
* Contains functionalities to install products via WooCommerce.com helper connection.
|
||||
*/
|
||||
class WC_WCCOM_Site_Installer {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Woo.com Product Installation.
|
||||
* WooCommerce.com Product Installation.
|
||||
*
|
||||
* @package WooCommerce\WCCom
|
||||
* @since 3.7.0
|
||||
@@ -14,7 +14,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
/**
|
||||
* WC_WCCOM_Site Class
|
||||
*
|
||||
* Main class for Woo.com connected site.
|
||||
* Main class for WooCommerce.com connected site.
|
||||
*/
|
||||
class WC_WCCOM_Site {
|
||||
|
||||
@@ -44,7 +44,7 @@ class WC_WCCOM_Site {
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate Woo.com request.
|
||||
* Authenticate WooCommerce.com request.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @param int|false $user_id User ID.
|
||||
@@ -183,7 +183,7 @@ class WC_WCCOM_Site {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify Woo.com request from a given body and signature request.
|
||||
* Verify WooCommerce.com request from a given body and signature request.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @param string $body Request body.
|
||||
@@ -223,6 +223,7 @@ class WC_WCCOM_Site {
|
||||
require_once WC_ABSPATH . 'includes/wccom-site/rest-api/endpoints/abstract-wc-rest-wccom-site-controller.php';
|
||||
require_once WC_ABSPATH . 'includes/wccom-site/rest-api/endpoints/class-wc-rest-wccom-site-installer-controller.php';
|
||||
require_once WC_ABSPATH . 'includes/wccom-site/rest-api/endpoints/class-wc-rest-wccom-site-ssr-controller.php';
|
||||
require_once WC_ABSPATH . 'includes/wccom-site/rest-api/endpoints/class-wc-rest-wccom-site-status-controller.php';
|
||||
|
||||
require_once WC_ABSPATH . 'includes/wccom-site/installation/class-wc-wccom-site-installation-state.php';
|
||||
require_once WC_ABSPATH . 'includes/wccom-site/installation/class-wc-wccom-site-installation-state-storage.php';
|
||||
@@ -238,6 +239,7 @@ class WC_WCCOM_Site {
|
||||
$namespaces['wccom-site/v2'] = array(
|
||||
'installer' => 'WC_REST_WCCOM_Site_Installer_Controller',
|
||||
'ssr' => 'WC_REST_WCCOM_Site_SSR_Controller',
|
||||
'status' => 'WC_REST_WCCOM_Site_Status_Controller',
|
||||
);
|
||||
|
||||
return $namespaces;
|
||||
|
||||
@@ -40,7 +40,7 @@ class WC_WCCOM_Site_Installation_Step_Get_Product_Info implements WC_WCCOM_Site_
|
||||
public function run() {
|
||||
$product_id = $this->state->get_product_id();
|
||||
|
||||
// Get product info from Woo.com.
|
||||
// Get product info from WooCommerce.com.
|
||||
$request = WC_Helper_API::get(
|
||||
add_query_arg(
|
||||
array( 'product_id' => $product_id ),
|
||||
|
||||
@@ -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