PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.10
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.10
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 / functions / i18n.php

i18n.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.10, at inc/functions/i18n.php

331 lines 16.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
3
4 /**
5 * Get all translations we can use with wp_localize_script().
6 *
7 * @since 1.5
8 * @author Jonathan Buttigieg
9 *
10 * @param string $context The translation context.
11 * @return array $translations The translations.
12 */
13 function get_imagify_localize_script_translations( $context ) {
14 global $post_id;
15
16 $imagifybeat_actions = \Imagify\Imagifybeat\Actions::get_instance();
17
18 switch ( $context ) {
19 case 'admin-bar':
20 if ( is_admin() ) {
21 return [];
22 }
23
24 return [
25 'ajaxurl' => admin_url( 'admin-ajax.php' ),
26 ];
27
28 case 'notices':
29 return [
30 'labels' => [
31 /* translators: Don't use escaped HTML entities here (like &nbsp;). */
32 'signupTitle' => __( 'Let\'s get you started!', 'imagify' ),
33 'signupText' => __( 'Enter your email to get an API key:', 'imagify' ),
34 'signupConfirmButtonText' => __( 'Sign Up', 'imagify' ),
35 'signupErrorEmptyEmail' => __( 'You need to specify an email!', 'imagify' ),
36 /* translators: Don't use escaped HTML entities here (like &nbsp;). */
37 'signupSuccessTitle' => __( 'Congratulations!', 'imagify' ),
38 'signupSuccessText' => __( 'Your account has been successfully created. Please check your mailbox, you are going to receive an email with API key.', 'imagify' ),
39 /* translators: Don't use escaped HTML entities here (like &nbsp;). */
40 'saveApiKeyTitle' => __( 'Connect to Imagify!', 'imagify' ),
41 'saveApiKeyText' => __( 'Paste your API key below:', 'imagify' ),
42 'saveApiKeyConfirmButtonText' => __( 'Connect me', 'imagify' ),
43 'ApiKeyErrorEmpty' => __( 'You need to specify your api key!', 'imagify' ),
44 'ApiKeyCheckSuccessTitle' => __( 'Congratulations!', 'imagify' ),
45 'ApiKeyCheckSuccessText' => __( 'Your API key is valid. You can now configure the Imagify settings to optimize your images.', 'imagify' ),
46 ],
47 ];
48
49 case 'sweetalert':
50 return [
51 'labels' => [
52 'cancelButtonText' => __( 'Cancel' ),
53 ],
54 ];
55
56 case 'options':
57 $translations = [
58 'getFilesTree' => imagify_can_optimize_custom_folders() ? get_imagify_admin_url( 'get-files-tree' ) : false,
59 'labels' => [
60 'ValidApiKeyText' => __( 'Your API key is valid.', 'imagify' ),
61 'waitApiKeyCheckText' => __( 'Check in progress...', 'imagify' ),
62 'ApiKeyCheckSuccessTitle' => __( 'Congratulations!', 'imagify' ),
63 'ApiKeyCheckSuccessText' => __( 'Your API key is valid. You can now configure the Imagify settings to optimize your images.', 'imagify' ),
64 'noBackupTitle' => __( 'Don\'t Need a Parachute?', 'imagify' ),
65 'noBackupText' => __( 'If you keep this option deactivated, you won\'t be able to re-optimize your images to another compression level and restore your original images in case of need.', 'imagify' ),
66 'removeFolder' => _x( 'Remove', 'custom folder', 'imagify' ),
67 'filesTreeTitle' => __( 'Select Folders', 'imagify' ),
68 'filesTreeSubTitle' => __( 'Select one or several folders to optimize.', 'imagify' ),
69 'cleaningInfo' => __( 'Some folders that do not contain any images are hidden.', 'imagify' ),
70 'confirmFilesTreeBtn' => __( 'Select Folders', 'imagify' ),
71 'customFilesLegend' => __( 'Choose the folders to optimize', 'imagify' ),
72 'error' => __( 'Error', 'imagify' ),
73 'themesAdded' => __( 'Added! All Good!', 'imagify' ),
74 ],
75 ];
76
77 if ( \Imagify\Stats\OptimizedMediaWithoutWebp::get_instance()->get_cached_stat() ) {
78 $contexts = imagify_get_context_names();
79 $translations['bulk'] = [
80 'curlMissing' => ! Imagify_Requirements::supports_curl(),
81 'editorMissing' => ! Imagify_Requirements::supports_image_editor(),
82 'extHttpBlocked' => Imagify_Requirements::is_imagify_blocked(),
83 'apiDown' => ! Imagify_Requirements::is_api_up(),
84 'keyIsValid' => Imagify_Requirements::is_api_key_valid(),
85 'isOverQuota' => Imagify_Requirements::is_over_quota(),
86 'imagifybeatIDs' => [
87 'queue' => $imagifybeat_actions->get_imagifybeat_id( 'bulk_optimization_status' ),
88 'requirements' => $imagifybeat_actions->get_imagifybeat_id( 'requirements' ),
89 ],
90 'ajaxActions' => [
91 'getMediaIds' => 'imagify_get_media_ids',
92 'bulkProcess' => 'imagify_bulk_optimize',
93 ],
94 'ajaxNonce' => wp_create_nonce( 'imagify-bulk-optimize' ),
95 'contexts' => $contexts,
96 'labels' => [
97 'curlMissing' => __( 'cURL is not available on the server.', 'imagify' ),
98 'editorMissing' => sprintf(
99 /* translators: %s is a "More info?" link. */
100 __( 'No php extensions are available to edit images on the server. ImageMagick or GD is required. %s', 'imagify' ),
101 '<a href="' . esc_url( imagify_get_external_url( 'documentation-imagick-gd' ) ) . '" target="_blank">' . __( 'More info?', 'imagify' ) . '</a>'
102 ),
103 'extHttpBlocked' => __( 'External HTTP requests are blocked.', 'imagify' ),
104 'apiDown' => __( 'Sorry, our servers are temporarily unavailable. Please, try again in a couple of minutes.', 'imagify' ),
105 'invalidAPIKeyTitle' => __( 'Your API key is not valid!', 'imagify' ),
106 'overQuotaTitle' => __( 'You have used all your credits!', 'imagify' ),
107 'processing' => __( 'Imagify is still processing. Are you sure you want to leave this page?', 'imagify' ),
108 'nothingToDoTitle' => __( 'Hold on!', 'imagify' ),
109 'nothingToDoText' => __( 'All your optimized images already have a WebP version. Congratulations!', 'imagify' ),
110 'nothingToDoNoBackupText' => __( 'Because the selected images did not have a backup copy, Imagify was unable to create WebP versions.', 'imagify' ),
111 'error' => __( 'Error', 'imagify' ),
112 'ajaxErrorText' => __( 'The operation failed.', 'imagify' ),
113 'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ),
114 'getUnoptimizedImagesErrorText' => __( 'An unknown error occurred when we tried to get all your unoptimized media files. Try again and if the issue still persists, please contact us!', 'imagify' ),
115 ],
116 ];
117
118 /**
119 * Filter the number of parallel queries generating WebP images by bulk method.
120 *
121 * @since 1.9
122 * @author Grégory Viguier
123 *
124 * @param int $bufferSize Number of parallel queries.
125 */
126 $translations['bulk']['bufferSize'] = apply_filters( 'imagify_bulk_generate_webp_buffer_size', 4 );
127 $translations['bulk']['bufferSize'] = max( 1, (int) $translations['bulk']['bufferSize'] );
128 }
129
130 return $translations;
131
132 case 'pricing-modal':
133 $translations = [
134 'imagify_app_domain' => IMAGIFY_APP_DOMAIN,
135 'labels' => [
136 'errorCouponAPI' => __( 'Error with checking this coupon.', 'imagify' ),
137 /* translators: 1 is a percentage, 2 is a coupon code. */
138 'successCouponAPI' => sprintf( _x( '%1$s off with %2$s', 'coupon validated', 'imagify' ), '<span class="imagify-coupon-offer"></span>', '<strong class="imagify-coupon-word"></strong>' ),
139 'errorPriceAPI' => __( 'Something went wrong with getting our updated offers. Please retry later.', 'imagify' ),
140 'defaultCouponLabel' => __( 'If you have a <strong>coupon code</strong><br> use it here:', 'imagify' ),
141 'errorCouponPlan' => __( 'This coupon is not valid with this plan.', 'imagify' ),
142 ],
143 ];
144
145 if ( Imagify_Requirements::is_api_key_valid() ) {
146 $translations['userDataCache'] = [
147 'deleteAction' => 'imagify_delete_user_data_cache',
148 'deleteNonce' => wp_create_nonce( 'imagify_delete_user_data_cache' ),
149 ];
150 }
151
152 return $translations;
153
154 case 'twentytwenty':
155 $image = [
156 'src' => '',
157 'width' => 0,
158 'height' => 0,
159 ];
160
161 if ( imagify_is_screen( 'attachment' ) && wp_attachment_is_image( $post_id ) ) {
162 $process = imagify_get_optimization_process( $post_id, 'wp' );
163
164 if ( $process->is_valid() ) {
165 $media = $process->get_media();
166
167 if ( $media->is_image() ) {
168 $dimensions = $media->get_dimensions();
169 $image = [
170 'src' => $media->get_fullsize_url(),
171 'width' => $dimensions['width'],
172 'height' => $dimensions['height'],
173 ];
174 }
175 }
176 }
177
178 return [
179 'imageSrc' => $image['src'],
180 'imageWidth' => $image['width'],
181 'imageHeight' => $image['height'],
182 'widthLimit' => 360, // See _imagify_add_actions_to_media_list_row().
183 'labels' => [
184 'filesize' => __( 'File Size:', 'imagify' ),
185 'saving' => __( 'Original Saving:', 'imagify' ),
186 'close' => __( 'Close', 'imagify' ),
187 'originalL' => __( 'Original File', 'imagify' ),
188 'optimizedL' => __( 'Optimized File', 'imagify' ),
189 'compare' => __( 'Compare Original VS Optimized', 'imagify' ),
190 'optimize' => __( 'Optimize', 'imagify' ),
191 ],
192 ];
193
194 case 'beat':
195 return \Imagify\Imagifybeat\Core::get_instance()->get_settings();
196
197 case 'media-modal':
198 return [
199 'imagifybeatID' => $imagifybeat_actions->get_imagifybeat_id( 'library_optimization_status' ),
200 ];
201
202 case 'library':
203 return [
204 'backupOption' => get_imagify_option( 'backup' ),
205 'labels' => [
206 'bulkActionsOptimize' => __( 'Optimize', 'imagify' ),
207 'bulkActionsOptimizeMissingSizes' => __( 'Optimize Missing Sizes', 'imagify' ),
208 'bulkActionsRestore' => __( 'Restore Original', 'imagify' ),
209 ],
210 ];
211
212 case 'bulk':
213 $translations = [
214 'curlMissing' => ! Imagify_Requirements::supports_curl(),
215 'editorMissing' => ! Imagify_Requirements::supports_image_editor(),
216 'extHttpBlocked' => Imagify_Requirements::is_imagify_blocked(),
217 'apiDown' => Imagify_Requirements::is_imagify_blocked() || ! Imagify_Requirements::is_api_up(),
218 'keyIsValid' => ! Imagify_Requirements::is_imagify_blocked() && Imagify_Requirements::is_api_up() && Imagify_Requirements::is_api_key_valid(),
219 'isOverQuota' => ! Imagify_Requirements::is_imagify_blocked() && Imagify_Requirements::is_api_up() && Imagify_Requirements::is_api_key_valid() && Imagify_Requirements::is_over_quota(),
220 'imagifybeatIDs' => [
221 'stats' => $imagifybeat_actions->get_imagifybeat_id( 'bulk_optimization_stats' ),
222 'queue' => $imagifybeat_actions->get_imagifybeat_id( 'bulk_optimization_status' ),
223 'requirements' => $imagifybeat_actions->get_imagifybeat_id( 'requirements' ),
224 ],
225 'waitImageUrl' => IMAGIFY_ASSETS_IMG_URL . 'popin-loader.svg',
226 'ajaxActions' => [
227 'getMediaIds' => 'imagify_get_media_ids',
228 'bulkProcess' => 'imagify_bulk_optimize',
229 'getFolderData' => 'imagify_get_folder_type_data',
230 'bulkInfoSeen' => 'imagify_bulk_info_seen',
231 ],
232 'ajaxNonce' => wp_create_nonce( 'imagify-bulk-optimize' ),
233 'bufferSizes' => [
234 'wp' => 4,
235 'custom-folders' => 4,
236 ],
237 'labels' => [
238 'overviewChartLabels' => [
239 'unoptimized' => __( 'Unoptimized', 'imagify' ),
240 'optimized' => __( 'Optimized', 'imagify' ),
241 'error' => __( 'Error', 'imagify' ),
242 ],
243 'curlMissing' => __( 'cURL is not available on the server.', 'imagify' ),
244 'editorMissing' => sprintf(
245 /* translators: %s is a "More info?" link. */
246 __( 'No php extensions are available to edit images on the server. ImageMagick or GD is required. %s', 'imagify' ),
247 '<a href="' . esc_url( imagify_get_external_url( 'documentation-imagick-gd' ) ) . '" target="_blank">' . __( 'More info?', 'imagify' ) . '</a>'
248 ),
249 'extHttpBlocked' => __( 'External HTTP requests are blocked.', 'imagify' ),
250 'apiDown' => __( 'Sorry, our servers are temporarily unavailable. Please, try again in a couple of minutes.', 'imagify' ),
251 'invalidAPIKeyTitle' => __( 'Your API key is not valid!', 'imagify' ),
252 'overQuotaTitle' => __( 'You have used all your credits!', 'imagify' ),
253 'processing' => __( 'Imagify is still processing. Are you sure you want to leave this page?', 'imagify' ),
254 'waitTitle' => __( 'Please wait...', 'imagify' ),
255 'waitText' => __( 'We are trying to get your unoptimized media files, it may take time depending on the number of files.', 'imagify' ),
256 'nothingToDoTitle' => __( 'Hold on!', 'imagify' ),
257 'nothingToDoText' => [
258 'optimize' => __( 'All your media files have been optimized by Imagify. Congratulations!', 'imagify' ),
259 'generate_webp' => __( 'All your optimized images already have a WebP version. Congratulations!', 'imagify' ),
260 ],
261 'optimizing' => __( 'Optimizing', 'imagify' ),
262 'error' => __( 'Error', 'imagify' ),
263 'ajaxErrorText' => __( 'The operation failed.', 'imagify' ),
264 'complete' => _x( 'Complete', 'adjective', 'imagify' ),
265 'alreadyOptimized' => _x( 'Already Optimized', 'file', 'imagify' ),
266 /* translators: %s is a number. Don't use %d. */
267 'nbrFiles' => __( '%s file(s)', 'imagify' ),
268 'notice' => _x( 'Notice', 'noun', 'imagify' ),
269 /* translators: %s is a number. Don't use %d. */
270 'nbrErrors' => __( '%s error(s)', 'imagify' ),
271 /* translators: 1 and 2 are file sizes. Don't use HTML entities here (like &nbsp;). */
272 'textToShare' => __( 'Discover @imagify, the new compression tool to optimize your images for free. I saved %1$s out of %2$s!', 'imagify' ),
273 'twitterShareURL' => imagify_get_external_url( 'share-twitter' ),
274 'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ),
275 'getUnoptimizedImagesErrorText' => __( 'An unknown error occurred when we tried to get all your unoptimized media files. Try again and if the issue still persists, please contact us!', 'imagify' ),
276 'waitingOtimizationsText' => __( 'Waiting other optimizations to finish.', 'imagify' ),
277 /* translators: %s is a formatted number, dont use %d. */
278 'imagesOptimizedText' => __( '%s Media File(s) Optimized', 'imagify' ),
279 /* translators: %s is a formatted number, dont use %d. */
280 'imagesErrorText' => __( '%s Error(s)', 'imagify' ),
281 'bulkInfoTitle' => __( 'Information', 'imagify' ),
282 'confirmBulk' => __( 'Start the optimization', 'imagify' ),
283 ],
284 ];
285
286 if ( get_transient( 'imagify_large_library' ) ) {
287 // On huge media libraries, don't use Imagifybeat, and fetch stats only when the process ends.
288 $translations['ajaxActions']['getStats'] = 'imagify_bulk_get_stats';
289 }
290
291 if ( isset( $translations['bufferSizes']['wp'] ) ) {
292 /**
293 * Filter the number of parallel queries during the Bulk Optimization (library).
294 *
295 * @since 1.5.4
296 * @since 1.7 Deprecated
297 * @deprecated
298 *
299 * @param int $buffer_size Number of parallel queries.
300 */
301 $translations['bufferSizes']['wp'] = apply_filters_deprecated( 'imagify_bulk_buffer_size', [ $translations['bufferSizes']['wp'] ], '1.7', 'imagify_bulk_buffer_sizes' );
302 }
303
304 /**
305 * Filter the number of parallel queries during the Bulk Optimization.
306 *
307 * @since 1.7
308 * @author Grégory Viguier
309 *
310 * @param array $buffer_sizes An array of number of parallel queries, keyed by context.
311 */
312 $translations['bufferSizes'] = apply_filters( 'imagify_bulk_buffer_sizes', $translations['bufferSizes'] );
313
314 return $translations;
315
316 case 'files-list':
317 return [
318 'backupOption' => get_imagify_option( 'backup' ),
319 'context' => 'custom-folders',
320 'imagifybeatID' => $imagifybeat_actions->get_imagifybeat_id( 'custom_folders_optimization_status' ),
321 'labels' => [
322 'bulkActionsOptimize' => __( 'Optimize', 'imagify' ),
323 'bulkActionsRestore' => __( 'Restore Original', 'imagify' ),
324 ],
325 ];
326
327 default:
328 return [];
329 } // End switch().
330 }
331