PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.5
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.5
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.5, at inc/admin/ui/notices.php

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