Conditionally add messages in customiser
This commit is contained in:
parent
7ae0f6c274
commit
d841cf3f27
|
@ -183,7 +183,7 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
|
|||
);
|
||||
|
||||
// Jetpack does the image resizing heavy lifting so you don't have to.
|
||||
if ( ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) || ! apply_filters( 'woocommerce_background_image_regeneration', ! is_multisite() ) ) {
|
||||
if ( ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) || ! apply_filters( 'woocommerce_background_image_regeneration', true ) ) {
|
||||
unset( $tools['regenerate_thumbnails'] );
|
||||
}
|
||||
|
||||
|
|
|
@ -47,18 +47,21 @@ class WC_Regenerate_Images {
|
|||
return;
|
||||
}
|
||||
|
||||
// Regenerate thumbnails in the background after settings change. Not ran on multisite to avoid multiple simultanious jobs, and not required when Jetpack Photon is in use.
|
||||
if ( apply_filters( 'woocommerce_background_image_regeneration', ! is_multisite() ) ) {
|
||||
if ( apply_filters( 'woocommerce_background_image_regeneration', true ) ) {
|
||||
include_once WC_ABSPATH . 'includes/class-wc-regenerate-images-request.php';
|
||||
|
||||
self::$background_process = new WC_Regenerate_Images_Request();
|
||||
|
||||
add_action( 'admin_init', array( __CLASS__, 'regenerating_notice' ) );
|
||||
add_action( 'woocommerce_hide_regenerating_thumbnails_notice', array( __CLASS__, 'dismiss_regenerating_notice' ) );
|
||||
|
||||
// Regenerate thumbnails in the background after settings changes. Not ran on multisite to avoid multiple simultanious jobs.
|
||||
if ( ! is_multisite() ) {
|
||||
add_action( 'customize_save_after', array( __CLASS__, 'maybe_regenerate_images' ) );
|
||||
add_action( 'after_switch_theme', array( __CLASS__, 'maybe_regenerate_images' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If an intermediate size meta differs from the actual image size (settings were changed?) return false so the wrong size is not used.
|
||||
|
|
|
@ -443,10 +443,21 @@ class WC_Shop_Customizer {
|
|||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||
*/
|
||||
private function add_product_images_section( $wp_customize ) {
|
||||
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
|
||||
$regen_description = ''; // Nothing to report; Jetpack will handle magically.
|
||||
} elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && ! is_multisite() ) {
|
||||
$regen_description = __( 'After publishing your changes, new image sizes will be generated automatically.', 'woocommerce' );
|
||||
} elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && is_multisite() ) {
|
||||
$regen_description = sprintf( __( 'After publishing your changes, new image sizes may not be shown until you regenerate thumbnails. You can do this from the <a href="%1$s" target="_blank">tools section in WooCommerce</a> or by using a plugin such as <a href="%2$s" target="_blank">Regenerate Thumbnails</a>.', 'woocommerce' ), admin_url( 'admin.php?page=wc-status&tab=tools' ), 'https://en-gb.wordpress.org/plugins/regenerate-thumbnails/' );
|
||||
} else {
|
||||
$regen_description = sprintf( __( 'After publishing your changes, new image sizes may not be shown until you <a href="%2$s" target="_blank">Regenerate Thumbnails</a>.', 'woocommerce' ), 'https://en-gb.wordpress.org/plugins/regenerate-thumbnails/' );
|
||||
}
|
||||
|
||||
$wp_customize->add_section(
|
||||
'woocommerce_product_images',
|
||||
array(
|
||||
'title' => __( 'Product Images', 'woocommerce' ),
|
||||
'description' => $regen_description,
|
||||
'priority' => 20,
|
||||
'panel' => 'woocommerce',
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue