auto-patch 638-dev-dev01-2024-05-14T20_44_36

This commit is contained in:
root
2024-05-14 20:44:36 +00:00
parent a941559057
commit 5dbb0b284e
1812 changed files with 29671 additions and 14588 deletions

View File

@@ -201,6 +201,16 @@ class AbstractBlock implements BlockInterface {
$this->attributes = $attributes;
}
/**
* Set a block attribute value without replacing the entire attributes object.
*
* @param string $key The attribute key.
* @param mixed $value The attribute value.
*/
public function set_attribute( string $key, $value ) {
$this->attributes[ $key ] = $value;
}
/**
* Get the template that this block belongs to.
*/

View File

@@ -73,7 +73,7 @@ class Coupons {
__( 'Coupons', 'woocommerce' ),
'manage_options',
'coupons-moved',
[ $this, 'coupon_menu_moved' ]
array( $this, 'coupon_menu_moved' )
);
}
@@ -117,15 +117,7 @@ class Coupons {
return;
}
$rtl = is_rtl() ? '-rtl' : '';
wp_enqueue_style(
'wc-admin-marketing-coupons',
WCAdminAssets::get_url( "marketing-coupons/style{$rtl}", 'css' ),
array(),
WCAdminAssets::get_file_version( 'css' )
);
WCAdminAssets::register_style( 'marketing-coupons', 'style' );
WCAdminAssets::register_script( 'wp-admin-scripts', 'marketing-coupons', true );
}
}

View File

