PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.4.6
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.4.6
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / inc / admin / ui / notices.php

notices.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.4.6, at inc/admin/ui/notices.php

372 lines 18.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3
4 /**
5 * This warning is displayed when the API key is empty
6 *
7 * @since 1.0
8 */
9 add_action( 'all_admin_notices', '_imagify_warning_empty_api_key_notice' );
10 function _imagify_warning_empty_api_key_notice() {
11 $current_screen = get_current_screen();
12 $ignored_notices = get_user_meta( $GLOBALS['current_user']->ID, '_imagify_ignore_notices', true );
13 $cap = ( imagify_is_active_for_network() ) ? 'manage_network_options' : 'manage_options';
14
15 if ( ( isset( $current_screen ) && ( 'settings_page_imagify' === $current_screen->base || 'settings_page_imagify-network' === $current_screen->base ) ) || in_array( 'welcome-steps', (array) $ignored_notices ) || get_imagify_option( 'api_key', false ) || ! current_user_can( apply_filters( 'imagify_capacity', $cap ) ) ) {
16 return;
17 }
18 ?>
19 <div class="imagify-welcome">
20 <div class="imagify-title">
21 <img class="imagify-logo" src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>imagify-logo.png" width="225" height="26" alt="Imagify" /> <small><sup><?php echo IMAGIFY_VERSION; ?></sup></small>
22 <span class="baseline">
23 <?php _e( 'Welcome to Imagify, the best way to easily optimize your images!', 'imagify' ); ?>
24 </span>
25 <a href="<?php echo get_imagify_admin_url( 'dismiss-notice', 'welcome-steps' ); ?>" class="imagify-notice-dismiss imagify-welcome-remove" title="<?php _e( 'Dismiss this notice', 'imagify' ); ?>"><span class="dashicons dashicons-dismiss"></span><span class="screen-reader-text"><?php _e( 'Dismiss this notice', 'imagify' ); ?></span></a>
26 </div>
27 <div class="imagify-settings-section">
28 <div class="imagify-columns counter">
29 <div class="col-1-3">
30 <img src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>user.svg" width="48" height="48" alt="">
31 <div class="imagify-col-content">
32 <p class="imagify-col-title"><?php _e( 'Create an Account', 'imagify' ); ?></p>
33 <p class="imagify-col-desc"><?php _e( 'Don\'t have an Imagify account yet? Optimize your images by creating an account in a few seconds!', 'imagify' ); ?></p>
34 <p>
35 <?php wp_nonce_field( 'imagify-signup', 'imagifysignupnonce', false ); ?>
36 <a id="imagify-signup" href="<?php echo IMAGIFY_APP_MAIN; ?>/#/register" class="button button-primary"><?php _e( 'Sign up, It\'s FREE!', 'imagify' ); ?></a></p>
37 </div>
38 </div>
39 <div class="col-1-3">
40 <img src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>key.svg" width="48" height="48" alt="">
41 <div class="imagify-col-content">
42 <p class="imagify-col-title"><?php _e( 'Enter your API Key', 'imagify' ); ?></p>
43 <p class="imagify-col-desc"><?php printf( __( 'Save your API Key you have received by email or you can get it on your %sImagify account page%s.', 'imagify' ), '<a href="' . IMAGIFY_APP_MAIN . '/#/api">', '</a>' ); ?></p>
44 <p>
45 <?php wp_nonce_field( 'imagify-check-api-key', 'imagifycheckapikeynonce', false ); ?>
46 <a id="imagify-save-api-key" href="<?php echo get_imagify_admin_url(); ?>" class="button button-primary"><?php _e( 'I have my API key', 'imagify' ); ?></a></p>
47 </div>
48 </div>
49 <div class="col-1-3">
50 <img src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>gear.svg" width="48" height="48" alt="">
51 <div class="imagify-col-content">
52 <p class="imagify-col-title"><?php _e( 'Configure it', 'imagify' ); ?></p>
53 <p class="imagify-col-desc"><?php _e( 'It’s almost done! You have just to configure your optimization settings.', 'imagify' ); ?></p>
54 <p><a href="<?php echo get_imagify_admin_url(); ?>" class="button button-primary"><?php _e( 'Go to Settings', 'imagify' ); ?></a></p>
55 </div>
56 </div>
57 </div>
58 </div>
59 </div>
60 <?php
61 }
62
63 /**
64 * This warning is displayed when the API key is empty
65 *
66 * @since 1.0
67 */
68 add_action( 'all_admin_notices', '_imagify_warning_wrong_api_key_notice' );
69 function _imagify_warning_wrong_api_key_notice() {
70 $current_screen = get_current_screen();
71 $ignored_notices = get_user_meta( $GLOBALS['current_user']->ID, '_imagify_ignore_notices', true );
72 $api_key = get_imagify_option( 'api_key', false );
73 $cap = ( imagify_is_active_for_network() ) ? 'manage_network_options' : 'manage_options';
74
75 if ( ( isset( $current_screen ) && 'media_page_imagify-bulk-optimization' !== $current_screen->base ) || in_array( 'wrong-api-key', (array) $ignored_notices ) || empty( $api_key ) || imagify_valid_key() || ! current_user_can( apply_filters( 'imagify_capacity', $cap ) ) ) {
76 return;
77 }
78 ?>
79 <div class="clear"></div>
80 <div class="error imagify-notice below-h2">
81 <div class="imagify-notice-logo">
82 <img class="imagify-logo" src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>imagify-logo.png" width="138" height="16" alt="Imagify" />
83 </div>
84 <div class="imagify-notice-content">
85 <p class="imagify-notice-title"><strong><?php _e( 'Your API key isn\'t valid!', 'imagify' ); ?></strong></p>
86 <p>
87 <?php wp_nonce_field( 'imagify-signup', 'imagifysignupnonce', false ); ?>
88 <?php printf( __( 'Go to your Imagify account page to get your API Key and specify it on %1$syour settings%3$s or %2$screate an account for free%3$s if you don\'t have one yet.', 'imagify' ), '<a href="' . get_imagify_admin_url() . '">', '<a id="imagify-signup" href="' . IMAGIFY_WEB_MAIN . '">', '</a>' ); ?></p>
89 </div>
90 <a href="<?php echo get_imagify_admin_url( 'dismiss-notice', 'wrong-api-key' ); ?>" class="imagify-notice-dismiss notice-dismiss" title="<?php esc_attr_e( 'Dismiss this notice', 'imagify' ); ?>"><span class="screen-reader-text"><?php _e( 'Dismiss this notice', 'imagify' ); ?></span></a>
91 </div>
92
93 <?php
94 }
95
96 /**
97 * This warning is displayed when some plugins may conflict with Imagify
98 *
99 * @since 1.0
100 */
101 add_action( 'all_admin_notices', '_imagify_warning_plugins_to_deactivate_notice' );
102 function _imagify_warning_plugins_to_deactivate_notice() {
103 $plugins_to_deactivate = array();
104 $cap = ( imagify_is_active_for_network() ) ? 'manage_network_options' : 'manage_options';
105
106 // Deactivate all plugins who can cause conflicts with Imagify
107 $plugins = array(
108 'wp-smush' => 'wp-smushit/wp-smush.php', // WP Smush
109 'kraken' => 'kraken-image-optimizer/kraken.php', // Kraken.io
110 'tinypng' => 'tiny-compress-images/tiny-compress-images.php', // TinyPNG
111 'shortpixel' => 'shortpixel-image-optimiser/wp-shortpixel.php', // Shortpixel
112 'ewww' => 'ewww-image-optimizer/ewww-image-optimizer.php', // EWWW Image Optimizer
113 'ewww-cloud' => 'ewww-image-optimizer-cloud/ewww-image-optimizer-cloud.php', // EWWW Image Optimizer Cloud
114 'imagerecycle' => 'imagerecycle-pdf-image-compression/wp-image-recycle.php', // ImageRecycle
115 );
116
117 /**
118 * Filter the recommended plugins to deactivate to prevent conflicts
119 *
120 * @since 1.0
121 *
122 * @param string $plugins List of recommended plugins to deactivate
123 */
124 $plugins = apply_filters( 'imagify_plugins_to_deactivate', $plugins );
125 $plugins = array_filter( $plugins, 'is_plugin_active' );
126
127 /** This filter is documented in inc/admin/options.php */
128 if ( ! (bool) $plugins || ! current_user_can( apply_filters( 'imagify_capacity', $cap ) ) ) {
129 return;
130 }
131 ?>
132 <div class="clear"></div>
133 <div class="imagify-notice error below-h2">
134 <div class="imagify-notice-logo">
135 <img class="imagify-logo" src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>imagify-logo.png" width="138" height="16" alt="Imagify" />
136 </div>
137 <div class="imagify-notice-content">
138 <p><?php _e( 'The following plugins are not compatible with this plugin and may cause unexpected results:', 'imagify' ); ?></p>
139
140 <ul class="imagify-plugins-error">
141 <?php
142 foreach ( $plugins as $plugin ) {
143 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin );
144 echo '<li>' . $plugin_data['Name'] . '</span> <a href="' . wp_nonce_url( admin_url( 'admin-post.php?action=imagify_deactivate_plugin&plugin=' . urlencode( $plugin ) ), 'imagifydeactivatepluginnonce' ) . '" class="button button-mini alignright">' . __( 'Deactivate', 'imagify' ) . '</a></li>';
145 }
146 ?>
147 </ul>
148 </div>
149 </div>
150 <?php
151 }
152
153 /**
154 * This notice is displayed when external HTTP requests are blocked via the WP_HTTP_BLOCK_EXTERNAL constant
155 *
156 * @since 1.0
157 */
158 add_action( 'all_admin_notices', '_imagify_http_block_external_notice' );
159 function _imagify_http_block_external_notice() {
160 $current_screen = get_current_screen();
161 $ignored_notices = get_user_meta( $GLOBALS['current_user']->ID, '_imagify_ignore_notices', true );
162
163 if ( ( isset( $current_screen ) && ( 'settings_page_imagify' === $current_screen->base || 'settings_page_imagify-network' === $current_screen->base ) ) || in_array( 'http-block-external', (array) $ignored_notices ) || ! current_user_can( apply_filters( 'imagify_capacity', 'manage_options' ) ) || ! is_imagify_blocked() ) {
164 return;
165 }
166 ?>
167 <div class="clear"></div>
168 <div class="error imagify-notice below-h2">
169 <div class="imagify-notice-logo">
170 <img class="imagify-logo" src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>imagify-logo.png" width="138" height="16" alt="Imagify" />
171 </div>
172 <div class="imagify-notice-content">
173 <p class="imagify-notice-title"><strong><?php _e( 'The external HTTP requests are blocked!', 'imagify' ); ?></strong></p>
174 <p><?php _e( 'You defined the <code>WP_HTTP_BLOCK_EXTERNAL</code> constant in the <code>wp-config.php</code> to block all external HTTP requests.', 'imagify' ); ?></p>
175 <p>
176 <?php _e( 'To optimize your images, you have to put the following code in your <code>wp-config.php</code> file so that it works correctly.', 'imagify' ); ?><br/>
177 <?php _e( 'Click on the field and press Ctrl-A to select all.', 'imagify' ); ?>
178 </p>
179 <p><textarea readonly="readonly" class="large-text readonly" rows="1">define( 'WP_ACCESSIBLE_HOSTS', '*.imagify.io' );</textarea></p>
180 </div>
181 <a href="<?php echo get_imagify_admin_url( 'dismiss-notice', 'http-block-external' ); ?>" class="imagify-notice-dismiss notice-dismiss" title="<?php esc_attr_e( 'Dismiss this notice', 'imagify' ); ?>"><span class="screen-reader-text"><?php _e( 'Dismiss this notice', 'imagify' ); ?></span></a>
182 </div>
183 <?php
184 }
185
186 /**
187 * This warning is displayed when the grid view is active on the library
188 *
189 * @since 1.0.2
190 */
191 add_action( 'all_admin_notices', '_imagify_warning_grid_view_notice' );
192 function _imagify_warning_grid_view_notice() {
193 global $wp_version;
194 $current_screen = get_current_screen();
195 $ignored_notices = get_user_meta( $GLOBALS['current_user']->ID, '_imagify_ignore_notices', true );
196 $media_library_mode = get_user_option( 'media_library_mode', get_current_user_id() );
197
198 if ( ( isset( $current_screen ) && 'upload' !== $current_screen->base ) || in_array( 'grid-view', (array) $ignored_notices ) || ! current_user_can( 'upload_files' ) || $media_library_mode == 'list' || version_compare( $wp_version, '4.0' ) < 0 ) {
199 return;
200 }
201
202 // Don't display the notice if the API key isn't valid
203 if ( ! imagify_valid_key() ) {
204 return;
205 }
206 ?>
207 <div class="clear"></div>
208 <div class="error imagify-notice below-h2">
209 <div class="imagify-notice-logo">
210 <img class="imagify-logo" src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>imagify-logo.png" width="138" height="16" alt="Imagify" />
211 </div>
212 <div class="imagify-notice-content">
213 <p class="imagify-notice-title"><strong><?php _e( 'You\'re missing out!', 'imagify' ); ?></strong></p>
214 <p><?php _e( 'Use the List view to optimize images with Imagify.', 'imagify' ); ?></p>
215 <p><a href="<?php echo admin_url( 'upload.php?mode=list' ); ?>"><?php _e( 'Switch to the List View', 'imagify' ); ?></a></p>
216 </div>
217 <a href="<?php echo get_imagify_admin_url( 'dismiss-notice', 'grid-view' ); ?>" class="imagify-notice-dismiss notice-dismiss" title="<?php esc_attr_e( 'Dismiss this notice', 'imagify' ); ?>"><span class="screen-reader-text"><?php _e( 'Dismiss this notice', 'imagify' ); ?></span></a>
218 </div>
219 <?php
220 }
221
222 /**
223 * This warning is displayed to warn the user that its quota is consumed for the current month
224 *
225 * @since 1.1.1
226 */
227 add_action( 'all_admin_notices', '_imagify_warning_over_quota_notice' );
228 function _imagify_warning_over_quota_notice() {
229 $current_screen = get_current_screen();
230 $ignored_notices = get_user_meta( $GLOBALS['current_user']->ID, '_imagify_ignore_notices', true );
231 $cap = ( imagify_is_active_for_network() ) ? 'manage_network_options' : 'manage_options';
232
233 if ( ( isset( $current_screen ) && ( 'media_page_imagify-bulk-optimization' !== $current_screen->base && 'settings_page_imagify' !== $current_screen->base && 'settings_page_imagify-network' !== $current_screen->base ) ) || in_array( 'free-over-quota', (array) $ignored_notices ) || ! current_user_can( apply_filters( 'imagify_capacity', $cap ) ) ) {
234 return;
235 }
236
237 $user = new Imagify_User();
238
239 // Don't display the notice if the user doesn't use all his quota or the API key isn't valid
240 if ( ! $user->is_over_quota() || ! imagify_valid_key() ) {
241 return;
242 }
243
244 ?>
245 <div class="clear"></div>
246 <div class="error imagify-notice below-h2">
247 <div class="imagify-notice-logo">
248 <img class="imagify-logo" src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>imagify-logo.png" width="138" height="16" alt="Imagify" />
249 </div>
250 <div class="imagify-notice-content">
251 <p class="imagify-notice-title"><strong><?php _e( 'Oops, It\'s Over!', 'imagify' ); ?></strong></p>
252 <p>
253 <?php printf( __( 'You have consumed all your credit for this month. You will have <strong>%s back on %s</strong>.', 'imagify' ), size_format( $user->quota * 1048576 ), date_i18n( get_option( 'date_format' ), strtotime( $user->next_date_update ) ) ) . '<br/><br/>' . sprintf( __( 'To continue to optimize your images, log in to your Imagify account to %sbuy a pack or subscribe to a plan%s.', 'imagify' ), '<a href="' . IMAGIFY_APP_MAIN . '/#/subscription' . '">', '</a>' ); ?>
254 </p>
255 </div>
256 <a href="<?php echo get_imagify_admin_url( 'dismiss-notice', 'free-over-quota' ); ?>" class="imagify-notice-dismiss notice-dismiss" title="<?php esc_attr_e( 'Dismiss this notice', 'imagify' ); ?>"><span class="screen-reader-text"><?php _e( 'Dismiss this notice', 'imagify' ); ?></span></a>
257 </div>
258 <?php
259 }
260
261 /**
262 * Add a message about WP Rocket on the "Bulk Optimization" screen.
263 *
264 * @since 2.7
265 */
266 add_action( 'admin_notices', '_imagify_rocket_notice' );
267 function _imagify_rocket_notice() {
268 $current_screen = get_current_screen();
269 $ignored_notices = get_user_meta( $GLOBALS['current_user']->ID, '_imagify_ignore_notices', true );
270
271 if ( ( isset( $current_screen ) && 'media_page_imagify-bulk-optimization' !== $current_screen->base ) || in_array( 'wp-rocket', (array) $ignored_notices ) || ! current_user_can( apply_filters( 'imagify_capacity', 'manage_options' ) ) || defined( 'WP_ROCKET_VERSION' ) ) {
272 return;
273 }
274
275 $dismiss_url = get_imagify_admin_url( 'dismiss-notice', 'wp-rocket' );
276
277 $coupon_code = 'IMAGIFY20';
278 $wprocket_url = 'http://wp-rocket.me/';
279
280 switch( get_locale() ) {
281 case 'fr_FR' :
282 $wprocket_url = 'http://wp-rocket.me/fr/';
283 break;
284 case 'es_ES' :
285 $wprocket_url = 'http://wp-rocket.me/es/';
286 break;
287 case 'it_IT' :
288 $wprocket_url = 'http://wp-rocket.me/it/';
289 break;
290 case 'de_DE' :
291 $wprocket_url = 'http://wp-rocket.me/de/';
292 break;
293 }
294
295 $wprocket_url .= '?utm_source=imagify-coupon&utm_medium=plugin&utm_campaign=imagify';
296 ?>
297
298 <div class="updated imagify-rkt-notice">
299 <a href="<?php echo $dismiss_url; ?>" class="imagify-cross"><span class="dashicons dashicons-no"></span></a>
300
301 <p class="imagify-rkt-logo">
302 <img src="<?php echo IMAGIFY_ASSETS_IMG_URL ?>logo-wprocket.png" srcset="<?php echo IMAGIFY_ASSETS_IMG_URL ?>logo-wprocket2x.png 2x" alt="WP Rocket" width="118" height="32">
303 </p>
304 <p class="imagify-rkt-msg">
305 <?php
306 esc_html_e( 'Discover the best caching plugin to speed up your website.', 'imagify');
307 echo '<br>';
308 printf(
309 esc_html__( '%sGet %s off%s with this coupon code:%s', 'imagify' ),
310 '<strong>', '20%', '</strong>', ' ' . $coupon_code
311 );
312 ?>
313 </p>
314 <p class="imagify-rkt-coupon">
315 <span class="imagify-rkt-coupon-code"><?php echo $coupon_code; ?></span>
316 </p>
317 <p class="imagify-rkt-cta">
318 <a href="<?php echo $wprocket_url; ?>" class="button button-primary tgm-plugin-update-modal"><?php esc_html_e( 'Get WP Rocket now', 'imagify' ); ?></a>
319 </p>
320 </div>
321
322 <?php
323 }
324
325 /**
326 * This notice is displayed to rate the plugin after 100 optimization & 7 days after the first installation
327 *
328 * @since 1.4.2
329 */
330 add_action( 'all_admin_notices', '_imagify_rating_notice' );
331 function _imagify_rating_notice() {
332 $user_images_count = get_site_transient( 'imagify_user_images_count' );
333
334 if ( ! $user_images_count || get_site_transient( 'imagify_seen_rating_notice' ) ) {
335 return;
336 }
337
338 $current_screen = get_current_screen();
339 $ignored_notices = get_user_meta( $GLOBALS['current_user']->ID, '_imagify_ignore_notices', true );
340
341 if ( ( isset( $current_screen ) && ( 'media_page_imagify-bulk-optimization' !== $current_screen->base && 'upload' !== $current_screen->base && 'media' !== $current_screen->base ) ) || in_array( 'rating', (array) $ignored_notices ) || ! current_user_can( apply_filters( 'imagify_capacity', 'manage_options' ) ) ) {
342 return;
343 }
344 ?>
345 <div class="clear"></div>
346 <div class="updated imagify-notice below-h2">
347 <div class="imagify-notice-logo">
348 <img class="imagify-logo" src="<?php echo IMAGIFY_ASSETS_IMG_URL; ?>imagify-logo.png" width="138" height="16" alt="Imagify" />
349 </div>
350 <div class="imagify-notice-content">
351 <?php
352 $imagify_rate_url = 'https://wordpress.org/support/view/plugin-reviews/imagify?rate=5#postform';
353 ?>
354 <p><?php printf( __( '%1$sCongratulations%2$s, you have optimized %1$s%3$d images%2$s and improved your website\'s speed by reducing your images size.', 'imagify' ), '<strong>', '</strong>', $user_images_count ); ?></p>
355 <p class="imagify-rate-us">
356 <?php printf( __( '%sDo you like this plugin?%s Please take a few seconds to %srate it on WordPress.org%s!', 'imagify' ), '<strong>', '</strong><br />', '<a href="' . $imagify_rate_url . '">', '</a>' ); ?>
357 <br>
358 <a class="stars" href="<?php echo $imagify_rate_url; ?>">☆☆☆☆☆</a>
359 </p>
360 </div>
361 <a href="<?php echo get_imagify_admin_url( 'dismiss-notice', 'rating' ); ?>" class="imagify-notice-dismiss notice-dismiss" title="<?php esc_attr_e( 'Dismiss this notice', 'imagify' ); ?>"><span class="screen-reader-text"><?php _e( 'Dismiss this notice', 'imagify' ); ?></span></a>
362 </div>
363 <?php
364 }
365
366 add_action( 'imagify_dismiss_notice', '_imagify_clear_scheduled_rating' );
367 function _imagify_clear_scheduled_rating( $notice ) {
368 if ( 'rating' === $notice ) {
369 set_site_transient( 'do_imagify_rating_cron', 'no' );
370 wp_clear_scheduled_hook( 'imagify_rating_event' );
371 }
372 }