Plugin Updates
This commit is contained in:
@@ -79,31 +79,19 @@ class WC_Admin_Addons {
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
public static function fetch_featured() {
|
||||
$transient_name = 'wc_addons_featured';
|
||||
// Important: WCCOM Extensions API v2.0 is used.
|
||||
$url = 'https://woocommerce.com/wp-json/wccom-extensions/2.0/featured';
|
||||
$locale = get_user_locale();
|
||||
$featured = self::get_locale_data_from_transient( 'wc_addons_featured', $locale );
|
||||
$featured = self::get_locale_data_from_transient( $transient_name, $locale );
|
||||
|
||||
if ( false === $featured ) {
|
||||
$headers = array();
|
||||
$auth = WC_Helper_Options::get( 'auth' );
|
||||
|
||||
if ( ! empty( $auth['access_token'] ) ) {
|
||||
$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
|
||||
}
|
||||
|
||||
$parameter_string = '?' . http_build_query( array( 'locale' => get_user_locale() ) );
|
||||
$country = WC()->countries->get_base_country();
|
||||
if ( ! empty( $country ) ) {
|
||||
$parameter_string = $parameter_string . '&' . http_build_query( array( 'country' => $country ) );
|
||||
}
|
||||
|
||||
// Important: WCCOM Extensions API v2.0 is used.
|
||||
$raw_featured = wp_safe_remote_get(
|
||||
'https://woocommerce.com/wp-json/wccom-extensions/2.0/featured' . $parameter_string,
|
||||
array(
|
||||
'headers' => $headers,
|
||||
'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ),
|
||||
)
|
||||
$fetch_options = array(
|
||||
'auth' => true,
|
||||
'locale' => true,
|
||||
'country' => true,
|
||||
);
|
||||
$raw_featured = self::fetch( $url, $fetch_options );
|
||||
|
||||
if ( is_wp_error( $raw_featured ) ) {
|
||||
do_action( 'woocommerce_page_wc-addons_connection_error', $raw_featured->get_error_message() );
|
||||
@@ -143,7 +131,7 @@ class WC_Admin_Addons {
|
||||
}
|
||||
|
||||
if ( $featured ) {
|
||||
self::set_locale_data_in_transient( 'wc_addons_featured', $featured, $locale, DAY_IN_SECONDS );
|
||||
self::set_locale_data_in_transient( $transient_name, $featured, $locale, DAY_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1556,4 +1544,49 @@ class WC_Admin_Addons {
|
||||
$transient_value[ $locale ] = $value;
|
||||
return set_transient( $transient, $transient_value, $expiration );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make wp_safe_remote_get request to Woo.com endpoint.
|
||||
* Optionally pass user auth token, locale or country.
|
||||
*
|
||||
* @param string $url URL to request.
|
||||
* @param ?array $options Options for the request. For example, to pass auth token, locale and country,
|
||||
* pass array( 'auth' => true, 'locale' => true, 'country' => true, ).
|
||||
*
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
public static function fetch( $url, $options = array() ) {
|
||||
$headers = array();
|
||||
|
||||
if ( isset( $options['auth'] ) && $options['auth'] ) {
|
||||
$auth = WC_Helper_Options::get( 'auth' );
|
||||
|
||||
if ( isset( $auth['access_token'] ) && ! empty( $auth['access_token'] ) ) {
|
||||
$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
|
||||
}
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
|
||||
if ( isset( $options['locale'] ) && $options['locale'] ) {
|
||||
$parameters['locale'] = get_user_locale();
|
||||
}
|
||||
|
||||
if ( isset( $options['country'] ) && $options['country'] ) {
|
||||
$country = WC()->countries->get_base_country();
|
||||
if ( ! empty( $country ) ) {
|
||||
$parameters['country'] = $country;
|
||||
}
|
||||
}
|
||||
|
||||
$query_string = ! empty( $parameters ) ? '?' . http_build_query( $parameters ) : '';
|
||||
|
||||
return wp_safe_remote_get(
|
||||
$url . $query_string,
|
||||
array(
|
||||
'headers' => $headers,
|
||||
'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,6 +554,22 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
||||
);
|
||||
wp_enqueue_script( 'marketplace-suggestions' );
|
||||
}
|
||||
|
||||
// Marketplace promotions.
|
||||
if ( in_array( $screen_id, array( 'woocommerce_page_wc-admin' ), true ) ) {
|
||||
|
||||
$promotions = get_transient( WC_Admin_Marketplace_Promotions::TRANSIENT_NAME );
|
||||
|
||||
if ( false === $promotions ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_add_inline_script(
|
||||
'wc-admin-app',
|
||||
'window.wcMarketplace = ' . wp_json_encode( array( 'promotions' => $promotions ) ),
|
||||
'before'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -293,11 +293,11 @@ class WC_Admin_Importers {
|
||||
'position' => 'done',
|
||||
'percentage' => 100,
|
||||
'url' => add_query_arg( array( '_wpnonce' => wp_create_nonce( 'woocommerce-csv-importer' ) ), admin_url( 'edit.php?post_type=product&page=product_importer&step=done' ) ),
|
||||
'imported' => count( $results['imported'] ),
|
||||
'imported_variations' => count( $results['imported_variations'] ),
|
||||
'failed' => count( $results['failed'] ),
|
||||
'updated' => count( $results['updated'] ),
|
||||
'skipped' => count( $results['skipped'] ),
|
||||
'imported' => is_countable( $results['imported'] ) ? count( $results['imported'] ) : 0,
|
||||
'imported_variations' => is_countable( $results['imported_variations'] ) ? count( $results['imported_variations'] ) : 0,
|
||||
'failed' => is_countable( $results['failed'] ) ? count( $results['failed'] ) : 0,
|
||||
'updated' => is_countable( $results['updated'] ) ? count( $results['updated'] ) : 0,
|
||||
'skipped' => is_countable( $results['skipped'] ) ? count( $results['skipped'] ) : 0,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
@@ -305,11 +305,11 @@ class WC_Admin_Importers {
|
||||
array(
|
||||
'position' => $importer->get_file_position(),
|
||||
'percentage' => $percent_complete,
|
||||
'imported' => count( $results['imported'] ),
|
||||
'imported_variations' => count( $results['imported_variations'] ),
|
||||
'failed' => count( $results['failed'] ),
|
||||
'updated' => count( $results['updated'] ),
|
||||
'skipped' => count( $results['skipped'] ),
|
||||
'imported' => is_countable( $results['imported'] ) ? count( $results['imported'] ) : 0,
|
||||
'imported_variations' => is_countable( $results['imported_variations'] ) ? count( $results['imported_variations'] ) : 0,
|
||||
'failed' => is_countable( $results['failed'] ) ? count( $results['failed'] ) : 0,
|
||||
'updated' => is_countable( $results['updated'] ) ? count( $results['updated'] ) : 0,
|
||||
'skipped' => is_countable( $results['skipped'] ) ? count( $results['skipped'] ) : 0,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/**
|
||||
* Addons Page
|
||||
*
|
||||
* @package WooCommerce\Admin
|
||||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WC_Admin_Marketplace_Promotions class.
|
||||
*/
|
||||
class WC_Admin_Marketplace_Promotions {
|
||||
|
||||
const TRANSIENT_NAME = 'woocommerce_marketplace_promotions';
|
||||
const SCHEDULED_ACTION_HOOK = 'woocommerce_marketplace_fetch_promotions';
|
||||
/**
|
||||
* The user's locale, for example en_US.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static string $locale;
|
||||
|
||||
/**
|
||||
* On all admin pages, schedule an action to fetch promotions data.
|
||||
* Add menu badge to WooCommerce Extensions item if the promotions
|
||||
* API requests one.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init_marketplace_promotions() {
|
||||
// Add the callback for our scheduled action.
|
||||
if ( ! has_action( self::SCHEDULED_ACTION_HOOK, array( __CLASS__, 'fetch_marketplace_promotions' ) ) ) {
|
||||
add_action( self::SCHEDULED_ACTION_HOOK, array( __CLASS__, 'fetch_marketplace_promotions' ) );
|
||||
}
|
||||
|
||||
if ( self::is_admin_page() ) {
|
||||
// Schedule the action twice a day, starting now.
|
||||
if ( false === wp_next_scheduled( self::SCHEDULED_ACTION_HOOK ) ) {
|
||||
wp_schedule_event( time(), 'twicedaily', self::SCHEDULED_ACTION_HOOK );
|
||||
}
|
||||
|
||||
self::$locale = ( self::$locale ?? get_user_locale() ) ?? 'en_US';
|
||||
self::maybe_show_bubble_promotions();
|
||||
}
|
||||
|
||||
register_deactivation_hook( WC_PLUGIN_FILE, array( __CLASS__, 'clear_scheduled_event' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the request is for an admin page, and not ajax.
|
||||
* We may want to add a menu bubble to WooCommerce Extensions
|
||||
* on any admin page, as the user may view the WooCommerce flyout
|
||||
* menu.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function is_admin_page(): bool {
|
||||
if (
|
||||
( defined( 'DOING_AJAX' ) && DOING_AJAX )
|
||||
|| ! is_admin()
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get promotions to show in the Woo in-app marketplace.
|
||||
* Only run on selected pages in the main WooCommerce menu in wp-admin.
|
||||
* Loads promotions in transient with one day life.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function fetch_marketplace_promotions() {
|
||||
$url = 'https://woo.com/wp-json/wccom-extensions/3.0/promotions';
|
||||
$promotions = get_transient( self::TRANSIENT_NAME );
|
||||
|
||||
if ( false !== $promotions ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fetch_options = array(
|
||||
'auth' => true,
|
||||
'country' => true,
|
||||
);
|
||||
$raw_promotions = WC_Admin_Addons::fetch( $url, $fetch_options );
|
||||
|
||||
// phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
if ( is_wp_error( $raw_promotions ) ) {
|
||||
/**
|
||||
* Allows connection error to be handled.
|
||||
*
|
||||
* @since 8.7
|
||||
*/
|
||||
do_action( 'woocommerce_page_wc-addons_connection_error', $raw_promotions->get_error_message() );
|
||||
}
|
||||
|
||||
$response_code = (int) wp_remote_retrieve_response_code( $raw_promotions );
|
||||
if ( 200 !== $response_code ) {
|
||||
/**
|
||||
* Allows connection error to be handled.
|
||||
*
|
||||
* @since 8.7
|
||||
*/
|
||||
do_action( 'woocommerce_page_wc-addons_connection_error', $response_code );
|
||||
}
|
||||
|
||||
$promotions = json_decode( wp_remote_retrieve_body( $raw_promotions ), true );
|
||||
if ( empty( $promotions ) || ! is_array( $promotions ) ) {
|
||||
/**
|
||||
* Allows connection error to be handled.
|
||||
*
|
||||
* @since 8.7
|
||||
*/
|
||||
do_action( 'woocommerce_page_wc-addons_connection_error', 'Empty or malformed response' );
|
||||
}
|
||||
// phpcs:enable WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
|
||||
if ( $promotions ) {
|
||||
// Filter out any expired promotions.
|
||||
$promotions = self::get_active_promotions( $promotions );
|
||||
set_transient( self::TRANSIENT_NAME, $promotions, DAY_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If there's an active promotion of the format `menu_bubble`,
|
||||
* add a filter to show a bubble on the Extensions item in the
|
||||
* WooCommerce menu.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception If we are unable to create a DateTime from the date_to_gmt.
|
||||
*/
|
||||
private static function maybe_show_bubble_promotions() {
|
||||
$promotions = get_transient( self::TRANSIENT_NAME );
|
||||
if ( ! $promotions ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bubble_promotions = self::get_promotions_of_format( $promotions, 'menu_bubble' );
|
||||
if ( empty( $bubble_promotions ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$now_date_time = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
||||
|
||||
// Let's make absolutely sure the promotion is still active.
|
||||
foreach ( $bubble_promotions as $promotion ) {
|
||||
if ( ! isset( $promotion['date_to_gmt'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$date_to_gmt = new DateTime( $promotion['date_to_gmt'], new DateTimeZone( 'UTC' ) );
|
||||
} catch ( \Exception $ex ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $now_date_time < $date_to_gmt ) {
|
||||
add_filter(
|
||||
'woocommerce_marketplace_menu_items',
|
||||
function ( $marketplace_pages ) use ( $promotion ) {
|
||||
return self::filter_marketplace_menu_items( $marketplace_pages, $promotion );
|
||||
}
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* From the array of promotions, select those of a given format.
|
||||
*
|
||||
* @param ? array $promotions Array of data about promotions of all formats.
|
||||
* @param ? string $format Format we want to filter for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function get_promotions_of_format( $promotions = array(), $format = '' ): array {
|
||||
if ( empty( $promotions ) || empty( $format ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return array_filter(
|
||||
$promotions,
|
||||
function( $promotion ) use ( $format ) {
|
||||
return isset( $promotion['format'] ) && $format === $promotion['format'];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find promotions that are still active – they have a date range that
|
||||
* includes the current date.
|
||||
*
|
||||
* @param ?array $promotions Data about current promotions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function get_active_promotions( $promotions = array() ) {
|
||||
$now_date_time = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
||||
$active_promotions = array();
|
||||
|
||||
foreach ( $promotions as $promotion ) {
|
||||
if ( ! isset( $promotion['date_from_gmt'] ) || ! isset( $promotion['date_to_gmt'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$date_from_gmt = new DateTime( $promotion['date_from_gmt'], new DateTimeZone( 'UTC' ) );
|
||||
$date_to_gmt = new DateTime( $promotion['date_to_gmt'], new DateTimeZone( 'UTC' ) );
|
||||
} catch ( \Exception $ex ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $now_date_time >= $date_from_gmt && $now_date_time <= $date_to_gmt ) {
|
||||
$active_promotions[] = $promotion;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort promotions so the ones starting more recently are at the top.
|
||||
usort(
|
||||
$active_promotions,
|
||||
function ( $a, $b ) {
|
||||
return $b['date_from_gmt'] <=> $a['date_from_gmt'];
|
||||
}
|
||||
);
|
||||
|
||||
return $active_promotions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for the `woocommerce_marketplace_menu_items` filter
|
||||
* in `Automattic\WooCommerce\Internal\Admin\Marketplace::get_marketplace_pages`.
|
||||
* At the moment, the Extensions page is the only page in `$menu_items`.
|
||||
* Adds a bubble to the menu item.
|
||||
*
|
||||
* @param array $menu_items Arrays representing items in nav menu.
|
||||
* @param ?array $promotion Data about a promotion from the Woo.com API.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function filter_marketplace_menu_items( $menu_items, $promotion = array() ) {
|
||||
if ( ! isset( $promotion['menu_item_id'] ) || ! isset( $promotion['content'] ) ) {
|
||||
return $menu_items;
|
||||
}
|
||||
foreach ( $menu_items as $index => $menu_item ) {
|
||||
if (
|
||||
'woocommerce' === $menu_item['parent']
|
||||
&& $promotion['menu_item_id'] === $menu_item['id']
|
||||
) {
|
||||
$bubble_text = $promotion['content'][ self::$locale ] ?? ( $promotion['content']['en_US'] ?? __( 'Sale', 'woocommerce' ) );
|
||||
$menu_items[ $index ]['title'] = $menu_item['title'] . self::append_bubble( $bubble_text );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $menu_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the markup for a menu item bubble with a given text.
|
||||
*
|
||||
* @param string $bubble_text Text of bubble.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function append_bubble( $bubble_text ) {
|
||||
return ' <span class="awaiting-mod update-plugins remaining-tasks-badge woocommerce-task-list-remaining-tasks-badge">' . esc_html( $bubble_text ) . '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* When WooCommerce is deactivated, clear the scheduled action.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function clear_scheduled_event() {
|
||||
$timestamp = wp_next_scheduled( self::SCHEDULED_ACTION_HOOK );
|
||||
wp_unschedule_event( $timestamp, self::SCHEDULED_ACTION_HOOK );
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ class WC_Admin_Meta_Boxes {
|
||||
* @return string[] Templates array excluding block-based templates.
|
||||
*/
|
||||
public function remove_block_templates( $templates ) {
|
||||
if ( count( $templates ) === 0 || ! wc_current_theme_is_fse_theme() || ( ! function_exists( 'gutenberg_get_block_template' ) && ! function_exists( 'get_block_template' ) ) ) {
|
||||
if ( count( $templates ) === 0 || ! wc_current_theme_is_fse_theme() ) {
|
||||
return $templates;
|
||||
}
|
||||
|
||||
@@ -296,9 +296,7 @@ class WC_Admin_Meta_Boxes {
|
||||
continue;
|
||||
}
|
||||
|
||||
$block_template = function_exists( 'gutenberg_get_block_template' ) ?
|
||||
gutenberg_get_block_template( $theme . '//' . $template_key ) :
|
||||
get_block_template( $theme . '//' . $template_key );
|
||||
$block_template = get_block_template( $theme . '//' . $template_key );
|
||||
|
||||
// If the block template has the product post type specified, include it.
|
||||
if ( $block_template && is_array( $block_template->post_types ) && in_array( 'product', $block_template->post_types ) ) {
|
||||
|
||||
@@ -305,6 +305,8 @@ class WC_Admin_Notices {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once WC_ABSPATH . 'includes/admin/wc-admin-functions.php';
|
||||
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
$show_on_screens = array(
|
||||
|
||||
@@ -192,7 +192,7 @@ class WC_Admin_Webhooks {
|
||||
$webhook_id = absint( $_GET['delete'] );
|
||||
|
||||
if ( $webhook_id ) {
|
||||
$this->bulk_delete( array( $webhook_id ) );
|
||||
self::bulk_delete( array( $webhook_id ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ class WC_Admin {
|
||||
if ( isset( $_GET['page'] ) && 'wc-addons' === $_GET['page'] ) {
|
||||
add_filter( 'admin_body_class', array( 'WC_Admin_Addons', 'filter_admin_body_classes' ) );
|
||||
}
|
||||
|
||||
// Fetch list of promotions from Woo.com for WooCommerce admin UI. We need to fire earlier than admin_init so we can filter menu items.
|
||||
add_action( 'woocommerce_init', array( 'WC_Admin_Marketplace_Promotions', 'init_marketplace_promotions' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,6 +80,9 @@ class WC_Admin {
|
||||
// Marketplace suggestions & related REST API.
|
||||
include_once __DIR__ . '/marketplace-suggestions/class-wc-marketplace-suggestions.php';
|
||||
include_once __DIR__ . '/marketplace-suggestions/class-wc-marketplace-updater.php';
|
||||
|
||||
// Marketplace promotions.
|
||||
include_once __DIR__ . '/class-wc-admin-marketplace-promotions.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -408,7 +408,7 @@ class WC_Helper {
|
||||
}
|
||||
|
||||
$filters = array_fill_keys( array_keys( self::get_filters() ), 0 );
|
||||
if ( empty( $subscriptions ) ) {
|
||||
if ( ! is_array( $subscriptions ) || empty( $subscriptions ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -1461,7 +1461,7 @@ class WC_Helper {
|
||||
if ( is_readable( $txt ) ) {
|
||||
$txt = file_get_contents( $txt );
|
||||
$txt = preg_split( '#\s#', $txt );
|
||||
if ( count( $txt ) >= 2 ) {
|
||||
if ( is_array( $txt ) && count( $txt ) >= 2 ) {
|
||||
$header = sprintf( '%d:%s', $txt[0], $txt[1] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ class WC_Tax_Rate_Importer extends WP_Importer {
|
||||
if ( false !== $handle ) {
|
||||
|
||||
$header = fgetcsv( $handle, 0, $this->delimiter );
|
||||
|
||||
if ( 10 === count( $header ) ) {
|
||||
$count = is_countable( $header ) ? count( $header ) : 0;
|
||||
if ( 10 === $count ) {
|
||||
|
||||
$row = fgetcsv( $handle, 0, $this->delimiter );
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( count( $errors ) ) {
|
||||
if ( is_array( $errors ) && count( $errors ) ) {
|
||||
foreach ( $errors as $error ) {
|
||||
if ( ! is_wp_error( $error ) ) {
|
||||
continue;
|
||||
|
||||
@@ -136,8 +136,7 @@ class WC_Admin_List_Table_Coupons extends WC_Admin_List_Table {
|
||||
*/
|
||||
protected function render_products_column() {
|
||||
$product_ids = $this->object->get_product_ids();
|
||||
|
||||
if ( count( $product_ids ) > 0 ) {
|
||||
if ( is_array( $product_ids ) && count( $product_ids ) > 0 ) {
|
||||
echo esc_html( implode( ', ', $product_ids ) );
|
||||
} else {
|
||||
echo '–';
|
||||
|
||||
@@ -15,8 +15,7 @@ $arrow_img_url = WC_ADMIN_IMAGES_FOLDER_URL . '/product_data/no-variati
|
||||
?>
|
||||
<div id="variable_product_options" class="panel wc-metaboxes-wrapper hidden">
|
||||
<div id="variable_product_options_inner">
|
||||
|
||||
<?php if ( ! count( $variation_attributes ) ) : ?>
|
||||
<?php if ( ! isset( $variation_attributes ) || ! is_array( $variation_attributes ) || count( $variation_attributes ) === 0 ) : ?>
|
||||
|
||||
<div class="add-attributes-container">
|
||||
<div class="add-attributes-message">
|
||||
|
||||
@@ -343,7 +343,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
|
||||
$index = 0;
|
||||
foreach ( $chart_data as $data ) {
|
||||
$color = isset( $this->chart_colours[ $index ] ) ? $this->chart_colours[ $index ] : $this->chart_colours[0];
|
||||
$width = $this->barwidth / sizeof( $chart_data );
|
||||
$width = $this->barwidth / count( $chart_data );
|
||||
$offset = ( $width * $index );
|
||||
$series = $data['data'];
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||
public function output_tax_rates() {
|
||||
global $current_section;
|
||||
|
||||
$current_class = $this->get_current_tax_class();
|
||||
$current_class = self::get_current_tax_class();
|
||||
|
||||
$countries = array();
|
||||
foreach ( WC()->countries->get_allowed_countries() as $value => $label ) {
|
||||
@@ -320,7 +320,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing -- this is called via "do_action('woocommerce_settings_save_'...") in base class, where nonce is verified first.
|
||||
global $wpdb;
|
||||
|
||||
$current_class = sanitize_title( $this->get_current_tax_class() );
|
||||
$current_class = sanitize_title( self::get_current_tax_class() );
|
||||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Missing
|
||||
$posted_countries = wc_clean( wp_unslash( $_POST['tax_rate_country'] ) );
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
<div>
|
||||
<button id="btn-back" class="button button-large wc-backbone-modal-back-{{ data.status === 'new' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Back', 'woocommerce' ); ?></button>
|
||||
<button id="btn-ok" data-status='{{ data.status }}' class="button button-primary button-large">
|
||||
<div class="wc-backbone-modal-action-{{ data.status === 'new' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Create', 'woocommerce' ); ?></div>
|
||||
<div class="wc-backbone-modal-action-{{ data.status === 'new' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Create and save', 'woocommerce' ); ?></div>
|
||||
<div class="wc-backbone-modal-action-{{ data.status === 'existing' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Save', 'woocommerce' ); ?></div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -21,9 +21,14 @@ $dropins_mu_plugins = $report['dropins_mu_plugins'];
|
||||
$theme = $report['theme'];
|
||||
$security = $report['security'];
|
||||
$settings = $report['settings'];
|
||||
$logging = $report['logging'];
|
||||
$wp_pages = $report['pages'];
|
||||
$plugin_updates = new WC_Plugin_Updates();
|
||||
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) );
|
||||
|
||||
$active_plugins_count = is_countable( $active_plugins ) ? count( $active_plugins ) : 0;
|
||||
$inactive_plugins_count = is_countable( $inactive_plugins ) ? count( $inactive_plugins ) : 0;
|
||||
|
||||
?>
|
||||
<div class="updated woocommerce-message inline">
|
||||
<p>
|
||||
@@ -87,26 +92,6 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Cons
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-export-label="WC Blocks Version"><?php esc_html_e( 'WooCommerce Blocks package', 'woocommerce' ); ?>:</td>
|
||||
<td class="help"><?php echo wc_help_tip( esc_html__( 'The WooCommerce Blocks package running on your site.', 'woocommerce' ) ); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ( class_exists( '\Automattic\WooCommerce\Blocks\Package' ) ) {
|
||||
$version = \Automattic\WooCommerce\Blocks\Package::get_version();
|
||||
$path = \Automattic\WooCommerce\Blocks\Package::get_path(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
} else {
|
||||
$version = null;
|
||||
}
|
||||
|
||||
if ( ! is_null( $version ) ) {
|
||||
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> ' . esc_html( $version ) . ' <code class="private">' . esc_html( $path ) . '</code></mark> ';
|
||||
} else {
|
||||
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Unable to detect the Blocks package.', 'woocommerce' ) . '</mark>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-export-label="Action Scheduler Version"><?php esc_html_e( 'Action Scheduler package', 'woocommerce' ); ?>:</td>
|
||||
<td class="help"><?php echo wc_help_tip( esc_html__( 'Action Scheduler package running on your site.', 'woocommerce' ) ); ?></td>
|
||||
@@ -594,7 +579,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Cons
|
||||
<table class="wc_status_table widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3" data-export-label="Active Plugins (<?php echo count( $active_plugins ); ?>)"><h2><?php esc_html_e( 'Active plugins', 'woocommerce' ); ?> (<?php echo count( $active_plugins ); ?>)</h2></th>
|
||||
<th colspan="3" data-export-label="Active Plugins (<?php echo esc_attr( $active_plugins_count ); ?>)"><h2><?php esc_html_e( 'Active plugins', 'woocommerce' ); ?> (<?php echo esc_attr( $active_plugins_count ); ?>)</h2></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -604,7 +589,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Cons
|
||||
<table class="wc_status_table widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3" data-export-label="Inactive Plugins (<?php echo count( $inactive_plugins ); ?>)"><h2><?php esc_html_e( 'Inactive plugins', 'woocommerce' ); ?> (<?php echo count( $inactive_plugins ); ?>)</h2></th>
|
||||
<th colspan="3" data-export-label="Inactive Plugins (<?php echo esc_attr( $inactive_plugins_count ); ?>)"><h2><?php esc_html_e( 'Inactive plugins', 'woocommerce' ); ?> (<?php echo esc_attr( $inactive_plugins_count ); ?>)</h2></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -612,12 +597,13 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Cons
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
if ( 0 < count( $dropins_mu_plugins['dropins'] ) ) :
|
||||
$dropins_count = is_countable( $dropins_mu_plugins['dropins'] ) ? count( $dropins_mu_plugins['dropins'] ) : 0;
|
||||
if ( 0 < $dropins_count ) :
|
||||
?>
|
||||
<table class="wc_status_table widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3" data-export-label="Dropin Plugins (<?php echo count( $dropins_mu_plugins['dropins'] ); ?>)"><h2><?php esc_html_e( 'Dropin Plugins', 'woocommerce' ); ?> (<?php echo count( $dropins_mu_plugins['dropins'] ); ?>)</h2></th>
|
||||
<th colspan="3" data-export-label="Dropin Plugins (<?php $dropins_count; ?>)"><h2><?php esc_html_e( 'Dropin Plugins', 'woocommerce' ); ?> (<?php $dropins_count; ?>)</h2></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -636,12 +622,14 @@ if ( 0 < count( $dropins_mu_plugins['dropins'] ) ) :
|
||||
</table>
|
||||
<?php
|
||||
endif;
|
||||
if ( 0 < count( $dropins_mu_plugins['mu_plugins'] ) ) :
|
||||
|
||||
$mu_plugins_count = is_countable( $dropins_mu_plugins['mu_plugins'] ) ? count( $dropins_mu_plugins['mu_plugins'] ) : 0;
|
||||
if ( 0 < $mu_plugins_count ) :
|
||||
?>
|
||||
<table class="wc_status_table widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3" data-export-label="Must Use Plugins (<?php echo count( $dropins_mu_plugins['mu_plugins'] ); ?>)"><h2><?php esc_html_e( 'Must Use Plugins', 'woocommerce' ); ?> (<?php echo count( $dropins_mu_plugins['mu_plugins'] ); ?>)</h2></th>
|
||||
<th colspan="3" data-export-label="Must Use Plugins (<?php echo esc_attr( $mu_plugins_count ); ?>)"><h2><?php esc_html_e( 'Must Use Plugins', 'woocommerce' ); ?> (<?php echo esc_attr( $mu_plugins_count ); ?>)</h2></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -770,6 +758,55 @@ if ( 0 < count( $dropins_mu_plugins['mu_plugins'] ) ) :
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wc_status_table widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3" data-export-label="Logging"><h2><?php esc_html_e( 'Logging', 'woocommerce' ); ?></h2></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td data-export-label="Enabled"><?php esc_html_e( 'Enabled', 'woocommerce' ); ?></td>
|
||||
<td class="help"><?php echo wc_help_tip( esc_html__( 'Is logging enabled?', 'woocommerce' ) ); ?></td>
|
||||
<td><?php echo $logging['logging_enabled'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<mark class="no">–</mark>'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-export-label="Handler"><?php esc_html_e( 'Handler', 'woocommerce' ); ?></td>
|
||||
<td class="help"><?php echo wc_help_tip( esc_html__( 'How log entries are being stored.', 'woocommerce' ) ); ?></td>
|
||||
<td><?php echo esc_html( $logging['default_handler'] ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-export-label="Retention period"><?php esc_html_e( 'Retention period', 'woocommerce' ); ?></td>
|
||||
<td class="help"><?php echo wc_help_tip( esc_html__( 'How many days log entries will be kept before being auto-deleted.', 'woocommerce' ) ); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
printf(
|
||||
esc_html(
|
||||
// translators: %s is a number of days.
|
||||
_n(
|
||||
'%s day',
|
||||
'%s days',
|
||||
$logging['retention_period_days'],
|
||||
'woocommerce'
|
||||
)
|
||||
),
|
||||
esc_html( number_format_i18n( $logging['retention_period_days'] ) )
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-export-label="Level threshold"><?php esc_html_e( 'Level threshold', 'woocommerce' ); ?></td>
|
||||
<td class="help"><?php echo wc_help_tip( esc_html__( 'The minimum severity level of logs that will be stored.', 'woocommerce' ) ); ?></td>
|
||||
<td><?php echo $logging['level_threshold'] ? esc_html( $logging['level_threshold'] ) : '<mark class="no">–</mark>'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-export-label="Log directory size"><?php esc_html_e( 'Log directory size', 'woocommerce' ); ?></td>
|
||||
<td class="help"><?php echo wc_help_tip( esc_html__( 'The total size of the files in the log directory.', 'woocommerce' ) ); ?></td>
|
||||
<td><?php echo esc_html( $logging['log_directory_size'] ); ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wc_status_table widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -929,7 +966,7 @@ if ( 0 < count( $dropins_mu_plugins['mu_plugins'] ) ) :
|
||||
<td class="help"> </td>
|
||||
<td>
|
||||
<?php
|
||||
$total_overrides = count( $theme['overrides'] );
|
||||
$total_overrides = is_countable( $theme['overrides'] ) ? count( $theme['overrides'] ) : 0;
|
||||
for ( $i = 0; $i < $total_overrides; $i++ ) {
|
||||
$override = $theme['overrides'][ $i ];
|
||||
if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) {
|
||||
@@ -944,7 +981,8 @@ if ( 0 < count( $dropins_mu_plugins['mu_plugins'] ) ) :
|
||||
} else {
|
||||
echo esc_html( $override['file'] );
|
||||
}
|
||||
if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) {
|
||||
|
||||
if ( ( $total_overrides - 1 ) !== $i ) {
|
||||
echo ', ';
|
||||
}
|
||||
echo '<br />';
|
||||
|
||||
@@ -45,6 +45,10 @@ foreach ( $tools as $action_name => $tool ) {
|
||||
</p>
|
||||
</th>
|
||||
<td class="run-tool">
|
||||
<?php if ( ! empty( $tool['status_text'] ) ) : ?>
|
||||
<span class="run-tool-status"><?php echo wp_kses_post( $tool['status_text'] ); ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<input <?php echo ArrayUtil::is_truthy( $tool, 'disabled' ) ? 'disabled' : ''; ?> type="submit" form="<?php echo 'form_' . $action_name; ?>" class="button button-large" value="<?php echo esc_attr( $tool['button'] ); ?>" />
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user