Only show the product image upload tip once, and on all product edit pages (#34739)
* Only show the product image upload tip once, and on all product edit pages. * Use max upload size in message.
This commit is contained in:
parent
e3a9ddee6d
commit
9d96419520
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Only show the product image upload tip once, and on all product edit pages.
|
|
@ -14,13 +14,6 @@ defined( 'ABSPATH' ) || exit;
|
|||
*/
|
||||
class WC_Product_Simple extends WC_Product {
|
||||
|
||||
/**
|
||||
* Track wehther post_upload_ui hook was run.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public static $post_upload_hook_done = false;
|
||||
|
||||
/**
|
||||
* Initialize simple product.
|
||||
*
|
||||
|
@ -29,23 +22,6 @@ class WC_Product_Simple extends WC_Product {
|
|||
public function __construct( $product = 0 ) {
|
||||
$this->supports[] = 'ajax_add_to_cart';
|
||||
parent::__construct( $product );
|
||||
add_filter('admin_post_thumbnail_html', array( $this, 'add_product_photo_suggestions' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding product photo suggestions in upload modal.
|
||||
*/
|
||||
public function add_product_photo_suggestions ( $content ) {
|
||||
|
||||
$suggestion = '<div class="image-added-detail">';
|
||||
$suggestion .= '<p>';
|
||||
$suggestion .= '<span class="dashicons-info-outline dashicons"></span>';
|
||||
$suggestion .= esc_html__( 'Upload JPEG files that are 1000 x 1000 pixels or larger (max. 2 GB).', 'woocommerce' );
|
||||
$suggestion .= ' <a href="https://woocommerce.com/posts/fast-high-quality-product-photos/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'How to prepare images?', 'woocommerce' ) . '<span class="dashicons-external dashicons"></span></a>';
|
||||
$suggestion .= '</p>';
|
||||
$suggestion .= '</div>';
|
||||
|
||||
return $content . $suggestion;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -281,6 +281,37 @@ function wc_product_post_type_link( $permalink, $post ) {
|
|||
}
|
||||
add_filter( 'post_type_link', 'wc_product_post_type_link', 10, 2 );
|
||||
|
||||
/**
|
||||
* Filter to add upload tips under the product image thumbnail.
|
||||
*
|
||||
* @param string $content The HTML markup for the admin post thumbnail.
|
||||
* @return string
|
||||
*/
|
||||
function wc_product_post_thumbnail_html( $content ) {
|
||||
$suggestion = '<div class="image-added-detail">';
|
||||
$suggestion .= '<p>';
|
||||
$suggestion .= '<span class="dashicons-info-outline dashicons"></span>';
|
||||
/* translators: 1: formatted file size */
|
||||
$suggestion .= esc_html( sprintf( __( 'Upload JPEG files that are 1000 x 1000 pixels or larger (max. %1$s).', 'woocommerce' ), size_format( wp_max_upload_size() ) ) );
|
||||
$suggestion .= ' <a href="https://woocommerce.com/posts/fast-high-quality-product-photos/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'How to prepare images?', 'woocommerce' ) . '<span class="dashicons-external dashicons"></span></a>';
|
||||
$suggestion .= '</p>';
|
||||
$suggestion .= '</div>';
|
||||
|
||||
return $content . $suggestion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to add the filter to add upload tips under the product image thumbnail.
|
||||
*
|
||||
* @param WP_Screen $current_screen Current WP_Screen object.
|
||||
*/
|
||||
function wc_add_product_post_thumbnail_html_filter( $current_screen ) {
|
||||
if ( 'product' === $current_screen->post_type && 'post' === $current_screen->base ) {
|
||||
add_filter( 'admin_post_thumbnail_html', 'wc_product_post_thumbnail_html' );
|
||||
}
|
||||
}
|
||||
add_action( 'current_screen', 'wc_add_product_post_thumbnail_html_filter' );
|
||||
|
||||
/**
|
||||
* Get the placeholder image URL either from media, or use the fallback image.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue