This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
/**
* Notification for auto Bulk Smush on scan completed while re-checking images.
*
* @var bool $background_processing_enabled Background optimization is enabled.
*
*/
?>
<div class="sui-notice sui-notice-grey wp-smush-auto-bulk-smush-notification sui-hidden">
<div class="sui-notice-content">
<div class="sui-notice-message">
<span class="sui-notice-icon sui-icon-info sui-md" aria-hidden="true"></span>
<p>
<?php
if( $background_processing_enabled ) {
esc_html_e( 'Upon completion of the image recheck process, Smush will automatically proceed to initiate bulk image compression.', 'wp-smushit' );
} else {
esc_html_e( 'Once Smush completes the recheck process it will begin the Smush, it is recommended to keep this page open to initiate bulk image compression.', 'wp-smushit' );
}
?>
</p>
</div>
</div>
</div>

View File

@ -0,0 +1,23 @@
<?php
/**
* We also show up it via js after clicking on Bulk Smush Now.
*
* @see bulk-smush.js - background-process.js
*
* @var bool $background_in_processing Whether background is in processing or not.
* @var string $bulk_upgrade_url CDN upgrade url.
*/
?>
<div class="sui-box-body sui-margin-top wp-smush-upsell-cdn <?php echo ! $background_in_processing ? ' sui-hidden' : ''; ?>">
<div class="smush-box-image">
<img class="sui-image-icon" src="<?php echo esc_url( WP_SMUSH_URL . 'app/assets/images/bulk-smush/cdn-upsell-icon.png' ); ?>"
srcset="<?php echo esc_url( WP_SMUSH_URL . 'app/assets/images/bulk-smush/cdn-upsell-icon@2x.png' ); ?> 2x"
alt="<?php esc_html_e( 'Smush CDN Icon', 'wp-smushit' ); ?>">
</div>
<div class="sui-box-content">
<p>
<?php esc_html_e( 'Want to serve images even faster? Get up to 2x more speed with Smush Pros CDN, which spans 45 servers worldwide.', 'wp-smushit' ); ?>
</p>
<a href="<?php echo esc_url( $bulk_upgrade_url ); ?>" class="smush-upsell-link" target="_blank"><?php esc_html_e( 'Unlock now with Pro.', 'wp-smushit' ); ?></a>
</div>
</div>

View File

@ -0,0 +1,20 @@
<?php
/**
* Show Unlimited upsell on Bulk Smush completed.
* @var string $bulk_upgrade_url Upgrade pro url.
* @var string $global_upsell_desc Upgrade pro notice description.
*/
?>
<div class="sui-box-body sui-margin-top wp-smush-global-upsell wp-smush-upsell-on-completed sui-hidden">
<div class="smush-box-image">
<img class="sui-image-icon" src="<?php echo esc_url( WP_SMUSH_URL . 'app/assets/images/bulk-smush/global-upsell-icon.png' ); ?>"
srcset="<?php echo esc_url( WP_SMUSH_URL . 'app/assets/images/bulk-smush/global-upsell-icon@2x.png' ); ?> 2x"
alt="<?php esc_html_e( 'Smush Upsell Icon', 'wp-smushit' ); ?>">
</div>
<div class="sui-box-content">
<p>
<?php echo esc_html( $global_upsell_desc ); ?>
</p>
<a href="<?php echo esc_url( $bulk_upgrade_url ); ?>" class="smush-upsell-link" target="_blank"><?php echo esc_html__( 'Upgrade to Pro and get 60% off', 'wp-smushit' ); ?></a>
</div>
</div>

View File

@ -0,0 +1,35 @@
<?php
/**
* Limit reached notice metabox on bulk smush page.
*
* @var bool $with_resume_button With resume button or not.
*/
?>
<div id="smush-limit-reached-notice" class="sui-notice sui-notice-warning sui-hidden smush-limit-reached-notice">
<div class="sui-notice-content">
<div class="sui-notice-message">
<i class="sui-notice-icon sui-icon-info sui-md" aria-hidden="true"></i>
<p>
<?php
$is_directory_smush = 'smush-directory' === $this->get_slug();
$upgrade_url = $this->get_utm_link(
array(
'utm_campaign' => $is_directory_smush ? 'smush_directory_smush_paused_50_limit' : 'smush_bulk_smush_paused_50_limit',
)
);
$bg_optimization = WP_Smush::get_instance()->core()->mod->bg_optimization;
$discount_text = '<strong>' . esc_html__( 'Get 60% off when you upgrade today.', 'wp-smushit' ) . '</strong>';
printf(
/* translators: %s1$d - bulk smush limit, %2$s - upgrade link, %3$s - <strong>, %4$s - </strong>, %5$s - Bulk Smush limit */
esc_html__( 'The free version of Smush only allows you to compress %1$d images at a time. %2$s to compress %3$sunlimited images at once%4$s or click Resume to compress another %1$d images. %5$s', 'wp-smushit' ),
Smush\Core\Core::MAX_FREE_BULK,
'<a class="smush-upsell-link" href="' . esc_url( $upgrade_url ) . '" target="_blank"><strong>'. esc_html__('Upgrade to Smush Pro', 'wp-smushit') .'</strong></a>',
'<strong>',
'</strong>',
$discount_text
)
?>
</p>
</div>
</div>
</div>

