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