plugin updates

This commit is contained in:
Tony Volpe
2024-11-15 13:53:04 -05:00
parent 1293d604ca
commit 0238f0c4ca
2009 changed files with 163492 additions and 89543 deletions

View File

@@ -538,7 +538,7 @@ class Notes extends \WC_REST_CRUD_Controller {
*
* @param string $url The URL needing a nonce.
* @param string $action The nonce action.
* @param string $name The nonce anme.
* @param string $name The nonce name.
* @return string A fully formed URL.
*/
private function maybe_add_nonce_to_url( string $url, string $action = '', string $name = '' ) : string {
@@ -547,7 +547,7 @@ class Notes extends \WC_REST_CRUD_Controller {
}
if ( empty( $name ) ) {
// Default paramater name.
// Default parameter name.
$name = '_wpnonce';
}

View File

@@ -11,6 +11,7 @@ defined( 'ABSPATH' ) || exit;
use ActionScheduler;
use Automattic\Jetpack\Connection\Manager;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Admin\PluginsHelper;
use Automattic\WooCommerce\Admin\PluginsInstallLoggers\AsynPluginsInstallLogger;
use WC_REST_Data_Controller;
@@ -192,7 +193,7 @@ class OnboardingPlugins extends WC_REST_Data_Controller {
$actions = array_filter(
PluginsHelper::get_action_data( $actions ),
function( $action ) use ( $job_id ) {
function ( $action ) use ( $job_id ) {
return $action['job_id'] === $job_id;
}
);
@@ -236,21 +237,66 @@ class OnboardingPlugins extends WC_REST_Data_Controller {
}
$redirect_url = $request->get_param( 'redirect_url' );
$calypso_env = defined( 'WOOCOMMERCE_CALYPSO_ENVIRONMENT' ) && in_array( WOOCOMMERCE_CALYPSO_ENVIRONMENT, [ 'development', 'wpcalypso', 'horizon', 'stage' ], true ) ? WOOCOMMERCE_CALYPSO_ENVIRONMENT : 'production';
$calypso_env = defined( 'WOOCOMMERCE_CALYPSO_ENVIRONMENT' ) && in_array( WOOCOMMERCE_CALYPSO_ENVIRONMENT, array( 'development', 'wpcalypso', 'horizon', 'stage' ), true ) ? WOOCOMMERCE_CALYPSO_ENVIRONMENT : 'production';
$authorization_url = $manager->get_authorization_url( null, $redirect_url );
$authorization_url = add_query_arg( 'locale', $this->get_wpcom_locale(), $authorization_url );
if ( Features::is_enabled( 'use-wp-horizon' ) ) {
$calypso_env = 'horizon';
}
return [
'success' => ! $errors->has_errors(),
'errors' => $errors->get_error_messages(),
'url' => add_query_arg(
[
array(
'from' => $request->get_param( 'from' ),
'calypso_env' => $calypso_env,
],
$manager->get_authorization_url( null, $redirect_url )
),
$authorization_url,
),
];
}
/**
* Return a locale string for wpcom.
*
* @return string
*/
private function get_wpcom_locale() {
// List of locales that should be used with region code.
$locale_to_lang = array(
'bre' => 'br',
'de_AT' => 'de-at',
'de_CH' => 'de-ch',
'de' => 'de_formal',
'el' => 'el-po',
'en_GB' => 'en-gb',
'es_CL' => 'es-cl',
'es_MX' => 'es-mx',
'fr_BE' => 'fr-be',
'fr_CA' => 'fr-ca',
'nl_BE' => 'nl-be',
'nl' => 'nl_formal',
'pt_BR' => 'pt-br',
'sr' => 'sr_latin',
'zh_CN' => 'zh-cn',
'zh_HK' => 'zh-hk',
'zh_SG' => 'zh-sg',
'zh_TW' => 'zh-tw',
);
$system_locale = get_locale();
if ( isset( $locale_to_lang[ $system_locale ] ) ) {
// Return the locale with region code if it's in the list.
return $locale_to_lang[ $system_locale ];
}
// If the locale is not in the list, return the language code only.
return explode( '_', $system_locale )[0];
}
/**
* Check whether the current user has permission to install plugins
*
@@ -400,7 +446,7 @@ class OnboardingPlugins extends WC_REST_Data_Controller {
),
$slug
),
'type' => 'plugin_info_api_error',
'type' => 'plugin_info_api_error',
'slug' => $slug,
'api_version' => $api->version,
'api_download_link' => $api->download_link,

View File

@@ -37,7 +37,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
protected $rest_base = 'onboarding/tasks';
/**
* Duration to milisecond mapping.
* Duration to millisecond mapping.
*
* @var array
*/

View File

@@ -349,36 +349,36 @@ class OnboardingThemes extends \WC_REST_Data_Controller {
'link_url' => add_query_arg( $in_app_purchase_params, 'https://woocommerce.com/products/luminate/' ),
),
array(
'name' => 'Nokul',
'name' => 'Gizmo',
/* translators: %d: price */
'price' => sprintf( __( '$%d/year', 'woocommerce' ), 79 ),
'is_free' => false,
'color_palettes' => array(
array(
'title' => 'Foreground and background',
'primary' => '#000000',
'secondary' => '#f1eee2',
'title' => 'Primary',
'primary' => '#ff5833',
'secondary' => '#ff5833',
),
array(
'title' => 'Foreground and secondary',
'primary' => '#000000',
'secondary' => '#999999',
'title' => 'Foreground',
'primary' => '#111111',
'secondary' => '#111111',
),
array(
'title' => 'Foreground and accent',
'primary' => '#000000',
'secondary' => '#d82f16',
'title' => 'Background',
'primary' => '#FFFFFF',
'secondary' => '#FFFFFF',
),
array(
'title' => 'Primary and background',
'primary' => '#d9d0bf',
'secondary' => '#f1eee2',
'title' => 'Base',
'primary' => '#595959',
'secondary' => '#595959',
),
),
'total_palettes' => 6,
'slug' => 'nokul',
'thumbnail_url' => 'https://woocommerce.com/wp-content/uploads/2022/11/Product-logo.jpg',
'link_url' => add_query_arg( $in_app_purchase_params, 'https://woocommerce.com/products/nokul/' ),
'total_palettes' => 10,
'slug' => 'gizmo',
'thumbnail_url' => 'https://woocommerce.com/wp-content/uploads/2022/11/gizmo-regular-card-product-logo.jpg?w=900',
'link_url' => add_query_arg( $in_app_purchase_params, 'https://woocommerce.com/products/gizmo/' ),
),
);

View File

@@ -2,7 +2,7 @@
/**
* REST API Payment Gateway Suggestions Controller
*
* Handles requests to install and activate depedent plugins.
* Handles requests to install and activate dependent plugins.
*/
namespace Automattic\WooCommerce\Admin\API;

View File

@@ -2,7 +2,7 @@
/**
* REST API Plugins Controller
*
* Handles requests to install and activate depedent plugins.
* Handles requests to install and activate dependent plugins.
*/
namespace Automattic\WooCommerce\Admin\API;
@@ -592,9 +592,9 @@ class Plugins extends \WC_REST_Data_Controller {
}
/**
* Returns a URL that can be used to by WCPay to verify business details.
* Returns a URL that can be used by WooPayments to verify business details.
*
* @return WP_Error|array Connect URL.
* @return \WP_Error|array Connect URL.
*/
public function connect_wcpay() {
if ( ! class_exists( 'WC_Payments' ) ) {

View File

@@ -5,6 +5,8 @@
* Handles requests to /products/*
*/
declare( strict_types = 1 );
namespace Automattic\WooCommerce\Admin\API;
defined( 'ABSPATH' ) || exit;

View File

@@ -263,7 +263,7 @@ final class ProductsLowInStock extends \WC_REST_Products_Controller {
/**
* Return a query string for low in stock products.
* The query string incldues the following replacement strings:
* The query string includes the following replacement strings:
* - :selects
* - :postmeta_join
* - :postmeta_wheres

View File

@@ -32,7 +32,7 @@ class Controller extends GenericController implements ExportableInterface {
protected $rest_base = 'reports/categories';
/**
* Get data from `'categories'` Query.
* Get data from `'categories'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -171,13 +171,15 @@ class Controller extends GenericController implements ExportableInterface {
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['default'] = 'category_id';
$params['orderby']['enum'] = array(
'category_id',
'items_sold',
'net_revenue',
'orders_count',
'products_count',
'category',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'category_id',
'items_sold',
'net_revenue',
'orders_count',
'products_count',
'category',
)
);
$params['interval'] = array(
'description' => __( 'Time interval to use for buckets in the returned data.', 'woocommerce' ),

View File

@@ -23,7 +23,7 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Categories\Query
*
* @deprecated 9.3.0 Categories\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Categories\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
@@ -32,22 +32,26 @@ class Query extends ReportsQuery {
/**
* Valid fields for Categories report.
*
* @deprecated 9.3.0 Categories\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Categories\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get categories data based on the current query vars.
*
* @deprecated 9.3.0 Categories\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Categories\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_categories_query_args', $this->get_query_vars() );
$results = \WC_Data_Store::load( self::REPORT_NAME )->get_data( $args );
return apply_filters( 'woocommerce_analytics_categories_select_query', $results, $args );

View File

@@ -31,7 +31,7 @@ class Controller extends GenericController implements ExportableInterface {
protected $rest_base = 'reports/coupons';
/**
* Get data from `'coupons'` Query.
* Get data from `'coupons'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -184,11 +184,13 @@ class Controller extends GenericController implements ExportableInterface {
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['default'] = 'coupon_id';
$params['orderby']['enum'] = array(
'coupon_id',
'code',
'amount',
'orders_count',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'coupon_id',
'code',
'amount',
'orders_count',
)
);
$params['coupons'] = array(
'description' => __( 'Limit result set to coupons assigned specific coupon IDs.', 'woocommerce' ),

View File

@@ -22,29 +22,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Coupons\Query
*
* @deprecated 9.3.0 Coupons\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Coupons\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Products report.
*
* @deprecated 9.3.0 Coupons\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Coupons\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get product data based on the current query vars.
*
* @deprecated 9.3.0 Coupons\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Coupons\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_coupons_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-coupons' );

View File

@@ -54,7 +54,7 @@ class Controller extends GenericStatsController {
}
/**
* Get data from `'coupons-stats'` Query.
* Get data from `'coupons-stats'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -142,11 +142,13 @@ class Controller extends GenericStatsController {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'amount',
'coupons_count',
'orders_count',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'amount',
'coupons_count',
'orders_count',
)
);
$params['coupons'] = array(
'description' => __( 'Limit result set to coupons assigned specific coupon IDs.', 'woocommerce' ),

View File

@@ -22,29 +22,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Coupons\Stats\Query
*
* @deprecated 9.3.0 Coupons\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Coupons\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Products report.
*
* @deprecated 9.3.0 Coupons\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Coupons\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get product data based on the current query vars.
*
* @deprecated 9.3.0 Coupons\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Coupons\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_coupons_stats_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-coupons-stats' );

View File

@@ -34,7 +34,7 @@ class Controller extends GenericController implements ExportableInterface {
protected $rest_base = 'reports/customers';
/**
* Get data from Query.
* Get data from Customers\Query.
*
* @override GenericController::get_datastore_data()
*
@@ -304,18 +304,20 @@ class Controller extends GenericController implements ExportableInterface {
'validate_callback' => 'rest_validate_request_arg',
);
$params['orderby']['default'] = 'date_registered';
$params['orderby']['enum'] = array(
'username',
'name',
'country',
'city',
'state',
'postcode',
'date_registered',
'date_last_active',
'orders_count',
'total_spend',
'avg_order_value',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'username',
'name',
'country',
'city',
'state',
'postcode',
'date_registered',
'date_last_active',
'orders_count',
'total_spend',
'avg_order_value',
)
);
$params['match'] = array(
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce' ),

View File

@@ -615,6 +615,11 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
if ( is_null( $customer_user ) ) {
$customer_user = new \WC_Customer( $user_id );
}
// Set email as customer email instead of Order Billing Email if we have a customer.
$data['email'] = $customer_user->get_email( 'edit' );
// Adding other relevant customer data.
$data['user_id'] = $user_id;
$data['username'] = $customer_user->get_username( 'edit' );
$data['date_registered'] = $customer_user->get_date_created( 'edit' ) ? $customer_user->get_date_created( 'edit' )->date( TimeInterval::$sql_datetime_format ) : null;
@@ -913,14 +918,18 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
* Anonymize the customer data for a single order.
*
* @internal
* @param int $order_id Order id.
* @param int|WC_Order $order Order instance or ID.
* @return void
*/
public static function anonymize_customer( $order_id ) {
public static function anonymize_customer( $order ) {
global $wpdb;
if ( ! is_object( $order ) ) {
$order = wc_get_order( absint( $order ) );
}
$customer_id = $wpdb->get_var(
$wpdb->prepare( "SELECT customer_id FROM {$wpdb->prefix}wc_order_stats WHERE order_id = %d", $order_id )
$wpdb->prepare( "SELECT customer_id FROM {$wpdb->prefix}wc_order_stats WHERE order_id = %d", $order->get_id() )
);
if ( ! $customer_id ) {

View File

@@ -23,18 +23,20 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Customers\Stats\Query
*
* @deprecated 9.3.0 Customers\Stats\Query class is deprecated, please use Reports\Customers\Query with a custom name, GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Customers\Stats\Query class is deprecated, please use `Reports\Customers\Query` with a custom name, `GenericQuery`, `\WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Customers report.
*
* @deprecated 9.3.0 Customers\Stats\Query class is deprecated, please use Reports\Customers\Query with a custom name, GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Customers\Stats\Query class is deprecated, please use `Reports\Customers\Query` with a custom name, `GenericQuery`, `\WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`Reports\Customers\Query` with a custom name, `GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array(
'per_page' => get_option( 'posts_per_page' ), // not sure if this should be the default.
'page' => 1,
@@ -47,11 +49,13 @@ class Query extends ReportsQuery {
/**
* Get product data based on the current query vars.
*
* @deprecated 9.3.0 Customers\Stats\Query class is deprecated, please use Reports\Customers\Query with a custom name, GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Customers\Stats\Query class is deprecated, please use `Reports\Customers\Query` with a custom name, `GenericQuery`, `\WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'x.x.x', '`Reports\Customers\Query` with a custom name, `GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_customers_stats_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-customers-stats' );

View File

@@ -32,7 +32,7 @@ class Controller extends GenericController implements ExportableInterface {
protected $rest_base = 'reports/downloads';
/**
* Get data from `'downloads'` Query.
* Get data from `'downloads'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -219,9 +219,11 @@ class Controller extends GenericController implements ExportableInterface {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'product',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'product',
)
);
$params['match'] = array(
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: products, orders, username, ip_address.', 'woocommerce' ),

View File

@@ -22,29 +22,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Downloads\Query
*
* @deprecated 9.3.0 Downloads\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Downloads\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for downloads report.
*
* @deprecated 9.3.0 Downloads\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Downloads\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get downloads data based on the current query vars.
*
* @deprecated 9.3.0 Downloads\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Downloads\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_downloads_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-downloads' );

View File

@@ -60,7 +60,7 @@ class Controller extends GenericStatsController {
}
/**
* Get data from `'downloads-stats'` Query.
* Get data from `'downloads-stats'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -196,9 +196,11 @@ class Controller extends GenericStatsController {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'download_count',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'download_count',
)
);
$params['match'] = array(
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce' ),

View File

@@ -12,29 +12,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Downloads\Stats\Query
*
* @deprecated 9.3.0 Downloads\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Downloads\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Orders report.
*
* @deprecated 9.3.0 Downloads\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Downloads\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get revenue data based on the current query vars.
*
* @deprecated 9.3.0 Downloads\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Downloads\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_downloads_stats_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-downloads-stats' );

View File

@@ -175,7 +175,7 @@ abstract class GenericController extends \WC_REST_Reports_Controller {
/**
* Get the report data.
*
* Prepares query params, fetches the report data from the Query object,
* Prepares query params, fetches the report data from the data store,
* prepares it for the response, and packs it into the convention-conforming response object.
*
* @throws \WP_Error When the queried data is invalid.
@@ -237,7 +237,7 @@ abstract class GenericController extends \WC_REST_Reports_Controller {
}
/**
* Maps query arguments from the REST request, to be fed to Query.
* Maps query arguments from the REST request, to be used to query the datastore.
*
* `WP_REST_Request` does not expose a method to return all params covering defaults,
* as it does for `$request['param']` accessor.
@@ -257,4 +257,31 @@ abstract class GenericController extends \WC_REST_Reports_Controller {
return $args;
}
/**
* Apply a filter for custom orderby enum.
*
* @param array $orderby_enum An array of orderby enum options.
*
* @return array An array of filtered orderby enum options.
*
* @since 9.4.0
*/
protected function apply_custom_orderby_filters( $orderby_enum ) {
/**
* Filter orderby query parameter enum.
*
* There was an initial concern about potential SQL injection with the custom orderby.
* However, testing shows it is safely blocked by validation in the controller,
* which results in an "Invalid parameter(s): orderby" error.
*
* Additionally, it's the responsibility of the merchant/developer to ensure the custom orderby is valid,
* or a WordPress database error will occur for unknown columns.
*
* @since 9.4.0
*
* @param array $orderby_enum The orderby query parameter enum.
*/
return apply_filters( "woocommerce_analytics_orderby_enum_{$this->rest_base}", $orderby_enum );
}
}

View File

@@ -207,7 +207,7 @@ abstract class GenericStatsController extends GenericController {
/**
* Get the report data.
*
* Prepares query params, fetches the report data from the Query object,
* Prepares query params, fetches the report data from the data store,
* prepares it for the response, and packs it into the convention-conforming response object.
*
* @override GenericController::get_items()

View File

@@ -31,7 +31,7 @@ class Controller extends GenericController implements ExportableInterface {
protected $rest_base = 'reports/orders';
/**
* Get data from Query.
* Get data from Orders\Query.
*
* @override GenericController::get_datastore_data()
*
@@ -233,10 +233,12 @@ class Controller extends GenericController implements ExportableInterface {
public function get_collection_params() {
$params = parent::get_collection_params();
$params['per_page']['minimum'] = 0;
$params['orderby']['enum'] = array(
'date',
'num_items_sold',
'net_total',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'num_items_sold',
'net_total',
)
);
$params['product_includes'] = array(
'description' => __( 'Limit result set to items that have the specified product(s) assigned.', 'woocommerce' ),

View File

@@ -86,7 +86,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
*/
protected function assign_report_columns() {
$table_name = self::get_db_table_name();
// Avoid ambigious columns in SQL query.
// Avoid ambiguous columns in SQL query.
$this->report_columns = array(
'order_id' => "DISTINCT {$table_name}.order_id",
'parent_id' => "{$table_name}.parent_id",

View File

@@ -31,7 +31,7 @@ class Controller extends GenericStatsController {
protected $rest_base = 'reports/orders/stats';
/**
* Get data from Query.
* Get data from Orders\Stats\Query.
*
* @override GenericController::get_datastore_data()
*
@@ -202,11 +202,13 @@ class Controller extends GenericStatsController {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'net_revenue',
'orders_count',
'avg_order_value',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'net_revenue',
'orders_count',
'avg_order_value',
)
);
$params['match'] = array(
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce' ),

View File

@@ -96,7 +96,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
*/
protected function assign_report_columns() {
$table_name = self::get_db_table_name();
// Avoid ambigious columns in SQL query.
// Avoid ambiguous columns in SQL query.
$refunds = "ABS( SUM( CASE WHEN {$table_name}.net_total < 0 THEN {$table_name}.net_total ELSE 0 END ) )";
$gross_sales =
"( SUM({$table_name}.total_sales)" .

View File

@@ -478,7 +478,7 @@ class Controller extends GenericController {
/**
* Prepare links for the request.
*
* @param \Automattic\WooCommerce\Admin\API\Reports\Query $object Object data.
* @param object $object data.
* @return array
*/
protected function prepare_links( $object ) {

View File

@@ -42,7 +42,7 @@ class Controller extends GenericController implements ExportableInterface {
);
/**
* Get data from `'products'` Query.
* Get data from `'products'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -231,14 +231,16 @@ class Controller extends GenericController implements ExportableInterface {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'net_revenue',
'orders_count',
'items_sold',
'product_name',
'variations',
'sku',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'net_revenue',
'orders_count',
'items_sold',
'product_name',
'variations',
'sku',
)
);
$params['categories'] = array(
'description' => __( 'Limit result to items from the specified categories.', 'woocommerce' ),

View File

@@ -23,29 +23,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Products\Query
*
* @deprecated 9.3.0 Products\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Products\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Products report.
*
* @deprecated 9.3.0 Products\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Products\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get product data based on the current query vars.
*
* @deprecated 9.3.0 Products\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Products\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_products_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-products' );

View File

@@ -48,7 +48,7 @@ class Controller extends GenericStatsController {
}
/**
* Get data from `'products-stats'` Query.
* Get data from `'products-stats'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -61,7 +61,7 @@ class Controller extends GenericStatsController {
}
/**
* Maps query arguments from the REST request, to be fed to Query.
* Maps query arguments from the REST request to be used to query the datastore.
*
* @param \WP_REST_Request $request Full request object.
* @return array Simplified array of params.
@@ -197,16 +197,18 @@ class Controller extends GenericStatsController {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'net_revenue',
'coupons',
'refunds',
'shipping',
'taxes',
'net_revenue',
'orders_count',
'items_sold',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'net_revenue',
'coupons',
'refunds',
'shipping',
'taxes',
'net_revenue',
'orders_count',
'items_sold',
)
);
$params['categories'] = array(
'description' => __( 'Limit result to items from the specified categories.', 'woocommerce' ),

View File

@@ -23,29 +23,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Products\Stats\Query
*
* @deprecated 9.3.0 Products\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Products\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Products report.
*
* @deprecated 9.3.0 Products\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Products\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get product data based on the current query vars.
*
* @deprecated 9.3.0 Products\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Products\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_products_stats_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-products-stats' );

View File

@@ -10,17 +10,31 @@ defined( 'ABSPATH' ) || exit;
/**
* Admin\API\Reports\Query
*
* @deprecated 9.3.0 Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
abstract class Query extends \WC_Object_Query {
/**
* Create a new query.
*
* @deprecated 9.3.0 Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @param array $args Criteria to query on in a format similar to WP_Query.
*/
public function __construct( $args = array() ) {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
parent::__construct( $args );
}
/**
* Get report data matching the current query vars.
*
* @deprecated 9.3.0 Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array|object of WC_Product objects
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
/* translators: %s: Method name */
return new \WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
}

View File

@@ -223,17 +223,19 @@ class Controller extends GenericStatsController implements ExportableInterface {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'total_sales',
'coupons',
'refunds',
'shipping',
'taxes',
'net_revenue',
'orders_count',
'items_sold',
'gross_sales',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'total_sales',
'coupons',
'refunds',
'shipping',
'taxes',
'net_revenue',
'orders_count',
'items_sold',
'gross_sales',
)
);
$params['segmentby'] = array(
'description' => __( 'Segment the response by additional constraint.', 'woocommerce' ),

View File

@@ -105,7 +105,7 @@ trait StatsDataStoreTrait {
'pages' => $total_pages,
'page_no' => (int) $query_args['page'],
);
// If the requested page is out off range, return the deault empty object.
// If the requested page is out off range, return the default empty object.
if ( $query_args['page'] >= 1 && $query_args['page'] <= $total_pages ) {
// Fetch the actual data.
$data = $this->get_noncached_stats_data( $query_args, $params, $data, $expected_interval_count );

View File

@@ -443,14 +443,16 @@ class Controller extends GenericController implements ExportableInterface {
);
$params['order']['default'] = 'asc';
$params['orderby']['default'] = 'stock_status';
$params['orderby']['enum'] = array(
'stock_status',
'stock_quantity',
'date',
'id',
'include',
'title',
'sku',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'stock_status',
'stock_quantity',
'date',
'id',
'include',
'title',
'sku',
)
);
$params['parent'] = array(
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),

View File

@@ -36,7 +36,7 @@ class Controller extends GenericController implements ExportableInterface {
protected $rest_base = 'reports/taxes';
/**
* Get data from `'taxes'` Query.
* Get data from `'taxes'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -195,15 +195,17 @@ class Controller extends GenericController implements ExportableInterface {
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['default'] = 'tax_rate_id';
$params['orderby']['enum'] = array(
'name',
'tax_rate_id',
'tax_code',
'rate',
'order_tax',
'total_tax',
'shipping_tax',
'orders_count',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'name',
'tax_rate_id',
'tax_code',
'rate',
'order_tax',
'total_tax',
'shipping_tax',
'orders_count',
)
);
$params['taxes'] = array(
'description' => __( 'Limit result set to items assigned one or more tax rates.', 'woocommerce' ),
@@ -242,7 +244,15 @@ class Controller extends GenericController implements ExportableInterface {
*/
public function prepare_item_for_export( $item ) {
return array(
'tax_code' => \WC_Tax::get_rate_code( $item['tax_rate_id'] ),
'tax_code' => \WC_Tax::get_rate_code(
(object) array(
'tax_rate_id' => $item['tax_rate_id'],
'tax_rate_country' => $item['country'],
'tax_rate_state' => $item['state'],
'tax_rate_name' => $item['name'],
'tax_rate_priority' => $item['priority'],
)
),
'rate' => $item['tax_rate'],
'total_tax' => self::csv_number_format( $item['total_tax'] ),
'order_tax' => self::csv_number_format( $item['order_tax'] ),

View File

@@ -124,6 +124,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
/**
* Updates the database query with parameters used for Taxes report: categories and order status.
*
* @see Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore::update_sql_query_params()
* @param array $query_args Query arguments supplied by the user.
*/
protected function add_sql_query_params( $query_args ) {

View File

@@ -22,29 +22,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Taxes\Query
*
* @deprecated 9.3.0 Taxes\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Taxes\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Taxes report.
*
* @deprecated 9.3.0 Taxes\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Taxes\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get product data based on the current query vars.
*
* @deprecated 9.3.0 Taxes\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Taxes\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_taxes_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-taxes' );

View File

@@ -84,7 +84,7 @@ class Controller extends GenericStatsController {
}
/**
* Get data from `'taxes-stats'` Query.
* Get data from `'taxes-stats'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -186,12 +186,14 @@ class Controller extends GenericStatsController {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'items_sold',
'total_sales',
'orders_count',
'products_count',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'items_sold',
'total_sales',
'orders_count',
'products_count',
)
);
$params['taxes'] = array(
'description' => __( 'Limit result set to all items that have the specified term assigned in the taxes taxonomy.', 'woocommerce' ),

View File

@@ -79,28 +79,29 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
/**
* Updates the database query with parameters used for Taxes Stats report
*
* @see Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore::add_sql_query_params()
* @param array $query_args Query arguments supplied by the user.
*/
protected function update_sql_query_params( $query_args ) {
global $wpdb;
$taxes_where_clause = '';
$order_tax_lookup_table = self::get_db_table_name();
$this->add_time_period_sql_params( $query_args, $order_tax_lookup_table );
$taxes_where_clause = '';
$order_status_filter = $this->get_status_subquery( $query_args );
if ( isset( $query_args['taxes'] ) && ! empty( $query_args['taxes'] ) ) {
$query_args['taxes'] = (array) $query_args['taxes'];
$tax_id_placeholders = implode( ',', array_fill( 0, count( $query_args['taxes'] ), '%d' ) );
/* phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared */
$taxes_where_clause .= $wpdb->prepare( " AND {$order_tax_lookup_table}.tax_rate_id IN ({$tax_id_placeholders})", $query_args['taxes'] );
$allowed_taxes = self::get_filtered_ids( $query_args, 'taxes' );
/* phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- `$allowed_taxes` was prepared by get_filtered_ids above. */
$taxes_where_clause .= " AND {$order_tax_lookup_table}.tax_rate_id IN ({$allowed_taxes})";
/* phpcs:enable */
}
$order_status_filter = $this->get_status_subquery( $query_args );
if ( $order_status_filter ) {
$taxes_where_clause .= " AND ( {$order_status_filter} )";
}
$this->add_time_period_sql_params( $query_args, $order_tax_lookup_table );
$this->total_query->add_sql_clause( 'where', $taxes_where_clause );
$this->add_intervals_sql_params( $query_args, $order_tax_lookup_table );

View File

@@ -23,29 +23,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Taxes\Stats\Query
*
* @deprecated 9.3.0 Taxes\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Taxes\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Taxes report.
*
* @deprecated 9.3.0 Taxes\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Taxes\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get tax stats data based on the current query vars.
*
* @deprecated 9.3.0 Taxes\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Taxes\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_taxes_stats_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-taxes-stats' );

View File

@@ -50,7 +50,7 @@ class Controller extends GenericController implements ExportableInterface {
);
/**
* Get data from `'variations'` Query.
* Get data from `'variations'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -246,12 +246,14 @@ class Controller extends GenericController implements ExportableInterface {
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array(
'date',
'net_revenue',
'orders_count',
'items_sold',
'sku',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'net_revenue',
'orders_count',
'items_sold',
'sku',
)
);
$params['match'] = array(
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'woocommerce' ),

View File

@@ -23,29 +23,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Variations\Query
*
* @deprecated 9.3.0 Variations\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Variations\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Products report.
*
* @deprecated 9.3.0 Variations\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Variations\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get product data based on the current query vars.
*
* @deprecated 9.3.0 Variations\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Variations\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_variations_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-variations' );

View File

@@ -46,7 +46,7 @@ class Controller extends GenericStatsController {
}
/**
* Get data from `'variations-stats'` Query.
* Get data from `'variations-stats'` GenericQuery.
*
* @override GenericController::get_datastore_data()
*
@@ -210,16 +210,18 @@ class Controller extends GenericStatsController {
),
'validate_callback' => 'rest_validate_request_arg',
);
$params['orderby']['enum'] = array(
'date',
'net_revenue',
'coupons',
'refunds',
'shipping',
'taxes',
'net_revenue',
'orders_count',
'items_sold',
$params['orderby']['enum'] = $this->apply_custom_orderby_filters(
array(
'date',
'net_revenue',
'coupons',
'refunds',
'shipping',
'taxes',
'net_revenue',
'orders_count',
'items_sold',
)
);
$params['category_includes'] = array(
'description' => __( 'Limit result to items from the specified categories.', 'woocommerce' ),

View File

@@ -23,29 +23,33 @@ use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery;
/**
* API\Reports\Variations\Stats\Query
*
* @deprecated 9.3.0 Variations\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Variations\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*/
class Query extends ReportsQuery {
/**
* Valid fields for Products report.
*
* @deprecated 9.3.0 Variations\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Variations\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
protected function get_default_query_vars() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
return array();
}
/**
* Get variations data based on the current query vars.
*
* @deprecated 9.3.0 Variations\Stats\Query class is deprecated, please use GenericQuery or \WC_Object_Query instead.
* @deprecated 9.3.0 Variations\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly.
*
* @return array
*/
public function get_data() {
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' );
$args = apply_filters( 'woocommerce_analytics_variations_stats_query_args', $this->get_query_vars() );
$data_store = \WC_Data_Store::load( 'report-variations-stats' );

View File

@@ -27,7 +27,6 @@ class Features {
*/
protected static $optional_features = array(
'navigation' => array( 'default' => 'no' ),
'settings' => array( 'default' => 'no' ),
'analytics' => array( 'default' => 'yes' ),
'remote-inbox-notifications' => array( 'default' => 'yes' ),
);
@@ -353,7 +352,6 @@ class Features {
'Automattic\WooCommerce\Internal\Admin\Marketing' => 'Automattic\WooCommerce\Admin\Features\Marketing',
'Automattic\WooCommerce\Internal\Admin\MobileAppBanner' => 'Automattic\WooCommerce\Admin\Features\MobileAppBanner',
'Automattic\WooCommerce\Internal\Admin\RemoteInboxNotifications' => 'Automattic\WooCommerce\Admin\Features\RemoteInboxNotifications',
'Automattic\WooCommerce\Internal\Admin\SettingsNavigationFeature' => 'Automattic\WooCommerce\Admin\Features\Settings',
'Automattic\WooCommerce\Internal\Admin\ShippingLabelBanner' => 'Automattic\WooCommerce\Admin\Features\ShippingLabelBanner',
'Automattic\WooCommerce\Internal\Admin\ShippingLabelBannerDisplayRules' => 'Automattic\WooCommerce\Admin\Features\ShippingLabelBannerDisplayRules',
'Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage' => 'Automattic\WooCommerce\Admin\Features\WcPayWelcomePage',

View File

@@ -107,6 +107,22 @@ class DefaultMarketingRecommendations {
),
'tags' => array(),
),
array(
'title' => 'Facebook for WooCommerce',
'description' => __( 'List products and create ads on Facebook and Instagram.', 'woocommerce' ),
'url' => "https://woocommerce.com/products/facebook/{$utm_string}",
'direct_install' => true,
'icon' => "{$icon_dir_url}/facebook.svg",
'product' => 'facebook-for-woocommerce',
'plugin' => 'facebook-for-woocommerce/facebook-for-woocommerce.php',
'categories' => array(
$marketing,
),
'subcategories' => array(
$sales_channels,
),
'tags' => array(),
),
array(
'title' => 'MailPoet',
'description' => __( 'Create and send purchase follow-up emails, newsletters, and promotional campaigns straight from your dashboard.', 'woocommerce' ),

View File

@@ -2,7 +2,7 @@
/**
* WooCommerce Navigation Core Menu
*
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.4.
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.5.
* @package Woocommerce Admin
*/

View File

@@ -2,7 +2,7 @@
/**
* WooCommerce Navigation Favorite
*
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.4.
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.5.
* @package Woocommerce Navigation
*/

View File

@@ -2,7 +2,7 @@
/**
* Navigation Experience
*
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.4.
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.5.
* @package Woocommerce Admin
*/
@@ -44,6 +44,6 @@ class Init {
*/
public static function deprecation_notice( $fcn ) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log( 'Automattic\WooCommerce\Admin\Features\Navigation\\' . $fcn . ' is deprecated since 9.3 with no alternative. Navigation classes will be removed in WooCommerce 9.4' );
error_log( 'Automattic\WooCommerce\Admin\Features\Navigation\\' . $fcn . ' is deprecated since 9.3 with no alternative. Navigation classes will be removed in WooCommerce 9.5' );
}
}

View File

@@ -2,7 +2,7 @@
/**
* WooCommerce Navigation Menu
*
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.4.
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.5.
* @package Woocommerce Navigation
*/

View File

@@ -2,7 +2,7 @@
/**
* WooCommerce Navigation Screen
*
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.4.
* @deprecated 9.3.0 Navigation is no longer a feature and its classes will be removed in WooCommerce 9.5.
* @package Woocommerce Navigation
*/

View File

@@ -61,7 +61,7 @@ abstract class Task {
protected $task_list;
/**
* Duration to milisecond mapping.
* Duration to millisecond mapping.
*
* @var string
*/

View File

@@ -4,8 +4,6 @@
namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\Payments;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\WooCommercePayments;
use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\Init;
/**
@@ -98,7 +96,7 @@ class AdditionalPayments extends Payments {
return $this->can_view_result;
}
// Show task if woocommerce-payments is connected or if there are any suggested gateways in other category enabled.
// Show task if WooPayments is connected or if there are any suggested gateways in other category enabled.
$this->can_view_result = (
WooCommercePayments::is_connected() ||
self::has_enabled_other_category_gateways()

View File

@@ -7,6 +7,8 @@ use WP_Post;
/**
* Customize Your Store Task
*
* @internal
*/
class CustomizeStore extends Task {
/**

View File

@@ -76,13 +76,13 @@ class Payments extends Task {
* @return bool
*/
public function can_view() {
$woocommerce_payments = $this->task_list->get_task( 'woocommerce-payments' );
// Make sure the task is mutually exclusive with the WooPayments task.
return Features::is_enabled( 'payment-gateway-suggestions' ) && ! $woocommerce_payments->can_view();
// The task is visible if WooPayments is not supported in the current store location country.
// Otherwise, the WooPayments task will be shown.
return Features::is_enabled( 'payment-gateway-suggestions' ) && ! WooCommercePayments::is_supported();
}
/**
* Check if the store has any enabled gateways, other than WooPayments.
* Check if the store has any enabled gateways.
*
* @return bool
*/
@@ -91,8 +91,7 @@ class Payments extends Task {
$enabled_gateways = array_filter(
$gateways,
function( $gateway ) {
// Filter out any WooPayments gateways as this task is mutually exclusive with the WooPayments task.
return 'yes' === $gateway->enabled && 0 !== strpos( $gateway->id, 'woocommerce_payments' );
return 'yes' === $gateway->enabled;
}
);
@@ -117,7 +116,7 @@ class Payments extends Task {
}
// Check if there is an active WooPayments incentive via the welcome page.
if ( WcPayWelcomePage::instance()->must_be_visible() ) {
if ( WcPayWelcomePage::instance()->is_incentive_visible() ) {
// Point to the WooPayments welcome page.
return add_query_arg( 'from', 'WCADMIN_PAYMENT_TASK', admin_url( 'admin.php?page=wc-admin&path=/wc-pay-welcome-page' ) );
}

View File

@@ -1,203 +0,0 @@
<?php
namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks;
use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProducts;
use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingThemes;
use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProfile;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
/**
* Purchase Task
*/
class Purchase extends Task {
/**
* Constructor
*
* @param TaskList $task_list Parent task list.
*/
public function __construct( $task_list ) {
parent::__construct( $task_list );
add_action( 'update_option_woocommerce_onboarding_profile', array( $this, 'clear_dismissal' ), 10, 2 );
}
/**
* Clear dismissal on onboarding product type changes.
*
* @param array $old_value Old value.
* @param array $new_value New value.
*/
public function clear_dismissal( $old_value, $new_value ) {
$product_types = isset( $new_value['product_types'] ) ? (array) $new_value['product_types'] : array();
$previous_product_types = isset( $old_value['product_types'] ) ? (array) $old_value['product_types'] : array();
if ( empty( array_diff( $product_types, $previous_product_types ) ) ) {
return;
}
$this->undo_dismiss();
}
/**
* Get the task arguments.
* ID.
*
* @return string
*/
public function get_id() {
return 'purchase';
}
/**
* Title.
*
* @return string
*/
public function get_title() {
$products = $this->get_paid_products_and_themes();
$first_product = count( $products['purchaseable'] ) >= 1 ? $products['purchaseable'][0] : false;
if ( ! $first_product ) {
return null;
}
$product_label = isset( $first_product['label'] ) ? $first_product['label'] : $first_product['title'];
$additional_count = count( $products['purchaseable'] ) - 1;
if ( $this->get_parent_option( 'use_completed_title' ) && $this->is_complete() ) {
return count( $products['purchaseable'] ) === 1
? sprintf(
/* translators: %1$s: a purchased product name */
__(
'You added %1$s',
'woocommerce'
),
$product_label
)
: sprintf(
/* translators: %1$s: a purchased product name, %2$d the number of other products purchased */
_n(
'You added %1$s and %2$d other product',
'You added %1$s and %2$d other products',
$additional_count,
'woocommerce'
),
$product_label,
$additional_count
);
}
return count( $products['purchaseable'] ) === 1
? sprintf(
/* translators: %1$s: a purchaseable product name */
__(
'Add %s to my store',
'woocommerce'
),
$product_label
)
: sprintf(
/* translators: %1$s: a purchaseable product name, %2$d the number of other products to purchase */
_n(
'Add %1$s and %2$d more product to my store',
'Add %1$s and %2$d more products to my store',
$additional_count,
'woocommerce'
),
$product_label,
$additional_count
);
}
/**
* Content.
*
* @return string
*/
public function get_content() {
$products = $this->get_paid_products_and_themes();
if ( count( $products['remaining'] ) === 1 ) {
return isset( $products['purchaseable'][0]['description'] ) ? $products['purchaseable'][0]['description'] : $products['purchaseable'][0]['excerpt'];
}
return sprintf(
/* translators: %1$s: list of product names comma separated, %2%s the last product name */
__(
'Good choice! You chose to add %1$s and %2$s to your store.',
'woocommerce'
),
implode( ', ', array_slice( $products['remaining'], 0, -1 ) ) . ( count( $products['remaining'] ) > 2 ? ',' : '' ),
end( $products['remaining'] )
);
}
/**
* Action label.
*
* @return string
*/
public function get_action_label() {
return __( 'Purchase & install now', 'woocommerce' );
}
/**
* Time.
*
* @return string
*/
public function get_time() {
return __( '2 minutes', 'woocommerce' );
}
/**
* Task completion.
*
* @return bool
*/
public function is_complete() {
$products = $this->get_paid_products_and_themes();
return count( $products['remaining'] ) === 0;
}
/**
* Dismissable.
*
* @return bool
*/
public function is_dismissable() {
return true;
}
/**
* Task visibility.
*
* @return bool
*/
public function can_view() {
$products = $this->get_paid_products_and_themes();
return count( $products['purchaseable'] ) > 0;
}
/**
* Get purchaseable and remaining products.
*
* @return array purchaseable and remaining products and themes.
*/
public static function get_paid_products_and_themes() {
$relevant_products = OnboardingProducts::get_relevant_products();
$profiler_data = get_option( OnboardingProfile::DATA_OPTION, array() );
$theme = isset( $profiler_data['theme'] ) ? $profiler_data['theme'] : null;
$paid_theme = $theme ? OnboardingThemes::get_paid_theme_by_slug( $theme ) : null;
if ( $paid_theme ) {
$relevant_products['purchaseable'][] = $paid_theme;
if ( isset( $paid_theme['is_installed'] ) && false === $paid_theme['is_installed'] ) {
$relevant_products['remaining'][] = $paid_theme['title'];
}
}
return $relevant_products;
}
}

View File

@@ -15,6 +15,7 @@ class Tax extends Task {
/**
* Used to cache is_complete() method result.
*
* @var null
*/
private $is_complete_result = null;
@@ -109,19 +110,23 @@ class Tax extends Task {
*/
public function is_complete() {
if ( $this->is_complete_result === null ) {
$wc_connect_taxes_enabled = get_option( 'wc_connect_taxes_enabled' );
$wc_connect_taxes_enabled = get_option( 'wc_connect_taxes_enabled' );
$is_wc_connect_taxes_enabled = ( $wc_connect_taxes_enabled === 'yes' ) || ( $wc_connect_taxes_enabled === true ); // seems that in some places boolean is used, and other places 'yes' | 'no' is used
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment -- We will replace this with a formal system by WC 9.6 so lets not advertise it yet.
$third_party_complete = apply_filters( 'woocommerce_admin_third_party_tax_setup_complete', false );
$this->is_complete_result = $is_wc_connect_taxes_enabled ||
count( TaxDataStore::get_taxes( array() ) ) > 0 ||
get_option( 'woocommerce_no_sales_tax' ) !== false;
get_option( 'woocommerce_no_sales_tax' ) !== false ||
$third_party_complete;
}
return $this->is_complete_result;
}
/**
* Addtional data.
* Additional data.
*
* @return array
*/
@@ -129,9 +134,11 @@ class Tax extends Task {
return array(
'avalara_activated' => PluginsHelper::is_plugin_active( 'woocommerce-avatax' ),
'tax_jar_activated' => class_exists( 'WC_Taxjar' ),
'stripe_tax_activated' => PluginsHelper::is_plugin_active( 'stripe-tax-for-woocommerce' ),
'woocommerce_tax_activated' => PluginsHelper::is_plugin_active( 'woocommerce-tax' ),
'woocommerce_shipping_activated' => PluginsHelper::is_plugin_active( 'woocommerce-shipping' ),
'woocommerce_tax_countries' => self::get_automated_support_countries(),
'stripe_tax_countries' => self::get_stripe_tax_support_countries(),
);
}
@@ -162,4 +169,54 @@ class Tax extends Task {
return $tax_supported_countries;
}
/**
* Get an array of countries that support Stripe tax.
*
* @return array
*/
private static function get_stripe_tax_support_countries() {
// https://docs.stripe.com/tax/supported-countries#supported-countries accurate as of 2024-08-26.
// countries with remote sales not included.
return array(
'AU',
'AT',
'BE',
'BG',
'CA',
'HR',
'CY',
'CZ',
'DK',
'EE',
'FI',
'FR',
'DE',
'GR',
'HK',
'HU',
'IE',
'IT',
'JP',
'LV',
'LT',
'LU',
'MT',
'NL',
'NZ',
'NO',
'PL',
'PT',
'RO',
'SG',
'SK',
'SI',
'ES',
'SE',
'CH',
'AE',
'GB',
'US',
);
}
}

View File

@@ -6,7 +6,6 @@ use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProfile;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
use Automattic\WooCommerce\Admin\PluginsHelper;
use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\Init as Suggestions;
use Automattic\WooCommerce\Internal\Admin\WCPayPromotion\Init as WCPayPromotionInit;
use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\DefaultPaymentGateways;
/**
@@ -65,6 +64,22 @@ class WooCommercePayments extends Task {
);
}
/**
* Additional data.
*
* @return mixed
*/
public function get_additional_data() {
/**
* Filter WooPayments onboarding task additional data.
*
* @since 9.4.0
*
* @param ?array $additional_data The task additional data.
*/
return apply_filters( 'woocommerce_admin_woopayments_onboarding_task_additional_data', null );
}
/**
* Time.
*
@@ -90,7 +105,9 @@ class WooCommercePayments extends Task {
*/
public function is_complete() {
if ( null === $this->is_complete_result ) {
$this->is_complete_result = self::is_connected() && ! self::is_account_partially_onboarded();
// This task is complete if there are other ecommerce gateways enabled (offline payment methods are excluded),
// or if WooPayments is active and has a connected, fully onboarded account.
$this->is_complete_result = self::has_other_ecommerce_gateways() || ( self::is_connected() && ! self::is_account_partially_onboarded() );
}
return $this->is_complete_result;
@@ -102,10 +119,7 @@ class WooCommercePayments extends Task {
* @return bool
*/
public function can_view() {
$payments = $this->task_list->get_task( 'payments' );
return ! $payments->is_complete() && // Do not re-display the task if the general "Payments" task has already been completed.
self::is_supported();
return self::is_supported();
}
/**
@@ -147,11 +161,13 @@ class WooCommercePayments extends Task {
* @return bool
*/
public static function is_connected() {
if ( class_exists( '\WC_Payments' ) ) {
$wc_payments_gateway = \WC_Payments::get_gateway();
return method_exists( $wc_payments_gateway, 'is_connected' )
? $wc_payments_gateway->is_connected()
: false;
if ( ! self::is_wcpay_active() ) {
return false;
}
$wc_payments_gateway = self::get_gateway();
if ( $wc_payments_gateway && method_exists( $wc_payments_gateway, 'is_connected' ) ) {
return $wc_payments_gateway->is_connected();
}
return false;
@@ -164,11 +180,13 @@ class WooCommercePayments extends Task {
* @return bool
*/
public static function is_account_partially_onboarded() {
if ( class_exists( '\WC_Payments' ) ) {
$wc_payments_gateway = \WC_Payments::get_gateway();
return method_exists( $wc_payments_gateway, 'is_account_partially_onboarded' )
? $wc_payments_gateway->is_account_partially_onboarded()
: false;
if ( ! self::is_wcpay_active() ) {
return false;
}
$wc_payments_gateway = self::get_gateway();
if ( $wc_payments_gateway && method_exists( $wc_payments_gateway, 'is_account_partially_onboarded' ) ) {
return $wc_payments_gateway->is_account_partially_onboarded();
}
return false;
@@ -195,4 +213,39 @@ class WooCommercePayments extends Task {
}
return false;
}
/**
* Get the WooPayments gateway.
*
* @return \WC_Payments|null
*/
private static function get_gateway() {
$payment_gateways = WC()->payment_gateways->payment_gateways();
if ( isset( $payment_gateways['woocommerce_payments'] ) ) {
return $payment_gateways['woocommerce_payments'];
}
return null;
}
/**
* Check if the store has any enabled ecommerce gateways, other than WooPayments.
*
* We exclude offline payment methods from this check.
*
* @return bool
*/
public static function has_other_ecommerce_gateways(): bool {
$gateways = WC()->payment_gateways->get_available_payment_gateways();
$enabled_gateways = array_filter(
$gateways,
function ( $gateway ) {
// Filter out any WooPayments-related or offline gateways.
return 'yes' === $gateway->enabled
&& 0 !== strpos( $gateway->id, 'woocommerce_payments' )
&& ! in_array( $gateway->id, array( 'bacs', 'cheque', 'cod' ), true );
}
);
return ! empty( $enabled_gateways );
}
}

View File

@@ -13,6 +13,13 @@ use Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\RuleEvaluator;
* Evaluates the spec and returns the evaluated suggestion.
*/
class EvaluateSuggestion {
/**
* Stores memoized results of evaluate_specs.
*
* @var array
*/
protected static $memo = array();
/**
* Evaluates the spec and returns the suggestion.
*
@@ -58,6 +65,12 @@ class EvaluateSuggestion {
* @return array The visible suggestions and errors.
*/
public static function evaluate_specs( $specs, $logger_args = array() ) {
$specs_key = self::get_memo_key( $specs );
if ( isset( self::$memo[ $specs_key ] ) ) {
return self::$memo[ $specs_key ];
}
$suggestions = array();
$errors = array();
@@ -72,9 +85,43 @@ class EvaluateSuggestion {
}
}
return array(
$result = array(
'suggestions' => $suggestions,
'errors' => $errors,
);
// Memoize results, with a fail safe to prevent unbounded memory growth.
// This limit is unlikely to be reached under normal circumstances.
if ( count( self::$memo ) > 50 ) {
self::reset_memo();
}
self::$memo[ $specs_key ] = $result;
return $result;
}
/**
* Resets the memoized results. Useful for testing.
*/
public static function reset_memo() {
self::$memo = array();
}
/**
* Returns a memoization key for the given specs.
*
* @param array $specs The specs to generate a key for.
*
* @return string The memoization key.
*/
private static function get_memo_key( $specs ) {
$data = wp_json_encode( $specs );
if ( function_exists( 'hash' ) && in_array( 'xxh3', hash_algos(), true ) ) {
// Use xxHash (xxh3) if available.
return hash( 'xxh3', $data );
}
// Fall back to CRC32.
return (string) crc32( $data );
}
}

View File

@@ -172,7 +172,7 @@ class Init {
if ( ! PageController::is_admin_page() ) {
return;
}
// Dequeing this to avoid conflicts, until we remove the 'woocommerce-page' class.
// Dequeuing this to avoid conflicts, until we remove the 'woocommerce-page' class.
wp_dequeue_style( 'woocommerce-blocktheme' );
}

View File

@@ -59,7 +59,7 @@ class ProductFormsController {
}
/**
* Create ot update a product_form post for each product form template.
* Create or update a product_form post for each product form template.
* If the post already exists, it will be updated.
* If the post does not exist, it will be created even if the action is `update`.
*

View File

@@ -96,7 +96,7 @@ class RedirectionController {
/**
* Check if a product is supported by the new experience.
*
* @param array $product_templates The registered product teamplates.
* @param array $product_templates The registered product templates.
*/
public function set_product_templates( array $product_templates ): void {
$this->product_templates = $product_templates;

View File

@@ -0,0 +1,145 @@
<?php
/**
* WooCommerce Product Data Views
*/
declare( strict_types = 1 );
namespace Automattic\WooCommerce\Admin\Features\ProductDataViews;
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Blocks\Utils\Utils;
use Automattic\WooCommerce\Internal\Admin\WCAdminAssets;
/**
* Loads assets related to the product block editor.
*/
class Init {
/**
* Constructor
*/
public function __construct() {
if ( $this->has_data_views_support() ) {
add_action( 'admin_menu', array( $this, 'woocommerce_add_new_products_dashboard' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
if ( $this->is_product_data_view_page() ) {
add_filter(
'admin_body_class',
static function ( $classes ) {
return "$classes is-fullscreen-mode";
}
);
}
}
}
/**
* Returns true if we are on a JS powered admin page.
*/
private static function is_product_data_view_page() {
// phpcs:disable WordPress.Security.NonceVerification
return isset( $_GET['page'] ) && 'woocommerce-products-dashboard' === $_GET['page'];
// phpcs:enable WordPress.Security.NonceVerification
}
/**
* Checks for data views support.
*/
private function has_data_views_support() {
if ( Utils::wp_version_compare( '6.6', '>=' ) ) {
return true;
}
if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
$gutenberg_version = '';
if ( defined( 'GUTENBERG_VERSION' ) ) {
$gutenberg_version = GUTENBERG_VERSION;
}
if ( ! $gutenberg_version ) {
$gutenberg_data = get_file_data(
WP_PLUGIN_DIR . '/gutenberg/gutenberg.php',
array( 'Version' => 'Version' )
);
$gutenberg_version = $gutenberg_data['Version'];
}
return version_compare( $gutenberg_version, '19.0', '>=' );
}
return false;
}
/**
* Enqueue styles needed for the rich text editor.
*/
public function enqueue_styles() {
if ( ! $this->is_product_data_view_page() ) {
return;
}
wp_enqueue_style( 'wc-product-editor' );
}
/**
* Enqueue scripts needed for the product form block editor.
*/
public function enqueue_scripts() {
if ( ! $this->is_product_data_view_page() ) {
return;
}
$script_handle = 'wc-admin-edit-product';
wp_register_script( $script_handle, '', array( 'wp-blocks' ), '0.1.0', true );
wp_enqueue_script( $script_handle );
wp_enqueue_media();
wp_register_style( 'wc-global-presets', false ); // phpcs:ignore
wp_add_inline_style( 'wc-global-presets', wp_get_global_stylesheet( array( 'presets' ) ) );
wp_enqueue_style( 'wc-global-presets' );
}
/**
* Replaces the default posts menu item with the new posts dashboard.
*/
public function woocommerce_add_new_products_dashboard() {
$gutenberg_experiments = get_option( 'gutenberg-experiments' );
if ( ! $gutenberg_experiments ) {
return;
}
$ptype_obj = get_post_type_object( 'product' );
add_submenu_page(
'woocommerce',
$ptype_obj->labels->name,
esc_html__( 'All Products', 'woocommerce' ),
'manage_woocommerce',
'woocommerce-products-dashboard',
array( $this, 'woocommerce_products_dashboard' ),
1
);
}
/**
* Renders the new posts dashboard page.
*/
public function woocommerce_products_dashboard() {
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
if ( function_exists( 'gutenberg_url' ) ) {
// phpcs:disable WordPress.WP.EnqueuedResourceParameters.MissingVersion
wp_register_style(
'wp-gutenberg-posts-dashboard',
gutenberg_url( 'build/edit-site/posts.css', __FILE__ ),
array( 'wp-components' ),
);
// phpcs:enable WordPress.WP.EnqueuedResourceParameters.MissingVersion
wp_enqueue_style( 'wp-gutenberg-posts-dashboard' );
}
WCAdminAssets::get_instance();
wp_enqueue_script( 'wc-admin-product-editor', WC()->plugin_url() . '/assets/js/admin/product-editor' . $suffix . '.js', array( 'wc-product-editor' ), $version, false );
wp_add_inline_script( 'wp-edit-site', 'window.wc.productEditor.initializeProductsDashboard( "woocommerce-products-dashboard" );', 'after' );
wp_enqueue_script( 'wp-edit-site' );
echo '<div id="woocommerce-products-dashboard"></div>';
}
}

View File

@@ -1,21 +1,16 @@
<?php
<?php //phpcs:ignore Generic.PHP.RequireStrictTypes.MissingDeclaration
/**
* WooCommerce Settings.
*/
namespace Automattic\WooCommerce\Internal\Admin;
namespace Automattic\WooCommerce\Admin\Features;
use Automattic\WooCommerce\Admin\PageController;
/**
* Contains backend logic for the Settings feature.
*/
class SettingsNavigationFeature {
/**
* Option name used to toggle this feature.
*/
const TOGGLE_OPTION_NAME = 'woocommerce_settings_enabled';
class Settings {
/**
* Class instance.
*
@@ -41,12 +36,6 @@ class SettingsNavigationFeature {
return;
}
add_filter( 'woocommerce_settings_features', array( $this, 'add_feature_toggle' ) );
if ( 'yes' !== get_option( 'woocommerce_settings_enabled', 'no' ) ) {
return;
}
add_filter( 'woocommerce_admin_shared_settings', array( __CLASS__, 'add_component_settings' ) );
// Run this after the original WooCommerce settings have been added.
add_action( 'admin_menu', array( $this, 'register_pages' ), 60 );
@@ -75,26 +64,6 @@ class SettingsNavigationFeature {
return $settings;
}
/**
* Add the feature toggle to the features settings.
*
* @param array $features Feature sections.
* @return array
*/
public static function add_feature_toggle( $features ) {
$features[] = array(
'title' => __( 'Settings', 'woocommerce' ),
'desc' => __(
'Adds the new WooCommerce settings UI.',
'woocommerce'
),
'id' => 'woocommerce_settings_enabled',
'type' => 'checkbox',
);
return $features;
}
/**
* Registers settings pages.
*/

View File

@@ -316,19 +316,10 @@ class DefaultShippingPartners {
* @return object Rules to match.
*/
public static function get_rules_for_countries( $countries ) {
$rules = array();
foreach ( $countries as $country ) {
$rules[] = (object) array(
'type' => 'base_location_country',
'value' => $country,
'operation' => '=',
);
}
return (object) array(
'type' => 'or',
'operands' => $rules,
'type' => 'base_location_country',
'operation' => 'in',
'value' => $countries,
);
}
}

View File

@@ -534,7 +534,7 @@ class Note extends \WC_Data {
$this->error( 'admin_note_invalid_data', __( 'The admin note date prop cannot be empty.', 'woocommerce' ) );
}
if ( is_string( $date ) ) {
if ( is_string( $date ) && ! is_numeric( $date ) ) {
$date = wc_string_to_timestamp( $date );
}
$this->set_date_prop( 'date_created', $date );
@@ -546,7 +546,7 @@ class Note extends \WC_Data {
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.
*/
public function set_date_reminder( $date ) {
if ( is_string( $date ) ) {
if ( is_string( $date ) && ! is_numeric( $date ) ) {
$date = wc_string_to_timestamp( $date );
}
$this->set_date_prop( 'date_reminder', $date );
@@ -579,6 +579,11 @@ class Note extends \WC_Data {
$layout = 'plain';
}
$valid_layouts = array( 'banner', 'plain', 'thumbnail' );
if ( 'banner' === $layout ) {
wc_deprecated_argument( 'Note::set_layout', '9.4.0', 'The "banner" layout is deprecated. Please use "thumbnail" instead to display a image.' );
}
if ( in_array( $layout, $valid_layouts, true ) ) {
$this->set_prop( 'layout', $layout );
} else {
@@ -676,7 +681,7 @@ class Note extends \WC_Data {
*
* @param string $note_action_name Name of action to add a nonce to.
* @param string $nonce_action The nonce action.
* @param string $nonce_name The nonce Name. This is used as the paramater name in the resulting URL for the action.
* @param string $nonce_name The nonce Name. This is used as the parameter name in the resulting URL for the action.
* @return void
* @throws \Exception If note name cannot be found.
*/

View File

@@ -24,6 +24,7 @@ class Notes {
add_action( 'admin_init', array( __CLASS__, 'schedule_unsnooze_notes' ) );
add_action( 'admin_init', array( __CLASS__, 'possibly_delete_survey_notes' ) );
add_action( 'update_option_woocommerce_show_marketplace_suggestions', array( __CLASS__, 'possibly_delete_marketing_notes' ), 10, 2 );
add_action( self::UNSNOOZE_HOOK, array( __CLASS__, 'unsnooze_notes' ) );
}
/**
@@ -406,7 +407,6 @@ class Notes {
wp_set_current_user( $user_id );
self::record_tracks_event_without_cookies( $event_name, $params );
wp_set_current_user( $current_user_id );
}
/**

View File

@@ -220,7 +220,7 @@ class PageController {
*/
public function get_current_page() {
// If 'current_screen' hasn't fired yet, the current page calculation
// will fail which causes `false` to be returned for all subsquent calls.
// will fail which causes `false` to be returned for all subsequent calls.
if ( ! did_action( 'current_screen' ) ) {
_doing_it_wrong( __FUNCTION__, esc_html__( 'Current page retrieval should be called on or after the `current_screen` hook.', 'woocommerce' ), '0.16.0' );
}
@@ -394,7 +394,7 @@ class PageController {
}
/**
* Returns true if we are on a page registed with this controller.
* Returns true if we are on a page registered with this controller.
*
* @return boolean
*/
@@ -530,7 +530,7 @@ class PageController {
*/
public function remove_app_entry_page_menu_item() {
global $submenu;
// User does not have capabilites to see the submenu.
// User does not have capabilities to see the submenu.
if ( ! current_user_can( 'manage_woocommerce' ) || empty( $submenu['woocommerce'] ) ) {
return;
}

View File

@@ -33,17 +33,24 @@ if ( ! function_exists( 'get_plugins' ) ) {
class PluginsHelper {
/**
* Indicates whether the expiration notice for subscriptions can be displayed.
* Subscription notices in Woo screens are shown in clear priority order, first
* expired, and if those don't exist, expiring, and finally if none of those exist,
* then missing. This keeps track of whether we can show the next set of notices.
*
* @var bool
*/
public static $can_show_expiring_subs_notice = true;
public static $subscription_usage_notices_already_shown = false;
/**
* The URL for the WooCommerce subscription page.
*/
const WOO_SUBSCRIPTION_PAGE_URL = 'https://woocommerce.com/my-account/my-subscriptions/';
/**
* The URL for the WooCommerce.com cart page.
*/
const WOO_CART_PAGE_URL = 'https://woocommerce.com/cart/';
/**
* The URL for the WooCommerce.com add payment method page.
*/
@@ -59,6 +66,11 @@ class PluginsHelper {
*/
const DISMISS_EXPIRING_SUBS_NOTICE = 'woo_subscription_expiring_notice_dismiss';
/**
* Meta key for dismissing missing subscription notices
*/
const DISMISS_MISSING_SUBS_NOTICE = 'woo_subscription_missing_notice_dismiss';
/**
* Initialize hooks.
*/
@@ -67,10 +79,7 @@ class PluginsHelper {
add_action( 'woocommerce_plugins_install_and_activate_async_callback', array( __CLASS__, 'install_and_activate_plugins_async_callback' ), 10, 2 );
add_action( 'woocommerce_plugins_activate_callback', array( __CLASS__, 'activate_plugins' ), 10, 2 );
add_action( 'admin_notices', array( __CLASS__, 'maybe_show_connect_notice_in_plugin_list' ) );
add_action( 'admin_notices', array( __CLASS__, 'maybe_show_expired_subscriptions_notice' ), 10 );
add_action( 'admin_notices', array( __CLASS__, 'maybe_show_expiring_subscriptions_notice' ), 11 );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'maybe_enqueue_scripts_for_connect_notice' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'maybe_enqueue_scripts_for_subscription_notice' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'maybe_enqueue_scripts_for_notices_in_plugins' ) );
}
@@ -365,7 +374,7 @@ class PluginsHelper {
}
/**
* Callback regsitered by OnboardingPlugins::install_and_activate_async.
* Callback registered by OnboardingPlugins::install_and_activate_async.
*
* It is used to call install_plugins and activate_plugins with a custom logger.
*
@@ -659,6 +668,7 @@ class PluginsHelper {
wp_enqueue_script( 'woo-plugin-update-connect-notice' );
wp_enqueue_script( 'woo-enable-autorenew' );
wp_enqueue_script( 'woo-renew-subscription' );
wp_enqueue_script( 'woo-purchase-subscription' );
}
/**
@@ -733,11 +743,15 @@ class PluginsHelper {
* @return array notice data to return. Contains type, parsed_message and product_id.
*/
public static function get_subscriptions_notice_data( array $all_subs, array $subs_to_show, int $total, array $messages, string $type ) {
$utm_campaign = 'expired' === $type ?
'pu_settings_screen_renew' :
( 'missing' === $type ? 'pu_settings_screen_purchase' : 'pu_settings_screen_enable_autorenew' );
if ( 1 < $total ) {
$hyperlink_url = add_query_arg(
array(
'utm_source' => 'pu',
'utm_campaign' => 'expired' === $type ? 'pu_settings_screen_renew' : 'pu_settings_screen_enable_autorenew',
'utm_campaign' => $utm_campaign,
),
self::WOO_SUBSCRIPTION_PAGE_URL
@@ -750,10 +764,18 @@ class PluginsHelper {
esc_attr( $total ),
);
// All product ids.
$product_ids = array_map(
function ( $sub ) {
return $sub['product_id'];
},
$subs_to_show
);
return array(
'type' => 'different_subscriptions',
'parsed_message' => $parsed_message,
'product_id' => '',
'product_ids' => $product_ids,
);
}
@@ -769,8 +791,9 @@ class PluginsHelper {
)
);
$message_key = $has_multiple_subs_for_product ? 'multiple_manage' : 'single_manage';
$renew_string = __( 'Renew', 'woocommerce' );
$message_key = $has_multiple_subs_for_product ? 'multiple_manage' : 'single_manage';
$renew_string = __( 'Renew', 'woocommerce' );
$subscribe_string = __( 'Subscribe', 'woocommerce' );
if ( isset( $subscription['product_regular_price'] ) ) {
/* translators: 1: Product price */
$renew_string = sprintf( __( 'Renew for %1$s', 'woocommerce' ), $subscription['product_regular_price'] );
@@ -781,7 +804,7 @@ class PluginsHelper {
'product_id' => $product_id,
'type' => $type,
'utm_source' => 'pu',
'utm_campaign' => 'expired' === $type ? 'pu_settings_screen_renew' : 'pu_settings_screen_enable_autorenew',
'utm_campaign' => $utm_campaign,
),
self::WOO_SUBSCRIPTION_PAGE_URL
@@ -798,7 +821,8 @@ class PluginsHelper {
esc_attr( $subscription['product_name'] ),
esc_attr( $expiry_date ),
esc_url( $hyperlink_url ),
esc_attr( $renew_string ),
// Show subscribe for missing subscriptions, renew otherwise.
'missing' === $type ? esc_attr( $subscribe_string ) : esc_attr( $renew_string ),
);
return array(
@@ -826,7 +850,7 @@ class PluginsHelper {
return array();
}
if ( ! self::$can_show_expiring_subs_notice ) {
if ( self::$subscription_usage_notices_already_shown ) {
return array();
}
@@ -851,6 +875,9 @@ class PluginsHelper {
$total_expiring_subscriptions = count( $expiring_subscriptions );
// Don't show missing notice if there are expiring subscriptions.
self::$subscription_usage_notices_already_shown = true;
// When payment method is missing on WooCommerce.com.
$helper_notices = WC_Helper::get_notices();
if ( ! empty( $helper_notices['missing_payment_method_notice'] ) ) {
@@ -927,8 +954,8 @@ class PluginsHelper {
return array();
}
$total_expired_subscriptions = count( $expired_subscriptions );
self::$can_show_expiring_subs_notice = false;
$total_expired_subscriptions = count( $expired_subscriptions );
self::$subscription_usage_notices_already_shown = true;
$notice_data = self::get_subscriptions_notice_data(
$subscriptions,
@@ -947,17 +974,17 @@ class PluginsHelper {
$button_link = add_query_arg(
array(
'add-to-cart' => $notice_data['product_ids'],
'utm_source' => 'pu',
'utm_campaign' => $allowed_link ? 'pu_settings_screen_renew' : 'pu_in_apps_screen_renew',
),
self::WOO_SUBSCRIPTION_PAGE_URL
self::WOO_CART_PAGE_URL
);
if ( in_array( $notice_data['type'], array( 'single_manage', 'multiple_manage' ), true ) ) {
$button_link = add_query_arg(
array(
'product_id' => $notice_data['product_id'],
'type' => 'expiring',
'add-to-cart' => $notice_data['product_id'],
),
$button_link
);
@@ -970,6 +997,86 @@ class PluginsHelper {
);
}
/**
* Get formatted notice information for missing subscription.
*
* @return array notice information.
*/
public static function get_missing_subscription_notice() {
if ( ! WC_Helper::is_site_connected() ) {
return array();
}
if ( self::$subscription_usage_notices_already_shown ) {
return array();
}
if ( ! self::should_show_notice( self::DISMISS_MISSING_SUBS_NOTICE ) ) {
return array();
}
$subscriptions = WC_Helper::get_subscription_list_data();
$missing_subscriptions = array_filter(
$subscriptions,
function ( $sub ) {
return ( ! empty( $sub['local']['installed'] ) && empty( $sub['product_key'] ) );
},
);
// Remove WUM from missing subscriptions list.
$missing_subscriptions = array_filter(
$missing_subscriptions,
function ( $sub ) {
return 'woo-update-manager' !== $sub['zip_slug'];
}
);
if ( ! $missing_subscriptions ) {
return array();
}
$total_missing_subscriptions = count( $missing_subscriptions );
$notice_data = self::get_subscriptions_notice_data(
$subscriptions,
$missing_subscriptions,
$total_missing_subscriptions,
array(
/* translators: 1) product name */
'single_manage' => __( 'You don\'t have a subscription for <strong>%1$s</strong>. Subscribe to receive updates and streamlined support.', 'woocommerce' ),
/* translators: 1) total expired subscriptions */
'different_subscriptions' => __( 'You don\'t have subscriptions for <strong>%1$s Woo extensions</strong>. Subscribe to receive updates and streamlined support.', 'woocommerce' ),
),
'missing',
);
$button_link = add_query_arg(
array(
'add-to-cart' => $notice_data['product_ids'],
'utm_source' => 'pu',
'utm_campaign' => 'pu_in_apps_screen_purchase',
),
self::WOO_CART_PAGE_URL
);
if ( in_array( $notice_data['type'], array( 'single_manage', 'multiple_manage' ), true ) ) {
$button_link = add_query_arg(
array(
'add-to-cart' => $notice_data['product_id'],
),
$button_link
);
}
$button_text = __( 'Subscribe', 'woocommerce' );
return array(
'description' => $notice_data['parsed_message'],
'button_text' => $button_text,
'button_link' => $button_link,
);
}
/**
* Determine whether a specific notice should be shown to the current user.
*

View File

@@ -32,7 +32,7 @@ class AsyncPluginsInstallLogger implements PluginsInstallLogger {
'no'
);
// Set status as failed in case we run out of exectuion time.
// Set status as failed in case we run out of execution time.
register_shutdown_function(
function () {
$error = error_get_last();
@@ -57,7 +57,7 @@ class AsyncPluginsInstallLogger implements PluginsInstallLogger {
}
/**
* Retreive the option.
* Retrieve the option.
*
* @return false|mixed|void
*/

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor that performs a comparison operation against the base
* location - country.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
defined( 'ABSPATH' ) || exit;
/**
* Rule processor that performs a comparison operation against the base
* location - country.
*
* @deprecated 8.8.0
*/
class BaseLocationCountryRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\BaseLocationCountryRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor that performs a comparison operation against the base
* location - state.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
defined( 'ABSPATH' ) || exit;
/**
* Rule processor that performs a comparison operation against the base
* location - state.
*
* @deprecated 8.8.0
*/
class BaseLocationStateRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\BaseLocationStateRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Compare two operands using the specified operation.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Compare two operands using the specified operation.
*
* @deprecated 8.8.0
*/
class ComparisonOperation extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\ComparisonOperation';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Evaluates the spec and returns a status.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Evaluates the spec and returns a status.
*
* @deprecated 8.8.0
*/
class EvaluateAndGetStatus extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\EvaluateAndGetStatus';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,27 +0,0 @@
<?php
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Class EvaluationLogger
*
* @package Automattic\WooCommerce\Admin\RemoteInboxNotifications
*
* @deprecated 8.8.0
*/
class EvaluationLogger extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\EvaluationLogger';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor that fails.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that fails.
*
* @deprecated 8.8.0
*/
class FailRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\FailRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Gets the processor for the specified rule type.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Class encapsulating getting the processor for a given rule type.
*
* @deprecated 8.8.0
*/
class GetRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\GetRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,35 +0,0 @@
<?php
/**
* Rule processor that passes (or fails) when the site is on the eCommerce
* plan.
*
* @package WooCommerce\Admin\Classes
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that passes (or fails) when the site is on the eCommerce
* plan.
*
* @deprecated 8.8.0
*/
class IsEcommerceRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\IsEcommerceRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,34 +0,0 @@
<?php
/**
* Rule processor that passes (or fails) when the site is on a Woo Express plan.
*
* @package WooCommerce\Admin\Classes
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that passes (or fails) when the site is on a Woo Express plan.
* You may optionally pass a plan name to target a specific Woo Express plan.
*
* @deprecated 8.8.0
*/
class IsWooExpressRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\IsWooExpressRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor that negates the rules in the rule's operand.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that negates the rules in the rule's operand.
*
* @deprecated 8.8.0
*/
class NotRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\NotRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor that compares against the status of another note. For
* example, this could be used to conditionally create a note only if another
* note has not been actioned.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that compares against the status of another note.
*
* @deprecated 8.8.0
*/
class NoteStatusRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\NoteStatusRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor that performs a comparison operation against a value in the
* onboarding profile.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that performs a comparison operation against a value in the
* onboarding profile.
*
* @deprecated 8.8.0
*/
class OnboardingProfileRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\OnboardingProfileRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor that performs a comparison operation against an option value.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that performs a comparison operation against an option value.
*
* @deprecated 8.8.0
*/
class OptionRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\OptionRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor that performs an OR operation on the rule's left and right
* operands.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that performs an OR operation on the rule's left and right
* operands.
*
* @deprecated 8.8.0
*/
class OrRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\OrRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor for publishing based on the number of orders.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor for publishing based on the number of orders.
*
* @deprecated 8.8.0
*/
class OrderCountRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\OrderCountRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Provider for order-related queries and operations.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Provider for order-related queries and operations.
*
* @deprecated 8.8.0
*/
class OrdersProvider extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\OrdersProvider';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,32 +0,0 @@
<?php
/**
* Rule processor that passes. This is required because an empty set of rules
* (or predicate) evaluates to false.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that passes.
*
* @deprecated 8.8.0
*/
class PassRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\PassRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor for sending when the provided plugin is activated and
* matches the specified version.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor for sending when the provided plugin is activated and
* matches the specified version.
*
* @deprecated 8.8.0
*/
class PluginVersionRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\PluginVersionRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor for sending when the provided plugins are activated.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor for sending when the provided plugins are activated.
*
* @deprecated 8.8.0
*/
class PluginsActivatedRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\PluginsActivatedRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor that performs a comparison operation against the number of
* products.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that performs a comparison operation against the number of
* products.
*
* @deprecated 8.8.0
*/
class ProductCountRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\ProductCountRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor for sending after a specified date/time.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor for sending after a specified date/time.
*
* @deprecated 8.8.0
*/
class PublishAfterTimeRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\PublishAfterTimeRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor for sending before a specified date/time.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor for sending before a specified date/time.
*
* @deprecated 8.8.0
*/
class PublishBeforeTimeRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\PublishBeforeTimeRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* Evaluate the given rules as an AND operation - return false early if a
* rule evaluates to false.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Evaluate the given rules as an AND operation - return false early if a
* rule evaluates to false.
*
* @deprecated 8.8.0
*/
class RuleEvaluator extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\RuleEvaluator';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* Interface for a rule processor.
*
* @deprecated 9.4.0 Use \Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\RuleProcessorInterface instead.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
@@ -9,6 +11,8 @@ defined( 'ABSPATH' ) || exit;
/**
* Rule processor interface
*
* @deprecated 9.4.0 Use \Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\RuleProcessorInterface instead.
*/
interface RuleProcessorInterface {
/**

View File

@@ -72,6 +72,9 @@ class SpecRunner {
if ( isset( $spec->source ) ) {
$note->set_source( $spec->source );
}
if ( isset( $spec->layout ) ) {
$note->set_layout( $spec->layout );
}
// Recreate actions.
$note->set_actions( self::get_actions( $spec ) );

View File

@@ -1,33 +0,0 @@
<?php
/**
* Rule processor that performs a comparison operation against a value in the
* stored state object.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that performs a comparison operation against a value in the
* stored state object.
*
* @deprecated 8.8.0
*/
class StoredStateRuleProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\StoredStateRuleProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Handles stored state setup for products.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Handles stored state setup for products.
*
* @deprecated 8.8.0
*/
class StoredStateSetupForProducts extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\StoredStateSetupForProducts';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* Rule processor that passes when a store's payments volume exceeds a provided amount.
*/
namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
/**
* Rule processor that passes when a store's payments volume exceeds a provided amount.
*
* @deprecated 8.8.0
*/
class TotalPaymentsVolumeProcessor extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\TotalPaymentsVolumeProcessor';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '8.8.0';
}

Some files were not shown because too many files have changed in this diff Show More