View File

@ -0,0 +1,12 @@
<div class="smush-final-log sui-hidden">
<div class="smush-bulk-errors"></div>
<div class="smush-bulk-errors-actions sui-hidden">
<a href="<?php echo esc_url( apply_filters( 'smush_unsmushed_media_filter_url', admin_url( 'upload.php?mode=list&attachment-filter=post_mime_type:image&smush-filter=failed_processing' ) ) ); ?>" class="sui-button">
<i class="sui-icon-eye" aria-hidden="true"></i>
<?php esc_html_e( 'View all in library', 'wp-smushit' ); ?>
</a>
<span class="sui-button sui-button-ghost wp_smush_ignore_all_failed_items">
<?php esc_html_e( 'Ignore all', 'wp-smushit' ); ?>
</span>
</div>
</div>

View File

@ -0,0 +1,173 @@
<?php
/**
* Compression Level.
*
* @var $name string Compression field name.
* @var $value mixed Current compression value.
*/
use Smush\Core\Settings;
$settings = Settings::get_instance();
$lossy_level_setting = $settings->get_lossy_level_setting();
$level_basic = Settings::LEVEL_LOSSLESS;
$level_super = Settings::LEVEL_SUPER_LOSSY;
$level_ultra = Settings::LEVEL_ULTRA_LOSSY;
$level_labels = array(
Settings::LEVEL_LOSSLESS => __( 'Basic', 'wp-smushit' ),
Settings::LEVEL_SUPER_LOSSY => __( 'Super', 'wp-smushit' ),
Settings::LEVEL_ULTRA_LOSSY => __( 'Ultra', 'wp-smushit' ),
);
$level_notices = array(
Settings::LEVEL_LOSSLESS => sprintf(
/* translators: 1: opening <strong>, 2: closing </strong> */
__( '%1$sBasic:%2$s Achieve flawless, lossless compression for pixel-perfect images. Minimal file size reduction, negligible impact on speed.', 'wp-smushit' ),
'<strong>',
'</strong>'
),
Settings::LEVEL_SUPER_LOSSY => sprintf(
/* translators: 1: opening <strong>, 2: closing </strong> */
__( '%1$sSuper:%2$s Harness the power of lossy compression for substantial file size reduction with excellent image clarity. Accelerate page loads for better performance.', 'wp-smushit' ),
'<strong>',
'</strong>'
),
Settings::LEVEL_ULTRA_LOSSY => sprintf(
/* translators: 1: opening <strong>, 2: closing </strong> */
__( '%1$sUltra:%2$s Unlock unprecedented compression levels up to 5x greater than Super, while preserving remarkable image quality. The ultimate choice for unparalleled performance.', 'wp-smushit' ),
'<strong>',
'</strong>'
),
);
?>
<div class="sui-tabs sui-side-tabs wp-smush-lossy-level-tabs">
<div role="tablist" class="sui-tabs-menu">
<!-- Basic -->
<button
type="button"
role="tab"
id="lossy-level__basic"
class="sui-tab-item<?php echo $level_basic === $lossy_level_setting ? ' active' : ''; ?>"
aria-controls="lossy-level__basic-notice">
<?php echo esc_html( $settings->get_lossy_level_label( $level_basic ) ); ?>
</button>
<input
type="radio"
class="sui-screen-reader-text"
aria-hidden="true"
name="<?php echo esc_attr( $name ); ?>"
aria-labelledby="<?php echo esc_attr( $name . '-label' ); ?>"
aria-describedby="<?php echo esc_attr( $name . '-desc' ); ?>"
value="<?php echo (int) $level_basic; ?>"
<?php checked( $lossy_level_setting, $level_basic, true ); ?> />
<!-- Super -->
<button
type="button"
role="tab"
id="lossy-level__super"
class="sui-tab-item<?php echo $level_super === $lossy_level_setting ? ' active' : ''; ?>"
aria-controls="lossy-level__super-notice"
tabindex="-1">
<?php echo esc_html( $settings->get_lossy_level_label( $level_super ) ); ?>
</button>
<input
type="radio"
class="sui-screen-reader-text"
aria-hidden="true"
name="<?php echo esc_attr( $name ); ?>"
aria-labelledby="<?php echo esc_attr( $name . '-label' ); ?>"
aria-describedby="<?php echo esc_attr( $name . '-desc' ); ?>"
value="<?php echo (int) $level_super; ?>"
<?php checked( $lossy_level_setting, $level_super, true ); ?> />
<!-- Ultra -->
<?php if ( WP_Smush::is_pro() ) : ?>
<button
type="button"
role="tab"
id="lossy-level__ultra"
class="sui-tab-item<?php echo $level_ultra === $lossy_level_setting ? ' active' : ''; ?>"
aria-controls="lossy-level__ultra-notice"
tabindex="-1">
<?php echo esc_html( $settings->get_lossy_level_label( $level_ultra ) ); ?>
</button>
<input
type="radio"
class="sui-screen-reader-text"
aria-hidden="true"
name="<?php echo esc_attr( $name ); ?>"
aria-labelledby="<?php echo esc_attr( $name . '-label' ); ?>"
aria-describedby="<?php echo esc_attr( $name . '-desc' ); ?>"
value="<?php echo (int) $level_ultra; ?>"
<?php checked( $lossy_level_setting, $level_ultra, true ); ?> />
<?php else :
$utm_link = $this->get_utm_link(
array(
'utm_campaign' => 'smush_ultra_bulksmush_radio',
)
);
?>
<a target="_blank" href="<?php echo esc_url( $utm_link ); ?>" class="sui-tab-item wp-smush-ultra-compression-link wp-smush-upsell-ultra-compression">
<?php esc_html_e( '🚀 Ultra - unlock 5x more compression', 'wp-smushit' ); ?>
<span class="sui-icon-open-new-window" aria-hidden="true"></span>
</a>
<?php endif; ?>
</div>
<div class="sui-tabs-content">
<div role="tabpanel"
id="lossy-level__basic-notice"
class="sui-tab-content<?php echo $level_basic === $lossy_level_setting ? ' active' : ''; ?>"
aria-labelledby="lossy-level__basic"
tabindex="0">
<p>
<i class="sui-notice-icon sui-icon-info sui-md" aria-hidden="true"></i>
<?php
echo wp_kses(
$level_notices[ $level_basic ],
array(
'strong' => array(),
)
);
?>
</p>
</div>
<div role="tabpanel"
id="lossy-level__super-notice"
class="sui-tab-content<?php echo $level_super === $lossy_level_setting ? ' active' : ''; ?>"
aria-labelledby="lossy-level__super"
tabindex="0"
hidden>
<p>
<i class="sui-notice-icon sui-icon-info sui-md" aria-hidden="true"></i>
<?php
echo wp_kses(
$level_notices[ $level_super ],
array(
'strong' => array(),
)
);
?>
</p>
</div>
<div role="tabpanel"
id="lossy-level__ultra-notice"
class="sui-tab-content<?php echo $level_ultra === $lossy_level_setting ? ' active' : ''; ?>"
aria-labelledby="lossy-level__ultra"
tabindex="0"
hidden>
<p>
<i class="sui-notice-icon sui-icon-info sui-md" aria-hidden="true"></i>
<?php
echo wp_kses(
$level_notices[ $level_ultra ],
array(
'strong' => array(),
)
);
?>
</p>
</div>
</div>
</div>