@@ -8,7 +8,7 @@ namespace Automattic\WooCommerce\Internal\Admin;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Admin\RemoteInboxNotifications\DataSourcePoller;
use Automattic\WooCommerce\Admin\RemoteInboxNotifications\RemoteInboxNotificationsDataSourcePoller;
use Automattic\WooCommerce\Admin\RemoteInboxNotifications\RemoteInboxNotificationsEngine;
use Automattic\WooCommerce\Internal\Admin\Notes\AddFirstProduct;
use Automattic\WooCommerce\Internal\Admin\Notes\ChoosingTheme;
@@ -146,7 +146,7 @@ class Events {
$this->possibly_refresh_data_source_pollers();
if ( $this->is_remote_inbox_notifications_enabled() ) {
DataSourcePoller::get_instance()->read_specs_from_data_sources();
RemoteInboxNotificationsDataSourcePoller::get_instance()->read_specs_from_data_sources();
RemoteInboxNotificationsEngine::run();
}

View File

@@ -124,12 +124,25 @@ class Loader {
$sections = self::get_embed_breadcrumbs();
$sections = is_array( $sections ) ? $sections : array( $sections );
$page_title = '';
$pages_with_tabs = array( 'Settings', 'Reports', 'Status' );
if (
count( $sections ) > 2 &&
is_array( $sections[1] ) &&
in_array( $sections[1][1], $pages_with_tabs, true )
) {
$page_title = $sections[1][1];
} else {
$page_title = end( $sections );
}
?>
<div id="woocommerce-embedded-root" class="is-embed-loading">
<div class="woocommerce-layout">
<div class="woocommerce-layout__header is-embed-loading">
<h1 class="woocommerce-layout__header-heading">
<?php self::output_heading( end( $sections ) ); ?>
<?php self::output_heading( $page_title ); ?>
</h1>
</div>
</div>
@@ -293,7 +306,7 @@ class Loader {
$settings['orderStatuses'] = self::get_order_statuses( wc_get_order_statuses() );
$settings['stockStatuses'] = self::get_order_statuses( wc_get_product_stock_status_options() );
$settings['currency'] = self::get_currency_settings();
$settings['locale'] = [
$settings['locale'] = array(
'siteLocale' => isset( $settings['siteLocale'] )
? $settings['siteLocale']
: get_locale(),
@@ -303,7 +316,7 @@ class Loader {
'weekdaysShort' => isset( $settings['l10n']['weekdaysShort'] )
? $settings['l10n']['weekdaysShort']
: array_values( $wp_locale->weekday_abbrev ),
];
);
}
$preload_data_endpoints = apply_filters( 'woocommerce_component_settings_preload_endpoints', array() );
@@ -327,7 +340,7 @@ class Loader {
$setting_options = new \WC_REST_Setting_Options_V2_Controller();
foreach ( $preload_settings as $group ) {
$group_settings = $setting_options->get_group_settings( $group );
$preload_settings = [];
$preload_settings = array();
foreach ( $group_settings as $option ) {
if ( array_key_exists( 'id', $option ) && array_key_exists( 'value', $option ) ) {
$preload_settings[ $option['id'] ] = $option['value'];
@@ -374,7 +387,7 @@ class Loader {
if ( ! empty( $preload_data_endpoints ) ) {
$settings['dataEndpoints'] = isset( $settings['dataEndpoints'] )
? $settings['dataEndpoints']
: [];
: array();
foreach ( $preload_data_endpoints as $key => $endpoint ) {
// Handle error case: rest_do_request() doesn't guarantee success.
if ( empty( $preload_data[ $endpoint ] ) ) {

View File

@@ -4,7 +4,8 @@ declare( strict_types = 1 );
namespace Automattic\WooCommerce\Internal\Admin\Logging\FileV2;
use Automattic\Jetpack\Constants;
use WP_Filesystem_Direct;
use Automattic\WooCommerce\Internal\Utilities\FilesystemUtil;
use Exception;
/**
* File class.
@@ -60,14 +61,6 @@ class File {
* @param string $path The absolute path of the file.
*/
public function __construct( $path ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
global $wp_filesystem;
if ( ! $wp_filesystem instanceof WP_Filesystem_Direct ) {
WP_Filesystem();
}
$this->path = $path;
$this->ingest_path();
}
@@ -237,27 +230,33 @@ class File {
/**
* Check if the file represented by the class instance is a file and is readable.
*
* @global WP_Filesystem_Direct $wp_filesystem
*
* @return bool
*/
public function is_readable(): bool {
global $wp_filesystem;
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$is_readable = $filesystem->is_file( $this->path ) && $filesystem->is_readable( $this->path );
} catch ( Exception $exception ) {
return false;
}
return $wp_filesystem->is_file( $this->path ) && $wp_filesystem->is_readable( $this->path );
return $is_readable;
}
/**
* Check if the file represented by the class instance is a file and is writable.
*
* @global WP_Filesystem_Direct $wp_filesystem
*
* @return bool
*/
public function is_writable(): bool {
global $wp_filesystem;
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$is_writable = $filesystem->is_file( $this->path ) && $filesystem->is_writable( $this->path );
} catch ( Exception $exception ) {
return false;
}
return $wp_filesystem->is_file( $this->path ) && $wp_filesystem->is_writable( $this->path );
return $is_writable;
}
/**
@@ -372,31 +371,38 @@ class File {
/**
* Get the time of the last modification of the file, as a Unix timestamp. Or false if the file isn't readable.
*
* @global WP_Filesystem_Direct $wp_filesystem
*
* @return int|false
*/
public function get_modified_timestamp() {
global $wp_filesystem;
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$timestamp = $filesystem->mtime( $this->path );
} catch ( Exception $exception ) {
return false;
}
return $wp_filesystem->mtime( $this->path );
return $timestamp;
}
/**
* Get the size of the file in bytes. Or false if the file isn't readable.
*
* @global WP_Filesystem_Direct $wp_filesystem
*
* @return int|false
*/
public function get_file_size() {
global $wp_filesystem;
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
if ( ! $wp_filesystem->is_readable( $this->path ) ) {
if ( ! $filesystem->is_readable( $this->path ) ) {
return false;
}
$size = $filesystem->size( $this->path );
} catch ( Exception $exception ) {
return false;
}
return $wp_filesystem->size( $this->path );
return $size;
}
/**
@@ -405,10 +411,13 @@ class File {
* @return bool
*/
protected function create(): bool {
global $wp_filesystem;
$created = $wp_filesystem->touch( $this->path );
$modded = $wp_filesystem->chmod( $this->path );
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$created = $filesystem->touch( $this->path );
$modded = $filesystem->chmod( $this->path );
} catch ( Exception $exception ) {
return false;
}
return $created && $modded;
}
@@ -463,8 +472,6 @@ class File {
return false;
}
global $wp_filesystem;
$created = 0;
if ( $this->has_standard_filename() ) {
$created = $this->get_created_timestamp();
@@ -489,7 +496,13 @@ class File {
$new_filename = str_replace( $search, $replace, $old_filename );
$new_path = str_replace( $old_filename, $new_filename, $this->path );
$moved = $wp_filesystem->move( $this->path, $new_path, true );
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$moved = $filesystem->move( $this->path, $new_path, true );
} catch ( Exception $exception ) {
return false;
}
if ( ! $moved ) {
return false;
}
@@ -503,13 +516,16 @@ class File {
/**
* Delete the file from the filesystem.
*
* @global WP_Filesystem_Direct $wp_filesystem
*
* @return bool True on success, false on failure.
*/
public function delete(): bool {
global $wp_filesystem;
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$deleted = $filesystem->delete( $this->path, false, 'f' );
} catch ( Exception $exception ) {
return false;
}
return $wp_filesystem->delete( $this->path, false, 'f' );
return $deleted;
}
}

View File

@@ -4,6 +4,7 @@ declare( strict_types = 1 );
namespace Automattic\WooCommerce\Internal\Admin\Logging\FileV2;
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Internal\Admin\Logging\Settings;
use PclZip;
use WC_Cache_Helper;
use WP_Error;
@@ -75,20 +76,6 @@ class FileController {
*/
private const SEARCH_CACHE_KEY = 'logs_previous_search';
/**
* The absolute path to the log directory.
*
* @var string
*/
private $log_directory;
/**
* Class FileController
*/
public function __construct() {
$this->log_directory = trailingslashit( Constants::get_constant( 'WC_LOG_DIR' ) );
}
/**
* Get the file size limit that determines when to rotate a file.
*
@@ -141,7 +128,7 @@ class FileController {
}
if ( ! $file instanceof File ) {
$new_path = $this->log_directory . $this->generate_filename( $source, $time );
$new_path = Settings::get_log_directory() . $this->generate_filename( $source, $time );
$file = new File( $new_path );
}
@@ -217,7 +204,7 @@ class FileController {
$args = wp_parse_args( $args, self::DEFAULTS_GET_FILES );
$pattern = $args['source'] . '*.log';
$paths = glob( $this->log_directory . $pattern );
$paths = glob( Settings::get_log_directory() . $pattern );
if ( false === $paths ) {
return new WP_Error(
@@ -332,14 +319,15 @@ class FileController {
* @return File[]
*/
public function get_files_by_id( array $file_ids ): array {
$paths = array();
$log_directory = Settings::get_log_directory();
$paths = array();
foreach ( $file_ids as $file_id ) {
// Look for the standard filename format first, which includes a hash.
$glob = glob( $this->log_directory . $file_id . '-*.log' );
$glob = glob( $log_directory . $file_id . '-*.log' );
if ( ! $glob ) {
$glob = glob( $this->log_directory . $file_id . '.log' );
$glob = glob( $log_directory . $file_id . '.log' );
}
if ( is_array( $glob ) ) {
@@ -423,7 +411,7 @@ class FileController {
$created_pattern = $created ? '-' . gmdate( 'Y-m-d', $created ) . '-' : '';
$rotation_pattern = $this->log_directory . $source . $rotations_pattern . $created_pattern . '*.log';
$rotation_pattern = Settings::get_log_directory() . $source . $rotations_pattern . $created_pattern . '*.log';
$rotation_paths = glob( $rotation_pattern );
$rotation_files = $this->convert_paths_to_objects( $rotation_paths );
foreach ( $rotation_files as $rotation_file ) {
@@ -462,7 +450,7 @@ class FileController {
* @return array|WP_Error
*/
public function get_file_sources() {
$paths = glob( $this->log_directory . '*.log' );
$paths = glob( Settings::get_log_directory() . '*.log' );
if ( false === $paths ) {
return new WP_Error(
'wc_log_directory_error',
@@ -493,10 +481,7 @@ class FileController {
$files = $this->get_files_by_id( $file_ids );
foreach ( $files as $file ) {
$result = false;
if ( $file->is_writable() ) {
$result = $file->delete();
}
$result = $file->delete();
if ( true === $result ) {
$deleted ++;
@@ -671,10 +656,10 @@ class FileController {
*/
public function get_log_directory_size(): int {
$bytes = 0;
$path = realpath( $this->log_directory );
$path = realpath( Settings::get_log_directory() );
if ( wp_is_writable( $path ) ) {
$iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path, \FilesystemIterator::SKIP_DOTS ) );
$iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path, \FilesystemIterator::SKIP_DOTS ), \RecursiveIteratorIterator::CATCH_GET_CHILD );
foreach ( $iterator as $file ) {
$bytes += $file->getSize();

View File

@@ -3,8 +3,9 @@ declare( strict_types=1 );
namespace Automattic\WooCommerce\Internal\Admin\Logging\FileV2;
use Automattic\WooCommerce\Internal\Utilities\FilesystemUtil;
use Exception;
use WP_Error;
use WP_Filesystem_Direct;
/**
* FileExport class.
@@ -39,11 +40,6 @@ class FileExporter {
* part of the path.
*/
public function __construct( string $path, string $alternate_filename = '' ) {
global $wp_filesystem;
if ( ! $wp_filesystem instanceof WP_Filesystem_Direct ) {
WP_Filesystem();
}
$this->path = $path;
$this->alternate_filename = $alternate_filename;
}
@@ -54,8 +50,14 @@ class FileExporter {
* @return WP_Error|void Only returns something if there is an error.
*/
public function emit_file() {
global $wp_filesystem;
if ( ! $wp_filesystem->is_file( $this->path ) || ! $wp_filesystem->is_readable( $this->path ) ) {
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$is_readable = $filesystem->is_file( $this->path ) && $filesystem->is_readable( $this->path );
} catch ( Exception $exception ) {
$is_readable = false;
}
if ( ! $is_readable ) {
return new WP_Error(
'wc_logs_invalid_file',
__( 'Could not access file.', 'woocommerce' )
@@ -104,11 +106,11 @@ class FileExporter {
* @return void
*/
private function send_contents(): void {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen -- No suitable alternative.
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- No suitable alternative.
$stream = fopen( $this->path, 'rb' );
while ( is_resource( $stream ) && ! feof( $stream ) ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fread -- No suitable alternative.
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fread -- No suitable alternative.
$chunk = fread( $stream, self::CHUNK_SIZE );
if ( is_string( $chunk ) ) {
@@ -117,7 +119,7 @@ class FileExporter {
}
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose -- No suitable alternative.
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- No suitable alternative.
fclose( $stream );
}

View File

@@ -104,7 +104,7 @@ class PageController {
if ( ! $this->settings->logging_is_enabled() ) {
add_action(
'admin_notices',
function() {
function () {
?>
<div class="notice notice-warning">
<p>
@@ -395,7 +395,7 @@ class PageController {
if ( is_string( $line ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- format_line does the escaping.
echo $this->format_line( $line, $line_number );
$line_number ++;
++$line_number;
}
?>
<?php endwhile; ?>
@@ -464,7 +464,7 @@ class PageController {
array(
'file_id' => array(
'filter' => FILTER_CALLBACK,
'options' => function( $file_id ) {
'options' => function ( $file_id ) {
return sanitize_file_name( wp_unslash( $file_id ) );
},
),
@@ -484,13 +484,13 @@ class PageController {
),
'search' => array(
'filter' => FILTER_CALLBACK,
'options' => function( $search ) {
'options' => function ( $search ) {
return esc_html( wp_unslash( $search ) );
},
),
'source' => array(
'filter' => FILTER_CALLBACK,
'options' => function( $source ) {
'options' => function ( $source ) {
return File::sanitize_source( wp_unslash( $source ) );
},
),
@@ -624,7 +624,7 @@ class PageController {
}
if ( is_wp_error( $export_error ) ) {
wp_die( wp_kses_post( $export_error ) );
wp_die( wp_kses_post( $export_error->get_error_message() ) );
}
break;
case 'delete':
@@ -654,7 +654,7 @@ class PageController {
if ( is_numeric( $deleted ) ) {
add_action(
'admin_notices',
function() use ( $deleted ) {
function () use ( $deleted ) {
?>
<div class="notice notice-info is-dismissible">
<p>

View File

@@ -8,8 +8,12 @@ use Automattic\WooCommerce\Internal\Admin\Logging\FileV2\File;
use Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2;
use Automattic\WooCommerce\Internal\Admin\Logging\FileV2\FileController;
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
use Automattic\WooCommerce\Internal\Utilities\FilesystemUtil;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Exception;
use WC_Admin_Settings;
use WC_Log_Handler_DB, WC_Log_Handler_File, WC_Log_Levels;
use WP_Filesystem_Direct;
/**
* Settings class.
@@ -44,6 +48,51 @@ class Settings {
self::add_action( 'wc_logs_load_tab', array( $this, 'save_settings' ) );
}
/**
* Get the directory for storing log files.
*
* The `wp_upload_dir` function takes into account the possibility of multisite, and handles changing
* the directory if the context is switched to a different site in the network mid-request.
*
* @return string The full directory path, with trailing slash.
*/
public static function get_log_directory(): string {
if ( true === Constants::get_constant( 'WC_LOG_DIR_CUSTOM' ) ) {
$dir = Constants::get_constant( 'WC_LOG_DIR' );
} else {
$upload_dir = wc_get_container()->get( LegacyProxy::class )->call_function( 'wp_upload_dir' );
/**
* Filter to change the directory for storing WooCommerce's log files.
*
* @param string $dir The full directory path, with trailing slash.
*
* @since 8.8.0
*/
$dir = apply_filters( 'woocommerce_log_directory', $upload_dir['basedir'] . '/wc-logs/' );
}
$dir = trailingslashit( $dir );
$realpath = realpath( $dir );
if ( false === $realpath ) {
$result = wp_mkdir_p( $dir );
if ( true === $result ) {
// Create infrastructure to prevent listing contents of the logs directory.
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
$filesystem->put_contents( $dir . '.htaccess', 'deny from all' );
$filesystem->put_contents( $dir . 'index.html', '' );
} catch ( Exception $exception ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
// Creation failed.
}
}
}
return $dir;
}
/**
* The definitions used by WC_Admin_Settings to render and save settings controls.
*
@@ -242,7 +291,21 @@ class Settings {
*/
private function get_filesystem_settings_definitions(): array {
$location_info = array();
$directory = trailingslashit( Constants::get_constant( 'WC_LOG_DIR' ) );
$directory = self::get_log_directory();
$status_info = array();
try {
$filesystem = FilesystemUtil::get_wp_filesystem();
if ( $filesystem instanceof WP_Filesystem_Direct ) {
$status_info[] = __( '✅ Ready', 'woocommerce' );
} else {
$status_info[] = __( '⚠️ The file system is not configured for direct writes. This could cause problems for the logger.', 'woocommerce' );
$status_info[] = __( 'You may want to switch to the database for log storage.', 'woocommerce' );
}
} catch ( Exception $exception ) {
$status_info[] = __( '⚠️ The file system connection could not be initialized.', 'woocommerce' );
$status_info[] = __( 'You may want to switch to the database for log storage.', 'woocommerce' );
}
$location_info[] = sprintf(
// translators: %s is a location in the filesystem.
@@ -257,13 +320,6 @@ class Settings {
$location_info[] = __( '⚠️ This directory does not appear to be writable.', 'woocommerce' );
}
$location_info[] = sprintf(
// translators: %1$s is a code variable. %2$s is the name of a file.
__( 'Change the location by defining the %1$s constant in your %2$s file with a new path.', 'woocommerce' ),
'<code>WC_LOG_DIR</code>',
'<code>wp-config.php</code>'
);
$location_info[] = sprintf(
// translators: %s is an amount of computer disk space, e.g. 5 KB.
__( 'Directory size: %s', 'woocommerce' ),
@@ -276,6 +332,11 @@ class Settings {
'id' => self::PREFIX . 'settings',
'type' => 'title',
),
'file_status' => array(
'title' => __( 'Status', 'woocommerce' ),
'type' => 'info',
'text' => implode( "\n\n", $status_info ),
),
'log_directory' => array(
'title' => __( 'Location', 'woocommerce' ),
'type' => 'info',
@@ -299,7 +360,7 @@ class Settings {
$table = "{$wpdb->prefix}woocommerce_log";
$location_info = sprintf(
// translators: %s is a location in the filesystem.
// translators: %s is the name of a table in the database.
__( 'Log entries are stored in this database table: %s', 'woocommerce' ),
"<code>$table</code>"
);

View File

@@ -2,7 +2,7 @@
/**
* Marketing Specs Handler
*
* Fetches the specifications for the marketing feature from Woo.com API.
* Fetches the specifications for the marketing feature from WooCommerce.com API.
*/
namespace Automattic\WooCommerce\Internal\Admin\Marketing;
@@ -22,7 +22,7 @@ class MarketingSpecs {
const KNOWLEDGE_BASE_TRANSIENT = 'wc_marketing_knowledge_base';
/**
* Load knowledge base posts from Woo.com
* Load knowledge base posts from WooCommerce.com
*
* @param string|null $topic The topic of marketing knowledgebase to retrieve.
* @return array

View File

@@ -7,6 +7,8 @@ namespace Automattic\WooCommerce\Internal\Admin;
use Automattic\WooCommerce\Utilities\FeaturesUtil;
use Automattic\WooCommerce\Internal\Features\FeaturesController;
use WC_Helper_Updater;
use WC_Woo_Update_Manager_Plugin;
/**
* Contains backend logic for the Marketplace feature.
@@ -17,6 +19,8 @@ class Marketplace {
/**
* Class initialization, to be executed when the class is resolved by the container.
*
* @internal
*/
final public function init() {
if ( false === FeaturesUtil::feature_is_enabled( 'marketplace' ) ) {
@@ -55,10 +59,11 @@ class Marketplace {
public static function get_marketplace_pages() {
$marketplace_pages = array(
array(
'id' => 'woocommerce-marketplace',
'parent' => 'woocommerce',
'title' => __( 'Extensions', 'woocommerce' ),
'path' => '/extensions',
'id' => 'woocommerce-marketplace',
'parent' => 'woocommerce',
'title' => __( 'Extensions', 'woocommerce' ) . WC_Helper_Updater::get_updates_count_html(),
'page_title' => __( 'Extensions', 'woocommerce' ),
'path' => '/extensions',
),
);
@@ -79,7 +84,7 @@ class Marketplace {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( 'woocommerce_page_wc-admin' !== $hook_suffix ) {
return;
};
}
if ( ! isset( $_GET['path'] ) || '/extensions' !== $_GET['path'] ) {
return;

View File

@@ -67,7 +67,7 @@ class AddFirstProduct {
sprintf( __( 'Nice one; you\'ve created a WooCommerce store! Now it\'s time to add your first product and get ready to start selling.%s', 'woocommerce' ), '<br/><br/>' ),
__( 'There are three ways to add your products: you can <strong>create products manually, import them at once via CSV file</strong>, or <strong>migrate them from another service</strong>.<br/><br/>', 'woocommerce' ),
/* translators: %1$s is an open anchor tag (<a>) and %2$s is a close link tag (</a>). */
sprintf( __( '%1$1sExplore our docs%2$2s for more information, or just get started!', 'woocommerce' ), '<a href="https://woo.com/document/managing-products/?utm_source=help_panel&utm_medium=product">', '</a>' ),
sprintf( __( '%1$1sExplore our docs%2$2s for more information, or just get started!', 'woocommerce' ), '<a href="https://woocommerce.com/document/managing-products/?utm_source=help_panel&utm_medium=product">', '</a>' ),
);
$additional_data = array(

View File

@@ -48,7 +48,7 @@ class ChoosingTheme {
$note->add_action(
'visit-the-theme-marketplace',
__( 'Visit the theme marketplace', 'woocommerce' ),
'https://woo.com/product-category/themes/?utm_source=inbox&utm_medium=product'
'https://woocommerce.com/product-category/themes/?utm_source=inbox&utm_medium=product'
);
return $note;
}

View File

@@ -78,7 +78,7 @@ class CustomizeStoreWithBlocks {
$note->add_action(
'customize-store-with-blocks',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/posts/how-to-customize-your-online-store-with-woocommerce-blocks/?utm_source=inbox&utm_medium=product',
'https://woocommerce.com/posts/how-to-customize-your-online-store-with-woocommerce-blocks/?utm_source=inbox&utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED
);
return $note;

View File

@@ -75,7 +75,7 @@ class CustomizingProductCatalog {
$note->add_action(
'day-after-first-product',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/document/woocommerce-customizer/?utm_source=inbox&utm_medium=product'
'https://woocommerce.com/document/woocommerce-customizer/?utm_source=inbox&utm_medium=product'
);
return $note;

View File

@@ -54,7 +54,7 @@ class EUVATNumber {
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/products/eu-vat-number/?utm_medium=product',
'https://woocommerce.com/products/eu-vat-number/?utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED
);
return $note;

View File

@@ -63,7 +63,7 @@ class EditProductsOnTheMove {
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/mobile/?utm_source=inbox&utm_medium=product'
'https://woocommerce.com/mobile/?utm_source=inbox&utm_medium=product'
);
return $note;

View File

@@ -54,7 +54,7 @@ class LaunchChecklist {
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woo.com/posts/pre-launch-checklist-the-essentials/?utm_source=inbox&utm_medium=product' );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woocommerce.com/posts/pre-launch-checklist-the-essentials/?utm_source=inbox&utm_medium=product' );
return $note;
}
}

View File

@@ -92,7 +92,7 @@ class MagentoMigration {
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/posts/how-migrate-from-magento-to-woocommerce/?utm_source=inbox'
'https://woocommerce.com/posts/how-migrate-from-magento-to-woocommerce/?utm_source=inbox'
);
return $note;

View File

@@ -56,7 +56,7 @@ class ManageOrdersOnTheGo {
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/mobile/?utm_source=inbox&utm_medium=product'
'https://woocommerce.com/mobile/?utm_source=inbox&utm_medium=product'
);
return $note;

View File

@@ -20,7 +20,7 @@ use Automattic\WooCommerce\Admin\PluginsHelper;
*
* Note: This should probably live in the Jetpack plugin in the future.
*
* @see https://developer.woo.com/2020/10/16/using-the-admin-notes-inbox-in-woocommerce/
* @see https://developer.woocommerce.com/2020/10/16/using-the-admin-notes-inbox-in-woocommerce/
*/
class MarketingJetpack {
// Shared Note Traits.

View File

@@ -71,7 +71,7 @@ class MigrateFromShopify {
$note->add_action(
'migrate-from-shopify',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/posts/migrate-from-shopify-to-woocommerce/?utm_source=inbox&utm_medium=product',
'https://woocommerce.com/posts/migrate-from-shopify-to-woocommerce/?utm_source=inbox&utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED
);
return $note;

View File

@@ -47,7 +47,7 @@ class MobileApp {
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woo.com/mobile/?utm_medium=product' );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woocommerce.com/mobile/?utm_medium=product' );
return $note;
}
}

View File

@@ -59,7 +59,7 @@ class OnboardingPayments {
$note->add_action(
'view-payment-gateways',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/product-category/woocommerce-extensions/payment-gateways/?utm_medium=product',
'https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED,
true
);

View File

@@ -90,7 +90,7 @@ class OnlineClothingStore {
$note->add_action(
'online-clothing-store',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/posts/starting-an-online-clothing-store/?utm_source=inbox&utm_medium=product',
'https://woocommerce.com/posts/starting-an-online-clothing-store/?utm_source=inbox&utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED
);
return $note;

View File

@@ -239,13 +239,13 @@ class OrderMilestones {
return array(
'name' => 'learn-more',
'label' => __( 'Learn more', 'woocommerce' ),
'query' => 'https://woo.com/document/managing-orders/?utm_source=inbox&utm_medium=product',
'query' => 'https://woocommerce.com/document/managing-orders/?utm_source=inbox&utm_medium=product',
);
case 10:
return array(
'name' => 'browse',
'label' => __( 'Browse', 'woocommerce' ),
'query' => 'https://woo.com/success-stories/?utm_source=inbox&utm_medium=product',
'query' => 'https://woocommerce.com/success-stories/?utm_source=inbox&utm_medium=product',
);
case 100:
case 250:

View File

@@ -72,7 +72,7 @@ class PaymentsMoreInfoNeeded {
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'learn-more', __( 'Learn more here', 'woocommerce' ), 'https://woo.com/payments/' );
$note->add_action( 'learn-more', __( 'Learn more here', 'woocommerce' ), 'https://woocommerce.com/payments/' );
return $note;
}
}

View File

@@ -60,7 +60,7 @@ class PerformanceOnMobile {
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/mobile/?utm_source=inbox&utm_medium=product'
'https://woocommerce.com/mobile/?utm_source=inbox&utm_medium=product'
);
return $note;

View File

@@ -51,7 +51,7 @@ class RealTimeOrderAlerts {
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woo.com/mobile/?utm_source=inbox&utm_medium=product' );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woocommerce.com/mobile/?utm_source=inbox&utm_medium=product' );
return $note;
}
}

View File

@@ -76,7 +76,7 @@ class SellingOnlineCourses {
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce' ),
'https://woo.com/posts/how-to-sell-online-courses-wordpress/?utm_source=inbox&utm_medium=product',
'https://woocommerce.com/posts/how-to-sell-online-courses-wordpress/?utm_source=inbox&utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED
);

View File

@@ -49,7 +49,7 @@ class TrackingOptIn {
return;
}
/* translators: 1: open link to Woo.com settings, 2: open link to Woo.com tracking documentation, 3: close link tag. */
/* translators: 1: open link to WooCommerce.com settings, 2: open link to WooCommerce.com tracking documentation, 3: close link tag. */
$content_format = __(
'Gathering usage data allows us to improve WooCommerce. Your store will be considered as we evaluate new features, judge the quality of an update, or determine if an improvement makes sense. You can always visit the %1$sSettings%3$s and choose to stop sharing data. %2$sRead more%3$s about what data we collect.',
'woocommerce'
@@ -58,7 +58,7 @@ class TrackingOptIn {
$note_content = sprintf(
$content_format,
'<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=woocommerce_com' ) ) . '" target="_blank">',
'<a href="https://woo.com/usage-tracking?utm_medium=product" target="_blank">',
'<a href="https://woocommerce.com/usage-tracking?utm_medium=product" target="_blank">',
'</a>'
);

View File

@@ -37,7 +37,7 @@ class UnsecuredReportFiles {
sprintf(
/* translators: 1: opening analytics docs link tag. 2: closing link tag */
__( 'Files that may contain %1$sstore analytics%2$s reports were found in your uploads directory - we recommend assessing and deleting any such files.', 'woocommerce' ),
'<a href="https://woo.com/document/woocommerce-analytics/" target="_blank">',
'<a href="https://woocommerce.com/document/woocommerce-analytics/" target="_blank">',
'</a>'
)
);
@@ -48,7 +48,7 @@ class UnsecuredReportFiles {
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce' ),
'https://developer.woo.com/2021/09/22/important-security-patch-released-in-woocommerce/',
'https://developer.woocommerce.com/2021/09/22/important-security-patch-released-in-woocommerce/',
Note::E_WC_ADMIN_NOTE_UNACTIONED,
true
);

View File

@@ -118,7 +118,7 @@ class WooCommercePayments {
$note->set_type( Note::E_WC_ADMIN_NOTE_MARKETING );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woo.com/payments/?utm_medium=product', Note::E_WC_ADMIN_NOTE_UNACTIONED );
$note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://woocommerce.com/payments/?utm_medium=product', Note::E_WC_ADMIN_NOTE_UNACTIONED );
$note->add_action( 'get-started', __( 'Get started', 'woocommerce' ), wc_admin_url( '&action=setup-woocommerce-payments' ), Note::E_WC_ADMIN_NOTE_ACTIONED, true );
$note->add_nonce_to_action( 'get-started', 'setup-woocommerce-payments', '' );

View File

@@ -53,7 +53,7 @@ class WooCommerceSubscriptions {
$note->add_action(
'learn-more',
__( 'Learn More', 'woocommerce' ),
'https://woo.com/products/woocommerce-subscriptions/?utm_source=inbox&utm_medium=product',
'https://woocommerce.com/products/woocommerce-subscriptions/?utm_source=inbox&utm_medium=product',
Note::E_WC_ADMIN_NOTE_UNACTIONED,
true
);

View File

@@ -1,8 +1,8 @@
<?php
/**
* WooCommerce Admin (Dashboard) Woo.com Extension Subscriptions Note Provider.
* WooCommerce Admin (Dashboard) WooCommerce.com Extension Subscriptions Note Provider.
*
* Adds notes to the merchant's inbox concerning Woo.com extension subscriptions.
* Adds notes to the merchant's inbox concerning WooCommerce.com extension subscriptions.
*/
namespace Automattic\WooCommerce\Internal\Admin\Notes;
@@ -129,7 +129,7 @@ class WooSubscriptionsNotes {
}
/**
* Whether or not we think the site is currently connected to Woo.com.
* Whether or not we think the site is currently connected to WooCommerce.com.
*
* @return bool
*/
@@ -139,7 +139,7 @@ class WooSubscriptionsNotes {
}
/**
* Returns the Woo.com provided site ID for this site.
* Returns the WooCommerce.com provided site ID for this site.
*
* @return int|false
*/
@@ -187,7 +187,7 @@ class WooSubscriptionsNotes {
}
/**
* Adds a note prompting to connect to Woo.com.
* Adds a note prompting to connect to WooCommerce.com.
*/
public function add_no_connection_note() {
$note = self::get_note();
@@ -195,11 +195,11 @@ class WooSubscriptionsNotes {
}
/**
* Get the Woo.com connection note
* Get the WooCommerce.com connection note
*/
public static function get_note() {
$note = new Note();
$note->set_title( __( 'Connect to Woo.com', 'woocommerce' ) );
$note->set_title( __( 'Connect to WooCommerce.com', 'woocommerce' ) );
$note->set_content( __( 'Connect to get important product notifications and updates.', 'woocommerce' ) );
$note->set_content_data( (object) array() );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
@@ -221,6 +221,9 @@ class WooSubscriptionsNotes {
* @return int|false
*/
public function get_product_id_from_subscription_note( &$note ) {
if ( ! is_object( $note ) ) {
return false;
}
$content_data = $note->get_content_data();
if ( property_exists( $content_data, 'product_id' ) ) {
@@ -358,7 +361,7 @@ class WooSubscriptionsNotes {
$note->add_action(
'enable-autorenew',
__( 'Enable Autorenew', 'woocommerce' ),
'https://woo.com/my-account/my-subscriptions/?utm_medium=product'
'https://woocommerce.com/my-account/my-subscriptions/?utm_medium=product'
);
$note->set_content( $note_content );
$note->set_content_data( $note_content_data );

View File

@@ -44,7 +44,7 @@ class OnboardingSync {
}
/**
* Send profile data to Woo.com.
* Send profile data to WooCommerce.com.
*/
private function send_profile_data() {
if ( 'yes' !== get_option( 'woocommerce_allow_tracking', 'no' ) ) {
@@ -142,7 +142,7 @@ class OnboardingSync {
! $task_list ||
$task_list->is_hidden() ||
! isset( $_SERVER['HTTP_REFERER'] ) ||
0 !== strpos( $_SERVER['HTTP_REFERER'], 'https://woo.com/checkout?utm_medium=product' ) // phpcs:ignore sanitization ok.
0 !== strpos( wp_unslash( $_SERVER['HTTP_REFERER'] ), 'https://woocommerce.com/checkout?utm_medium=product' ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
) {
return;
}

View File

@@ -69,9 +69,9 @@ class OnboardingThemes {
}
/**
* Sort themes returned from Woo.com
* Sort themes returned from WooCommerce.com
*
* @param array $themes Array of themes from Woo.com.
* @param array $themes Array of themes from WooCommerce.com.
* @return array
*/
public static function sort_woocommerce_themes( $themes ) {

View File

@@ -282,7 +282,7 @@ class ListTable extends WP_List_Table {
</h2>
<div class="woocommerce-BlankState-buttons">
<a class="woocommerce-BlankState-cta button-primary button" target="_blank" href="https://woo.com/document/managing-orders/?utm_source=blankslate&utm_medium=product&utm_content=ordersdoc&utm_campaign=woocommerceplugin"><?php esc_html_e( 'Learn more about orders', 'woocommerce' ); ?></a>
<a class="woocommerce-BlankState-cta button-primary button" target="_blank" href="https://woocommerce.com/document/managing-orders/?utm_source=blankslate&utm_medium=product&utm_content=ordersdoc&utm_campaign=woocommerceplugin"><?php esc_html_e( 'Learn more about orders', 'woocommerce' ); ?></a>
</div>
<?php
@@ -982,7 +982,7 @@ class ListTable extends WP_List_Table {
*
* @return string Edit link for the order.
*/
private function get_order_edit_link( WC_Order $order ) : string {
private function get_order_edit_link( WC_Order $order ): string {
return $this->page_controller->get_edit_url( $order->get_id() );
}
@@ -1352,7 +1352,7 @@ class ListTable extends WP_List_Table {
}
do_action( 'woocommerce_remove_order_personal_data', $order ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
$changed++;
++$changed;
}
return $changed;
@@ -1380,7 +1380,7 @@ class ListTable extends WP_List_Table {
$order->update_status( $new_status, __( 'Order status changed by bulk edit.', 'woocommerce' ), true );
do_action( 'woocommerce_order_edit_status', $id, $new_status ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
$changed++;
++$changed;
}
return $changed;
@@ -1403,7 +1403,7 @@ class ListTable extends WP_List_Table {
$updated_order = wc_get_order( $id );
if ( ( $force_delete && false === $updated_order ) || ( ! $force_delete && $updated_order->get_status() === 'trash' ) ) {
$changed++;
++$changed;
}
}
@@ -1423,7 +1423,7 @@ class ListTable extends WP_List_Table {
foreach ( $ids as $id ) {
if ( $orders_store->untrash_order( wc_get_order( $id ) ) ) {
$changed++;
++$changed;
}
}
@@ -1547,6 +1547,11 @@ class ListTable extends WP_List_Table {
<a href="{{ data.shipping_address_map_url }}" target="_blank">{{{ data.formatted_shipping_address }}}</a>
<# } #>
<# if ( data.data.shipping.phone ) { #>
<strong><?php esc_html_e( 'Phone', 'woocommerce' ); ?></strong>
<a href="tel:{{ data.data.shipping.phone }}">{{ data.data.shipping.phone }}</a>
<# } #>
<# if ( data.shipping_via ) { #>
<strong><?php esc_html_e( 'Shipping method', 'woocommerce' ); ?></strong>
{{ data.shipping_via }}
@@ -1629,10 +1634,25 @@ class ListTable extends WP_List_Table {
'products' => __( 'Products', 'woocommerce' ),
'all' => __( 'All', 'woocommerce' ),
);
/**
* Filters the search filters available in the admin order search. Can be used to add new or remove existing filters.
* When adding new filters, `woocommerce_hpos_generate_where_for_search_filter` should also be used to generate the WHERE clause for the new filter
*
* @since 8.9.0.
*
* @param $options array List of available filters.
*/
$options = apply_filters( 'woocommerce_hpos_admin_search_filters', $options );
$saved_setting = get_user_setting( 'wc-search-filter-hpos-admin', 'all' );
$selected = sanitize_text_field( wp_unslash( $_REQUEST['search-filter'] ?? $saved_setting ) );
if ( $saved_setting !== $selected ) {
set_user_setting( 'wc-search-filter-hpos-admin', $selected );
}
?>
<select name="search-filter" id="order-search-filter">
<?php foreach ( $options as $value => $label ) { ?>
<option value="<?php echo esc_attr( wp_unslash( sanitize_text_field( $value ) ) ); ?>" <?php selected( $value, sanitize_text_field( wp_unslash( $_REQUEST['search-filter'] ?? 'all' ) ) ); ?>><?php echo esc_html( $label ); ?></option>
<option value="<?php echo esc_attr( wp_unslash( sanitize_text_field( $value ) ) ); ?>" <?php selected( $value, sanitize_text_field( wp_unslash( $selected ) ) ); ?>><?php echo esc_html( $label ); ?></option>
<?php
}
}

View File

@@ -5,8 +5,8 @@
namespace Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes;
use WC_Data_Store;
use WC_Meta_Data;
use Automattic\WooCommerce\Internal\DataStores\CustomMetaDataStore;
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStoreMeta;
use WC_Order;
use WP_Ajax_Response;
@@ -92,16 +92,44 @@ class CustomMetaBox {
* Compute keys to display in autofill when adding new meta key entry in custom meta box.
* Currently, returns empty keys, will be implemented after caching is merged.
*
* @param array|null $keys Keys to display in autofill.
* @param \WP_Post|\WC_Order $order Order object.
* @param mixed $deprecated Unused argument. For backwards compatibility.
* @param \WP_Post|\WC_Order $order Order object.
*
* @return array|mixed Array of keys to display in autofill.
* @return array Array of keys to display in autofill.
*/
public function order_meta_keys_autofill( $keys, $order ) {
if ( is_a( $order, \WC_Order::class ) ) {
public function order_meta_keys_autofill( $deprecated, $order ) {
if ( ! is_a( $order, \WC_Order::class ) ) {
return array();
}
/**
* Filters values for the meta key dropdown in the Custom Fields meta box.
*
* Compatibility filter for `postmeta_form_keys` filter.
*
* @since 6.9.0
*
* @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
* @param \WC_Order $order The current post object.
*/
$keys = apply_filters( 'postmeta_form_keys', null, $order );
if ( null === $keys || ! is_array( $keys ) ) {
/**
* Compatibility filter for 'postmeta_form_limit', which filters the number of custom fields to retrieve
* for the drop-down in the Custom Fields meta box.
*
* @since 8.8.0
*
* @param int $limit Number of custom fields to retrieve. Default 30.
*/
$limit = apply_filters( 'postmeta_form_limit', 30 );
$keys = wc_get_container()->get( OrdersTableDataStoreMeta::class )->get_meta_keys( $limit );
}
if ( $keys ) {
natcasesort( $keys );
}
return $keys;
}
@@ -116,17 +144,6 @@ class CustomMetaBox {
$meta_key_input_id = 'metakeyselect';
$keys = $this->order_meta_keys_autofill( null, $order );
/**
* Filters values for the meta key dropdown in the Custom Fields meta box.
*
* Compatibility filter for `postmeta_form_keys` filter.
*
* @since 6.9.0
*
* @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
* @param \WC_Order $order The current post object.
*/
$keys = apply_filters( 'postmeta_form_keys', $keys, $order );
?>
<p><strong><?php esc_html_e( 'Add New Custom Field:', 'woocommerce' ); ?></strong></p>
<table id="newmeta">
@@ -145,43 +162,42 @@ class CustomMetaBox {
<option value="#NONE#"><?php esc_html_e( '&mdash; Select &mdash;', 'woocommerce' ); ?></option>
<?php
foreach ( $keys as $key ) {
if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'edit_others_shop_order', $order->get_id() ) ) {
if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'edit_others_shop_orders' ) ) {
continue;
}
echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
}
?>
</select>
<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
<span id="enternew"><?php esc_html_e( 'Enter new', 'woocommerce' ); ?></span>
<span id="cancelnew" class="hidden"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></span></a>
<input class="hidden" type="text" id="metakeyinput" name="metakeyinput" value="" aria-label="<?php esc_attr_e( 'New custom field name', 'woocommerce' ); ?>" />
<button type="button" id="newmeta-button" class="button button-small hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggleClass('hidden');jQuery('#metakeyinput, #metakeyselect').filter(':visible').trigger('focus');">
<span id="enternew"><?php esc_html_e( 'Enter new', 'woocommerce' ); ?></span>
<span id="cancelnew" class="hidden"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></span>
<?php } else { ?>
<input type="text" id="metakeyinput" name="metakeyinput" value="" />
<?php } ?>
</td>
<td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea></td>
<td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea>
<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
</td>
</tr>
<tr><td colspan="2">
<div class="submit">
<?php
submit_button(
__( 'Add Custom Field', 'woocommerce' ),
'',
'addmeta',
false,
array(
'id' => 'newmeta-submit',
'data-wp-lists' => 'add:the-list:newmeta',
)
);
?>
</div>
<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
</td></tr>
</tbody>
</table>
<div class="submit add-custom-field">
<?php
submit_button(
__( 'Add Custom Field', 'woocommerce' ),
'',
'addmeta',
false,
array(
'id' => 'newmeta-submit',
'data-wp-lists' => 'add:the-list:newmeta',
)
);
?>
</div>
<?php
}
@@ -218,17 +234,20 @@ class CustomMetaBox {
$order_id = (int) $_POST['order_id'] ?? 0;
$order = $this->verify_order_edit_permission_for_ajax( $order_id );
if ( isset( $_POST['metakeyselect'] ) && '#NONE#' === $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) {
$select_meta_key = trim( sanitize_text_field( wp_unslash( $_POST['metakeyselect'] ?? '' ) ) );
$input_meta_key = trim( sanitize_text_field( wp_unslash( $_POST['metakeyinput'] ?? '' ) ) );
if ( empty( $_POST['meta'] ) && in_array( $select_meta_key, array( '', '#NONE#' ), true ) && ! $input_meta_key ) {
wp_die( 1 );
}
if ( isset( $_POST['metakeyinput'] ) ) { // add meta.
$meta_key = sanitize_text_field( wp_unslash( $_POST['metakeyinput'] ) );
$meta_value = sanitize_text_field( wp_unslash( $_POST['metavalue'] ?? '' ) );
$this->handle_add_meta( $order, $meta_key, $meta_value );
} else { // update.
$meta = wp_unslash( $_POST['meta'] ?? array() ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitization done below in array_walk.
if ( ! empty( $_POST['meta'] ) ) { // update.
$meta = wp_unslash( $_POST['meta'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitization done below in array_walk.
$this->handle_update_meta( $order, $meta );
} else { // add meta.
$meta_value = sanitize_text_field( wp_unslash( $_POST['metavalue'] ?? '' ) );
$meta_key = $input_meta_key ? $input_meta_key : $select_meta_key;
$this->handle_add_meta( $order, $meta_key, $meta_value );
}
}

View File

@@ -66,18 +66,20 @@ class OrderAttribution {
public function output( WC_Order $order ) {
$meta = $this->filter_meta_data( $order->get_meta_data() );
// If we don't have any meta to show, return.
if ( empty( $meta ) ) {
esc_html_e( 'No order source data available.', 'woocommerce' );
return;
}
$this->format_meta_data( $meta );
// No more details if there is only the origin value - this is for unknown source types.
$has_more_details = array( 'origin' ) !== array_keys( $meta );
// For direct, web admin, or mobile app orders, also don't show more details.
$simple_sources = array( 'typein', 'admin', 'mobile_app' );
if ( isset( $meta['source_type'] ) && in_array( $meta['source_type'], $simple_sources, true ) ) {
$has_more_details = false;
}
$template_data = array(
'meta' => $meta,
// Only show more details toggle if there is more than just the origin.
'has_more_details' => array( 'origin' ) !== array_keys( $meta ),
'has_more_details' => $has_more_details,
);
wc_get_template( 'order/attribution-details.php', $template_data );
}

View File

@@ -2,6 +2,7 @@
namespace Automattic\WooCommerce\Internal\Admin\Orders;
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
use Automattic\WooCommerce\Utilities\OrderUtil;
/**
* When {@see OrdersTableDataStore} is in use, this class takes care of redirecting admins from CPT-based URLs
@@ -126,11 +127,16 @@ class PostsRedirectionController {
*/
private function maybe_redirect_to_edit_order_page(): void {
$post_id = absint( $_GET['post'] ?? 0 );
if ( ! $post_id ) {
return;
}
$redirect_from_types = wc_get_order_types( 'admin-menu' );
$redirect_from_types[] = 'shop_order_placehold';
if ( ! $post_id || ! in_array( get_post_type( $post_id ), $redirect_from_types, true ) || ! isset( $_GET['action'] ) ) {
$post_type = get_post_type( $post_id );
$order_type = $post_type ? $post_type : OrderUtil::get_order_type( $post_id );
if ( ! in_array( $order_type, $redirect_from_types, true ) || ! isset( $_GET['action'] ) ) {
return;
}

View File

@@ -97,7 +97,7 @@ class DefaultFreeExtensions {
'description' => sprintf(
/* translators: 1: opening product link tag. 2: closing link tag */
__( 'Drive sales with %1$sGoogle Listings and Ads%2$s', 'woocommerce' ),
'<a href="https://woo.com/products/google-listings-and-ads" target="_blank">',
'<a href="https://woocommerce.com/products/google-listings-and-ads" target="_blank">',
'</a>'
),
'image_url' => plugins_url( '/assets/images/onboarding/google.svg', WC_PLUGIN_FILE ),
@@ -124,7 +124,7 @@ class DefaultFreeExtensions {
),
'facebook-for-woocommerce' => array(
'name' => __( 'Facebook for WooCommerce', 'woocommerce' ),
'description' => __( 'List products and create ads on Facebook and Instagram with <a href="https://woo.com/products/facebook/">Facebook for WooCommerce</a>', 'woocommerce' ),
'description' => __( 'List products and create ads on Facebook and Instagram with <a href="https://woocommerce.com/products/facebook/">Facebook for WooCommerce</a>', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/onboarding/facebook.png', WC_PLUGIN_FILE ),
'manage_url' => 'admin.php?page=wc-facebook',
'is_visible' => false,
@@ -180,7 +180,7 @@ class DefaultFreeExtensions {
'description' => sprintf(
/* translators: 1: opening product link tag. 2: closing link tag */
__( 'Accept credit cards and other popular payment methods with %1$sWooPayments%2$s', 'woocommerce' ),
'<a href="https://woo.com/products/woocommerce-payments" target="_blank">',
'<a href="https://woocommerce.com/products/woocommerce-payments" target="_blank">',
'</a>'
),
'is_visible' => array(
@@ -395,7 +395,7 @@ class DefaultFreeExtensions {
'description' => sprintf(
/* translators: 1: opening product link tag. 2: closing link tag */
__( 'Print shipping labels with %1$sWooCommerce Shipping%2$s', 'woocommerce' ),
'<a href="https://woo.com/products/shipping" target="_blank">',
'<a href="https://woocommerce.com/products/shipping" target="_blank">',
'</a>'
),
'is_visible' => array(
@@ -464,7 +464,7 @@ class DefaultFreeExtensions {
'description' => sprintf(
/* translators: 1: opening product link tag. 2: closing link tag */
__( 'Get automated sales tax with %1$sWooCommerce Tax%2$s', 'woocommerce' ),
'<a href="https://woo.com/products/tax" target="_blank">',
'<a href="https://woocommerce.com/products/tax" target="_blank">',
'</a>'
),
'is_visible' => array(
@@ -546,7 +546,7 @@ class DefaultFreeExtensions {
'description' => sprintf(
/* translators: 1: opening product link tag. 2: closing link tag */
__( 'Enhance speed and security with %1$sJetpack%2$s', 'woocommerce' ),
'<a href="https://woo.com/products/jetpack" target="_blank">',
'<a href="https://woocommerce.com/products/jetpack" target="_blank">',
'</a>'
),
'is_visible' => array(
@@ -569,7 +569,7 @@ class DefaultFreeExtensions {
'description' => sprintf(
/* translators: 1: opening product link tag. 2: closing link tag */
__( 'Level up your email marketing with %1$sMailPoet%2$s', 'woocommerce' ),
'<a href="https://woo.com/products/mailpoet" target="_blank">',
'<a href="https://woocommerce.com/products/mailpoet" target="_blank">',
'</a>'
),
'manage_url' => 'admin.php?page=mailpoet-newsletters',
@@ -814,7 +814,7 @@ class DefaultFreeExtensions {
'description' => sprintf(
/* translators: 1: opening product link tag. 2: closing link tag */
__( 'Create ad campaigns and reach one billion global users with %1$sTikTok for WooCommerce%2$s', 'woocommerce' ),
'<a href="https://woo.com/products/tiktok-for-woocommerce" target="_blank">',
'<a href="https://woocommerce.com/products/tiktok-for-woocommerce" target="_blank">',
'</a>'
),
'manage_url' => 'admin.php?page=tiktok',
@@ -846,56 +846,56 @@ class DefaultFreeExtensions {
'label' => __( 'Get paid with WooPayments', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-woo.svg', WC_PLUGIN_FILE ),
'description' => __( "Securely accept payments and manage payment activity straight from your store's dashboard", 'woocommerce' ),
'learn_more_link' => 'https://woo.com/products/woocommerce-payments',
'learn_more_link' => 'https://woocommerce.com/products/woocommerce-payments',
'install_priority' => 5,
),
'woocommerce-services:shipping' => array(
'label' => __( 'Print shipping labels with WooCommerce Shipping', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-woo.svg', WC_PLUGIN_FILE ),
'description' => __( 'Print USPS and DHL labels directly from your dashboard and save on shipping.', 'woocommerce' ),
'learn_more_link' => 'https://woo.com/woocommerce-shipping',
'learn_more_link' => 'https://woocommerce.com/woocommerce-shipping',
'install_priority' => 3,
),
'jetpack' => array(
'label' => __( 'Boost content creation with Jetpack AI Assistant', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-jetpack.svg', WC_PLUGIN_FILE ),
'description' => __( 'Save time on content creation — unlock high-quality blog posts and pages using AI.', 'woocommerce' ),
'learn_more_link' => 'https://woo.com/products/jetpack',
'learn_more_link' => 'https://woocommerce.com/products/jetpack',
'install_priority' => 8,
),
'pinterest-for-woocommerce' => array(
'label' => __( 'Showcase your products with Pinterest', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-pinterest.svg', WC_PLUGIN_FILE ),
'description' => __( 'Get your products in front of a highly engaged audience.', 'woocommerce' ),
'learn_more_link' => 'https://woo.com/products/pinterest-for-woocommerce',
'learn_more_link' => 'https://woocommerce.com/products/pinterest-for-woocommerce',
'install_priority' => 2,
),
'mailpoet' => array(
'label' => __( 'Reach your customers with MailPoet', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-mailpoet.svg', WC_PLUGIN_FILE ),
'description' => __( 'Send purchase follow-up emails, newsletters, and promotional campaigns.', 'woocommerce' ),
'learn_more_link' => 'https://woo.com/products/mailpoet',
'learn_more_link' => 'https://woocommerce.com/products/mailpoet',
'install_priority' => 7,
),
'tiktok-for-business' => array(
'label' => __( 'Create ad campaigns with TikTok', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-tiktok.svg', WC_PLUGIN_FILE ),
'description' => __( 'Create advertising campaigns and reach one billion global users.', 'woocommerce' ),
'learn_more_link' => 'https://woo.com/products/tiktok-for-woocommerce',
'learn_more_link' => 'https://woocommerce.com/products/tiktok-for-woocommerce',
'install_priority' => 1,
),
'google-listings-and-ads' => array(
'label' => __( 'Drive sales with Google Listings & Ads', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-google.svg', WC_PLUGIN_FILE ),
'description' => __( 'Reach millions of active shoppers across Google with free product listings and ads.', 'woocommerce' ),
'learn_more_link' => 'https://woo.com/products/google-listings-and-ads',
'learn_more_link' => 'https://woocommerce.com/products/google-listings-and-ads',
'install_priority' => 6,
),
'woocommerce-services:tax' => array(
'label' => __( 'Get automated tax rates with WooCommerce Tax', 'woocommerce' ),
'image_url' => plugins_url( '/assets/images/core-profiler/logo-woo.svg', WC_PLUGIN_FILE ),
'description' => __( 'Automatically calculate how much sales tax should be collected by city, country, or state.', 'woocommerce' ),
'learn_more_link' => 'https://woo.com/products/tax',
'learn_more_link' => 'https://woocommerce.com/products/tax',
'install_priority' => 4,
),
);

View File

@@ -8,7 +8,7 @@ namespace Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\PluginsHelper;
use Automattic\WooCommerce\Admin\RemoteInboxNotifications\RuleEvaluator;
use Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\RuleEvaluator;
/**
* Evaluates the extension and returns it.

View File

@@ -2,15 +2,16 @@
namespace Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions;
use Automattic\WooCommerce\Admin\RemoteSpecs\DataSourcePoller;
/**
* Specs data source poller class for remote free extensions.
*/
class RemoteFreeExtensionsDataSourcePoller extends \Automattic\WooCommerce\Admin\DataSourcePoller {
class RemoteFreeExtensionsDataSourcePoller extends DataSourcePoller {
const ID = 'remote_free_extensions';
const DATA_SOURCES = array(
'https://woocommerce.com/wp-json/wccom/obw-free-extensions/3.0/extensions.json',
'https://woocommerce.com/wp-json/wccom/obw-free-extensions/4.0/extensions.json',
);
/**

View File

@@ -128,14 +128,7 @@ class ShippingLabelBanner {
* @param string $hook current page hook.
*/
public function add_print_shipping_label_script( $hook ) {
$rtl = is_rtl() ? '.rtl' : '';
wp_enqueue_style(
'print-shipping-label-banner-style',
WCAdminAssets::get_url( "print-shipping-label-banner/style{$rtl}", 'css' ),
array( 'wp-components' ),
WCAdminAssets::get_file_version( 'css' )
);
WCAdminAssets::register_style( 'print-shipping-label-banner', 'style', array( 'wp-components' ) );
WCAdminAssets::register_script( 'wp-admin-scripts', 'print-shipping-label-banner', true );
$payload = array(

View File

@@ -98,15 +98,22 @@ class WCAdminAssets {
}
/**
* Gets the file modified time as a cache buster if we're in dev mode, or the plugin version otherwise.
* Gets the file modified time as a cache buster if we're in dev mode,
* or the asset version (file content hash) if exists, or the WooCommerce version.
*
* @param string $ext File extension.
* @param string $ext File extension.
* @param string|null $asset_version Optional. The version from the asset file.
* @return string The cache buster value to use for the given file.
*/
public static function get_file_version( $ext ) {
public static function get_file_version( $ext, $asset_version = null ) {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
return filemtime( WC_ADMIN_ABSPATH . self::get_path( $ext ) );
}
if ( ! empty( $asset_version ) ) {
return $asset_version;
}
return WC_VERSION;
}
@@ -253,9 +260,7 @@ class WCAdminAssets {
return;
}
$js_file_version = self::get_file_version( 'js' );
$css_file_version = self::get_file_version( 'css' );
// Register the JS scripts.
$scripts = array(
'wc-admin-layout',
'wc-explat',
@@ -299,6 +304,7 @@ class WCAdminAssets {
try {
$script_assets_filename = self::get_script_asset_filename( $script_path_name, 'index' );
$script_assets = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . $script_path_name . '/' . $script_assets_filename;
$script_version = self::get_file_version( 'js', $script_assets['version'] );
global $wp_version;
if ( 'app' === $script_path_name && version_compare( $wp_version, '6.3', '<' ) ) {
@@ -320,92 +326,83 @@ class WCAdminAssets {
wp_register_script(
$script,
self::get_url( $script_path_name . '/index', 'js' ),
$script_assets ['dependencies'],
$js_file_version,
$script_assets['dependencies'],
$script_version,
true
);
if ( in_array( $script, $translated_scripts, true ) ) {
wp_set_script_translations( $script, 'woocommerce' );
}
if ( WC_ADMIN_APP === $script ) {
wp_localize_script(
WC_ADMIN_APP,
'wcAdminAssets',
array(
'path' => plugins_url( self::get_path( 'js' ), WC_ADMIN_PLUGIN_FILE ),
'version' => $script_version,
)
);
}
} catch ( \Exception $e ) {
// Avoid crashing WordPress if an asset file could not be loaded.
wc_caught_exception( $e, __CLASS__ . '::' . __FUNCTION__, $script_path_name );
}
}
wp_register_style(
'wc-admin-layout',
self::get_url( 'admin-layout/style', 'css' ),
array(),
$css_file_version
);
wp_style_add_data( 'wc-admin-layout', 'rtl', 'replace' );
wp_register_style(
'wc-components',
self::get_url( 'components/style', 'css' ),
array(),
$css_file_version
);
wp_style_add_data( 'wc-components', 'rtl', 'replace' );
wp_register_style(
'wc-block-templates',
self::get_url( 'block-templates/style', 'css' ),
array(),
$css_file_version
);
wp_style_add_data( 'wc-block-templates', 'rtl', 'replace' );
wp_register_style(
'wc-product-editor',
self::get_url( 'product-editor/style', 'css' ),
array(),
$css_file_version
);
wp_style_add_data( 'wc-product-editor', 'rtl', 'replace' );
wp_register_style(
'wc-customer-effort-score',
self::get_url( 'customer-effort-score/style', 'css' ),
array(),
$css_file_version
);
wp_style_add_data( 'wc-customer-effort-score', 'rtl', 'replace' );
wp_register_style(
'wc-experimental',
self::get_url( 'experimental/style', 'css' ),
array(),
$css_file_version
);
wp_style_add_data( 'wc-experimental', 'rtl', 'replace' );
wp_localize_script(
WC_ADMIN_APP,
'wcAdminAssets',
// Register the CSS styles.
$styles = array(
array(
'path' => plugins_url( self::get_path( 'js' ), WC_ADMIN_PLUGIN_FILE ),
'version' => $js_file_version,
)
'handle' => 'wc-admin-layout',
),
array(
'handle' => 'wc-components',
),
array(
'handle' => 'wc-block-templates',
),
array(
'handle' => 'wc-product-editor',
),
array(
'handle' => 'wc-customer-effort-score',
),
array(
'handle' => 'wc-experimental',
),
array(
'handle' => WC_ADMIN_APP,
'dependencies' => array( 'wc-components', 'wc-admin-layout', 'wc-customer-effort-score', 'wc-product-editor', 'wp-components', 'wc-experimental' ),
),
array(
'handle' => 'wc-onboarding',
),
);
wp_register_style(
WC_ADMIN_APP,
self::get_url( 'app/style', 'css' ),
array( 'wc-components', 'wc-admin-layout', 'wc-customer-effort-score', 'wc-product-editor', 'wp-components', 'wc-experimental' ),
$css_file_version
);
wp_style_add_data( WC_ADMIN_APP, 'rtl', 'replace' );
$css_file_version = self::get_file_version( 'css' );
foreach ( $styles as $style ) {
$handle = $style['handle'];
$style_path_name = isset( $scripts_map[ $handle ] ) ? $scripts_map[ $handle ] : str_replace( 'wc-', '', $handle );
wp_register_style(
'wc-onboarding',
self::get_url( 'onboarding/style', 'css' ),
array(),
$css_file_version
);
wp_style_add_data( 'wc-onboarding', 'rtl', 'replace' );
try {
$style_assets_filename = self::get_script_asset_filename( $style_path_name, 'style' );
$style_assets = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . $style_path_name . '/' . $style_assets_filename;
$version = $style_assets['version'];
} catch ( \Throwable $e ) {
// Use the default version if the asset file could not be loaded.
$version = $css_file_version;
}
$dependencies = isset( $style['dependencies'] ) ? $style['dependencies'] : array();
wp_register_style(
$handle,
self::get_url( $style_path_name . '/style', 'css' ),
$dependencies,
self::get_file_version( 'css', $version ),
);
wp_style_add_data( $handle, 'rtl', 'replace' );
}
}
/**
@@ -475,11 +472,32 @@ class WCAdminAssets {
'wc-admin-' . $script_name,
self::get_url( $script_path_name . '/' . $script_name, 'js' ),
array_merge( array( WC_ADMIN_APP ), $script_assets ['dependencies'], $dependencies ),
self::get_file_version( 'js' ),
self::get_file_version( 'js', $script_assets['version'] ),
true
);
if ( $need_translation ) {
wp_set_script_translations( 'wc-admin-' . $script_name, 'woocommerce' );
}
}
/**
* Loads a style
*
* @param string $style_path_name The style path name.
* @param string $style_name Filename of the style to load.
* @param array $dependencies Array of any extra dependencies.
*/
public static function register_style( $style_path_name, $style_name, $dependencies = array() ) {
$style_assets_filename = self::get_script_asset_filename( $style_path_name, $style_name );
$style_assets = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_CSS_FOLDER . $style_path_name . '/' . $style_assets_filename;
$handle = 'wc-admin-' . $style_name;
wp_enqueue_style(
$handle,
self::get_url( $style_path_name . '/' . $style_name, 'css' ),
$dependencies,
self::get_file_version( 'css', $style_assets['version'] ),
);
wp_style_add_data( $handle, 'rtl', 'replace' );
}
}

View File

@@ -59,8 +59,7 @@ class WCAdminSharedSettings {
$this->settings_prefix,
function() {
return apply_filters( 'woocommerce_admin_shared_settings', array() );
},
true
}
);
}
}

View File

@@ -41,8 +41,12 @@ class WCAdminUser {
'user',
'is_super_admin',
array(
'get_callback' => function() {
return is_super_admin();
'get_callback' => function( $user ) {
if ( ! isset( $user['id'] ) || 0 === $user['id'] ) {
return false;
}
return is_super_admin( $user['id'] );
},
'schema' => null,
)

View File

@@ -31,17 +31,7 @@ class Init extends RemoteSpecsEngine {
add_filter( 'woocommerce_payment_gateways', array( __CLASS__, 'possibly_register_pre_install_wc_pay_promotion_gateway' ) );
add_filter( 'option_woocommerce_gateway_order', array( __CLASS__, 'set_gateway_top_of_list' ) );
add_filter( 'default_option_woocommerce_gateway_order', array( __CLASS__, 'set_gateway_top_of_list' ) );
$rtl = is_rtl() ? '.rtl' : '';
wp_enqueue_style(
'wc-admin-payment-method-promotions',
WCAdminAssets::get_url( "payment-method-promotions/style{$rtl}", 'css' ),
array( 'wp-components' ),
WCAdminAssets::get_file_version( 'css' )
);
WCAdminAssets::register_script( 'wp-admin-scripts', 'payment-method-promotions', true );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_payment_method_promotions' ) );
}
/**
@@ -161,5 +151,13 @@ class Init extends RemoteSpecsEngine {
}
return WCPayPromotionDataSourcePoller::get_instance()->get_specs_from_data_sources();
}
/**
* Loads the payment method promotions scripts and styles.
*/
public static function load_payment_method_promotions() {
WCAdminAssets::register_style( 'payment-method-promotions', 'style', array( 'wp-components' ) );
WCAdminAssets::register_script( 'wp-admin-scripts', 'payment-method-promotions', true );
}
}

View File

@@ -1,4 +1,5 @@
<?php
namespace Automattic\WooCommerce\Internal\Admin\WCPayPromotion;
use Automattic\WooCommerce\Admin\DataSourcePoller;
@@ -14,13 +15,13 @@ class WCPayPromotionDataSourcePoller extends DataSourcePoller {
* Default data sources array.
*/
const DATA_SOURCES = array(
'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/1.0/payment-method/promotions.json',
'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/payment-method/promotions.json',
);
/**
* Class instance.
*
* @var Analytics instance
* @var WCPayPromotionDataSourcePoller instance
*/
protected static $instance = null;