| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); | |
| 2 | +defined( 'ABSPATH' ) || exit; | |
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Get the optimization data list for a specific media. |
| 6 | 6 | * |
| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | * @since 1.0 |
| 8 | 8 | * @since 1.9 Function signature changed. |
| 9 | 9 | * @author Jonathan Buttigieg |
| 10 | 10 | * |
| 11 | - * @param ProcessInterface $process The optimization process object. | |
| 11 | + * @param \Imagify\Optimization\Process\ProcessInterface $process The optimization process object. | |
| 12 | 12 | * @return string The output to print. |
| 13 | 13 | */ |
| 14 | 14 | function get_imagify_attachment_optimization_text( $process ) { |
| 15 | 15 | if ( ! $process->is_valid() ) { |
| @@ -17,15 +17,15 @@ | ||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | $is_media_page = Imagify_Views::get_instance()->is_media_page(); |
| 20 | 20 | $is_library_page = Imagify_Views::get_instance()->is_wp_library_page(); |
| 21 | - $output = $is_media_page ? '' : '<ul class="imagify-datas-list">'; | |
| 21 | + $output = $is_media_page ? '' : '<ul class="imagify-datas-list" id="imagify_data_sum">'; | |
| 22 | 22 | $output_before = $is_media_page ? '' : '<li class="imagify-data-item">'; |
| 23 | 23 | $output_after = $is_media_page ? '<br/>' : '</li>'; |
| 24 | 24 | $reoptimize_link = get_imagify_attachment_reoptimize_link( $process ); |
| 25 | 25 | $reoptimize_link .= get_imagify_attachment_optimize_missing_thumbnails_link( $process ); |
| 26 | - $reoptimize_link .= get_imagify_attachment_generate_webp_versions_link( $process ); | |
| 27 | - $reoptimize_link .= get_imagify_attachment_delete_webp_versions_link( $process ); | |
| 26 | + $reoptimize_link .= get_imagify_attachment_generate_nextgen_versions_link( $process ); | |
| 27 | + $reoptimize_link .= get_imagify_attachment_delete_nextgen_versions_link( $process ); | |
| 28 | 28 | $reoptimize_output = $reoptimize_link ? $reoptimize_link : ''; |
| 29 | 29 | $reoptimize_output_before = '<div class="imagify-datas-actions-links">'; |
| 30 | 30 | $reoptimize_output_after = '</div><!-- .imagify-datas-actions-links -->'; |
| 31 | 31 | $error = get_imagify_attachment_error_text( $process ); |
| @@ -41,8 +41,9 @@ | ||
| 41 | 41 | return $is_media_page ? $output_before . $error . $reoptimize_output . $output_after : $error . $reoptimize_output; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $data = $process->get_data(); |
| 45 | + $optimized_data = $data->get_optimization_data(); | |
| 45 | 46 | $attachment_id = $media->get_id(); |
| 46 | 47 | $optimization_level = imagify_get_optimization_level_label( $data->get_optimization_level() ); |
| 47 | 48 | |
| 48 | 49 | if ( ! $is_media_page ) { |
| @@ -48,8 +49,12 @@ | ||
| 48 | 49 | if ( ! $is_media_page ) { |
| 49 | 50 | $output .= $output_before . '<span class="data">' . __( 'New Filesize:', 'imagify' ) . '</span> <strong class="big">' . $data->get_optimized_size() . '</strong>' . $output_after; |
| 50 | 51 | } |
| 51 | 52 | |
| 53 | + if ( key_exists( 'message', $optimized_data ) && $optimized_data['message'] ) { | |
| 54 | + $output .= $output_before . '<span class="data">' . __( 'Convert:', 'imagify' ) . '</span> <strong class="big">' . $optimized_data['message'] . '</strong>' . $output_after; | |
| 55 | + } | |
| 56 | + | |
| 52 | 57 | $chart = ''; |
| 53 | 58 | |
| 54 | 59 | if ( ! $is_media_page ) { |
| 55 | 60 | if ( ! $is_library_page ) { |
| @@ -74,12 +79,12 @@ | ||
| 74 | 79 | if ( ! $is_media_page ) { |
| 75 | 80 | // New list. |
| 76 | 81 | $output .= '</ul>'; |
| 77 | 82 | $output .= '<p class="imagify-datas-more-action">'; |
| 78 | - $output .= '<a href="#imagify-view-details-' . $attachment_id . '" data-close="' . __( 'Close details', 'imagify' ) . '" data-open="' . __( 'View details', 'imagify' ) . '">'; | |
| 79 | - $output .= '<span class="the-text">' . __( 'View details', 'imagify' ) . '</span>'; | |
| 80 | - $output .= '<span class="dashicons dashicons-arrow-down-alt2"></span>'; | |
| 81 | - $output .= '</a>'; | |
| 83 | + $output .= '<a href="#imagify-view-details-' . $attachment_id . '" data-close="' . __( 'Close details', 'imagify' ) . '" data-open="' . __( 'View details', 'imagify' ) . '">'; | |
| 84 | + $output .= '<span class="the-text">' . __( 'View details', 'imagify' ) . '</span>'; | |
| 85 | + $output .= '<span class="dashicons dashicons-arrow-down-alt2"></span>'; | |
| 86 | + $output .= '</a>'; | |
| 82 | 87 | $output .= '</p>'; |
| 83 | 88 | $output .= '<ul id="imagify-view-details-' . $attachment_id . '" class="imagify-datas-list imagify-datas-details">'; |
| 84 | 89 | |
| 85 | 90 | // Not in metabox. |
| @@ -88,11 +93,31 @@ | ||
| 88 | 93 | |
| 89 | 94 | $output .= $output_before . '<span class="data">' . __( 'Level:', 'imagify' ) . '</span> <strong>' . $optimization_level . '</strong>' . $output_after; |
| 90 | 95 | |
| 91 | 96 | if ( $media->is_image() ) { |
| 92 | - $has_webp = $process->has_webp() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); | |
| 93 | - $output .= $output_before . '<span class="data">' . __( 'WebP generated:', 'imagify' ) . '</span> <strong class="big">' . esc_html( $has_webp ) . '</strong>' . $output_after; | |
| 97 | + $has_nextgen = $process->has_next_gen() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); | |
| 94 | 98 | |
| 99 | + if ( $process->has_next_gen() ) { | |
| 100 | + $has_nextgen = $process->is_full_next_gen() ? __( 'Yes', 'imagify' ) : __( 'Partially', 'imagify' ); | |
| 101 | + } | |
| 102 | + $output .= $output_before . '<span class="data">' . __( 'Next-Gen generated:', 'imagify' ) . '</span> <strong class="big">' . esc_html( $has_nextgen ) . '</strong>' . $output_after; | |
| 103 | + | |
| 104 | + // When the API permanently refused the conversion, show the reason it gave. | |
| 105 | + $nextgen_reason = ''; | |
| 106 | + | |
| 107 | + if ( ! empty( $optimized_data['sizes'] ) && is_array( $optimized_data['sizes'] ) ) { | |
| 108 | + foreach ( $optimized_data['sizes'] as $size_data ) { | |
| 109 | + if ( ! empty( $size_data['permanent_error'] ) && ! empty( $size_data['error'] ) ) { | |
| 110 | + $nextgen_reason = $size_data['error']; | |
| 111 | + break; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + } | |
| 115 | + | |
| 116 | + if ( $nextgen_reason ) { | |
| 117 | + $output .= $output_before . '<span class="data">' . __( 'Next-Gen status:', 'imagify' ) . '</span> <strong>' . esc_html( $nextgen_reason ) . '</strong>' . $output_after; | |
| 118 | + } | |
| 119 | + | |
| 95 | 120 | $total_optimized_thumbnails = $data->get_optimized_sizes_count(); |
| 96 | 121 | |
| 97 | 122 | if ( $total_optimized_thumbnails ) { |
| 98 | 123 | $output .= $output_before . '<span class="data">' . __( 'Thumbnails Optimized:', 'imagify' ) . '</span> <strong>' . $total_optimized_thumbnails . '</strong>' . $output_after; |
| @@ -108,19 +133,25 @@ | ||
| 108 | 133 | $output .= $reoptimize_output_before; |
| 109 | 134 | $output .= $reoptimize_output; |
| 110 | 135 | |
| 111 | 136 | if ( $media->has_backup() ) { |
| 112 | - $url = get_imagify_admin_url( 'restore', [ | |
| 113 | - 'attachment_id' => $attachment_id, | |
| 114 | - 'context' => $media->get_context(), | |
| 115 | - ] ); | |
| 137 | + $url = get_imagify_admin_url( | |
| 138 | + 'restore', | |
| 139 | + [ | |
| 140 | + 'attachment_id' => $attachment_id, | |
| 141 | + 'context' => $media->get_context(), | |
| 142 | + ] | |
| 143 | + ); | |
| 116 | 144 | |
| 117 | - $output .= Imagify_Views::get_instance()->get_template( 'button/restore', [ | |
| 118 | - 'url' => $url, | |
| 119 | - 'atts' => [ | |
| 120 | - 'class' => $is_media_page ? '' : null, | |
| 121 | - ], | |
| 122 | - ] ); | |
| 145 | + $output .= Imagify_Views::get_instance()->get_template( | |
| 146 | + 'button/restore', | |
| 147 | + [ | |
| 148 | + 'url' => $url, | |
| 149 | + 'atts' => [ | |
| 150 | + 'class' => $is_media_page ? '' : null, | |
| 151 | + ], | |
| 152 | + ] | |
| 153 | + ); | |
| 123 | 154 | |
| 124 | 155 | if ( ! $is_library_page ) { |
| 125 | 156 | $output .= '<input id="imagify-original-src" type="hidden" value="' . esc_url( $media->get_backup_url() ) . '">'; |
| 126 | 157 | $output .= '<input id="imagify-original-size" type="hidden" value="' . $data->get_original_size() . '">'; |
| @@ -162,24 +193,30 @@ | ||
| 162 | 193 | } |
| 163 | 194 | |
| 164 | 195 | $class = 'button'; |
| 165 | 196 | $media = $process->get_media(); |
| 166 | - $url = get_imagify_admin_url( 'optimize', [ | |
| 167 | - 'attachment_id' => $media->get_id(), | |
| 168 | - 'context' => $media->get_context(), | |
| 169 | - ] ); | |
| 197 | + $url = get_imagify_admin_url( | |
| 198 | + 'optimize', | |
| 199 | + [ | |
| 200 | + 'attachment_id' => $media->get_id(), | |
| 201 | + 'context' => $media->get_context(), | |
| 202 | + ] | |
| 203 | + ); | |
| 170 | 204 | |
| 171 | 205 | if ( ! Imagify_Views::get_instance()->is_media_page() ) { |
| 172 | 206 | $class .= ' button-imagify-optimize'; |
| 173 | 207 | } |
| 174 | 208 | |
| 175 | - return Imagify_Views::get_instance()->get_template( 'button/retry-optimize', [ | |
| 176 | - 'url' => $url, | |
| 177 | - 'error' => $data['sizes']['full']['error'], | |
| 178 | - 'atts' => [ | |
| 179 | - 'class' => $class, | |
| 180 | - ], | |
| 181 | - ] ); | |
| 209 | + return Imagify_Views::get_instance()->get_template( | |
| 210 | + 'button/retry-optimize', | |
| 211 | + [ | |
| 212 | + 'url' => $url, | |
| 213 | + 'error' => $data['sizes']['full']['error'], | |
| 214 | + 'atts' => [ | |
| 215 | + 'class' => $class, | |
| 216 | + ], | |
| 217 | + ] | |
| 218 | + ); | |
| 182 | 219 | } |
| 183 | 220 | |
| 184 | 221 | /** |
| 185 | 222 | * Get the re-optimize link for a specific attachment. |
| @@ -231,22 +268,20 @@ | ||
| 231 | 268 | 'class' => '', |
| 232 | 269 | ]; |
| 233 | 270 | } |
| 234 | 271 | |
| 235 | - foreach ( [ 2, 1, 0 ] as $level ) { | |
| 236 | - /** | |
| 237 | - * Display a link if: | |
| 238 | - * - the level is lower than the one used to optimize the media, | |
| 239 | - * - or, the level is higher and the media is not already optimized. | |
| 240 | - */ | |
| 241 | - if ( $media_level < $level || ( $media_level > $level && ! $is_already_optimized ) ) { | |
| 242 | - $url_args['optimization_level'] = $level; | |
| 243 | - $data['optimization_level'] = $level; | |
| 244 | - $data['url'] = get_imagify_admin_url( 'manual-reoptimize', $url_args ); | |
| 272 | + if ( $media_level < 1 ) { | |
| 273 | + $url_args['optimization_level'] = 2; | |
| 274 | + $data['optimization_level'] = 2; | |
| 275 | + $data['url'] = get_imagify_admin_url( 'manual-reoptimize', $url_args ); | |
| 245 | 276 | |
| 246 | - $output .= $views->get_template( 'button/re-optimize', $data ); | |
| 247 | - $output .= '<br/>'; | |
| 248 | - } | |
| 277 | + $output .= $views->get_template( 'button/re-optimize', $data ); | |
| 278 | + } elseif ( $media_level > 0 ) { | |
| 279 | + $url_args['optimization_level'] = 0; | |
| 280 | + $data['optimization_level'] = 0; | |
| 281 | + $data['url'] = get_imagify_admin_url( 'manual-reoptimize', $url_args ); | |
| 282 | + | |
| 283 | + $output .= $views->get_template( 'button/re-optimize', $data ); | |
| 249 | 284 | } |
| 250 | 285 | |
| 251 | 286 | return $output; |
| 252 | 287 | } |
| @@ -297,34 +332,42 @@ | ||
| 297 | 332 | if ( ! $missing_sizes || is_wp_error( $missing_sizes ) ) { |
| 298 | 333 | return ''; |
| 299 | 334 | } |
| 300 | 335 | |
| 301 | - $url = get_imagify_admin_url( 'optimize-missing-sizes', [ | |
| 302 | - 'attachment_id' => $media->get_id(), | |
| 303 | - 'context' => $context, | |
| 304 | - ] ); | |
| 336 | + $url = get_imagify_admin_url( | |
| 337 | + 'optimize-missing-sizes', | |
| 338 | + [ | |
| 339 | + 'attachment_id' => $media->get_id(), | |
| 340 | + 'context' => $context, | |
| 341 | + ] | |
| 342 | + ); | |
| 305 | 343 | |
| 306 | - return Imagify_Views::get_instance()->get_template( 'button/optimize-missing-sizes', [ | |
| 307 | - 'url' => $url, | |
| 308 | - 'count' => count( $missing_sizes ), | |
| 309 | - ] ); | |
| 344 | + return Imagify_Views::get_instance()->get_template( | |
| 345 | + 'button/optimize-missing-sizes', | |
| 346 | + [ | |
| 347 | + 'url' => $url, | |
| 348 | + 'count' => count( $missing_sizes ), | |
| 349 | + ] | |
| 350 | + ); | |
| 310 | 351 | } |
| 311 | 352 | |
| 312 | 353 | /** |
| 313 | - * Get the link to generate WebP versions if they are missing. | |
| 354 | + * Get the link to generate next-gen versions if they are missing. | |
| 314 | 355 | * |
| 315 | - * @since 1.9 | |
| 316 | - * @author Grégory Viguier | |
| 356 | + * @since 1.9 | |
| 317 | 357 | * |
| 318 | - * @param ProcessInterface $process The optimization process object. | |
| 319 | - * @return string The output to print. | |
| 358 | + * @param ProcessInterface $process The optimization process object. | |
| 359 | + * | |
| 360 | + * @return string The output to print. | |
| 320 | 361 | */ |
| 321 | -function get_imagify_attachment_generate_webp_versions_link( $process ) { | |
| 362 | +function get_imagify_attachment_generate_nextgen_versions_link( $process ) { | |
| 322 | 363 | if ( ! $process->is_valid() ) { |
| 323 | 364 | return ''; |
| 324 | 365 | } |
| 325 | 366 | |
| 326 | - if ( ! get_imagify_option( 'convert_to_webp' ) ) { | |
| 367 | + $formats = imagify_nextgen_images_formats(); | |
| 368 | + | |
| 369 | + if ( empty( $formats ) ) { | |
| 327 | 370 | return ''; |
| 328 | 371 | } |
| 329 | 372 | |
| 330 | 373 | $media = $process->get_media(); |
| @@ -332,8 +375,20 @@ | ||
| 332 | 375 | if ( ! $media->is_image() || ! Imagify_Requirements::is_api_key_valid() || ! $media->has_backup() ) { |
| 333 | 376 | return ''; |
| 334 | 377 | } |
| 335 | 378 | |
| 379 | + $format = get_imagify_option( 'optimization_format' ); | |
| 380 | + | |
| 381 | + if ( | |
| 382 | + 'avif' === $format | |
| 383 | + && | |
| 384 | + 'image/avif' === $media->get_mime_type() | |
| 385 | + ) { | |
| 386 | + return ''; | |
| 387 | + } elseif ( 'image/webp' === $media->get_mime_type() ) { | |
| 388 | + return ''; | |
| 389 | + } | |
| 390 | + | |
| 336 | 391 | $data = $process->get_data(); |
| 337 | 392 | |
| 338 | 393 | if ( ! $data->is_optimized() && ! $data->is_already_optimized() ) { |
| 339 | 394 | return ''; |
| @@ -338,16 +393,18 @@ | ||
| 338 | 393 | if ( ! $data->is_optimized() && ! $data->is_already_optimized() ) { |
| 339 | 394 | return ''; |
| 340 | 395 | } |
| 341 | 396 | |
| 342 | - if ( $process->has_webp() ) { | |
| 397 | + if ( $process->has_next_gen() ) { | |
| 343 | 398 | return ''; |
| 344 | 399 | } |
| 345 | 400 | |
| 346 | 401 | $context = $media->get_context(); |
| 347 | 402 | |
| 403 | + $display = apply_filters_deprecated( 'imagify_display_generate_webp_versions_link', [ true, $process, $context ], '2.2', 'imagify_display_generate_next_gen_versions_link' ); | |
| 404 | + | |
| 348 | 405 | /** |
| 349 | - * Allow to not display the "Generate WebP versions" link. | |
| 406 | + * Allow to not display the "Generate next-gen versions" link. | |
| 350 | 407 | * |
| 351 | 408 | * @since 1.9 |
| 352 | 409 | * @author Grégory Viguier |
| 353 | 410 | * |
| @@ -354,9 +411,9 @@ | ||
| 354 | 411 | * @param bool $display True to display the link. False to not display it. |
| 355 | 412 | * @param ProcessInterface $process The optimization process object. |
| 356 | 413 | * @param string $context The context. |
| 357 | 414 | */ |
| 358 | - $display = apply_filters( 'imagify_display_generate_webp_versions_link', true, $process, $context ); | |
| 415 | + $display = apply_filters( 'imagify_display_generate_next_gen_versions_link', $display, $process, $context ); | |
| 359 | 416 | |
| 360 | 417 | // Stop the process if the filter is false. |
| 361 | 418 | if ( ! $display ) { |
| 362 | 419 | return ''; |
| @@ -361,22 +418,28 @@ | ||
| 361 | 418 | if ( ! $display ) { |
| 362 | 419 | return ''; |
| 363 | 420 | } |
| 364 | 421 | |
| 365 | - $url = get_imagify_admin_url( 'generate-webp-versions', [ | |
| 366 | - 'attachment_id' => $media->get_id(), | |
| 367 | - 'context' => $context, | |
| 368 | - ] ); | |
| 422 | + $url = get_imagify_admin_url( | |
| 423 | + 'generate-nextgen-versions', | |
| 424 | + [ | |
| 425 | + 'attachment_id' => $media->get_id(), | |
| 426 | + 'context' => $context, | |
| 427 | + ] | |
| 428 | + ); | |
| 369 | 429 | |
| 370 | - $output = Imagify_Views::get_instance()->get_template( 'button/generate-webp', [ | |
| 371 | - 'url' => $url, | |
| 372 | - ] ); | |
| 430 | + $output = Imagify_Views::get_instance()->get_template( | |
| 431 | + 'button/generate-webp', | |
| 432 | + [ | |
| 433 | + 'url' => $url, | |
| 434 | + ] | |
| 435 | + ); | |
| 373 | 436 | |
| 374 | 437 | return $output . '<br/>'; |
| 375 | 438 | } |
| 376 | 439 | |
| 377 | 440 | /** |
| 378 | - * Get the link to delete WebP versions when the status is "already_optimized". | |
| 441 | + * Get the link to delete next-gen versions when the status is "already_optimized". | |
| 379 | 442 | * |
| 380 | 443 | * @since 1.9.6 |
| 381 | 444 | * @author Grégory Viguier |
| 382 | 445 | * |
| @@ -382,9 +445,9 @@ | ||
| 382 | 445 | * |
| 383 | 446 | * @param ProcessInterface $process The optimization process object. |
| 384 | 447 | * @return string The output to print. |
| 385 | 448 | */ |
| 386 | -function get_imagify_attachment_delete_webp_versions_link( $process ) { | |
| 449 | +function get_imagify_attachment_delete_nextgen_versions_link( $process ) { | |
| 387 | 450 | if ( ! $process->is_valid() ) { |
| 388 | 451 | return ''; |
| 389 | 452 | } |
| 390 | 453 | |
| @@ -397,28 +460,34 @@ | ||
| 397 | 460 | } |
| 398 | 461 | |
| 399 | 462 | $data = $process->get_data(); |
| 400 | 463 | |
| 401 | - if ( ! $data->is_already_optimized() || ! $process->has_webp() ) { | |
| 464 | + if ( ! $data->is_already_optimized() || ! $process->has_next_gen() ) { | |
| 402 | 465 | return ''; |
| 403 | 466 | } |
| 404 | 467 | |
| 405 | 468 | $class = ''; |
| 406 | - $url = get_imagify_admin_url( 'delete-webp-versions', [ | |
| 407 | - 'attachment_id' => $media_id, | |
| 408 | - 'context' => $context, | |
| 409 | - ] ); | |
| 469 | + $url = get_imagify_admin_url( | |
| 470 | + 'delete-nextgen-versions', | |
| 471 | + [ | |
| 472 | + 'attachment_id' => $media_id, | |
| 473 | + 'context' => $context, | |
| 474 | + ] | |
| 475 | + ); | |
| 410 | 476 | |
| 411 | 477 | if ( ! Imagify_Views::get_instance()->is_media_page() ) { |
| 412 | 478 | $class .= 'button-imagify-delete-webp'; |
| 413 | 479 | } |
| 414 | 480 | |
| 415 | - return Imagify_Views::get_instance()->get_template( 'button/delete-webp', [ | |
| 416 | - 'url' => $url, | |
| 417 | - 'atts' => [ | |
| 418 | - 'class' => $class, | |
| 419 | - ], | |
| 420 | - ] ); | |
| 481 | + return Imagify_Views::get_instance()->get_template( | |
| 482 | + 'button/delete-webp', | |
| 483 | + [ | |
| 484 | + 'url' => $url, | |
| 485 | + 'atts' => [ | |
| 486 | + 'class' => $class, | |
| 487 | + ], | |
| 488 | + ] | |
| 489 | + ); | |
| 421 | 490 | } |
| 422 | 491 | |
| 423 | 492 | /** |
| 424 | 493 | * Get all data to diplay for a specific media. |
| @@ -426,11 +495,12 @@ | ||
| 426 | 495 | * @since 1.2 |
| 427 | 496 | * @since 1.9 Function signature changed. |
| 428 | 497 | * @author Jonathan Buttigieg |
| 429 | 498 | * |
| 430 | - * @param ProcessInterface $process The optimization process object. | |
| 431 | - * @param bool $with_container Set to false to not return the HTML container. | |
| 432 | - * @return string The output to print. | |
| 499 | + * @param \Imagify\Optimization\Process\ProcessInterface $process The optimization process object. | |
| 500 | + * @param bool $with_container Set to false to not return the HTML container. | |
| 501 | + * | |
| 502 | + * @return string The output to print. | |
| 433 | 503 | */ |
| 434 | 504 | function get_imagify_media_column_content( $process, $with_container = true ) { |
| 435 | 505 | if ( ! $process->is_valid() ) { |
| 436 | 506 | return __( 'This media is not valid.', 'imagify' ); |
| @@ -479,26 +549,38 @@ | ||
| 479 | 549 | $lock_label = __( 'Processing...', 'imagify' ); |
| 480 | 550 | } |
| 481 | 551 | |
| 482 | 552 | if ( ! $with_container ) { |
| 483 | - return $views->get_template( 'button/processing', [ 'label' => $lock_label ] ); | |
| 553 | + return $views->get_template( | |
| 554 | + 'button/processing', | |
| 555 | + [ 'label' => $lock_label ] | |
| 556 | + ); | |
| 484 | 557 | } |
| 485 | 558 | |
| 486 | - return $views->get_template( 'container/data-actions', [ | |
| 487 | - 'media_id' => $media_id, | |
| 488 | - 'context' => $context, | |
| 489 | - 'content' => $views->get_template( 'button/processing', [ 'label' => $lock_label ] ), | |
| 490 | - ] ); | |
| 559 | + return $views->get_template( | |
| 560 | + 'container/data-actions', | |
| 561 | + [ | |
| 562 | + 'media_id' => $media_id, | |
| 563 | + 'context' => $context, | |
| 564 | + 'content' => $views->get_template( 'button/processing', [ 'label' => $lock_label ] ), | |
| 565 | + ] | |
| 566 | + ); | |
| 491 | 567 | } |
| 492 | 568 | |
| 493 | 569 | // Check if the image was optimized. |
| 494 | 570 | if ( ! $data->get_optimization_status() ) { |
| 495 | - $output = Imagify_Views::get_instance()->get_template( 'button/optimize', [ | |
| 496 | - 'url' => get_imagify_admin_url( 'manual-optimize', [ | |
| 497 | - 'attachment_id' => $media_id, | |
| 498 | - 'context' => $context, | |
| 499 | - ] ), | |
| 500 | - ] ); | |
| 571 | + $output = Imagify_Views::get_instance()->get_template( | |
| 572 | + 'button/optimize', | |
| 573 | + [ | |
| 574 | + 'url' => get_imagify_admin_url( | |
| 575 | + 'manual-optimize', | |
| 576 | + [ | |
| 577 | + 'attachment_id' => $media_id, | |
| 578 | + 'context' => $context, | |
| 579 | + ] | |
| 580 | + ), | |
| 581 | + ] | |
| 582 | + ); | |
| 501 | 583 | |
| 502 | 584 | if ( $media->has_backup() ) { |
| 503 | 585 | $output .= '<span class="attachment-has-backup hidden"></span>'; |
| 504 | 586 | } |
| @@ -509,10 +591,13 @@ | ||
| 509 | 591 | if ( ! $with_container ) { |
| 510 | 592 | return $output; |
| 511 | 593 | } |
| 512 | 594 | |
| 513 | - return $views->get_template( 'container/data-actions', [ | |
| 514 | - 'media_id' => $media_id, | |
| 515 | - 'context' => $context, | |
| 516 | - 'content' => $output, | |
| 517 | - ] ); | |
| 595 | + return $views->get_template( | |
| 596 | + 'container/data-actions', | |
| 597 | + [ | |
| 598 | + 'media_id' => $media_id, | |
| 599 | + 'context' => $context, | |
| 600 | + 'content' => $output, | |
| 601 | + ] | |
| 602 | + ); | |
| 518 | 603 | } |