View File

@ -0,0 +1,20 @@
<div class="sui-message">
<?php if ( ! apply_filters( 'wpmudev_branding_hide_branding', false ) ) : ?>
<img src="<?php echo esc_url( WP_SMUSH_URL . 'app/assets/images/smush-no-media.png' ); ?>"
srcset="<?php echo esc_url( WP_SMUSH_URL . 'app/assets/images/smush-no-media.png' ); ?>, <?php echo esc_url( WP_SMUSH_URL . 'app/assets/images/smush-no-media@2x.png' ); ?> 2x"
alt="<?php esc_attr_e( 'No attachments found - Upload some images', 'wp-smushit' ); ?>"
class="sui-image"
>
<?php endif; ?>
<div class="sui-message-content">
<p>
<?php esc_html_e( 'We havent found any images in your media library yet so theres no smushing to be done!', 'wp-smushit' ); ?><br>
<?php esc_html_e( 'Once you upload images, reload this page and start playing!', 'wp-smushit' ); ?>
</p>
<a class="sui-button sui-button-blue" href="<?php echo esc_url( admin_url( 'media-new.php' ) ); ?>">
<?php esc_html_e( 'UPLOAD IMAGES', 'wp-smushit' ); ?>
</a>
</div>
</div>

View File

@ -0,0 +1,31 @@
<?php
/**
* Bulk Smush meta box header.
*
* @package WP_Smush
*
* @var string $title Title.
*/
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<h3 class="sui-box-title">
<?php echo esc_html( $title ); ?>
</h3>
<div class="sui-actions-right">
<small>
<?php
printf(
/* translators: %1$s - a href opening tag, %2$s - a href closing tag */
esc_html__( 'Smush individual images via your %1$sMedia Library%2$s', 'wp-smushit' ),
'<a href="' . esc_url( admin_url( 'upload.php' ) ) . '" title="' . esc_html__( 'Media Library', 'wp-smushit' ) . '">',
'</a>'
);
?>
</small>
</div>

