Merged in feature/280-dev-dev01 (pull request #21)
auto-patch 280-dev-dev01-2024-01-19T16_41_58 * auto-patch 280-dev-dev01-2024-01-19T16_41_58
This commit is contained in:
@@ -49,6 +49,9 @@ class Init {
|
||||
|
||||
// Add currency symbol to orders endpoint response.
|
||||
add_filter( 'woocommerce_rest_prepare_shop_order_object', array( __CLASS__, 'add_currency_symbol_to_order_response' ) );
|
||||
|
||||
include_once WC_ABSPATH . 'includes/admin/class-wc-admin-upload-downloadable-product.php';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,7 +93,7 @@ class Controller extends GenericController implements ExportableInterface {
|
||||
$result = $query->query( $query_args );
|
||||
|
||||
$total_posts = $query->found_posts;
|
||||
if ( $total_posts < 1 ) {
|
||||
if ( $total_posts < 1 && isset( $query_args['paged'] ) && absint( $query_args['paged'] ) > 1 ) {
|
||||
// Out-of-bounds, run the query again without LIMIT for total count.
|
||||
unset( $query_args['paged'] );
|
||||
$count_query = new \WP_Query();
|
||||
|
||||
@@ -223,13 +223,16 @@ class Menu {
|
||||
}
|
||||
|
||||
if ( isset( self::$menu_items[ $args['id'] ] ) ) {
|
||||
error_log( // phpcs:ignore
|
||||
wc_doing_it_wrong(
|
||||
__METHOD__,
|
||||
sprintf(
|
||||
/* translators: 1: Duplicate menu item path. */
|
||||
esc_html__( 'You have attempted to register a duplicate item with WooCommerce Navigation: %1$s', 'woocommerce' ),
|
||||
'`' . $args['id'] . '`'
|
||||
)
|
||||
),
|
||||
'6.5.0'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class Shipping extends Task {
|
||||
return true;
|
||||
}
|
||||
|
||||
return in_array( $store_country, array( 'CA', 'AU', 'GB', 'ES', 'IT', 'DE', 'FR', 'MX', 'CO', 'CL', 'AR', 'PE', 'BR', 'UY', 'GT', 'NL', 'AT', 'BE' ), true );
|
||||
return in_array( $store_country, array( 'CA', 'AU', 'NZ', 'SG', 'HK', 'GB', 'ES', 'IT', 'DE', 'FR', 'CL', 'AR', 'PE', 'BR', 'UY', 'GT', 'NL', 'AT', 'BE' ), true );
|
||||
}
|
||||
|
||||
return self::has_physical_products();
|
||||
|
||||
@@ -30,6 +30,7 @@ class BlockRegistry {
|
||||
'woocommerce/product-radio-field',
|
||||
'woocommerce/product-pricing-field',
|
||||
'woocommerce/product-section',
|
||||
'woocommerce/product-section-description',
|
||||
'woocommerce/product-tab',
|
||||
'woocommerce/product-toggle-field',
|
||||
'woocommerce/product-taxonomy-field',
|
||||
@@ -59,10 +60,37 @@ class BlockRegistry {
|
||||
'woocommerce/product-variation-items-field',
|
||||
'woocommerce/product-variations-fields',
|
||||
'woocommerce/product-password-field',
|
||||
'woocommerce/product-list-field',
|
||||
'woocommerce/product-has-variations-notice',
|
||||
'woocommerce/product-single-variation-notice',
|
||||
);
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @var BlockRegistry
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Get the singleton instance.
|
||||
*/
|
||||
public static function get_instance(): BlockRegistry {
|
||||
if ( ! self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
protected function __construct() {
|
||||
add_filter( 'block_categories_all', array( $this, 'register_categories' ), 10, 2 );
|
||||
$this->register_product_blocks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file path for a given block file.
|
||||
*
|
||||
@@ -73,14 +101,6 @@ class BlockRegistry {
|
||||
return WC_ABSPATH . WCAdminAssets::get_path( 'js' ) . trailingslashit( $dir ) . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all blocks.
|
||||
*/
|
||||
public function init() {
|
||||
add_filter( 'block_categories_all', array( $this, 'register_categories' ), 10, 2 );
|
||||
$this->register_product_blocks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all the product blocks.
|
||||
*/
|
||||
@@ -189,29 +209,65 @@ class BlockRegistry {
|
||||
$block_name = $this->remove_block_prefix( $block_name );
|
||||
$block_json_file = $this->get_file_path( $block_name . '/block.json', $block_dir );
|
||||
|
||||
if ( ! file_exists( $block_json_file ) ) {
|
||||
return $this->register_block_type_from_metadata( $block_json_file );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is registered.
|
||||
*
|
||||
* @param string $block_name Block name.
|
||||
*/
|
||||
public function is_registered( $block_name ): bool {
|
||||
$registry = \WP_Block_Type_Registry::get_instance();
|
||||
|
||||
return $registry->is_registered( $block_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a block.
|
||||
*
|
||||
* @param string $block_name Block name.
|
||||
*/
|
||||
public function unregister( $block_name ) {
|
||||
$registry = \WP_Block_Type_Registry::get_instance();
|
||||
|
||||
if ( $registry->is_registered( $block_name ) ) {
|
||||
$registry->unregister( $block_name );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a block type from metadata stored in the block.json file.
|
||||
*
|
||||
* @param string $file_or_folder Path to the JSON file with metadata definition for the block or
|
||||
* path to the folder where the `block.json` file is located.
|
||||
*
|
||||
* @return \WP_Block_Type|false The registered block type on success, or false on failure.
|
||||
*/
|
||||
public function register_block_type_from_metadata( $file_or_folder ) {
|
||||
$metadata_file = ( ! str_ends_with( $file_or_folder, 'block.json' ) )
|
||||
? trailingslashit( $file_or_folder ) . 'block.json'
|
||||
: $file_or_folder;
|
||||
|
||||
if ( ! file_exists( $metadata_file ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We are dealing with a local file, so we can use file_get_contents.
|
||||
// phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
|
||||
$metadata = json_decode( file_get_contents( $block_json_file ), true );
|
||||
$metadata = json_decode( file_get_contents( $metadata_file ), true );
|
||||
if ( ! is_array( $metadata ) || ! $metadata['name'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$registry = \WP_Block_Type_Registry::get_instance();
|
||||
|
||||
if ( $registry->is_registered( $metadata['name'] ) ) {
|
||||
$registry->unregister( $metadata['name'] );
|
||||
}
|
||||
$this->unregister( $metadata['name'] );
|
||||
|
||||
return register_block_type_from_metadata(
|
||||
$block_json_file,
|
||||
$metadata_file,
|
||||
array(
|
||||
'attributes' => $this->augment_attributes( isset( $metadata['attributes'] ) ? $metadata['attributes'] : array() ),
|
||||
'uses_context' => $this->augment_uses_context( isset( $metadata['usesContext'] ) ? $metadata['usesContext'] : array() ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ class Init {
|
||||
array_push( $this->supported_post_types, 'external' );
|
||||
}
|
||||
|
||||
if ( Features::is_enabled( 'product-grouped' ) ) {
|
||||
array_push( $this->supported_post_types, 'grouped' );
|
||||
}
|
||||
|
||||
$this->redirection_controller = new RedirectionController( $this->supported_post_types );
|
||||
|
||||
if ( \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ) {
|
||||
@@ -63,8 +67,8 @@ class Init {
|
||||
|
||||
add_action( 'current_screen', array( $this, 'set_current_screen_to_block_editor_if_wc_admin' ) );
|
||||
|
||||
$block_registry = new BlockRegistry();
|
||||
$block_registry->init();
|
||||
// Make sure the block registry is initialized so that core blocks are registered.
|
||||
BlockRegistry::get_instance();
|
||||
|
||||
$tracks = new Tracks();
|
||||
$tracks->init();
|
||||
@@ -175,7 +179,7 @@ class Init {
|
||||
$user_data_fields,
|
||||
array(
|
||||
'variable_product_block_tour_shown',
|
||||
'product_block_variable_options_notice_dismissed',
|
||||
'local_attributes_notice_dismissed_ids',
|
||||
'variable_items_without_price_notice_dismissed',
|
||||
)
|
||||
);
|
||||
|
||||
@@ -45,6 +45,7 @@ class DefaultShippingPartners {
|
||||
|
||||
return array(
|
||||
array(
|
||||
'id' => 'woocommerce-shipstation-integration',
|
||||
'name' => 'ShipStation',
|
||||
'slug' => 'woocommerce-shipstation-integration',
|
||||
'description' => __( 'Powerful yet easy-to-use solution:', 'woocommerce' ),
|
||||
@@ -90,6 +91,7 @@ class DefaultShippingPartners {
|
||||
'available_layouts' => array( 'row', 'column' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'skydropx-cotizador-y-envios',
|
||||
'name' => 'Skydropx',
|
||||
'slug' => 'skydropx-cotizador-y-envios',
|
||||
'layout_column' => array(
|
||||
@@ -99,11 +101,12 @@ class DefaultShippingPartners {
|
||||
'description' => '',
|
||||
'learn_more_link' => 'https://wordpress.org/plugins/skydropx-cotizador-y-envios/',
|
||||
'is_visible' => array(
|
||||
self::get_rules_for_countries( array( 'MX', 'CO' ) ),
|
||||
self::get_rules_for_countries( array() ), // No countries eligible for SkydropX promotion at this time.
|
||||
),
|
||||
'available_layouts' => array( 'column' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'envia',
|
||||
'name' => 'Envia',
|
||||
'slug' => '',
|
||||
'description' => '',
|
||||
@@ -118,6 +121,50 @@ class DefaultShippingPartners {
|
||||
'available_layouts' => array( 'column' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'easyship-woocommerce-shipping-rates',
|
||||
'name' => 'Easyship',
|
||||
'slug' => 'easyship-woocommerce-shipping-rates',
|
||||
'description' => __( 'Simplified shipping with: ', 'woocommerce' ),
|
||||
'layout_column' => array(
|
||||
'image' => $asset_base_url . 'easyship-column.svg',
|
||||
'features' => $column_layout_features,
|
||||
),
|
||||
'layout_row' => array(
|
||||
'image' => $asset_base_url . 'easyship-row.svg',
|
||||
'features' => array(
|
||||
array(
|
||||
'icon' => $check_icon,
|
||||
'description' => __( 'Highly discounted shipping rates', 'woocommerce' ),
|
||||
),
|
||||
array(
|
||||
'icon' => $check_icon,
|
||||
'description' => __(
|
||||
'Seamless order sync and label printing',
|
||||
'woocommerce'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'icon' => $check_icon,
|
||||
'description' => __( 'Branded tracking experience', 'woocommerce' ),
|
||||
),
|
||||
array(
|
||||
'icon' => $check_icon,
|
||||
'description' => __( 'Built-in Tax & Duties paperwork', 'woocommerce' ),
|
||||
),
|
||||
array(
|
||||
'icon' => $check_icon,
|
||||
'description' => __( 'Free Plan Available', 'woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'learn_more_link' => 'https://woo.com/products/easyship-shipping-rates/',
|
||||
'is_visible' => array(
|
||||
self::get_rules_for_countries( array( 'SG', 'HK', 'AU', 'NZ' ) ),
|
||||
),
|
||||
'available_layouts' => array( 'row', 'column' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'sendcloud-shipping',
|
||||
'name' => 'Sendcloud',
|
||||
'slug' => 'sendcloud-shipping',
|
||||
'description' => __( 'All-in-one shipping tool:', 'woocommerce' ),
|
||||
@@ -161,6 +208,7 @@ class DefaultShippingPartners {
|
||||
'available_layouts' => array( 'row', 'column' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'packlink-pro-shipping',
|
||||
'name' => 'Packlink',
|
||||
'slug' => 'packlink-pro-shipping',
|
||||
'description' => __( 'Optimize your full shipping process:', 'woocommerce' ),
|
||||
@@ -209,6 +257,7 @@ class DefaultShippingPartners {
|
||||
'available_layouts' => array( 'row', 'column' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'woocommerce-services',
|
||||
'name' => 'WooCommerce Shipping',
|
||||
'slug' => 'woocommerce-services',
|
||||
'description' => __( 'Save time and money by printing your shipping labels right from your computer with WooCommerce Shipping. Try WooCommerce Shipping for free.', 'woocommerce' ),
|
||||
|
||||
Reference in New Issue
Block a user