PluginProbe ʕ •ᴥ•ʔ
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN / 3.9.8
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN v3.9.8
4.1.0 4.0.3 4.0.2 2.8.1 2.9.1 3.0.0 3.0.1 3.0.2 3.1.1 3.10.1 3.10.2 3.10.3 3.11.1 3.12.3 3.12.4 3.12.5 3.12.6 3.13.0 3.13.1 3.13.2 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.15.2 3.15.3 3.15.4 3.15.5 3.16.2 3.16.4 3.16.5 3.16.6 3.17.0 3.17.1 3.18.0 3.18.1 3.2.0.1 3.2.1 3.2.2.1 3.2.4 3.20.0 3.21.1 3.22.1 3.22.3 3.23.0 3.23.1 3.23.2 3.23.3 3.23.4 3.24.0 3.24.0-beta.2 3.3.0 3.3.1 3.3.2 3.4.1 3.4.2 3.6.1 3.6.3 3.7.0 3.7.1 3.7.2 3.7.3 3.8.2 3.8.3 3.8.4 3.8.5 3.8.7 3.8.8 3.9.0 3.9.1 3.9.11 3.9.2 3.9.4 3.9.5 3.9.8 3.9.9 trunk 1.0.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.2 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.5.3 1.6.5.4 1.7 1.7.1 1.7.1.1 2.0 2.0.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.6.2 2.0.6.3 2.0.6.5 2.0.7 2.0.7.1 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.2 2.3 2.3.1 2.4 2.4.2 2.4.3 2.4.4 2.4.5 2.5.2 2.5.3 2.6.1 2.6.2 2.6.3 2.7 2.7.1 2.7.4 2.7.4.1 2.7.5 2.7.6 2.7.8 2.7.8.1 2.7.9.1 2.8.0 2.8.0.1
wp-smushit / app / class-admin.php
wp-smushit / app Last commit date
assets 4 years ago common 4 years ago modals 4 years ago pages 4 years ago views 4 years ago class-abstract-page.php 4 years ago class-abstract-summary-page.php 4 years ago class-admin.php 4 years ago class-ajax.php 4 years ago class-interface-page.php 4 years ago class-media-library.php 4 years ago
class-admin.php
618 lines
1 <?php
2 /**
3 * Admin class.
4 *
5 * @package Smush\App
6 */
7
8 namespace Smush\App;
9
10 use Smush\Core\Core;
11 use Smush\Core\Helper;
12 use Smush\Core\Settings;
13 use WP_Smush;
14
15 if ( ! defined( 'WPINC' ) ) {
16 die;
17 }
18
19 /**
20 * Class Admin
21 */
22 class Admin {
23
24 /**
25 * Plugin pages.
26 *
27 * @var array
28 */
29 public $pages = array();
30
31 /**
32 * AJAX module.
33 *
34 * @var Ajax
35 */
36 public $ajax;
37
38 /**
39 * List of smush settings pages.
40 *
41 * @var array $plugin_pages
42 */
43 public static $plugin_pages = array(
44 'gallery_page_wp-smush-nextgen-bulk',
45 'nextgen-gallery_page_wp-smush-nextgen-bulk', // Different since NextGen 3.3.6.
46 'toplevel_page_smush',
47 'toplevel_page_smush-network',
48 );
49
50 /**
51 * Admin constructor.
52 *
53 * @param Media_Library $media_lib Media uploads library.
54 */
55 public function __construct( Media_Library $media_lib ) {
56 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
57
58 add_action( 'admin_menu', array( $this, 'add_menu_pages' ) );
59 add_action( 'network_admin_menu', array( $this, 'add_menu_pages' ) );
60
61 add_action( 'admin_init', array( $this, 'smush_i18n' ) );
62 // Add information to privacy policy page (only during creation).
63 add_action( 'admin_init', array( $this, 'add_policy' ) );
64
65 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
66 $this->ajax = new Ajax();
67 }
68
69 // Init media library UI.
70 $media_lib->init_ui();
71
72 add_filter( 'plugin_action_links_' . WP_SMUSH_BASENAME, array( $this, 'settings_link' ) );
73 add_filter( 'network_admin_plugin_action_links_' . WP_SMUSH_BASENAME, array( $this, 'settings_link' ) );
74 add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
75
76 // Prints a membership validation issue notice in Media Library.
77 add_action( 'admin_notices', array( $this, 'media_library_membership_notice' ) );
78
79 // Plugin conflict notice.
80 add_action( 'admin_notices', array( $this, 'show_plugin_conflict_notice' ) );
81 add_action( 'smush_check_for_conflicts', array( $this, 'check_for_conflicts_cron' ) );
82 add_action( 'activated_plugin', array( $this, 'check_for_conflicts_cron' ) );
83 add_action( 'deactivated_plugin', array( $this, 'check_for_conflicts_cron' ) );
84
85 // Filter built-in wpmudev branding script.
86 add_filter( 'wpmudev_whitelabel_plugin_pages', array( $this, 'builtin_wpmudev_branding' ) );
87 }
88
89 /**
90 * Load translation files.
91 */
92 public function smush_i18n() {
93 load_plugin_textdomain(
94 'wp-smushit',
95 false,
96 dirname( WP_SMUSH_BASENAME ) . '/languages'
97 );
98 }
99
100 /**
101 * Register JS and CSS.
102 */
103 private function register_scripts() {
104 global $wp_version;
105 /**
106 * Queue clipboard.js from your plugin if WP's version is below 5.2.0
107 * since it's only included from 5.2.0 on.
108 *
109 * Use 'clipboard' as the handle so it matches WordPress' handle for the script.
110 *
111 * @since 3.8.0
112 */
113 if ( version_compare( $wp_version, '5.2', '<' ) ) {
114 wp_register_script( 'clipboard', WP_SMUSH_URL . 'app/assets/js/smush-clipboard.min.js', array(), WP_SMUSH_VERSION, true );
115 }
116
117 /**
118 * Share UI JS.
119 *
120 * @since 3.8.0 added 'clipboard' dependency.
121 */
122 wp_register_script( 'smush-sui', WP_SMUSH_URL . 'app/assets/js/smush-sui.min.js', array( 'jquery', 'clipboard' ), WP_SHARED_UI_VERSION, true );
123
124 // Main JS.
125 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 );
126
127 // JS that can be used on all pages in the WP backend.
128 wp_register_script( 'smush-admin-common', WP_SMUSH_URL . 'app/assets/js/smush-admin-common.min.js', array( 'jquery' ), WP_SMUSH_VERSION, true );
129
130 if ( ! WP_Smush::is_pro() ) {
131 // Used on dashboard video widget.
132 wp_register_script( 'smush-wistia', '//fast.wistia.com/assets/external/E-v1.js', array(), WP_SMUSH_VERSION, true );
133 }
134
135 // Main CSS.
136 wp_register_style( 'smush-admin', WP_SMUSH_URL . 'app/assets/css/smush-admin.min.css', array(), WP_SMUSH_VERSION );
137
138 // Styles that can be used on all pages in the WP backend.
139 wp_register_style( 'smush-admin-common', WP_SMUSH_URL . 'app/assets/css/smush-global.min.css', array(), WP_SMUSH_VERSION );
140
141 // Dismiss update info.
142 WP_Smush::get_instance()->core()->mod->smush->dismiss_update_info();
143 }
144
145 /**
146 * Enqueue scripts.
147 */
148 public function enqueue_scripts() {
149 $dismissed = get_option( 'wp-smush-hide-conflict-notice' );
150 if ( ! $dismissed ) {
151 wp_enqueue_script( 'smush-global', WP_SMUSH_URL . 'app/assets/js/smush-global.min.js', array(), WP_SMUSH_VERSION, true );
152 }
153
154 $current_page = '';
155 $current_screen = '';
156
157 if ( function_exists( 'get_current_screen' ) ) {
158 $current_screen = get_current_screen();
159 $current_page = ! empty( $current_screen ) ? $current_screen->base : $current_page;
160 }
161
162 if ( ! in_array( $current_page, Core::$external_pages, true ) && false === strpos( $current_page, 'page_smush' ) ) {
163 return;
164 }
165
166 // Allows to disable enqueuing smush files on a particular page.
167 if ( ! apply_filters( 'wp_smush_enqueue', true ) ) {
168 return;
169 }
170
171 $this->register_scripts();
172
173 // Load on all Smush page only.
174 if ( isset( $current_screen->id ) && ( in_array( $current_screen->id, self::$plugin_pages, true ) || false !== strpos( $current_screen->id, 'page_smush' ) ) ) {
175 // Smush admin (smush-admin) includes the Shared UI.
176 wp_enqueue_style( 'smush-admin' );
177 wp_enqueue_script( 'smush-wpmudev-sui' );
178
179 if ( ! WP_Smush::is_pro() ) {
180 // Used on dashboard video widget.
181 wp_enqueue_script( 'smush-wistia' );
182 }
183 }
184
185 if ( ! in_array( $current_page, array( 'post', 'post-new', 'page', 'edit-page' ), true ) ) {
186 // Skip these pages where the script isn't used.
187 wp_enqueue_script( 'smush-admin' );
188 } else {
189 // Otherwise, load only the common JS code.
190 wp_enqueue_script( 'smush-admin-common' );
191 }
192
193 // We need it on media pages and Smush pages.
194 wp_enqueue_style( 'smush-admin-common' );
195
196 // Localize translatable strings for js.
197 WP_Smush::get_instance()->core()->localize();
198 }
199
200 /**
201 * Adds a Smush pro settings link on plugin page.
202 *
203 * @param array $links Current links.
204 *
205 * @return array|string
206 */
207 public function settings_link( $links ) {
208 // Upgrade link.
209 if ( ! WP_Smush::is_pro() ) {
210 $upgrade_url = add_query_arg(
211 array(
212 'coupon' => 'SMUSH30OFF',
213 'checkout' => 0,
214 'utm_source' => 'smush',
215 'utm_medium' => 'plugin',
216 'utm_campaign' => 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ? 'smush_pluginlist_upgrade' : 'smush_pluginlist_renew',
217 ),
218 esc_url( 'https://wpmudev.com/project/wp-smush-pro/' )
219 );
220
221 $label = 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ? __( 'Upgrade to Smush Pro', 'wp-smushit' ) : __( 'Renew Membership', 'wp-smushit' );
222 $text = 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ? __( 'Upgrade *New Pricing*', 'wp-smushit' ) : __( 'Renew Membership', 'wp-smushit' );
223
224 $links['smush_upgrade'] = '<a href="' . esc_url( $upgrade_url ) . '" aria-label="' . esc_attr( $label ) . '" target="_blank" style="color: #8D00B1;">' . $text . '</a>';
225 }
226
227 // Documentation link.
228 $links['smush_docs'] = '<a href="https://wpmudev.com/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>';
229
230 // Settings link.
231 $settings_page = is_multisite() && is_network_admin() ? network_admin_url( 'admin.php?page=smush' ) : menu_page_url( 'smush', false );
232 $links['smush_dashboard'] = '<a href="' . $settings_page . '" aria-label="' . esc_attr( __( 'Go to Smush Dashboard', 'wp-smushit' ) ) . '">' . esc_html__( 'Settings', 'wp-smushit' ) . '</a>';
233
234 if ( is_network_admin() && ! is_plugin_active_for_network( WP_SMUSH_BASENAME ) ) {
235 // Remove links for network admin when plugin is not activated for network.
236 unset( $links['smush_dashboard'] );
237 }
238
239 return array_reverse( $links );
240 }
241
242 /**
243 * Add additional links next to the plugin version.
244 *
245 * @since 3.5.0
246 *
247 * @param array $links Links array.
248 * @param string $file Plugin basename.
249 *
250 * @return array
251 */
252 public function add_plugin_meta_links( $links, $file ) {
253 if ( ! defined( 'WP_SMUSH_BASENAME' ) || WP_SMUSH_BASENAME !== $file ) {
254 return $links;
255 }
256
257 if ( 'wp-smush-pro/wp-smush.php' !== WP_SMUSH_BASENAME ) {
258 $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>';
259 $links[] = '<a href="https://wordpress.org/support/plugin/wp-smushit/" target="_blank" title="' . esc_attr__( 'Support', 'wp-smushit' ) . '">' . esc_html__( 'Support', 'wp-smushit' ) . '</a>';
260 } else {
261 if ( isset( $links[2] ) && false !== strpos( $links[2], 'project/wp-smush-pro' ) ) {
262 $links[2] = sprintf(
263 '<a href="https://wpmudev.com/project/wp-smush-pro/" target="_blank">%s</a>',
264 __( 'View details', 'wp-smushit' )
265 );
266 }
267
268 $links[] = '<a href="https://wpmudev.com/get-support/" target="_blank" title="' . esc_attr__( 'Premium Support', 'wp-smushit' ) . '">' . esc_html__( 'Premium Support', 'wp-smushit' ) . '</a>';
269 }
270
271 $links[] = '<a href="https://wpmudev.com/roadmap/" target="_blank" title="' . esc_attr__( 'Roadmap', 'wp-smushit' ) . '">' . esc_html__( 'Roadmap', 'wp-smushit' ) . '</a>';
272
273 return $links;
274 }
275
276 /**
277 * Add menu pages.
278 */
279 public function add_menu_pages() {
280 $title = 'wp-smush-pro/wp-smush.php' === WP_SMUSH_BASENAME ? esc_html__( 'Smush Pro', 'wp-smushit' ) : esc_html__( 'Smush', 'wp-smushit' );
281
282 if ( Settings::can_access( false, true ) ) {
283 $this->pages['smush'] = new Pages\Dashboard( 'smush', $title );
284 $this->pages['dashboard'] = new Pages\Dashboard( 'smush', __( 'Dashboard', 'wp-smushit' ), 'smush' );
285
286 if ( Abstract_Page::should_render( 'bulk' ) ) {
287 $this->pages['bulk'] = new Pages\Bulk( 'smush-bulk', __( 'Bulk Smush', 'wp-smushit' ), 'smush' );
288 }
289
290 if ( Abstract_Page::should_render( 'directory' ) ) {
291 $this->pages['directory'] = new Pages\Directory( 'smush-directory', __( 'Directory Smush', 'wp-smushit' ), 'smush' );
292 }
293
294 if ( Abstract_Page::should_render( 'lazy_load' ) ) {
295 $this->pages['lazy-load'] = new Pages\Lazy( 'smush-lazy-load', __( 'Lazy Load', 'wp-smushit' ), 'smush' );
296 }
297
298 if ( Abstract_Page::should_render( 'cdn' ) ) {
299 $this->pages['cdn'] = new Pages\CDN( 'smush-cdn', __( 'CDN', 'wp-smushit' ), 'smush' );
300 }
301
302 if ( Abstract_Page::should_render( 'webp' ) ) {
303 $this->pages['webp'] = new Pages\WebP( 'smush-webp', __( 'Local WebP', 'wp-smushit' ), 'smush' );
304 }
305
306 if ( Abstract_Page::should_render( 'integrations' ) ) {
307 $this->pages['integrations'] = new Pages\Integrations( 'smush-integrations', __( 'Integrations', 'wp-smushit' ), 'smush' );
308 }
309
310 if ( Abstract_Page::should_render( 'tools' ) ) {
311 $this->pages['tools'] = new Pages\Tools( 'smush-tools', __( 'Tools', 'wp-smushit' ), 'smush' );
312 }
313
314 if ( ! is_multisite() || is_network_admin() ) {
315 $this->pages['settings'] = new Pages\Settings( 'smush-settings', __( 'Settings', 'wp-smushit' ), 'smush' );
316 }
317
318 if ( ! apply_filters( 'wpmudev_branding_hide_doc_link', false ) && Abstract_Page::should_render( 'tutorials' ) ) {
319 $this->pages['tutorials'] = new Pages\Tutorials( 'smush-tutorials', __( 'Tutorials', 'wp-smushit' ), 'smush' );
320 }
321
322 if ( ! WP_Smush::is_pro() ) {
323 $this->pages['smush-upgrade'] = new Pages\Upgrade( 'smush-upgrade', __( 'Smush Pro', 'wp-smushit' ), 'smush' );
324 }
325 }
326
327 // Add a bulk smush option for NextGen gallery.
328 if ( defined( 'NGGFOLDER' ) && WP_Smush::get_instance()->core()->nextgen->is_enabled() && WP_Smush::is_pro() && ! is_network_admin() ) {
329 $this->pages['nextgen'] = new Pages\Nextgen( 'wp-smush-nextgen-bulk', $title, NGGFOLDER, true );
330 }
331 }
332
333 /**
334 * Add Smush Policy to "Privacy Policy" page during creation.
335 *
336 * @since 2.3.0
337 */
338 public function add_policy() {
339 if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
340 return;
341 }
342
343 $content = '<h3>' . __( 'Plugin: Smush', 'wp-smushit' ) . '</h3>';
344 $content .=
345 '<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>';
346 $content .=
347 '<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>';
348 $content .=
349 '<p>' . sprintf( /* translators: %1$s - opening <a>, %2$s - closing </a> */
350 __( "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' ),
351 '<a href="https://www.stackpath.com/legal/privacy-statement/" target="_blank">',
352 '</a>'
353 ) . '</p>';
354
355 if ( strpos( WP_SMUSH_DIR, 'wp-smushit' ) !== false ) {
356 // Only for wordpress.org members.
357 $content .=
358 '<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>';
359 }
360
361 wp_add_privacy_policy_content(
362 __( 'WP Smush', 'wp-smushit' ),
363 wp_kses_post( wpautop( $content, false ) )
364 );
365 }
366
367 /**
368 * Prints the Membership Validation issue notice
369 */
370 public function media_library_membership_notice() {
371 // No need to print it for free version.
372 if ( ! WP_Smush::is_pro() ) {
373 return;
374 }
375
376 // Show it on Media Library page only.
377 $screen = get_current_screen();
378 if ( ! empty( $screen ) && ( 'upload' === $screen->id || in_array( $screen->id, self::$plugin_pages, true ) || false !== strpos( $screen->id, 'page_smush' ) ) ) {
379 ?>
380 <div id="wp-smush-invalid-member" data-message="<?php esc_attr_e( 'Validating...', 'wp-smushit' ); ?>" class="hidden notice notice-warning is-dismissible">
381 <p>
382 <?php
383 printf(
384 /* translators: $1$s: recheck link, $2$s: closing a tag, %3$s; contact link, %4$s: closing a tag */
385 esc_html__(
386 '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.',
387 'wp-smushit'
388 ),
389 '<a href="#" id="wp-smush-revalidate-member" data-message="%s">',
390 '</a>',
391 '<a href="https://wpmudev.com/contact" target="_blank">',
392 '</a>'
393 );
394 ?>
395 </p>
396 </div>
397 <?php
398 }
399 }
400
401 /**
402 * Check for plugin conflicts cron.
403 *
404 * @since 3.6.0
405 *
406 * @param string $deactivated Holds the slug of activated/deactivated plugin.
407 */
408 public function check_for_conflicts_cron( $deactivated = '' ) {
409 $conflicting_plugins = array(
410 'autoptimize/autoptimize.php',
411 'ewww-image-optimizer/ewww-image-optimizer.php',
412 'imagify/imagify.php',
413 'resmushit-image-optimizer/resmushit.php',
414 'shortpixel-image-optimiser/wp-shortpixel.php',
415 'tiny-compress-images/tiny-compress-images.php',
416 'wp-rocket/wp-rocket.php',
417 'optimole-wp/optimole-wp.php',
418 // lazy load plugins.
419 'rocket-lazy-load/rocket-lazy-load.php',
420 'a3-lazy-load/a3-lazy-load.php',
421 'jetpack/jetpack.php',
422 'sg-cachepress/sg-cachepress.php',
423 'w3-total-cache/w3-total-cache.php',
424 'wp-fastest-cache/wpFastestCache.php',
425 'wp-optimize/wp-optimize.php',
426 'nitropack/main.php',
427 );
428
429 $plugins = get_plugins();
430
431 $active_plugins = array();
432 foreach ( $conflicting_plugins as $plugin ) {
433 if ( ! array_key_exists( $plugin, $plugins ) ) {
434 continue;
435 }
436
437 if ( ! is_plugin_active( $plugin ) ) {
438 continue;
439 }
440
441 // Deactivation of the plugin in process.
442 if ( doing_action( 'deactivated_plugin' ) && $deactivated === $plugin ) {
443 continue;
444 }
445
446 $active_plugins[] = $plugins[ $plugin ]['Name'];
447 }
448
449 set_transient( 'wp-smush-conflict_check', $active_plugins, 3600 );
450 }
451
452 /**
453 * Display plugin incompatibility notice.
454 *
455 * @since 3.6.0
456 */
457 public function show_plugin_conflict_notice() {
458 // Do not show on lazy load module, there we show an inline notice.
459 if ( false !== strpos( get_current_screen()->id, 'page_smush-lazy-load' ) ) {
460 return;
461 }
462
463 $dismissed = get_option( 'wp-smush-hide-conflict-notice' );
464 if ( $dismissed ) {
465 return;
466 }
467
468 $conflict_check = get_transient( 'wp-smush-conflict_check' );
469
470 // Have never checked before.
471 if ( false === $conflict_check ) {
472 wp_schedule_single_event( time(), 'smush_check_for_conflicts' );
473 return;
474 }
475
476 // No conflicting plugins detected.
477 if ( isset( $conflict_check ) && is_array( $conflict_check ) && empty( $conflict_check ) ) {
478 return;
479 }
480
481 array_walk(
482 $conflict_check,
483 function( &$item ) {
484 $item = '<strong>' . $item . '</strong>';
485 }
486 );
487 ?>
488 <div class="notice notice-info is-dismissible" id="smush-conflict-notice">
489 <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>
490 <p>
491 <?php echo wp_kses_post( join( '<br>', $conflict_check ) ); ?>
492 </p>
493 <p>
494 <a href="<?php echo esc_url( admin_url( 'plugins.php' ) ); ?>" class="button button-primary">
495 <?php esc_html_e( 'Manage Plugins', 'wp-smushit' ); ?>
496 </a>
497 <a href="#" style="margin-left: 15px" id="smush-dismiss-conflict-notice" >
498 <?php esc_html_e( 'Dismiss', 'wp-smushit' ); ?>
499 </a>
500 </p>
501 </div>
502 <?php
503 }
504
505 /**
506 * Prints the content for pending images for the Bulk Smush section.
507 *
508 * @since 3.7.2
509 *
510 * @param int $total_count Resmush + unsmushed image count.
511 * @param int $resmush_count Resmush count.
512 * @param int $unsmushed_count Unsmushed image count.
513 */
514 public function print_pending_bulk_smush_content( $total_count, $resmush_count, $unsmushed_count ) {
515 $tooltip_message = sprintf(
516 /* translators: %d total number of images to smush. */
517 _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' ),
518 $total_count
519 );
520
521 $unsmushed_message = '';
522 if ( 0 < $unsmushed_count ) {
523 $unsmushed_message = sprintf(
524 /* translators: 1. opening strong tag, 2: unsmushed images count,3. closing strong tag. */
525 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' ) ),
526 '<strong>',
527 absint( $unsmushed_count ),
528 '</strong>'
529 );
530 }
531
532 $resmush_message = '';
533 if ( 0 < $resmush_count ) {
534 $resmush_message = sprintf(
535 /* translators: 1. opening strong tag, 2: re-smush images count,3. closing strong tag. */
536 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' ) ),
537 '<strong>',
538 esc_html( $resmush_count ),
539 '</strong>'
540 );
541 }
542
543 $image_count_description = sprintf(
544 /* translators: 1. username, 2. unsmushed images message, 3. 'and' text for when having both unsmushed and re-smush images, 4. re-smush images message. */
545 __( '%1$s, you have %2$s%3$s%4$s!', 'wp-smushit' ),
546 esc_html( Helper::get_user_name() ),
547 $unsmushed_message,
548 ( $unsmushed_message && $resmush_message ? esc_html__( ' and ', 'wp-smushit' ) : '' ),
549 $resmush_message
550 );
551
552 if ( ! WP_Smush::is_pro() && $total_count > Core::$max_free_bulk ) {
553 $upgrade_url = add_query_arg(
554 array(
555 'coupon' => 'SMUSH30OFF',
556 'checkout' => 0,
557 'utm_source' => 'smush',
558 'utm_medium' => 'plugin',
559 'utm_campaign' => 'smush_bulksmush_morethan50images_upgradetopro',
560 ),
561 esc_url( 'https://wpmudev.com/project/wp-smush-pro/' )
562 );
563
564 $image_count_description .= sprintf(
565 /* translators: 1. opening 'a' tag to the upgrade url, 2. closing 'a' tag, 3. bulk smush image limit for free */
566 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' ),
567 '<a href="' . esc_url( $upgrade_url ) . '" target="_blank" style="color: #8D00B1;">',
568 '</a>',
569 esc_html( Core::$max_free_bulk )
570 );
571 }
572
573 ?>
574 <span id="wp-smush-bulk-image-count"><?php echo esc_html( $total_count ); ?></span>
575 <span class="sui-tooltip sui-tooltip-constrained" data-tooltip="<?php echo esc_attr( $tooltip_message ); ?>" style="--tooltip-width: 240px;">
576 <i class="sui-icon-info sui-warning" aria-hidden="true"></i>
577 </span>
578 <p id="wp-smush-bulk-image-count-description">
579 <?php echo $image_count_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
580 </p>
581 <?php
582 }
583
584 /**
585 * Add more pages to builtin wpmudev branding.
586 *
587 * @since 3.0
588 *
589 * @param array $plugin_pages Nextgen pages is not introduced in built in wpmudev branding.
590 *
591 * @return array
592 */
593 public function builtin_wpmudev_branding( $plugin_pages ) {
594 $plugin_pages['gallery_page_wp-smush-nextgen-bulk'] = array(
595 'wpmudev_whitelabel_sui_plugins_branding',
596 'wpmudev_whitelabel_sui_plugins_footer',
597 'wpmudev_whitelabel_sui_plugins_doc_links',
598 );
599
600 // There's a different page ID since NextGen 3.3.6.
601 $plugin_pages['nextgen-gallery_page_wp-smush-nextgen-bulk'] = array(
602 'wpmudev_whitelabel_sui_plugins_branding',
603 'wpmudev_whitelabel_sui_plugins_footer',
604 'wpmudev_whitelabel_sui_plugins_doc_links',
605 );
606
607 foreach ( $this->pages as $key => $value ) {
608 $plugin_pages[ "smush-pro_page_smush-{$key}" ] = array(
609 'wpmudev_whitelabel_sui_plugins_branding',
610 'wpmudev_whitelabel_sui_plugins_footer',
611 'wpmudev_whitelabel_sui_plugins_doc_links',
612 );
613 }
614
615 return $plugin_pages;
616 }
617 }
618