View File

@ -0,0 +1,111 @@
<?php
/**
* Bulk Smush meta box.
*
* @since 2.9.0
* @package WP_Smush
*
* @var Smush\Core\Core $core Instance of Smush\Core\Core
* @var bool $can_use_background Check if user can use BO.
* @var bool $total_count
* @var integer $unsmushed_count Count of the images that need smushing.
* @var integer $resmush_count Count of the images that need re-smushing.
* @var integer $remaining_count Remaining count of all images to smush. Unsmushed images + images to re-smush.
* @var string $bulk_upgrade_url Bulk Smush upgrade to PRO url.
* @var string $upsell_cdn_url Upsell CDN URL.
* @var bool $background_processing_enabled Background optimization is enabled.
* @var bool $background_in_processing Background optimization in progressing or not.
* @var string $background_in_processing_notice
* @var string $in_processing_notice
*/
if ( ! defined( 'WPINC' ) ) {
die;
}
use Smush\Core\Stats\Global_Stats;
if ( 0 !== absint( $total_count ) ) :
if ( $background_processing_enabled ) {
$msg = __( 'Bulk smush detects images that can be optimized and allows you to compress them in bulk in the background without any quality loss.', 'wp-smushit' );
} else {
$msg = __( 'Bulk smush detects images that can be optimized and allows you to compress them in bulk.', 'wp-smushit' );
}
?>
<p><?php echo esc_html( $msg ); ?></p>
<?php endif; ?>
<?php
// If there are no images in media library.
if ( 0 === absint( $total_count ) ) {
$this->view( 'media-lib-empty', array(), 'views/bulk' );
return;
}
$this->view( 'auto-bulk-smush-notification', array(
'background_processing_enabled' => $background_processing_enabled,
), 'views/bulk' );
if ( ! $can_use_background ) {
$this->view(
'limit-reached-notice',
array(),
'views/bulk'
);
}
// Progress bar.
$this->view(
'progress-bar',
array(
'count' => $remaining_count,
'background_in_processing_notice' => $background_in_processing_notice,
'background_processing_enabled' => $background_processing_enabled,
'in_processing_notice' => $in_processing_notice,
),
'common'
);
// All images are smushed.
$this->view( 'all-images-smushed-notice', array( 'all_done' => empty( $remaining_count ) ), 'common' );
// List errors.
$this->view( 'list-errors', array(), 'views/bulk' );
?>
<div class="wp-smush-bulk-wrapper sui-border-frame<?php echo empty( $remaining_count ) || $background_in_processing ? ' sui-hidden' : ''; ?>">
<div id="wp-smush-bulk-content">
<?php WP_Smush::get_instance()->admin()->print_pending_bulk_smush_content( $remaining_count, $resmush_count, $unsmushed_count ); ?>
</div>
<?php
$bulk_smush_class = $background_processing_enabled ? 'wp-smush-bo-start' : 'wp-smush-all';
if ( Global_Stats::get()->is_outdated() && ! $background_in_processing ) {
$bulk_smush_class .= ' wp-smush-scan-and-bulk-smush';
}
?>
<button type="button" class="<?php echo esc_attr( $bulk_smush_class ); ?> sui-button sui-button-blue" title="<?php esc_attr_e( 'Click to start Bulk Smushing images in Media Library', 'wp-smushit' ); ?>">
<?php esc_html_e( 'BULK SMUSH', 'wp-smushit' ); ?>
</button>
</div>
<?php
if ( ! $can_use_background ) {
$global_upsell_desc = __( 'Process images 2x faster, leave this page while Bulk Smush runs in the background, and serve streamlined next-gen images via Smushs 114-point CDN and Local WebP features.', 'wp-smushit' );
$this->view(
'global-upsell',
array(
'bulk_upgrade_url' => $bulk_upgrade_url,
'global_upsell_desc' => $global_upsell_desc,
),
'views/bulk'
);
} elseif ( ! WP_Smush::is_pro() ) {
$this->view(
'cdn-upsell',
array(
'background_in_processing' => $background_in_processing,
'bulk_upgrade_url' => $upsell_cdn_url,
),
'views/bulk'
);
}