Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-smush.../app
File: class-admin.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Admin class.
[2] Fix | Delete
*
[3] Fix | Delete
* @package Smush\App
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
namespace Smush\App;
[7] Fix | Delete
[8] Fix | Delete
use Smush\Core\Core;
[9] Fix | Delete
use Smush\Core\Helper;
[10] Fix | Delete
use Smush\Core\Settings;
[11] Fix | Delete
use WP_Smush;
[12] Fix | Delete
[13] Fix | Delete
if ( ! defined( 'WPINC' ) ) {
[14] Fix | Delete
die;
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Class Admin
[19] Fix | Delete
*/
[20] Fix | Delete
class Admin {
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Plugin pages.
[24] Fix | Delete
*
[25] Fix | Delete
* @var array
[26] Fix | Delete
*/
[27] Fix | Delete
public $pages = array();
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* AJAX module.
[31] Fix | Delete
*
[32] Fix | Delete
* @var Ajax
[33] Fix | Delete
*/
[34] Fix | Delete
public $ajax;
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* List of smush settings pages.
[38] Fix | Delete
*
[39] Fix | Delete
* @var array $plugin_pages
[40] Fix | Delete
*/
[41] Fix | Delete
public static $plugin_pages = array(
[42] Fix | Delete
'gallery_page_wp-smush-nextgen-bulk',
[43] Fix | Delete
'nextgen-gallery_page_wp-smush-nextgen-bulk', // Different since NextGen 3.3.6.
[44] Fix | Delete
'toplevel_page_smush-network',
[45] Fix | Delete
'toplevel_page_smush',
[46] Fix | Delete
'smush_page_smush-upgrade-network',
[47] Fix | Delete
'smush_page_smush-upgrade',
[48] Fix | Delete
'smush-pro_page_smush-upgrade',
[49] Fix | Delete
);
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Admin constructor.
[53] Fix | Delete
*
[54] Fix | Delete
* @param Media_Library $media_lib Media uploads library.
[55] Fix | Delete
*/
[56] Fix | Delete
public function __construct( Media_Library $media_lib ) {
[57] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
[58] Fix | Delete
[59] Fix | Delete
add_action( 'admin_menu', array( $this, 'add_menu_pages' ) );
[60] Fix | Delete
add_action( 'network_admin_menu', array( $this, 'add_menu_pages' ) );
[61] Fix | Delete
[62] Fix | Delete
add_action( 'admin_init', array( $this, 'smush_i18n' ) );
[63] Fix | Delete
// Add information to privacy policy page (only during creation).
[64] Fix | Delete
add_action( 'admin_init', array( $this, 'add_policy' ) );
[65] Fix | Delete
[66] Fix | Delete
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
[67] Fix | Delete
$this->ajax = new Ajax();
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
// Init media library UI.
[71] Fix | Delete
$media_lib->init_ui();
[72] Fix | Delete
[73] Fix | Delete
add_filter( 'plugin_action_links_' . WP_SMUSH_BASENAME, array( $this, 'settings_link' ) );
[74] Fix | Delete
add_filter( 'network_admin_plugin_action_links_' . WP_SMUSH_BASENAME, array( $this, 'settings_link' ) );
[75] Fix | Delete
add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
[76] Fix | Delete
[77] Fix | Delete
// Prints a membership validation issue notice in Media Library.
[78] Fix | Delete
add_action( 'admin_notices', array( $this, 'media_library_membership_notice' ) );
[79] Fix | Delete
[80] Fix | Delete
// Plugin conflict notice.
[81] Fix | Delete
add_action( 'admin_notices', array( $this, 'show_plugin_conflict_notice' ) );
[82] Fix | Delete
add_action( 'smush_check_for_conflicts', array( $this, 'check_for_conflicts_cron' ) );
[83] Fix | Delete
add_action( 'activated_plugin', array( $this, 'check_for_conflicts_cron' ) );
[84] Fix | Delete
add_action( 'deactivated_plugin', array( $this, 'check_for_conflicts_cron' ) );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Load translation files.
[89] Fix | Delete
*/
[90] Fix | Delete
public function smush_i18n() {
[91] Fix | Delete
load_plugin_textdomain(
[92] Fix | Delete
'wp-smushit',
[93] Fix | Delete
false,
[94] Fix | Delete
dirname( WP_SMUSH_BASENAME ) . '/languages'
[95] Fix | Delete
);
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Register JS and CSS.
[100] Fix | Delete
*/
[101] Fix | Delete
private function register_scripts() {
[102] Fix | Delete
global $wp_version;
[103] Fix | Delete
/**
[104] Fix | Delete
* Queue clipboard.js from your plugin if WP's version is below 5.2.0
[105] Fix | Delete
* since it's only included from 5.2.0 on.
[106] Fix | Delete
*
[107] Fix | Delete
* Use 'clipboard' as the handle so it matches WordPress' handle for the script.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 3.8.0
[110] Fix | Delete
*/
[111] Fix | Delete
if ( version_compare( $wp_version, '5.2', '<' ) ) {
[112] Fix | Delete
wp_register_script( 'clipboard', WP_SMUSH_URL . 'app/assets/js/smush-clipboard.min.js', array(), WP_SMUSH_VERSION, true );
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Share UI JS.
[117] Fix | Delete
*
[118] Fix | Delete
* @since 3.8.0 added 'clipboard' dependency.
[119] Fix | Delete
*/
[120] Fix | Delete
wp_register_script( 'smush-sui', WP_SMUSH_URL . 'app/assets/js/smush-sui.min.js', array( 'jquery', 'clipboard' ), WP_SHARED_UI_VERSION, true );
[121] Fix | Delete
[122] Fix | Delete
// Main JS.
[123] Fix | Delete
wp_register_script( 'smush-admin', WP_SMUSH_URL . 'app/assets/js/smush-admin.min.js', array( 'jquery', 'smush-sui', 'underscore', 'wp-color-picker' ), WP_SMUSH_VERSION, true );
[124] Fix | Delete
[125] Fix | Delete
if ( ! WP_Smush::is_pro() ) {
[126] Fix | Delete
// Used on dashboard video widget.
[127] Fix | Delete
wp_register_script( 'smush-wistia', '//fast.wistia.com/assets/external/E-v1.js', array(), WP_SMUSH_VERSION, true );
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
// Main CSS.
[131] Fix | Delete
wp_register_style( 'smush-admin', WP_SMUSH_URL . 'app/assets/css/smush-admin.min.css', array(), WP_SMUSH_VERSION );
[132] Fix | Delete
[133] Fix | Delete
// Styles that can be used on all pages in the WP backend.
[134] Fix | Delete
wp_register_style( 'smush-admin-common', WP_SMUSH_URL . 'app/assets/css/smush-common.min.css', array(), WP_SMUSH_VERSION );
[135] Fix | Delete
[136] Fix | Delete
// Dismiss update info.
[137] Fix | Delete
WP_Smush::get_instance()->core()->mod->smush->dismiss_update_info();
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* Enqueue scripts.
[142] Fix | Delete
*/
[143] Fix | Delete
public function enqueue_scripts() {
[144] Fix | Delete
$dismissed = get_option( WP_SMUSH_PREFIX . 'hide-conflict-notice' );
[145] Fix | Delete
if ( ! $dismissed ) {
[146] Fix | Delete
wp_enqueue_script( 'smush-global', WP_SMUSH_URL . 'app/assets/js/smush-global.min.js', array(), WP_SMUSH_VERSION, true );
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
$current_page = '';
[150] Fix | Delete
$current_screen = '';
[151] Fix | Delete
[152] Fix | Delete
if ( function_exists( 'get_current_screen' ) ) {
[153] Fix | Delete
$current_screen = get_current_screen();
[154] Fix | Delete
$current_page = ! empty( $current_screen ) ? $current_screen->base : $current_page;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
if ( ! in_array( $current_page, Core::$pages, true ) ) {
[158] Fix | Delete
return;
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
// Allows to disable enqueuing smush files on a particular page.
[162] Fix | Delete
if ( ! apply_filters( 'wp_smush_enqueue', true ) ) {
[163] Fix | Delete
return;
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
$this->register_scripts();
[167] Fix | Delete
[168] Fix | Delete
// Load on all Smush page only.
[169] Fix | Delete
if ( isset( $current_screen->id ) && in_array( $current_screen->id, self::$plugin_pages, true ) ) {
[170] Fix | Delete
// Smush admin (smush-admin) includes the Shared UI.
[171] Fix | Delete
wp_enqueue_style( 'smush-admin' );
[172] Fix | Delete
wp_enqueue_script( 'smush-wpmudev-sui' );
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
// We need it on media pages and Smush pages.
[176] Fix | Delete
wp_enqueue_script( 'smush-admin' );
[177] Fix | Delete
wp_enqueue_style( 'smush-admin-common' );
[178] Fix | Delete
[179] Fix | Delete
if ( ! WP_Smush::is_pro() ) {
[180] Fix | Delete
// Used on dashboard video widget.
[181] Fix | Delete
wp_enqueue_script( 'smush-wistia' );
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
// Localize translatable strings for js.
[185] Fix | Delete
WP_Smush::get_instance()->core()->localize();
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
/**
[189] Fix | Delete
* Adds a Smush pro settings link on plugin page.
[190] Fix | Delete
*
[191] Fix | Delete
* @param array $links Current links.
[192] Fix | Delete
*
[193] Fix | Delete
* @return array|string
[194] Fix | Delete
*/
[195] Fix | Delete
public function settings_link( $links ) {
[196] Fix | Delete
// Upgrade link.
[197] Fix | Delete
if ( ! WP_Smush::is_pro() ) {
[198] Fix | Delete
$upgrade_url = add_query_arg(
[199] Fix | Delete
array(
[200] Fix | Delete
'coupon' => 'SMUSH30OFF',
[201] Fix | Delete
'checkout' => 0,
[202] Fix | Delete
'utm_source' => 'smush',
[203] Fix | Delete
'utm_medium' => 'plugin',
[204] Fix | Delete
'utm_campaign' => 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ? 'smush_pluginlist_upgrade' : 'smush_pluginlist_renew',
[205] Fix | Delete
),
[206] Fix | Delete
esc_url( 'https://premium.wpmudev.org/project/wp-smush-pro/' )
[207] Fix | Delete
);
[208] Fix | Delete
[209] Fix | Delete
$label = 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ? __( 'Upgrade to Smush Pro', 'wp-smushit' ) : __( 'Renew Membership', 'wp-smushit' );
[210] Fix | Delete
$text = 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ? __( 'Upgrade *New Pricing*', 'wp-smushit' ) : __( 'Renew Membership', 'wp-smushit' );
[211] Fix | Delete
[212] Fix | Delete
$links['smush_upgrade'] = '<a href="' . esc_url( $upgrade_url ) . '" aria-label="' . esc_attr( $label ) . '" target="_blank" style="color: #8D00B1;">' . $text . '</a>';
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
// Documentation link.
[216] Fix | Delete
$links['smush_docs'] = '<a href="https://premium.wpmudev.org/docs/wpmu-dev-plugins/smush/?utm_source=smush&utm_medium=plugin&utm_campaign=smush_pluginlist_docs" aria-label="' . esc_attr( __( 'View Smush Documentation', 'wp-smushit' ) ) . '" target="_blank">' . esc_html__( 'Docs', 'wp-smushit' ) . '</a>';
[217] Fix | Delete
[218] Fix | Delete
// Settings link.
[219] Fix | Delete
$settings_page = is_multisite() && is_network_admin() ? network_admin_url( 'admin.php?page=smush' ) : menu_page_url( 'smush', false );
[220] Fix | Delete
$links['smush_dashboard'] = '<a href="' . $settings_page . '" aria-label="' . esc_attr( __( 'Go to Smush Dashboard', 'wp-smushit' ) ) . '">' . esc_html__( 'Settings', 'wp-smushit' ) . '</a>';
[221] Fix | Delete
[222] Fix | Delete
return array_reverse( $links );
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
* Add additional links next to the plugin version.
[227] Fix | Delete
*
[228] Fix | Delete
* @since 3.5.0
[229] Fix | Delete
*
[230] Fix | Delete
* @param array $links Links array.
[231] Fix | Delete
* @param string $file Plugin basename.
[232] Fix | Delete
*
[233] Fix | Delete
* @return array
[234] Fix | Delete
*/
[235] Fix | Delete
public function add_plugin_meta_links( $links, $file ) {
[236] Fix | Delete
if ( ! defined( 'WP_SMUSH_BASENAME' ) || WP_SMUSH_BASENAME !== $file ) {
[237] Fix | Delete
return $links;
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
if ( 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ) {
[241] Fix | Delete
$links[] = '<a href="https://wordpress.org/support/plugin/wp-smushit/reviews/#new-post" target="_blank" title="' . esc_attr__( 'Rate Smush', 'wp-smushit' ) . '">' . esc_html__( 'Rate Smush', 'wp-smushit' ) . '</a>';
[242] Fix | Delete
$links[] = '<a href="https://wordpress.org/support/plugin/wp-smushit/" target="_blank" title="' . esc_attr__( 'Support', 'wp-smushit' ) . '">' . esc_html__( 'Support', 'wp-smushit' ) . '</a>';
[243] Fix | Delete
} else {
[244] Fix | Delete
if ( isset( $links[2] ) && false !== strpos( $links[2], 'project/wp-smush-pro' ) ) {
[245] Fix | Delete
$links[2] = sprintf(
[246] Fix | Delete
'<a href="https://premium.wpmudev.org/project/wp-smush-pro/" target="_blank">%s</a>',
[247] Fix | Delete
__( 'View details', 'wp-smushit' )
[248] Fix | Delete
);
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
$links[] = '<a href="https://premium.wpmudev.org/get-support/" target="_blank" title="' . esc_attr__( 'Premium Support', 'wp-smushit' ) . '">' . esc_html__( 'Premium Support', 'wp-smushit' ) . '</a>';
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
$links[] = '<a href="https://premium.wpmudev.org/roadmap/" target="_blank" title="' . esc_attr__( 'Roadmap', 'wp-smushit' ) . '">' . esc_html__( 'Roadmap', 'wp-smushit' ) . '</a>';
[255] Fix | Delete
[256] Fix | Delete
return $links;
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Add menu pages.
[261] Fix | Delete
*/
[262] Fix | Delete
public function add_menu_pages() {
[263] Fix | Delete
$title = 'wp-smush-pro/wp-smush.php' === WP_SMUSH_BASENAME ? esc_html__( 'Smush Pro', 'wp-smushit' ) : esc_html__( 'Smush', 'wp-smushit' );
[264] Fix | Delete
[265] Fix | Delete
if ( Settings::can_access( false, true ) ) {
[266] Fix | Delete
$this->pages['smush'] = new Pages\Dashboard( 'smush', $title );
[267] Fix | Delete
$this->pages['smush-dashboard'] = new Pages\Dashboard( 'smush', __( 'Dashboard', 'wp-smushit' ), 'smush' );
[268] Fix | Delete
[269] Fix | Delete
if ( ! WP_Smush::is_pro() ) {
[270] Fix | Delete
$this->pages['smush-upgrade'] = new Pages\Upgrade( 'smush-upgrade', __( 'Smush Pro', 'wp-smushit' ), 'smush' );
[271] Fix | Delete
}
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
// Add a bulk smush option for NextGen gallery.
[275] Fix | Delete
if ( defined( 'NGGFOLDER' ) && WP_Smush::get_instance()->core()->nextgen->is_enabled() && WP_Smush::is_pro() && ! is_network_admin() ) {
[276] Fix | Delete
$this->pages['nextgen'] = new Pages\Nextgen( 'wp-smush-nextgen-bulk', $title, NGGFOLDER, true );
[277] Fix | Delete
}
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
/**
[281] Fix | Delete
* Add Smush Policy to "Privacy Policy" page during creation.
[282] Fix | Delete
*
[283] Fix | Delete
* @since 2.3.0
[284] Fix | Delete
*/
[285] Fix | Delete
public function add_policy() {
[286] Fix | Delete
if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
[287] Fix | Delete
return;
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
$content = '<h3>' . __( 'Plugin: Smush', 'wp-smushit' ) . '</h3>';
[291] Fix | Delete
$content .=
[292] Fix | Delete
'<p>' . __( 'Note: Smush does not interact with end users on your website. The only input option Smush has is to a newsletter subscription for site admins only. If you would like to notify your users of this in your privacy policy, you can use the information below.', 'wp-smushit' ) . '</p>';
[293] Fix | Delete
$content .=
[294] Fix | Delete
'<p>' . __( 'Smush sends images to the WPMU DEV servers to optimize them for web use. This includes the transfer of EXIF data. The EXIF data will either be stripped or returned as it is. It is not stored on the WPMU DEV servers.', 'wp-smushit' ) . '</p>';
[295] Fix | Delete
$content .=
[296] Fix | Delete
'<p>' . sprintf(
[297] Fix | Delete
__( "Smush uses the Stackpath Content Delivery Network (CDN). Stackpath may store web log information of site visitors, including IPs, UA, referrer, Location and ISP info of site visitors for 7 days. Files and images served by the CDN may be stored and served from countries other than your own. Stackpath's privacy policy can be found %1\$shere%2\$s.", 'wp-smushit' ),
[298] Fix | Delete
'<a href="https://www.stackpath.com/legal/privacy-statement/" target="_blank">',
[299] Fix | Delete
'</a>'
[300] Fix | Delete
) . '</p>';
[301] Fix | Delete
[302] Fix | Delete
if ( strpos( WP_SMUSH_DIR, 'wp-smushit' ) !== false ) {
[303] Fix | Delete
// Only for wordpress.org members.
[304] Fix | Delete
$content .=
[305] Fix | Delete
'<p>' . __( 'Smush uses a third-party email service (Drip) to send informational emails to the site administrator. The administrator\'s email address is sent to Drip and a cookie is set by the service. Only administrator information is collected by Drip.', 'wp-smushit' ) . '</p>';
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
wp_add_privacy_policy_content(
[309] Fix | Delete
__( 'WP Smush', 'wp-smushit' ),
[310] Fix | Delete
wp_kses_post( wpautop( $content, false ) )
[311] Fix | Delete
);
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
/**
[315] Fix | Delete
* Prints the Membership Validation issue notice
[316] Fix | Delete
*/
[317] Fix | Delete
public function media_library_membership_notice() {
[318] Fix | Delete
// No need to print it for free version.
[319] Fix | Delete
if ( ! WP_Smush::is_pro() ) {
[320] Fix | Delete
return;
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
// Show it on Media Library page only.
[324] Fix | Delete
$screen = get_current_screen();
[325] Fix | Delete
if ( ! empty( $screen ) && ( 'upload' === $screen->id || in_array( $screen->id, self::$plugin_pages, true ) ) ) {
[326] Fix | Delete
?>
[327] Fix | Delete
<div id="wp-smush-invalid-member" data-message="<?php esc_attr_e( 'Validating..', 'wp-smushit' ); ?>" class="hidden notice notice-warning is-dismissible">
[328] Fix | Delete
<p>
[329] Fix | Delete
<?php
[330] Fix | Delete
printf(
[331] Fix | Delete
/* translators: $1$s: recheck link, $2$s: closing a tag, %3$s; contact link, %4$s: closing a tag */
[332] Fix | Delete
esc_html__(
[333] Fix | Delete
'It looks like Smush couldn’t verify your WPMU DEV membership so Pro features have been disabled for now. If you think this is an error, run a %1$sre-check%2$s or get in touch with our %3$ssupport team%4$s.',
[334] Fix | Delete
'wp-smushit'
[335] Fix | Delete
),
[336] Fix | Delete
'<a href="#" id="wp-smush-revalidate-member" data-message="%s">',
[337] Fix | Delete
'</a>',
[338] Fix | Delete
'<a href="https://premium.wpmudev.org/contact" target="_blank">',
[339] Fix | Delete
'</a>'
[340] Fix | Delete
);
[341] Fix | Delete
?>
[342] Fix | Delete
</p>
[343] Fix | Delete
</div>
[344] Fix | Delete
<?php
[345] Fix | Delete
}
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* Check for plugin conflicts cron.
[350] Fix | Delete
*
[351] Fix | Delete
* @since 3.6.0
[352] Fix | Delete
*
[353] Fix | Delete
* @param string $deactivated Holds the slug of activated/deactivated plugin.
[354] Fix | Delete
*/
[355] Fix | Delete
public function check_for_conflicts_cron( $deactivated = '' ) {
[356] Fix | Delete
$conflicting_plugins = array(
[357] Fix | Delete
'ewww-image-optimizer/ewww-image-optimizer.php',
[358] Fix | Delete
'imagify/imagify.php',
[359] Fix | Delete
'resmushit-image-optimizer/resmushit.php',
[360] Fix | Delete
'shortpixel-image-optimiser/wp-shortpixel.php',
[361] Fix | Delete
'tiny-compress-images/tiny-compress-images.php',
[362] Fix | Delete
);
[363] Fix | Delete
[364] Fix | Delete
$plugins = get_plugins();
[365] Fix | Delete
[366] Fix | Delete
$active_plugins = array();
[367] Fix | Delete
foreach ( $conflicting_plugins as $plugin ) {
[368] Fix | Delete
if ( ! array_key_exists( $plugin, $plugins ) ) {
[369] Fix | Delete
continue;
[370] Fix | Delete
}
[371] Fix | Delete
[372] Fix | Delete
if ( ! is_plugin_active( $plugin ) ) {
[373] Fix | Delete
continue;
[374] Fix | Delete
}
[375] Fix | Delete
[376] Fix | Delete
// Deactivation of the plugin in process.
[377] Fix | Delete
if ( doing_action( 'deactivated_plugin' ) && $deactivated === $plugin ) {
[378] Fix | Delete
continue;
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
$active_plugins[] = $plugins[ $plugin ]['Name'];
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
set_transient( WP_SMUSH_PREFIX . 'conflict_check', $active_plugins, 3600 );
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Display plugin incompatibility notice.
[389] Fix | Delete
*
[390] Fix | Delete
* @since 3.6.0
[391] Fix | Delete
*/
[392] Fix | Delete
public function show_plugin_conflict_notice() {
[393] Fix | Delete
$dismissed = get_option( WP_SMUSH_PREFIX . 'hide-conflict-notice' );
[394] Fix | Delete
if ( $dismissed ) {
[395] Fix | Delete
return;
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
$conflict_check = get_transient( WP_SMUSH_PREFIX . 'conflict_check' );
[399] Fix | Delete
[400] Fix | Delete
// Have never checked before.
[401] Fix | Delete
if ( false === $conflict_check ) {
[402] Fix | Delete
wp_schedule_single_event( time(), 'smush_check_for_conflicts' );
[403] Fix | Delete
return;
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
// No conflicting plugins detected.
[407] Fix | Delete
if ( isset( $conflict_check ) && is_array( $conflict_check ) && empty( $conflict_check ) ) {
[408] Fix | Delete
return;
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
array_walk(
[412] Fix | Delete
$conflict_check,
[413] Fix | Delete
function( &$item ) {
[414] Fix | Delete
$item = '<strong>' . $item . '</strong>';
[415] Fix | Delete
}
[416] Fix | Delete
);
[417] Fix | Delete
?>
[418] Fix | Delete
<div class="notice notice-info is-dismissible" id="smush-conflict-notice">
[419] Fix | Delete
<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>
[420] Fix | Delete
<p>
[421] Fix | Delete
<?php echo wp_kses_post( join( '<br>', $conflict_check ) ); ?>
[422] Fix | Delete
</p>
[423] Fix | Delete
<p>
[424] Fix | Delete
<a href="<?php echo esc_url( admin_url( 'plugins.php' ) ); ?>" class="button button-primary">
[425] Fix | Delete
<?php esc_html_e( 'Manage Plugins', 'wp-smushit' ); ?>
[426] Fix | Delete
</a>
[427] Fix | Delete
<a href="#" style="margin-left: 15px" id="smush-dismiss-conflict-notice" >
[428] Fix | Delete
<?php esc_html_e( 'Dismiss', 'wp-smushit' ); ?>
[429] Fix | Delete
</a>
[430] Fix | Delete
</p>
[431] Fix | Delete
</div>
[432] Fix | Delete
<?php
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
/**
[436] Fix | Delete
* Prints the content for pending images for the Bulk Smush section.
[437] Fix | Delete
*
[438] Fix | Delete
* @since 3.7.2
[439] Fix | Delete
*
[440] Fix | Delete
* @param int $total_count Resmush + unsmushed image count.
[441] Fix | Delete
* @param int $resmush_count Resmush count.
[442] Fix | Delete
* @param int $unsmushed_count Unsmushed image count.
[443] Fix | Delete
*/
[444] Fix | Delete
public function print_pending_bulk_smush_content( $total_count, $resmush_count, $unsmushed_count ) {
[445] Fix | Delete
$tooltip_message = sprintf(
[446] Fix | Delete
/* translators: %d total number of images to smush. */
[447] Fix | Delete
_n( 'You have %d attachment that needs smushing. Click Bulk Smush and compress the images in bulk.', 'You have %d attachments that need smushing. Click Bulk Smush and compress the images in bulk.', $total_count, 'wp-smushit' ),
[448] Fix | Delete
$total_count
[449] Fix | Delete
);
[450] Fix | Delete
[451] Fix | Delete
$unsmushed_message = '';
[452] Fix | Delete
if ( 0 < $unsmushed_count ) {
[453] Fix | Delete
$unsmushed_message = sprintf(
[454] Fix | Delete
/* translators: 1. opening strong tag, 2: unsmushed images count,3. closing strong tag. */
[455] Fix | Delete
esc_html( _n( '%1$s%2$d attachment%3$s that needs smushing', '%1$s%2$d attachments%3$s that need smushing', $unsmushed_count, 'wp-smushit' ) ),
[456] Fix | Delete
'<strong>',
[457] Fix | Delete
absint( $unsmushed_count ),
[458] Fix | Delete
'</strong>'
[459] Fix | Delete
);
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
$resmush_message = '';
[463] Fix | Delete
if ( 0 < $resmush_count ) {
[464] Fix | Delete
$resmush_message = sprintf(
[465] Fix | Delete
/* translators: 1. opening strong tag, 2: re-smush images count,3. closing strong tag. */
[466] Fix | Delete
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', $resmush_count, 'wp-smushit' ) ),
[467] Fix | Delete
'<strong>',
[468] Fix | Delete
esc_html( $resmush_count ),
[469] Fix | Delete
'</strong>'
[470] Fix | Delete
);
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
$image_count_description = sprintf(
[474] Fix | Delete
/* translators: 1. username, 2. unsmushed images message, 3. 'and' text for when having both unsmushed and re-smush images, 4. re-smush images message. */
[475] Fix | Delete
__( '%1$s, you have %2$s%3$s%4$s!', 'wp-smushit' ),
[476] Fix | Delete
esc_html( Helper::get_user_name() ),
[477] Fix | Delete
$unsmushed_message,
[478] Fix | Delete
( $unsmushed_message && $resmush_message ? esc_html__( ' and ', 'wp-smushit' ) : '' ),
[479] Fix | Delete
$resmush_message
[480] Fix | Delete
);
[481] Fix | Delete
[482] Fix | Delete
if ( ! WP_Smush::is_pro() && $total_count > Core::$max_free_bulk ) {
[483] Fix | Delete
$upgrade_url = add_query_arg(
[484] Fix | Delete
array(
[485] Fix | Delete
'coupon' => 'SMUSH30OFF',
[486] Fix | Delete
'checkout' => 0,
[487] Fix | Delete
'utm_source' => 'smush',
[488] Fix | Delete
'utm_medium' => 'plugin',
[489] Fix | Delete
'utm_campaign' => 'smush_bulksmush_morethan50images_upgradetopro',
[490] Fix | Delete
),
[491] Fix | Delete
esc_url( 'https://premium.wpmudev.org/project/wp-smush-pro/' )
[492] Fix | Delete
);
[493] Fix | Delete
[494] Fix | Delete
$image_count_description .= sprintf(
[495] Fix | Delete
/* translators: 1. opening 'a' tag to the upgrade url, 2. closing 'a' tag, 3. bulk smush image limit for free */
[496] Fix | Delete
esc_html__( ' %1$sUpgrade to Pro%2$s to bulk smush all images in one click. Free users can smush %3$d images per batch.', 'wp-smushit' ),
[497] Fix | Delete
'<a href="' . esc_url( $upgrade_url ) . '" target="_blank" style="color: #8D00B1;">',
[498] Fix | Delete
'</a>',
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function