* Internalize all WooCommerce Admin main API controllers

* Internalize all report and report stat controllers

* Make function public and label as internal to fix PHP unit tests

* Add changelog
This commit is contained in:
louwie17 2022-03-16 14:46:48 -03:00 committed by GitHub
parent 3f3f25f4b7
commit b2e83899b3
56 changed files with 117 additions and 35 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: Dev
Internalize our API controllers by using the @internal jsdoc. #8429

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Coupons controller.
*
* @internal
* @extends WC_REST_Coupons_Controller
*/
class Coupons extends \WC_REST_Coupons_Controller {
@ -72,6 +73,7 @@ class Coupons extends \WC_REST_Coupons_Controller {
/**
* Add code searching to the WP Query
*
* @internal
* @param string $where Where clause used to search posts.
* @param object $wp_query WP_Query object.
* @return string

View File

@ -9,11 +9,14 @@ defined( 'ABSPATH' ) || exit;
/**
* CustomAttributeTraits class.
*
* @internal
*/
trait CustomAttributeTraits {
/**
* Get a single attribute by its slug.
*
* @internal
* @param string $slug The attribute slug.
* @return WP_Error|object The matching attribute object or WP_Error if not found.
*/

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Customers controller.
*
* @internal
* @extends \Automattic\WooCommerce\Admin\API\Reports\Customers\Controller
*/
class Customers extends \Automattic\WooCommerce\Admin\API\Reports\Customers\Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Data controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class Data extends \WC_REST_Data_Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* REST API Data countries controller class.
*
* @internal
* @extends WC_REST_Data_Countries_Controller
*/
class DataCountries extends \WC_REST_Data_Countries_Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Data Download IP controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class DataDownloadIPs extends \WC_REST_Data_Controller {

View File

@ -14,6 +14,7 @@ use Automattic\WooCommerce\Admin\Features\Features as FeaturesClass;
/**
* Features Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class Features extends \WC_REST_Data_Controller {

View File

@ -13,6 +13,8 @@ use \Automattic\WooCommerce\Internal\Admin\Loader;
/**
* Init class.
*
* @internal
*/
class Init {
/**
@ -129,6 +131,7 @@ class Init {
/**
* Adds data stores.
*
* @internal
* @param array $data_stores List of data stores.
* @return array
*/
@ -162,6 +165,7 @@ class Init {
* Add the currency symbol (in addition to currency code) to each Order
* object in REST API responses. For use in formatAmount().
*
* @internal
* @param {WP_REST_Response} $response REST response object.
* @returns {WP_REST_Response}
*/

View File

@ -17,6 +17,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\Products\DataStore as ProductsData
/**
* Leaderboards controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class Leaderboards extends \WC_REST_Data_Controller {
@ -74,7 +75,7 @@ class Leaderboards extends \WC_REST_Data_Controller {
* @param string $before Items before date.
* @param string $persisted_query URL query string.
*/
public function get_coupons_leaderboard( $per_page, $after, $before, $persisted_query ) {
protected function get_coupons_leaderboard( $per_page, $after, $before, $persisted_query ) {
$coupons_data_store = new CouponsDataStore();
$coupons_data = $per_page > 0 ? $coupons_data_store->get_data(
apply_filters(
@ -143,7 +144,7 @@ class Leaderboards extends \WC_REST_Data_Controller {
* @param string $before Items before date.
* @param string $persisted_query URL query string.
*/
public function get_categories_leaderboard( $per_page, $after, $before, $persisted_query ) {
protected function get_categories_leaderboard( $per_page, $after, $before, $persisted_query ) {
$categories_data_store = new CategoriesDataStore();
$categories_data = $per_page > 0 ? $categories_data_store->get_data(
apply_filters(
@ -212,7 +213,7 @@ class Leaderboards extends \WC_REST_Data_Controller {
* @param string $before Items before date.
* @param string $persisted_query URL query string.
*/
public function get_customers_leaderboard( $per_page, $after, $before, $persisted_query ) {
protected function get_customers_leaderboard( $per_page, $after, $before, $persisted_query ) {
$customers_data_store = new CustomersDataStore();
$customers_data = $per_page > 0 ? $customers_data_store->get_data(
apply_filters(
@ -279,7 +280,7 @@ class Leaderboards extends \WC_REST_Data_Controller {
* @param string $before Items before date.
* @param string $persisted_query URL query string.
*/
public function get_products_leaderboard( $per_page, $after, $before, $persisted_query ) {
protected function get_products_leaderboard( $per_page, $after, $before, $persisted_query ) {
$products_data_store = new ProductsDataStore();
$products_data = $per_page > 0 ? $products_data_store->get_data(
apply_filters(

View File

@ -15,6 +15,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Marketing Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class Marketing extends \WC_REST_Data_Controller {

View File

@ -15,6 +15,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Marketing Overview Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class MarketingOverview extends \WC_REST_Data_Controller {

View File

@ -14,6 +14,7 @@ use Automattic\WooCommerce\Admin\Features\Navigation\Favorites;
/**
* REST API Favorites controller class.
*
* @internal
* @extends WC_REST_CRUD_Controller
*/
class NavigationFavorites extends \WC_REST_Data_Controller {

View File

@ -15,6 +15,7 @@ use \Automattic\WooCommerce\Admin\Notes\Notes as NotesFactory;
/**
* REST API Admin Note Action controller class.
*
* @internal
* @extends WC_REST_CRUD_Controller
*/
class NoteActions extends Notes {

View File

@ -15,6 +15,7 @@ use Automattic\WooCommerce\Admin\Notes\Notes as NotesRepository;
/**
* REST API Admin Notes controller class.
*
* @internal
* @extends WC_REST_CRUD_Controller
*/
class Notes extends \WC_REST_CRUD_Controller {
@ -399,7 +400,7 @@ class Notes extends \WC_REST_CRUD_Controller {
* @param WP_REST_Request $request Request object.
* @return array A list of the requested updates values.
*/
public function get_requested_updates( $request ) {
protected function get_requested_updates( $request ) {
$requested_updates = array();
if ( ! is_null( $request->get_param( 'status' ) ) ) {
$requested_updates['status'] = $request->get_param( 'status' );
@ -420,17 +421,6 @@ class Notes extends \WC_REST_CRUD_Controller {
return $requested_updates;
}
/**
* Batch update a set of notes.
*
* @param WP_REST_Request $request Request object.
* @return WP_REST_Request|WP_Error
*/
public function undoremove_items( $request ) {
wc_deprecated_function( 'undoremove_items', '4.4', '\Automattic\WooCommerce\Admin\API\Notes()->undoremove_items' );
return self::batch_update_items( $request );
}
/**
* Batch update a set of notes.
*

View File

@ -14,6 +14,7 @@ use Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions\Init as RemoteFre
/**
* Onboarding Payments Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class OnboardingFreeExtensions extends \WC_REST_Data_Controller {

View File

@ -14,6 +14,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Onboarding Product Types Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class OnboardingProductTypes extends \WC_REST_Data_Controller {

View File

@ -15,6 +15,7 @@ use \Automattic\Jetpack\Connection\Manager as Jetpack_Connection_Manager;
/**
* Onboarding Profile controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class OnboardingProfile extends \WC_REST_Data_Controller {
@ -137,7 +138,7 @@ class OnboardingProfile extends \WC_REST_Data_Controller {
* @param array $industries list of industries.
* @return array
*/
public function filter_industries( $industries ) {
protected function filter_industries( $industries ) {
return apply_filters(
'woocommerce_admin_onboarding_industries',
$industries

View File

@ -17,6 +17,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Onboarding Tasks Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class OnboardingTasks extends \WC_REST_Data_Controller {
@ -334,6 +335,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Import sample products from WooCommerce sample CSV.
*
* @internal
* @return WP_Error|WP_REST_Response
*/
public static function import_sample_products() {
@ -347,6 +349,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Creates a product from a template name passed in through the template_name param.
*
* @internal
* @param WP_REST_Request $request Request data.
* @return WP_REST_Response|WP_Error
*/
@ -380,6 +383,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Get header mappings from CSV columns.
*
* @internal
* @param string $file File path.
* @return array Mapped headers.
*/
@ -415,6 +419,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Sanitize special column name regex.
*
* @internal
* @param string $value Raw special column name.
* @return string
*/
@ -425,6 +430,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Returns a valid cover block with an image, if one exists, or background as a fallback.
*
* @internal
* @param array $image Image to use for the cover block. Should contain a media ID and image URL.
* @return string Block content.
*/
@ -464,6 +470,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Returns a valid media block with an image, if one exists, or a uninitialized media block the user can set.
*
* @internal
* @param array $image Image to use for the cover block. Should contain a media ID and image URL.
* @param string $align If the image should be aligned to the left or right.
* @return string Block content.
@ -490,6 +497,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Returns a homepage template to be inserted into a post. A different template will be used depending on the number of products.
*
* @internal
* @param int $post_id ID of the homepage template.
* @return string Template contents.
*/
@ -555,6 +563,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Gets the possible industry images from the plugin folder for sideloading. If an image doesn't exist, other.jpg is used a fallback.
*
* @internal
* @return array An array of images by industry.
*/
private static function get_available_homepage_images() {
@ -569,6 +578,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
/**
* Uploads a number of images to a homepage template, depending on the selected industry from the profile wizard.
*
* @internal
* @param int $post_id ID of the homepage template.
* @param int $number_of_images The number of images that should be sideloaded (depending on how many media slots are in the template).
* @return array An array of images that have been attached to the post.

View File

@ -14,6 +14,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Onboarding Themes Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class OnboardingThemes extends \WC_REST_Data_Controller {

View File

@ -14,6 +14,7 @@ use Automattic\WooCommerce\Admin\API\Reports\Controller as ReportsController;
/**
* Orders controller.
*
* @internal
* @extends WC_REST_Orders_Controller
*/
class Orders extends \WC_REST_Orders_Controller {

View File

@ -14,6 +14,7 @@ defined( 'ABSPATH' ) || exit;
/**
* PaymentGatewaySuggetsions Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class PaymentGatewaySuggestions extends \WC_REST_Data_Controller {

View File

@ -16,6 +16,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Plugins Controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class Plugins extends \WC_REST_Data_Controller {
@ -309,6 +310,7 @@ class Plugins extends \WC_REST_Data_Controller {
/**
* Returns a list of active plugins.
*
* @internal
* @return array Active plugins
*/
public static function get_active_plugins() {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Product attribute terms controller.
*
* @internal
* @extends WC_REST_Product_Attribute_Terms_Controller
*/
class ProductAttributeTerms extends \WC_REST_Product_Attribute_Terms_Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Product categories controller.
*
* @internal
* @extends WC_REST_Product_Attributes_Controller
*/
class ProductAttributes extends \WC_REST_Product_Attributes_Controller {
@ -107,7 +108,7 @@ class ProductAttributes extends \WC_REST_Product_Attributes_Controller {
* @param array $custom_attributes - CustomAttributeTraits::get_custom_attributes().
* @return array
*/
public function format_custom_attribute_items_for_response( $custom_attributes ) {
protected function format_custom_attribute_items_for_response( $custom_attributes ) {
$response = array();
foreach ( $custom_attributes as $attribute_key => $attribute_value ) {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Product categories controller.
*
* @internal
* @extends WC_REST_Product_Categories_Controller
*/
class ProductCategories extends \WC_REST_Product_Categories_Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Product reviews controller.
*
* @internal
* @extends WC_REST_Product_Reviews_Controller
*/
class ProductReviews extends \WC_REST_Product_Reviews_Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Product variations controller.
*
* @internal
* @extends WC_REST_Product_Variations_Controller
*/
class ProductVariations extends \WC_REST_Product_Variations_Controller {
@ -62,6 +63,7 @@ class ProductVariations extends \WC_REST_Product_Variations_Controller {
/**
* Add in conditional search filters for variations.
*
* @internal
* @param string $where Where clause used to search posts.
* @param object $wp_query WP_Query object.
* @return string
@ -90,6 +92,7 @@ class ProductVariations extends \WC_REST_Product_Variations_Controller {
/**
* Join posts meta tables when variation search query is present.
*
* @internal
* @param string $join Join clause used to search posts.
* @param object $wp_query WP_Query object.
* @return string

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Products controller.
*
* @internal
* @extends WC_REST_Products_Controller
*/
class Products extends \WC_REST_Products_Controller {
@ -207,6 +208,7 @@ class Products extends \WC_REST_Products_Controller {
/**
* Add in conditional select fields to the query.
*
* @internal
* @param string $select Select clause used to select fields from the query.
* @param object $wp_query WP_Query object.
* @return string
@ -226,6 +228,7 @@ class Products extends \WC_REST_Products_Controller {
/**
* Add in conditional search filters for products.
*
* @internal
* @param string $where Where clause used to search posts.
* @param object $wp_query WP_Query object.
* @return string
@ -265,6 +268,7 @@ class Products extends \WC_REST_Products_Controller {
/**
* Join posts meta tables when product search or low stock query is present.
*
* @internal
* @param string $join Join clause used to search posts.
* @param object $wp_query WP_Query object.
* @return string
@ -294,6 +298,7 @@ class Products extends \WC_REST_Products_Controller {
/**
* Join wc_product_meta_lookup to posts if not already joined.
*
* @internal
* @param string $sql SQL join.
* @return string
*/
@ -309,6 +314,7 @@ class Products extends \WC_REST_Products_Controller {
/**
* Group by post ID to prevent duplicates.
*
* @internal
* @param string $groupby Group by clause used to organize posts.
* @param object $wp_query WP_Query object.
* @return string

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* ProductsLowInStock controller.
*
* @internal
* @extends WC_REST_Products_Controller
*/
final class ProductsLowInStock extends \WC_REST_Products_Controller {

View File

@ -15,6 +15,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableInterface;
/**
* REST API Reports categories controller class.
*
* @internal
* @extends \Automattic\WooCommerce\Admin\API\Reports\Controller
*/
class Controller extends ReportsController implements ExportableInterface {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* REST API Reports controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {
@ -187,7 +188,7 @@ class Controller extends \WC_REST_Reports_Controller {
* @param int $order_id Order ID.
* @return string
*/
public function get_order_number( $order_id ) {
protected function get_order_number( $order_id ) {
$order = wc_get_order( $order_id );
if ( ! $order instanceof \WC_Order && ! $order instanceof \WC_Order_Refund ) {
@ -212,7 +213,7 @@ class Controller extends \WC_REST_Reports_Controller {
* @param int $order_id Order ID.
* @return string
*/
public function get_total_formatted( $order_id ) {
protected function get_total_formatted( $order_id ) {
$order = wc_get_order( $order_id );
if ( ! $order instanceof \WC_Order && ! $order instanceof \WC_Order_Refund ) {
@ -322,6 +323,7 @@ class Controller extends \WC_REST_Reports_Controller {
* Get order statuses without prefixes.
* Includes unregistered statuses that have been marked "actionable".
*
* @internal
* @return array
*/
public static function get_order_statuses() {
@ -341,6 +343,7 @@ class Controller extends \WC_REST_Reports_Controller {
/**
* Get order statuses (and labels) without prefixes.
*
* @internal
* @return array
*/
public static function get_order_status_labels() {

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableInterface;
/**
* REST API Reports coupons controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller implements ExportableInterface {

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ParameterException;
/**
* REST API Reports coupons stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {

View File

@ -16,6 +16,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\TimeInterval;
/**
* REST API Reports customers controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller implements ExportableInterface {

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\TimeInterval;
/**
* REST API Reports customers stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {

View File

@ -15,6 +15,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableInterface;
/**
* REST API Reports downloads controller class.
*
* @internal
* @extends Automattic\WooCommerce\Admin\API\Reports\Controller
*/
class Controller extends ReportsController implements ExportableInterface {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* REST API Reports downloads files controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* REST API Reports downloads stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {

View File

@ -16,6 +16,7 @@ use \Automattic\WooCommerce\Admin\ReportExporter;
/**
* Reports Export controller.
*
* @internal
* @extends \Automattic\WooCommerce\Admin\API\Reports\Controller
*/
class Controller extends \Automattic\WooCommerce\Admin\API\Reports\Controller {
@ -70,7 +71,7 @@ class Controller extends \Automattic\WooCommerce\Admin\API\Reports\Controller {
*
* @return array
*/
public function get_export_collection_params() {
protected function get_export_collection_params() {
$params = array();
$params['report_args'] = array(
'description' => __( 'Parameters to pass on to the exported report.', 'woocommerce-admin' ),

View File

@ -14,6 +14,7 @@ use Automattic\WooCommerce\Admin\ReportsSync;
/**
* Reports Imports controller.
*
* @internal
* @extends \Automattic\WooCommerce\Admin\API\Reports\Controller
*/
class Controller extends \Automattic\WooCommerce\Admin\API\Reports\Controller {

View File

@ -15,6 +15,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableInterface;
/**
* REST API Reports orders controller class.
*
* @internal
* @extends \Automattic\WooCommerce\Admin\API\Reports\Controller
*/
class Controller extends ReportsController implements ExportableInterface {
@ -498,7 +499,7 @@ class Controller extends ReportsController implements ExportableInterface {
* @param array $products Products from report row.
* @return string
*/
protected function _get_products( $products ) {
protected function get_products( $products ) {
$products_list = array();
foreach ( $products as $product ) {
@ -519,7 +520,7 @@ class Controller extends ReportsController implements ExportableInterface {
* @param array $coupons Coupons from report row.
* @return string
*/
protected function _get_coupons( $coupons ) {
protected function get_coupons( $coupons ) {
return implode( ', ', wp_list_pluck( $coupons, 'code' ) );
}
@ -568,9 +569,9 @@ class Controller extends ReportsController implements ExportableInterface {
'status' => $item['status'],
'customer_name' => isset( $item['extended_info']['customer'] ) ? $this->get_customer_name( $item['extended_info']['customer'] ) : null,
'customer_type' => $item['customer_type'],
'products' => isset( $item['extended_info']['products'] ) ? $this->_get_products( $item['extended_info']['products'] ) : null,
'products' => isset( $item['extended_info']['products'] ) ? $this->get_products( $item['extended_info']['products'] ) : null,
'num_items_sold' => $item['num_items_sold'],
'coupons' => isset( $item['extended_info']['coupons'] ) ? $this->_get_coupons( $item['extended_info']['coupons'] ) : null,
'coupons' => isset( $item['extended_info']['coupons'] ) ? $this->get_coupons( $item['extended_info']['coupons'] ) : null,
'net_total' => $item['net_total'],
);

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ParameterException;
/**
* REST API Reports orders stats controller class.
*
* @internal
* @extends \Automattic\WooCommerce\Admin\API\Reports\Controller
*/
class Controller extends \Automattic\WooCommerce\Admin\API\Reports\Controller {

View File

@ -14,6 +14,7 @@ defined( 'ABSPATH' ) || exit;
/**
* REST API Reports Performance indicators controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {
@ -131,7 +132,7 @@ class Controller extends \WC_REST_Reports_Controller {
/**
* Get analytics report data and endpoints.
*/
public function get_analytics_report_data() {
private function get_analytics_report_data() {
$request = new \WP_REST_Request( 'GET', '/wc-analytics/reports' );
$response = rest_do_request( $request );
@ -185,7 +186,7 @@ class Controller extends \WC_REST_Reports_Controller {
*
* @return array List of active Jetpack module slugs.
*/
public function get_active_jetpack_modules() {
private function get_active_jetpack_modules() {
if ( is_null( $this->active_jetpack_modules ) ) {
if ( class_exists( '\Jetpack' ) && method_exists( '\Jetpack', 'get_active_modules' ) ) {
$active_modules = \Jetpack::get_active_modules();
@ -201,6 +202,7 @@ class Controller extends \WC_REST_Reports_Controller {
/**
* Set active Jetpack modules.
*
* @internal
* @param array $modules List of active Jetpack module slugs.
*/
public function set_active_jetpack_modules( $modules ) {
@ -210,7 +212,7 @@ class Controller extends \WC_REST_Reports_Controller {
/**
* Get active Jetpack modules and endpoints.
*/
public function get_jetpack_modules_data() {
private function get_jetpack_modules_data() {
$active_modules = $this->get_active_jetpack_modules();
if ( empty( $active_modules ) ) {
@ -316,6 +318,7 @@ class Controller extends \WC_REST_Reports_Controller {
/**
* Sorts the list of stats. Sorted by custom arrangement.
*
* @internal
* @see https://github.com/woocommerce/woocommerce-admin/issues/1282
* @param object $a First item.
* @param object $b Second item.
@ -368,7 +371,7 @@ class Controller extends \WC_REST_Reports_Controller {
* @param array $query_args Report query args.
* @return WP_REST_Response|WP_Error Report stats data.
*/
public function get_stats_data( $report, $query_args ) {
private function get_stats_data( $report, $query_args ) {
// Return from cache if we've already requested these report stats.
if ( isset( $this->stats_data[ $report ] ) ) {
return $this->stats_data[ $report ];

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableInterface;
/**
* REST API Reports products controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller implements ExportableInterface {
@ -354,7 +355,7 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
* @param array $status Stock status from report row.
* @return string
*/
protected function _get_stock_status( $status ) {
protected function get_stock_status( $status ) {
$statuses = wc_get_product_stock_status_options();
return isset( $statuses[ $status ] ) ? $statuses[ $status ] : '';
@ -366,7 +367,7 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
* @param array $category_ids Category IDs from report row.
* @return string
*/
protected function _get_categories( $category_ids ) {
protected function get_categories( $category_ids ) {
$category_names = get_terms(
array(
'taxonomy' => 'product_cat',
@ -424,13 +425,13 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
'items_sold' => $item['items_sold'],
'net_revenue' => $item['net_revenue'],
'orders_count' => $item['orders_count'],
'product_cat' => $this->_get_categories( $item['extended_info']['category_ids'] ),
'product_cat' => $this->get_categories( $item['extended_info']['category_ids'] ),
'variations' => isset( $item['extended_info']['variations'] ) ? count( $item['extended_info']['variations'] ) : 0,
);
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
if ( $item['extended_info']['manage_stock'] ) {
$export_item['stock_status'] = $this->_get_stock_status( $item['extended_info']['stock_status'] );
$export_item['stock_status'] = $this->get_stock_status( $item['extended_info']['stock_status'] );
$export_item['stock'] = $item['extended_info']['stock_quantity'];
} else {
$export_item['stock_status'] = __( 'N/A', 'woocommerce-admin' );

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ParameterException;
/**
* REST API Reports products stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {
@ -284,6 +285,7 @@ class Controller extends \WC_REST_Reports_Controller {
/**
* Set the default results to 0 if API returns an empty array
*
* @internal
* @param Mixed $results Report data.
* @return object
*/

View File

@ -17,6 +17,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ParameterException;
/**
* REST API Reports revenue stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller implements ExportableInterface {

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableInterface;
/**
* REST API Reports stock controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller implements ExportableInterface {
@ -164,6 +165,7 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
/**
* Add in conditional search filters for products.
*
* @internal
* @param string $where Where clause used to search posts.
* @param object $wp_query WP_Query object.
* @return string
@ -208,6 +210,7 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
/**
* Join posts meta tables when product search or low stock query is present.
*
* @internal
* @param string $join Join clause used to search posts.
* @param object $wp_query WP_Query object.
* @return string
@ -231,6 +234,7 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
/**
* Join wc_product_meta_lookup to posts if not already joined.
*
* @internal
* @param string $sql SQL join.
* @return string
*/
@ -246,6 +250,7 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
/**
* Group by post ID to prevent duplicates.
*
* @internal
* @param string $groupby Group by clause used to organize posts.
* @param object $wp_query WP_Query object.
* @return string
@ -262,6 +267,7 @@ class Controller extends \WC_REST_Reports_Controller implements ExportableInterf
/**
* Custom orderby clauses using the lookup tables.
*
* @internal
* @param array $args Query args.
* @param object $wp_query WP_Query object.
* @return array

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* REST API Reports stock stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {

View File

@ -15,6 +15,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableTraits;
/**
* REST API Reports taxes controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller implements ExportableInterface {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* REST API Reports taxes stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {
@ -40,6 +41,7 @@ class Controller extends \WC_REST_Reports_Controller {
/**
* Set the default results to 0 if API returns an empty array
*
* @internal
* @param Mixed $results Report data.
* @return object
*/

View File

@ -16,6 +16,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ExportableTraits;
/**
* REST API Reports products controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends ReportsController implements ExportableInterface {

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\ParameterException;
/**
* REST API Reports variations stats controller class.
*
* @internal
* @extends WC_REST_Reports_Controller
*/
class Controller extends \WC_REST_Reports_Controller {

View File

@ -14,6 +14,7 @@ use \Automattic\WooCommerce\Admin\API\Reports\Cache as ReportsCache;
/**
* Setting Options controller.
*
* @internal
* @extends WC_REST_Setting_Options_Controller
*/
class SettingOptions extends \WC_REST_Setting_Options_Controller {

View File

@ -12,6 +12,7 @@ defined( 'ABSPATH' ) || exit;
/**
* Taxes controller.
*
* @internal
* @extends WC_REST_Taxes_Controller
*/
class Taxes extends \WC_REST_Taxes_Controller {

View File

@ -15,6 +15,7 @@ use Automattic\WooCommerce\Admin\Overrides\ThemeUpgraderSkin;
/**
* Themes controller.
*
* @internal
* @extends WC_REST_Data_Controller
*/
class Themes extends \WC_REST_Data_Controller {
@ -73,7 +74,7 @@ class Themes extends \WC_REST_Data_Controller {
*/
public function upload_theme( $request ) {
if (
! isset( $_FILES['pluginzip'] ) || ! isset( $_FILES['pluginzip']['tmp_name'] ) || ! is_uploaded_file( $_FILES['pluginzip']['tmp_name'] ) || ! is_file( $_FILES['pluginzip']['tmp_name'] ) ) { // WPCS: sanitization ok.
! isset( $_FILES['pluginzip'] ) || ! isset( $_FILES['pluginzip']['tmp_name'] ) || ! is_uploaded_file( $_FILES['pluginzip']['tmp_name'] ) || ! is_file( $_FILES['pluginzip']['tmp_name'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
return new \WP_Error( 'woocommerce_rest_invalid_file', __( 'Specified file failed upload test.', 'woocommerce-admin' ) );
}