Merged in release/release-1.09 (pull request #10)
Release/release 1.09 * Install missing plugins * rs set to 1 * rebase pantheon for aws * rebase pantheon for aws * prod config change * prod config change * fix campaing issue * revert Approved-by: Jay Sharma
This commit is contained in:
committed by
Jay Sharma
parent
779393381f
commit
22f10a9edd
@@ -19,17 +19,12 @@ class CustomizeStore extends Task {
|
||||
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'possibly_add_site_editor_scripts' ) );
|
||||
|
||||
add_action( 'show_admin_bar', array( $this, 'possibly_hide_wp_admin_bar' ) );
|
||||
|
||||
// Use "switch_theme" instead of "after_switch_theme" because the latter is fired after the next WP load and we don't want to trigger action when switching theme to TT3 via onboarding theme API.
|
||||
global $_GET;
|
||||
$theme_switch_via_cys_ai_loader = isset( $_GET['theme_switch_via_cys_ai_loader'] ) ? 1 === absint( $_GET['theme_switch_via_cys_ai_loader'] ) : false;
|
||||
if ( ! $theme_switch_via_cys_ai_loader ) {
|
||||
add_action( 'switch_theme', array( $this, 'mark_task_as_complete' ) );
|
||||
}
|
||||
|
||||
// Hook to remove unwanted UI elements when users are viewing with ?cys-hide-admin-bar=true.
|
||||
add_action( 'wp_head', array( $this, 'possibly_remove_unwanted_ui_elements' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,32 +81,17 @@ class CustomizeStore extends Task {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_action_url() {
|
||||
return admin_url( 'wp-admin/admin.php?page=wc-admin&path=%2Fcustomize-store' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Possibly add site editor scripts.
|
||||
*/
|
||||
public function possibly_add_site_editor_scripts() {
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
$is_wc_admin_page = (
|
||||
$is_customize_store_pages = (
|
||||
isset( $_GET['page'] ) &&
|
||||
'wc-admin' === $_GET['page'] &&
|
||||
isset( $_GET['path'] )
|
||||
isset( $_GET['path'] ) &&
|
||||
str_starts_with( wc_clean( wp_unslash( $_GET['path'] ) ), '/customize-store' )
|
||||
);
|
||||
|
||||
$is_assembler_hub = $is_wc_admin_page && str_starts_with( wc_clean( wp_unslash( $_GET['path'] ) ), '/customize-store/assembler-hub' );
|
||||
$is_transitional_page = $is_wc_admin_page && str_starts_with( wc_clean( wp_unslash( $_GET['path'] ) ), '/customize-store/transitional' );
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( ! ( $is_assembler_hub || $is_transitional_page ) ) {
|
||||
if ( ! $is_customize_store_pages ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,31 +204,4 @@ class CustomizeStore extends Task {
|
||||
public function mark_task_as_complete() {
|
||||
update_option( 'woocommerce_admin_customize_store_completed', 'yes' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a small style to hide admin bar
|
||||
*
|
||||
* @param bool $show Whether to show the admin bar.
|
||||
*/
|
||||
public function possibly_hide_wp_admin_bar( $show ) {
|
||||
if ( isset( $_GET['cys-hide-admin-bar'] ) ) { // @phpcs:ignore
|
||||
return false;
|
||||
}
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs script and add styles to remove unwanted elements and hide scrollbar
|
||||
* when users are viewing with ?cys-hide-admin-bar=true.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function possibly_remove_unwanted_ui_elements() {
|
||||
if ( isset( $_GET['cys-hide-admin-bar'] ) ) { // @phpcs:ignore
|
||||
echo '
|
||||
<style type="text/css">
|
||||
body { overflow: hidden; }
|
||||
</style>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class DefaultPaymentGateways {
|
||||
'image' => WC_ADMIN_IMAGES_FOLDER_URL . '/payment_methods/72x72/affirm.png',
|
||||
'image_72x72' => WC_ADMIN_IMAGES_FOLDER_URL . '/payment_methods/72x72/affirm.png',
|
||||
'plugins' => array(),
|
||||
'external_link' => 'https://woo.com/products/woocommerce-gateway-affirm',
|
||||
'external_link' => 'https://woocommerce.com/products/woocommerce-gateway-affirm',
|
||||
'is_visible' => array(
|
||||
self::get_rules_for_countries(
|
||||
array(
|
||||
|
||||
@@ -23,7 +23,7 @@ class BlockRegistry {
|
||||
/**
|
||||
* Array of all available generic blocks.
|
||||
*/
|
||||
const GENERIC_BLOCKS = array(
|
||||
const GENERIC_BLOCKS = [
|
||||
'woocommerce/conditional',
|
||||
'woocommerce/product-checkbox-field',
|
||||
'woocommerce/product-collapsible',
|
||||
@@ -35,12 +35,12 @@ class BlockRegistry {
|
||||
'woocommerce/product-taxonomy-field',
|
||||
'woocommerce/product-text-field',
|
||||
'woocommerce/product-number-field',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of all available product fields blocks.
|
||||
*/
|
||||
const PRODUCT_FIELDS_BLOCKS = array(
|
||||
const PRODUCT_FIELDS_BLOCKS = [
|
||||
'woocommerce/product-catalog-visibility-field',
|
||||
'woocommerce/product-description-field',
|
||||
'woocommerce/product-downloads-field',
|
||||
@@ -61,7 +61,7 @@ class BlockRegistry {
|
||||
'woocommerce/product-password-field',
|
||||
'woocommerce/product-has-variations-notice',
|
||||
'woocommerce/product-single-variation-notice',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Get a file path for a given block file.
|
||||
@@ -136,28 +136,20 @@ class BlockRegistry {
|
||||
// registerWooBlockType function in @woocommerce/block-templates.
|
||||
return array_merge(
|
||||
$attributes,
|
||||
array(
|
||||
'_templateBlockId' => array(
|
||||
[
|
||||
'_templateBlockId' => [
|
||||
'type' => 'string',
|
||||
'__experimentalRole' => 'content',
|
||||
),
|
||||
'_templateBlockOrder' => array(
|
||||
],
|
||||
'_templateBlockOrder' => [
|
||||
'type' => 'integer',
|
||||
'__experimentalRole' => 'content',
|
||||
),
|
||||
'_templateBlockHideConditions' => array(
|
||||
],
|
||||
'_templateBlockHideConditions' => [
|
||||
'type' => 'array',
|
||||
'__experimentalRole' => 'content',
|
||||
),
|
||||
'_templateBlockDisableConditions' => array(
|
||||
'type' => 'array',
|
||||
'__experimentalRole' => 'content',
|
||||
),
|
||||
'disabled' => isset( $attributes['disabled'] ) ? $attributes['disabled'] : array(
|
||||
'type' => 'boolean',
|
||||
'__experimentalRole' => 'content',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -170,10 +162,10 @@ class BlockRegistry {
|
||||
// Note: If you modify this function, also update the client-side
|
||||
// registerProductEditorBlockType function in @woocommerce/product-editor.
|
||||
return array_merge(
|
||||
isset( $uses_context ) ? $uses_context : array(),
|
||||
array(
|
||||
isset( $uses_context ) ? $uses_context : [],
|
||||
[
|
||||
'postType',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -207,10 +199,10 @@ class BlockRegistry {
|
||||
|
||||
return register_block_type_from_metadata(
|
||||
$block_json_file,
|
||||
array(
|
||||
'attributes' => $this->augment_attributes( isset( $metadata['attributes'] ) ? $metadata['attributes'] : array() ),
|
||||
'uses_context' => $this->augment_uses_context( isset( $metadata['usesContext'] ) ? $metadata['usesContext'] : array() ),
|
||||
)
|
||||
[
|
||||
'attributes' => $this->augment_attributes( isset( $metadata['attributes'] ) ? $metadata['attributes'] : [] ),
|
||||
'uses_context' => $this->augment_uses_context( isset( $metadata['usesContext'] ) ? $metadata['usesContext'] : [] ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
namespace Automattic\WooCommerce\Admin\Features\ProductBlockEditor;
|
||||
|
||||
use Automattic\WooCommerce\Admin\Features\Features;
|
||||
use Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates\SimpleProductTemplate;
|
||||
use Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates\ProductVariationTemplate;
|
||||
use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\SimpleProductTemplate;
|
||||
use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductVariationTemplate;
|
||||
use Automattic\WooCommerce\Admin\PageController;
|
||||
use Automattic\WooCommerce\Internal\Admin\BlockTemplateRegistry\BlockTemplateRegistry;
|
||||
use Automattic\WooCommerce\Internal\Admin\BlockTemplates\Block;
|
||||
use Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockTemplateLogger;
|
||||
use WP_Block_Editor_Context;
|
||||
|
||||
/**
|
||||
@@ -45,13 +43,14 @@ class Init {
|
||||
array_push( $this->supported_post_types, 'variable' );
|
||||
}
|
||||
|
||||
if ( Features::is_enabled( 'product-external-affiliate' ) ) {
|
||||
array_push( $this->supported_post_types, 'external' );
|
||||
}
|
||||
|
||||
$this->redirection_controller = new RedirectionController( $this->supported_post_types );
|
||||
|
||||
if ( \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ) {
|
||||
// Register the product block template.
|
||||
$template_registry = wc_get_container()->get( BlockTemplateRegistry::class );
|
||||
$template_registry->register( new SimpleProductTemplate() );
|
||||
$template_registry->register( new ProductVariationTemplate() );
|
||||
|
||||
if ( ! Features::is_enabled( 'new-product-management-experience' ) ) {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'dequeue_conflicting_styles' ), 100 );
|
||||
@@ -59,6 +58,7 @@ class Init {
|
||||
}
|
||||
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
add_filter( 'woocommerce_register_post_type_product', array( $this, 'add_product_template' ) );
|
||||
add_filter( 'woocommerce_register_post_type_product_variation', array( $this, 'enable_rest_api_for_product_variation' ) );
|
||||
|
||||
add_action( 'current_screen', array( $this, 'set_current_screen_to_block_editor_if_wc_admin' ) );
|
||||
@@ -68,9 +68,6 @@ class Init {
|
||||
|
||||
$tracks = new Tracks();
|
||||
$tracks->init();
|
||||
|
||||
// Make sure the block template logger is initialized before any templates are created.
|
||||
BlockTemplateLogger::get_instance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +78,21 @@ class Init {
|
||||
if ( ! PageController::is_admin_or_embed_page() ) {
|
||||
return;
|
||||
}
|
||||
$post_type_object = get_post_type_object( 'product' );
|
||||
$block_editor_context = new WP_Block_Editor_Context( array( 'name' => self::EDITOR_CONTEXT_NAME ) );
|
||||
$template_registry = wc_get_container()->get( BlockTemplateRegistry::class );
|
||||
|
||||
$this->register_product_editor_templates();
|
||||
$editor_settings = $this->get_product_editor_settings();
|
||||
$editor_settings = array();
|
||||
if ( ! empty( $post_type_object->template ) ) {
|
||||
$editor_settings['template'] = $post_type_object->template;
|
||||
$editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false;
|
||||
$editor_settings['templates'] = array(
|
||||
'product' => $post_type_object->template,
|
||||
'product_variation' => $template_registry->get_registered( 'product-variation' )->get_formatted_template(),
|
||||
);
|
||||
}
|
||||
|
||||
$editor_settings = get_block_editor_settings( $editor_settings, $block_editor_context );
|
||||
|
||||
$script_handle = 'wc-admin-edit-product';
|
||||
wp_register_script( $script_handle, '', array(), '0.1.0', true );
|
||||
@@ -152,6 +161,26 @@ class Init {
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles needed for the rich text editor.
|
||||
*
|
||||
* @param array $args Array of post type arguments.
|
||||
* @return array Array of post type arguments.
|
||||
*/
|
||||
public function add_product_template( $args ) {
|
||||
if ( ! isset( $args['template'] ) ) {
|
||||
// Get the template from the registry.
|
||||
$template_registry = wc_get_container()->get( BlockTemplateRegistry::class );
|
||||
$template = $template_registry->get_registered( 'simple-product' );
|
||||
|
||||
if ( isset( $template ) ) {
|
||||
$args['template_lock'] = 'all';
|
||||
$args['template'] = $template->get_formatted_template();
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables variation post type in REST API.
|
||||
*
|
||||
@@ -201,41 +230,4 @@ class Init {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product editor settings.
|
||||
*/
|
||||
private function get_product_editor_settings() {
|
||||
$editor_settings = array();
|
||||
|
||||
$template_registry = wc_get_container()->get( BlockTemplateRegistry::class );
|
||||
$block_template_logger = BlockTemplateLogger::get_instance();
|
||||
|
||||
$block_template_logger->log_template_events_to_file( 'simple-product' );
|
||||
$block_template_logger->log_template_events_to_file( 'product-variation' );
|
||||
|
||||
$editor_settings['templates'] = array(
|
||||
'product' => $template_registry->get_registered( 'simple-product' )->get_formatted_template(),
|
||||
'product_variation' => $template_registry->get_registered( 'product-variation' )->get_formatted_template(),
|
||||
);
|
||||
|
||||
$editor_settings['templateEvents'] = array(
|
||||
'product' => $block_template_logger->get_formatted_template_events( 'simple-product' ),
|
||||
'product_variation' => $block_template_logger->get_formatted_template_events( 'product-variation' ),
|
||||
);
|
||||
|
||||
$block_editor_context = new WP_Block_Editor_Context( array( 'name' => self::EDITOR_CONTEXT_NAME ) );
|
||||
|
||||
return get_block_editor_settings( $editor_settings, $block_editor_context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register product editor templates.
|
||||
*/
|
||||
private function register_product_editor_templates() {
|
||||
$template_registry = wc_get_container()->get( BlockTemplateRegistry::class );
|
||||
|
||||
$template_registry->register( new SimpleProductTemplate() );
|
||||
$template_registry->register( new ProductVariationTemplate() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ interface ProductFormTemplateInterface extends BlockTemplateInterface {
|
||||
* Adds a new group block.
|
||||
*
|
||||
* @param array $block_config block config.
|
||||
* @return GroupInterface new group block.
|
||||
* @return BlockInterface new block section.
|
||||
*/
|
||||
public function add_group( array $block_config ): GroupInterface;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class DefaultShippingPartners {
|
||||
'image' => $asset_base_url . 'envia-column.svg',
|
||||
'features' => $column_layout_features,
|
||||
),
|
||||
'learn_more_link' => 'https://woo.com/products/envia-shipping-and-fulfillment/',
|
||||
'learn_more_link' => 'https://woocommerce.com/products/envia-shipping-and-fulfillment/',
|
||||
'is_visible' => array(
|
||||
self::get_rules_for_countries( array( 'CL', 'AR', 'PE', 'BR', 'UY', 'GT' ) ),
|
||||
),
|
||||
@@ -233,7 +233,7 @@ class DefaultShippingPartners {
|
||||
),
|
||||
),
|
||||
),
|
||||
'learn_more_link' => 'https://woo.com/products/shipping/',
|
||||
'learn_more_link' => 'https://woocommerce.com/products/shipping/',
|
||||
'is_visible' => array(
|
||||
self::get_rules_for_countries( array( 'US' ) ),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user