: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$item = '<strong>' . $item . '</strong>';
<div class="notice notice-info is-dismissible smush-dismissible-notice"
id="smush-conflict-notice"
data-key="plugin-conflict">
<p><?php esc_html_e( 'You have multiple WordPress image optimization plugins installed. This may cause unpredictable behavior while optimizing your images, inaccurate reporting, or images to not display. For best results use only one image optimizer plugin at a time. These plugins may cause issues with Smush:', 'wp-smushit' ); ?></p>
<?php echo wp_kses_post( join( '<br>', $conflict_check ) ); ?>
<a href="<?php echo esc_url( admin_url( 'plugins.php' ) ); ?>" class="button button-primary">
<?php esc_html_e( 'Manage Plugins', 'wp-smushit' ); ?>
style="margin-left: 15px"
id="smush-dismiss-conflict-notice" class="smush-dismiss-notice-button">
<?php esc_html_e( 'Dismiss', 'wp-smushit' ); ?>
* Prints the content for pending images for the Bulk Smush section.
* @param int $remaining_count
* @param int $reoptimize_count
* @param int $optimize_count
public function print_pending_bulk_smush_content( $remaining_count, $reoptimize_count, $optimize_count ) {
if ( 0 < $optimize_count ) {
$optimize_message = sprintf(
/* translators: 1. opening strong tag, 2: unsmushed images count,3. closing strong tag. */
esc_html( _n( '%1$s%2$d attachment%3$s that needs smushing', '%1$s%2$d attachments%3$s that need smushing', $optimize_count, 'wp-smushit' ) ),
absint( $optimize_count ),
$reoptimize_message = '';
if ( 0 < $reoptimize_count ) {
$reoptimize_message = sprintf(
/* translators: 1. opening strong tag, 2: re-smush images count,3. closing strong tag. */
esc_html( _n( '%1$s%2$d attachment%3$s that needs re-smushing', '%1$s%2$d attachments%3$s that need re-smushing', $reoptimize_count, 'wp-smushit' ) ),
esc_html( $reoptimize_count ),
$bulk_limit_free_message = $this->generate_bulk_limit_message_for_free( $remaining_count );
$image_count_description = sprintf(
/* translators: 1. username, 2. unsmushed images message, 3. 'and' text for when having both unsmushed and re-smush images, 4. re-smush images message. */
__( '%1$s, you have %2$s%3$s%4$s! %5$s', 'wp-smushit' ),
esc_html( Helper::get_user_name() ),
( $optimize_message && $reoptimize_message ? esc_html__( ' and ', 'wp-smushit' ) : '' ),
<span id="wp-smush-bulk-image-count"><?php echo esc_html( $remaining_count ); ?></span>
<p id="wp-smush-bulk-image-count-description">
<?php echo wp_kses_post( $image_count_description ); ?>
public function get_global_stats_with_bulk_smush_content() {
$core = WP_Smush::get_instance()->core();
$stats = $core->get_global_stats();
$global_stats = Global_Stats::get();
$remaining_count = $global_stats->get_remaining_count();
$optimize_count = $global_stats->get_optimize_list()->get_count();
$reoptimize_count = $global_stats->get_redo_count();
$stats['errors'] = Error_Handler::get_last_errors();
if ( $remaining_count > 0 ) {
WP_Smush::get_instance()->admin()->print_pending_bulk_smush_content(
$content = ob_get_clean();
$stats['content'] = $content;
public function get_global_stats_with_bulk_smush_content_and_notice() {
$stats = $this->get_global_stats_with_bulk_smush_content();
$remaining_count = Global_Stats::get()->get_remaining_count();
if ( $remaining_count < 1 ) {
$stats['notice'] = esc_html__( 'Yay! All images are optimized as per your current settings.', 'wp-smushit' );
$stats['noticeType'] = 'success';
$stats['noticeType'] = 'warning';
$stats['notice'] = sprintf(
/* translators: %1$d - number of images, %2$s - opening a tag, %3$s - closing a tag */
esc_html__( 'Image check complete, you have %1$d images that need smushing. %2$sBulk smush now!%3$s', 'wp-smushit' ),
'<a href="#" class="wp-smush-trigger-bulk">',
private function generate_bulk_limit_message_for_free( $remaining_count ) {
$dont_limit = WP_Smush::get_instance()->core()->mod->bg_optimization->can_use_background();
if ( $dont_limit || $remaining_count < Core::MAX_FREE_BULK ) {
$upgrade_url = add_query_arg(
'utm_medium' => 'plugin',
'utm_campaign' => 'smush_bulk_smush_pre_smush_50_limit',
'https://wpmudev.com/project/wp-smush-pro/'
$batches = ceil( $remaining_count / Core::MAX_FREE_BULK );
/* translators: %s: Discount */
$discount_text = '<strong>' . sprintf( esc_html__( '%s off welcome discount available.', 'wp-smushit' ), $this->get_plugin_discount() ) . '</strong>';
/* translators: 1: max free bulk limit, 2: Total batches to smush, 3: opening a tag, 4: closing a tag. */
esc_html__( 'Free users can only Bulk Smush %1$d images at one time. Smush in %2$d batches or %3$sBulk Smush unlimited images with Pro%4$s. %5$s', 'wp-smushit' ),
'<a class="smush-upsell-link" target="_blank" href="' . $upgrade_url . '">',
* Add more pages to builtin wpmudev branding.
* @param array $plugin_pages Nextgen pages is not introduced in built in wpmudev branding.
public function builtin_wpmudev_branding( $plugin_pages ) {
$plugin_pages['gallery_page_wp-smush-nextgen-bulk'] = array(
'wpmudev_whitelabel_sui_plugins_branding',
'wpmudev_whitelabel_sui_plugins_footer',
'wpmudev_whitelabel_sui_plugins_doc_links',
// There's a different page ID since NextGen 3.3.6.
$plugin_pages['nextgen-gallery_page_wp-smush-nextgen-bulk'] = array(
'wpmudev_whitelabel_sui_plugins_branding',
'wpmudev_whitelabel_sui_plugins_footer',
'wpmudev_whitelabel_sui_plugins_doc_links',
foreach ( $this->pages as $key => $value ) {
$plugin_pages[ "smush-pro_page_smush-{$key}" ] = array(
'wpmudev_whitelabel_sui_plugins_branding',
'wpmudev_whitelabel_sui_plugins_footer',
'wpmudev_whitelabel_sui_plugins_doc_links',
public function is_notice_dismissed( $notice ) {
$dismissed_notices = get_option( 'wp-smush-dismissed-notices', array() );
return ! empty( $dismissed_notices[ $notice ] );
public function show_parallel_unavailability_notice() {
$smush = WP_Smush::get_instance()->core()->mod->smush;
$curl_multi_exec_available = $smush->curl_multi_exec_available();
$is_current_user_not_admin = ! current_user_can( 'manage_options' );
$is_not_bulk_smush_page = false === strpos( get_current_screen()->id, 'page_smush-bulk' );
$notice_hidden = $this->is_notice_dismissed( 'curl-multi-unavailable' );
$curl_multi_exec_available ||
$is_current_user_not_admin ||
$is_not_bulk_smush_page ||
/* translators: %s: <strong>curl_multi_exec()</strong> */
esc_html__( 'Smush was unable to activate parallel processing on your site as your web hosting provider has disabled the %s function on your server. We highly recommend contacting your hosting provider to enable that function to optimize images on your site faster.', 'wp-smushit' ),
'<strong>curl_multi_exec()</strong>'
<div class="notice notice-warning is-dismissible smush-dismissible-notice"
id="smush-parallel-unavailability-notice"
data-key="curl-multi-unavailable">
<strong style="font-size: 15px;line-height: 30px;margin: 8px 0 0 2px;display: inline-block;">
<?php esc_html_e( 'Smush images faster with parallel image optimization', 'wp-smushit' ); ?>
<p style="margin-bottom: 13px;margin-top: 0;">
<?php echo wp_kses_post( $notice_text ); ?><br/>
<a style="margin-top: 5px;display: inline-block;" href="#" class="smush-dismiss-notice-button">
<?php esc_html_e( 'Dismiss', 'wp-smushit' ); ?>
public function show_background_unavailability_notice() {
$bg_optimization = WP_Smush::get_instance()->core()->mod->bg_optimization;
$background_supported = $bg_optimization->is_background_supported();
$background_disabled = ! $bg_optimization->is_background_enabled();
$is_current_user_not_admin = ! current_user_can( 'manage_options' );
$is_not_bulk_smush_page = false === strpos( get_current_screen()->id, 'page_smush-bulk' );
$notice_hidden = $this->is_notice_dismissed( 'background-smush-unavailable' );
$is_current_user_not_admin ||
$is_not_bulk_smush_page ||
/* translators: 1: Current MYSQL version, 2: Required MYSQL version */
esc_html__( 'Smush was unable to activate background processing on your site as your web hosting provider is using an old version of MySQL on your server (version %1$s). We highly recommend contacting your hosting provider to upgrade MySQL to version %2$s or higher to optimize images in the background.', 'wp-smushit' ),
$bg_optimization->get_actual_mysql_version(),
$bg_optimization->get_required_mysql_version()
<div class="notice notice-warning is-dismissible smush-dismissible-notice"
id="smush-background-unavailability-notice"
data-key="background-smush-unavailable">
<strong style="font-size: 15px;line-height: 30px;margin: 8px 0 0 2px;display: inline-block;">
<?php esc_html_e( 'Smush images in the background', 'wp-smushit' ); ?>
<p style="margin-bottom: 13px;margin-top: 0;">
<?php echo wp_kses_post( $notice_text ); ?><br/>
<a style="margin-top: 5px;display: inline-block;" href="#" class="smush-dismiss-notice-button">
<?php esc_html_e( 'Dismiss', 'wp-smushit' ); ?>
public function maybe_show_local_webp_convert_original_images_notice() {
$redirected_from_webp = isset( $_GET['smush-action'] ) && 'start-bulk-webp-conversion' === $_GET['smush-action'];
$settings = Settings::get_instance();
$should_show_notice = $redirected_from_webp &&
current_user_can( 'manage_options' ) &&
$settings->has_webp_page() &&
! $settings->is_optimize_original_images_active();
if ( ! $should_show_notice ) {
$error_message = sprintf(
/* translators: 1: Open a link, 2: Close the link */
esc_html__( 'If you wish to also convert your original uploaded images to .webp format, please enable the %1$sOptimize original images%2$s setting below.', 'wp-smushit' ),
'<a href="#original" class="smush-close-and-dismiss-notice">',
$error_message = '<p>' . $error_message . '</p>';
<div role="alert" id="wp-smush-local-webp-convert-original-notice" class="sui-notice wp-smush-dismissible-header-notice" data-message="<?php echo esc_attr( $error_message ); ?>" aria-live="assertive"></div>
public function get_plugin_discount() {
return self::PLUGIN_DISCOUNT_PERCENT . '%';