rebase code on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:51:46 -04:00
parent b16ad94b69
commit 8f1a2c3a66
2197 changed files with 184921 additions and 35568 deletions

View File

@@ -21,13 +21,6 @@ class Favorites {
*/
const META_NAME = 'navigation_favorites';
/**
* Favorites instance.
*
* @var Favorites|null
*/
protected static $instance = null;
/**
* Get class instance.
*/

View File

@@ -16,27 +16,6 @@ class DeprecatedExtendedTask extends Task {
*/
public $id = '';
/**
* Additional info.
*
* @var string|null
*/
public $additional_info = '';
/**
* Content.
*
* @var string
*/
public $content = '';
/**
* Whether the task is complete or not.
*
* @var boolean
*/
public $is_complete = false;
/**
* Snoozeable.
*
@@ -51,35 +30,6 @@ class DeprecatedExtendedTask extends Task {
*/
public $is_dismissable = false;
/**
* Whether the store is capable of viewing the task.
*
* @var bool
*/
public $can_view = true;
/**
* Level.
*
* @var int
*/
public $level = 3;
/**
* Time.
*
* @var string|null
*/
public $time;
/**
* Title.
*
* @var string
*/
public $title = '';
/**
* Constructor.
*

View File

@@ -36,10 +36,7 @@ class TaskLists {
protected static $default_tasks_loaded = false;
/**
* The contents of this array is used in init_tasks() to run their init() methods.
* If the classes do not have an init() method then nothing is executed.
* Beyond that, adding tasks to this list has no effect, see init_default_lists() for the list of tasks.
* that are added for each task list.
* Array of default tasks.
*
* @var array
*/
@@ -112,7 +109,6 @@ class TaskLists {
*/
public static function init_default_lists() {
$tasks = array(
'CustomizeStore',
'StoreDetails',
'Purchase',
'Products',
@@ -125,18 +121,7 @@ class TaskLists {
);
if ( Features::is_enabled( 'core-profiler' ) ) {
$key = array_search( 'StoreDetails', $tasks, true );
if ( false !== $key ) {
unset( $tasks[ $key ] );
}
}
// Remove the old Personalize your store task if the new CustomizeStore is enabled.
$task_to_remove = Features::is_enabled( 'customize-store' ) ? 'Appearance' : 'CustomizeStore';
$store_customisation_task_index = array_search( $task_to_remove, $tasks, true );
if ( false !== $store_customisation_task_index ) {
unset( $tasks[ $store_customisation_task_index ] );
array_shift( $tasks );
}
self::add_list(
@@ -446,7 +431,7 @@ class TaskLists {
foreach ( $submenu['woocommerce'] as $key => $menu_item ) {
if ( 0 === strpos( $menu_item[0], _x( 'Home', 'Admin menu name', 'woocommerce' ) ) ) {
$submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins remaining-tasks-badge woocommerce-task-list-remaining-tasks-badge"><span class="count-' . esc_attr( $tasks_count ) . '">' . absint( $tasks_count ) . '</span></span>'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins remaining-tasks-badge count-' . esc_attr( $tasks_count ) . '">' . number_format_i18n( $tasks_count ) . '</span>'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
break;
}
}

View File

@@ -1,73 +0,0 @@
<?php
namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
/**
* Customize Your Store Task
*/
class CustomizeStore extends Task {
/**
* ID.
*
* @return string
*/
public function get_id() {
return 'customize-store';
}
/**
* Title.
*
* @return string
*/
public function get_title() {
return __( 'Customize your store ', 'woocommerce' );
}
/**
* Content.
*
* @return string
*/
public function get_content() {
return '';
}
/**
* Time.
*
* @return string
*/
public function get_time() {
return '';
}
/**
* Task completion.
*
* @return bool
*/
public function is_complete() {
return get_option( 'woocommerce_admin_customize_store_completed' ) === 'yes';
}
/**
* Task visibility.
*
* @return bool
*/
public function can_view() {
return true;
}
/**
* Action URL.
*
* @return string
*/
public function get_action_url() {
return admin_url( 'wp-admin/admin.php?page=wc-admin&path=%2Fcustomize-store' );
}
}

View File

@@ -6,7 +6,7 @@ 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\OnboardingTasks\TaskList;
/**
* WooCommercePayments Task
@@ -73,13 +73,6 @@ class WooCommercePayments extends Task {
* @return string
*/
public function get_additional_info() {
if ( WCPayPromotionInit::is_woopay_eligible() ) {
return __(
'By using WooPayments you agree to be bound by our <a href="https://wordpress.com/tos/" target="_blank">Terms of Service</a> (including WooPay <a href="https://wordpress.com/tos/#more-woopay-specifically" target="_blank">merchant terms</a>) and acknowledge that you have read our <a href="https://automattic.com/privacy/" target="_blank">Privacy Policy</a>',
'woocommerce'
);
}
return __(
'By using WooPayments you agree to be bound by our <a href="https://wordpress.com/tos/" target="_blank">Terms of Service</a> and acknowledge that you have read our <a href="https://automattic.com/privacy/" target="_blank">Privacy Policy</a>',
'woocommerce'
@@ -109,7 +102,8 @@ class WooCommercePayments extends Task {
return ! $payments->is_complete() && // Do not re-display the task if the "add payments" task has already been completed.
self::is_installed() &&
self::is_supported();
self::is_supported() &&
! self::is_connected();
}
/**

View File

@@ -904,7 +904,7 @@ class DefaultPaymentGateways {
* @return array Array of countries.
*/
public static function get_wcpay_countries() {
return array( 'US', 'PR', 'AU', 'CA', 'CY', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'IE', 'IT', 'LU', 'LT', 'LV', 'NO', 'NZ', 'MT', 'AT', 'BE', 'NL', 'PL', 'PT', 'CH', 'HK', 'SI', 'SK', 'SG', 'BG', 'CZ', 'HR', 'HU', 'RO', 'SE', 'JP', 'AE' );
return array( 'US', 'PR', 'AU', 'CA', 'CY', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'IE', 'IT', 'LU', 'LT', 'LV', 'NO', 'NZ', 'MT', 'AT', 'BE', 'NL', 'PL', 'PT', 'CH', 'HK', 'SI', 'SK', 'SG', 'BG', 'CZ', 'HR', 'HU', 'RO', 'SE' );
}
/**

View File

@@ -21,7 +21,6 @@ class BlockRegistry {
*/
const PRODUCT_BLOCKS = [
'woocommerce/conditional',
'woocommerce/product-catalog-visibility-field',
'woocommerce/product-category-field',
'woocommerce/product-checkbox-field',
'woocommerce/product-collapsible',
@@ -42,10 +41,7 @@ class BlockRegistry {
'woocommerce/product-tab',
'woocommerce/product-inventory-quantity-field',
'woocommerce/product-toggle-field',
'woocommerce/product-variation-items-field',
'woocommerce/product-variations-fields',
'woocommerce/product-password-field',
'woocommerce/product-has-variations-notice',
];
/**

View File

@@ -38,10 +38,6 @@ class Init {
* Constructor
*/
public function __construct() {
if ( Features::is_enabled( 'product-variation-management' ) ) {
array_push($this->supported_post_types, 'variable');
}
$this->redirection_controller = new RedirectionController( $this->supported_post_types );
if ( \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ) {
@@ -50,7 +46,6 @@ class Init {
add_action( 'admin_enqueue_scripts', array( $this, 'dequeue_conflicting_styles' ), 100 );
add_action( 'get_edit_post_link', array( $this, 'update_edit_product_link' ), 10, 2 );
}
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' ) );
@@ -353,20 +348,11 @@ class Init {
),
),
),
),
),
array(
'woocommerce/product-tab',
array(
'id' => 'organization',
'title' => __( 'Organization', 'woocommerce' ),
'order' => 15,
),
array(
array(
'woocommerce/product-section',
array(
'title' => __( 'Product catalog', 'woocommerce' ),
'title' => __( 'Organization & visibility', 'woocommerce' ),
'description' => __( 'Help customers find this product by assigning it to categories or featuring it across your sales channels.', 'woocommerce' ),
),
array(
array(
@@ -375,39 +361,18 @@ class Init {
'name' => 'categories',
),
),
array(
'woocommerce/product-catalog-visibility-field',
array(
'label' => __( 'Hide in product catalog', 'woocommerce' ),
'visibilty' => 'search',
),
),
array(
'woocommerce/product-catalog-visibility-field',
array(
'label' => __( 'Hide from search results', 'woocommerce' ),
'visibilty' => 'catalog',
),
),
array(
'woocommerce/product-checkbox-field',
array(
'label' => __( 'Enable product reviews', 'woocommerce' ),
'property' => 'reviews_allowed',
),
),
array(
'woocommerce/product-password-field',
array(
'label' => __( 'Require a password', 'woocommerce' ),
),
),
),
),
array(
'woocommerce/product-section',
array(
'title' => __( 'Attributes', 'woocommerce' ),
'title' => __( 'Attributes', 'woocommerce' ),
'description' => sprintf(
/* translators: %1$s: Attributes guide link opening tag. %2$s: Attributes guide link closing tag.*/
__( 'Add descriptive pieces of information that customers can use to filter and search for this product. %1$sLearn more%2$s', 'woocommerce' ),
'<a href="https://woocommerce.com/document/managing-product-taxonomies/#product-attributes" target="_blank" rel="noreferrer">',
'</a>'
),
),
array(
array(
@@ -425,15 +390,6 @@ class Init {
'order' => 20,
),
array(
array(
'woocommerce/product-has-variations-notice',
array(
'id' => 'wc-product-notice-has-options',
'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s price and other details individually.', 'woocommerce' ),
'buttonText' => __( 'Go to Variations', 'woocommerce' ),
'type' => 'info',
),
),
array(
'woocommerce/product-section',
array(
@@ -561,15 +517,6 @@ class Init {
'order' => 30,
),
array(
array(
'woocommerce/product-has-variations-notice',
array(
'id' => 'wc-product-notice-has-options',
'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s price and other details individually.', 'woocommerce' ),
'buttonText' => __( 'Go to Variations', 'woocommerce' ),
'type' => 'info',
),
),
array(
'woocommerce/product-section',
array(
@@ -732,15 +679,6 @@ class Init {
'order' => 40,
),
array(
array(
'woocommerce/product-has-variations-notice',
array(
'id' => 'wc-product-notice-has-options',
'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s price and other details individually.', 'woocommerce' ),
'buttonText' => __( 'Go to Variations', 'woocommerce' ),
'type' => 'info',
),
),
array(
'woocommerce/product-section',
array(
@@ -785,22 +723,7 @@ class Init {
'</strong>'
),
),
array(
array(
'woocommerce/product-section',
array(
'title' => __( 'Variation options', 'woocommerce' ),
),
array( array( 'woocommerce/product-variations-options-field' ) ),
),
array(
'woocommerce/product-section',
array(
'title' => __( 'Variations', 'woocommerce' ),
),
array( array( 'woocommerce/product-variation-items-field' ) ),
),
),
array(),
),
),
)
@@ -810,22 +733,6 @@ class Init {
return $args;
}
/**
* Adds fields so that we can store user preferences for the variations block.
*
* @param array $user_data_fields User data fields.
* @return array
*/
public function add_user_data_fields( $user_data_fields ) {
return array_merge(
$user_data_fields,
array(
'variable_product_block_tour_shown',
'product_block_variable_options_notice_dismissed',
)
);
}
/**
* Sets the current screen to the block editor if a wc-admin page.
*/

View File

@@ -62,8 +62,7 @@ class RedirectionController {
*/
protected function is_product_supported( $product_id ): bool {
$product = $product_id ? wc_get_product( $product_id ) : null;
$digital_product = $product->is_downloadable() || $product->is_virtual();
return $product && in_array( $product->get_type(), $this->supported_post_types, true ) && ! $digital_product;
return $product && in_array( $product->get_type(), $this->supported_post_types, true );
}
/**