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

259 lines 13.7 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 *
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 }