plugin updates

This commit is contained in:
Tony Volpe
2024-07-16 13:57:46 +00:00
parent 41f50eacc4
commit 8f93917880
1529 changed files with 259452 additions and 25451 deletions

View File

@@ -231,7 +231,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'gateway_toggle' => current_user_can( 'manage_woocommerce' ) ? wp_create_nonce( 'woocommerce-toggle-payment-gateway-enabled' ) : null,
),
'urls' => array(
'add_product' => Features::is_enabled( 'new-product-management-experience' ) || \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ? esc_url_raw( admin_url( 'admin.php?page=wc-admin&path=/add-product' ) ) : null,
'add_product' => \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ? esc_url_raw( admin_url( 'admin.php?page=wc-admin&path=/add-product' ) ) : null,
'import_products' => current_user_can( 'import' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ) : null,
'export_products' => current_user_can( 'export' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ) : null,
),

View File

@@ -485,7 +485,7 @@ class WC_Admin_Menus {
* Maybe add new management product experience.
*/
public function maybe_add_new_product_management_experience() {
if ( Features::is_enabled( 'new-product-management-experience' ) || FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ) {
if ( FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ) {
global $submenu;
if ( isset( $submenu['edit.php?post_type=product'][10] ) ) {
// Disable phpcs since we need to override submenu classes.

View File

@@ -33,7 +33,7 @@ class WC_Helper {
* @return string The absolute path to the view file.
*/
public static function get_view_filename( $view ) {
return dirname( __FILE__ ) . "/views/$view";
return __DIR__ . "/views/$view";
}
/**
@@ -119,7 +119,7 @@ class WC_Helper {
$subscriptions_list_data = self::get_subscription_list_data();
$subscriptions = array_filter(
$subscriptions_list_data,
function( $subscription ) {
function ( $subscription ) {
return ! empty( $subscription['product_key'] );
}
);
@@ -362,9 +362,9 @@ class WC_Helper {
*/
public static function add_utm_params_to_url_for_subscription_link( $url, $utm_content ) {
$utm_params = 'utm_source=subscriptionsscreen&' .
'utm_medium=product&' .
'utm_campaign=wcaddons&' .
'utm_content=' . $utm_content;
'utm_medium=product&' .
'utm_campaign=wcaddons&' .
'utm_content=' . $utm_content;
// there are already some URL parameters
if ( strpos( $url, '?' ) ) {
@@ -879,7 +879,8 @@ class WC_Helper {
$request = WC_Helper_API::post(
'oauth/access_token',
array(
'body' => array(
'timeout' => 30,
'body' => array(
'request_token' => wp_unslash( $_GET['request_token'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
'home_url' => home_url(),
),
@@ -1554,28 +1555,36 @@ class WC_Helper {
}
/**
* Get the connected user's subscription list data.
* This is used by the My Subscriptions page.
* Get the connected user's subscription list data. Here, we merge connected
* subscriptions with locally installed Woo plugins and themes. We also
* add in information about available updates.
*
* Used by the My Subscriptions page.
*
* @return array
*/
public static function get_subscription_list_data() {
// First, connected subscriptions.
$subscriptions = self::get_subscriptions();
// Installed plugins and themes, with or without an active subscription.
// Then, installed plugins and themes, with or without an active subscription.
$woo_plugins = self::get_local_woo_plugins();
$woo_themes = self::get_local_woo_themes();
// Get the product IDs of the subscriptions.
$subscriptions_product_ids = wp_list_pluck( $subscriptions, 'product_id' );
// Get the site ID.
$auth = WC_Helper_Options::get( 'auth' );
$site_id = isset( $auth['site_id'] ) ? absint( $auth['site_id'] ) : 0;
// Installed products without a subscription.
// Now, merge installed products without a subscription.
foreach ( array_merge( $woo_plugins, $woo_themes ) as $filename => $data ) {
if ( in_array( $data['_product_id'], $subscriptions_product_ids, true ) ) {
continue;
}
// We add these as subscriptions to the previous connected subscriptions list.
$subscriptions[] = array(
'product_key' => '',
'product_id' => $data['_product_id'],
@@ -1587,6 +1596,7 @@ class WC_Helper {
'key_type_label' => '',
'lifetime' => false,
'product_status' => 'publish',
// Connections is empty because this is not a connected subscription.
'connections' => array(),
'expires' => 0,
'expired' => true,
@@ -1598,11 +1608,13 @@ class WC_Helper {
);
}
// Fetch updates so we can refine subscriptions with information about updates.
$updates = WC_Helper_Updater::get_update_data();
// Add local data to merged subscriptions list (both locally installed and purchased).
foreach ( $subscriptions as &$subscription ) {
$subscription['active'] = in_array( $site_id, $subscription['connections'], true );
$updates = WC_Helper_Updater::get_update_data();
$subscription['local'] = self::get_subscription_local_data( $subscription );
$subscription['has_update'] = false;
@@ -1613,12 +1625,17 @@ class WC_Helper {
if ( ! empty( $updates[ $subscription['product_id'] ] ) ) {
$subscription['version'] = $updates[ $subscription['product_id'] ]['version'];
}
// If the update endpoint returns a URL, we prefer it over the default PluginURI.
if ( ! empty( $updates[ $subscription['product_id'] ]['url'] ) ) {
$subscription['product_url'] = $updates[ $subscription['product_id'] ]['url'];
}
}
// Sort subscriptions by name and expiration date.
usort(
$subscriptions,
function( $a, $b ) {
function ( $a, $b ) {
$compare_value = strcasecmp( $a['product_name'], $b['product_name'] );
if ( 0 === $compare_value ) {
return strcasecmp( $a['expires'], $b['expires'] );
@@ -1823,7 +1840,7 @@ class WC_Helper {
}
// No more sites available in this subscription.
if ( $_sub['sites_max'] && $_sub['sites_active'] >= $_sub['sites_max'] ) {
if ( isset( $_sub['maxed'] ) && $_sub['maxed'] ) {
continue;
}
@@ -1938,7 +1955,7 @@ class WC_Helper {
);
if ( wp_remote_retrieve_response_code( $deactivation_response ) === 200 ) {
$deactivated++;
++$deactivated;
/**
* Fires when the Helper activates a product successfully.
@@ -2011,7 +2028,7 @@ class WC_Helper {
$product_id = $data['_product_id'];
if ( version_compare( $updates[ $product_id ]['version'], $data['Version'], '>' ) ) {
$available++;
++$available;
}
}
@@ -2065,6 +2082,7 @@ class WC_Helper {
'oauth/me',
array(
'authenticated' => true,
'timeout' => 30,
)
);
@@ -2261,6 +2279,42 @@ class WC_Helper {
return $woo_com_base_url . 'auto-install-init/';
}
/**
* Retrieve notice for connected store.
*
* @return array An array containing notice data.
*/
public static function get_notices() {
$cache_key = '_woocommerce_helper_notices';
$cached_data = get_transient( $cache_key );
if ( false !== $cached_data ) {
return $cached_data;
}
// Fetch notice data for connected store.
$request = WC_Helper_API::get(
'notices',
array(
'authenticated' => true,
)
);
if ( 200 !== wp_remote_retrieve_response_code( $request ) ) {
set_transient( $cache_key, array(), 15 * MINUTE_IN_SECONDS );
return array();
}
$data = json_decode( wp_remote_retrieve_body( $request ), true );
if ( empty( $data ) || ! is_array( $data ) ) {
$data = array();
}
set_transient( $cache_key, $data, 1 * HOUR_IN_SECONDS );
return $data;
}
}
WC_Helper::load();

View File

@@ -562,7 +562,7 @@ class WC_Meta_Box_Order_Data {
}
if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' === get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $order->get_customer_note() ) { // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
echo '<p class="order_note"><strong>' . esc_html( __( 'Customer provided note:', 'woocommerce' ) ) . '</strong> ' . nl2br( esc_html( $order->get_customer_note() ) ) . '</p>';
echo '<p class="order_note"><strong>' . esc_html( __( 'Customer provided note:', 'woocommerce' ) ) . '</strong> ' . wp_kses( nl2br( esc_html( $order->get_customer_note() ) ), array() ) . '</p>';
}
?>
</div>
@@ -615,7 +615,7 @@ class WC_Meta_Box_Order_Data {
?>
<p class="form-field form-field-wide">
<label for="customer_note"><?php esc_html_e( 'Customer provided note', 'woocommerce' ); ?>:</label>
<textarea rows="1" cols="40" name="customer_note" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e( 'Customer notes about the order', 'woocommerce' ); ?>"><?php echo wp_kses_post( $order->get_customer_note() ); ?></textarea>
<textarea rows="1" cols="40" name="customer_note" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e( 'Customer notes about the order', 'woocommerce' ); ?>"><?php echo wp_kses( $order->get_customer_note(), array() ); ?></textarea>
</p>
<?php endif; ?>
</div>

View File

@@ -197,7 +197,7 @@ class WC_Meta_Box_Product_Data {
if ( ! empty( $file_urls ) ) {
$file_url_size = count( $file_urls );
for ( $i = 0; $i < $file_url_size; $i ++ ) {
for ( $i = 0; $i < $file_url_size; $i++ ) {
if ( ! empty( $file_urls[ $i ] ) ) {
$downloads[] = array(
'name' => wc_clean( $file_names[ $i ] ),
@@ -414,6 +414,9 @@ class WC_Meta_Box_Product_Data {
WC_Admin_Meta_Boxes::add_error( $errors->get_error_message() );
}
// Remove _product_template_id for products that were created with the new product editor.
$product->delete_meta_data( '_product_template_id' );
/**
* Set props before save.
*

View File

@@ -71,10 +71,10 @@ if ( ! defined( 'ABSPATH' ) ) {
echo '<input type="hidden" name="_original_stock" value="' . esc_attr( wc_stock_amount( $product_object->get_stock_quantity( 'edit' ) ) ) . '" />';
$backorder_args = array(
'id' => '_backorders',
'value' => $product_object->get_backorders( 'edit' ),
'label' => __( 'Allow backorders?', 'woocommerce' ),
'options' => wc_get_product_backorder_options(),
'id' => '_backorders',
'value' => $product_object->get_backorders( 'edit' ),
'label' => __( 'Allow backorders?', 'woocommerce' ),
'options' => wc_get_product_backorder_options(),
);
/**

View File

@@ -188,19 +188,27 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
echo wp_kses_post( $gateway->get_method_description() );
break;
case 'action':
if ( wc_string_to_bool( $gateway->enabled ) ) {
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Manage the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Manage', 'woocommerce' ) . '</a>';
} else {
if (
// Keep old brand name for backwards compatibility.
( 'WooCommerce Payments' === $method_title || 'WooPayments' === $method_title ) &&
class_exists( 'WC_Payments_Account' )
) {
$setup_url = WC_Payments_Account::get_connect_url();
$setup_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) );
// Override the behaviour for WooPayments plugin.
if (
// Keep old brand name for backwards compatibility.
( 'WooCommerce Payments' === $method_title || 'WooPayments' === $method_title ) &&
class_exists( 'WC_Payments_Account' )
) {
if ( ! WooCommercePayments::is_connected() || WooCommercePayments::is_account_partially_onboarded() ) {
// The CTA text and label is "Finish set up" if the account is not connected or not completely onboarded.
$setup_url = WC_Payments_Account::get_connect_url(); // Plugin will handle the redirection to the connect page or directly to the provider (e.g. Stripe).
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Set up the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( $setup_url ) . '">' . esc_html__( 'Finish set up', 'woocommerce' ) . '</a>';
} else {
$setup_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) );
// If the account is fully onboarded, the CTA text and label is "Manage" regardless gateway is enabled or not.
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Manage the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( $setup_url ) . '">' . esc_html__( 'Manage', 'woocommerce' ) . '</a>';
}
} elseif ( wc_string_to_bool( $gateway->enabled ) ) {
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Manage the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( $setup_url ) . '">' . esc_html__( 'Manage', 'woocommerce' ) . '</a>';
} else {
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Set up the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( $setup_url ) . '">' . esc_html__( 'Finish set up', 'woocommerce' ) . '</a>';
}

View File

@@ -11,6 +11,13 @@ defined( 'ABSPATH' ) || exit;
<div id="key-fields" class="settings-panel">
<h2><?php esc_html_e( 'Key details', 'woocommerce' ); ?></h2>
<div class="inline notice">
<ul class="advice">
<li><?php esc_html_e( 'API keys open up access to potentially sensitive information. Only share them with organizations you trust.', 'woocommerce' ); ?></li>
<li><?php esc_html_e( 'Stick to one key per client: this makes it easier to revoke access in the future for a single client, without causing disruption for others.', 'woocommerce' ); ?></li>
</ul>
</div>
<input type="hidden" id="key_id" value="<?php echo esc_attr( $key_id ); ?>" />
<table id="api-keys-options" class="form-table">
@@ -24,6 +31,9 @@ defined( 'ABSPATH' ) || exit;
</th>
<td class="forminp">
<input maxlength="200" id="key_description" type="text" class="input-text regular-input" value="<?php echo esc_attr( $key_data['description'] ); ?>" />
<p class="description">
<?php esc_html_e( 'Add a meaningful description, including a note of the person, company or app you are sharing the key with.', 'woocommerce' ); ?>
</p>
</td>
</tr>
<tr valign="top">
@@ -72,6 +82,9 @@ defined( 'ABSPATH' ) || exit;
<option value="<?php echo esc_attr( $permission_id ); ?>" <?php selected( $key_data['permissions'], $permission_id, true ); ?>><?php echo esc_html( $permission_name ); ?></option>
<?php endforeach; ?>
</select>
<p class="conditional description" data-depends-on="#key_permissions" data-show-if-equals="write">
<?php esc_html_e( 'Write-only keys do not prevent clients from seeing information about the entities they are updating.', 'woocommerce' ); ?>
</p>
</td>
</tr>

View File

@@ -6,6 +6,7 @@
*/
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils;
use Automattic\WooCommerce\Utilities\RestApiUtil;
defined( 'ABSPATH' ) || exit;
@@ -873,10 +874,38 @@ if ( 0 < $mu_plugins_count ) :
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . ( $_page['block_required'] ? sprintf( esc_html__( 'Page does not contain the %1$s shortcode or the %2$s block.', 'woocommerce' ), esc_html( $_page['shortcode'] ), esc_html( $_page['block'] ) ) : sprintf( esc_html__( 'Page does not contain the %s shortcode.', 'woocommerce' ), esc_html( $_page['shortcode'] ) ) ) . '</mark>'; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */
$found_error = true;
}
// Warn merchants if both the shortcode and block are present, which will be a confusing shopper experience.
if ( $_page['shortcode_present'] && $_page['block_present'] ) {
/* Translators: %1$s: shortcode text, %2$s: block slug. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Page contains both the %1$s shortcode and the %2$s block.', 'woocommerce' ), esc_html( $_page['shortcode'] ), esc_html( $_page['block'] ) ) . '</mark>'; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */
$found_error = true;
}
}
if ( ! $found_error ) {
echo '<mark class="yes">#' . absint( $_page['page_id'] ) . ' - ' . esc_html( str_replace( home_url(), '', get_permalink( $_page['page_id'] ) ) ) . '</mark>';
$additional_info = '';
// We only state the used type on the Checkout and the Cart page.
if ( in_array( $_page['block'], array( 'woocommerce/checkout', 'woocommerce/cart' ), true ) ) {
// We check first if, in a blocks theme, the template content does not load the page content.
if ( CartCheckoutUtils::is_overriden_by_custom_template_content( $_page['block'] ) ) {
$additional_info = __( "This page's content is overridden by custom template content", 'woocommerce' );
} elseif ( $_page['shortcode_present'] ) {
/* Translators: %1$s: shortcode text. */
$additional_info = sprintf( __( 'Contains the <strong>%1$s</strong> shortcode', 'woocommerce' ), esc_html( $_page['shortcode'] ) );
} elseif ( $_page['block_present'] ) {
/* Translators: %1$s: block slug. */
$additional_info = sprintf( __( 'Contains the <strong>%1$s</strong> block', 'woocommerce' ), esc_html( $_page['block'] ) );
}
if ( ! empty( $additional_info ) ) {
$additional_info = '<mark class="no"> - <span class="dashicons dashicons-info"></span> ' . $additional_info . '</mark>';
}
}
echo '<mark class="yes">#' . absint( $_page['page_id'] ) . ' - ' . esc_html( str_replace( home_url(), '', get_permalink( $_page['page_id'] ) ) ) . '</mark>' . $additional_info; /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */
}
echo '</td></tr>';
@@ -969,7 +998,7 @@ if ( 0 < $mu_plugins_count ) :
</tr>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<table class="wc_status_table widefat" id="status-table-templates" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Templates"><h2><?php esc_html_e( 'Templates', 'woocommerce' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows any files that are overriding the default WooCommerce template pages.', 'woocommerce' ) ); ?></h2></th>

View File

@@ -24,6 +24,6 @@ $theme = wp_get_theme();
</p>
<p class="submit">
<a class="button-primary" href="https://woocommerce.com/document/template-structure/" target="_blank"><?php esc_html_e( 'Learn more about templates', 'woocommerce' ); ?></a>
<a class="button-primary" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-status' ) ); ?>" target="_blank"><?php esc_html_e( 'View affected templates', 'woocommerce' ); ?></a>
<a class="button-primary" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-status#status-table-templates' ) ); ?>" target="_blank"><?php esc_html_e( 'View affected templates', 'woocommerce' ); ?></a>
</p>
</div>