| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ); |
| 3 |
|
| 4 |
/** |
| 5 |
* Add a "Optimize It" button or the Imagify optimization data in the attachment submit area |
| 6 |
* |
| 7 |
* @since 1.0 |
| 8 |
*/ |
| 9 |
add_action( 'attachment_submitbox_misc_actions', '_imagify_attachment_submitbox_misc_actions', PHP_INT_MAX ); |
| 10 |
function _imagify_attachment_submitbox_misc_actions() |
| 11 |
{ |
| 12 |
/** This filter is documented in inc/admin/options.php */ |
| 13 |
if ( current_user_can( apply_filters( 'imagify_capacity', 'manage_options' ) ) ) { |
| 14 |
global $post; |
| 15 |
$attachment = new Imagify_Attachment(); |
| 16 |
|
| 17 |
if ( ! imagify_valid_key() && ! $attachment->is_optimized() ) { |
| 18 |
echo '<div class="misc-pub-section misc-pub-imagify"><h4>' . __( 'Imagify', 'imagify' ) . '</h4></div>'; |
| 19 |
echo '<div class="misc-pub-section misc-pub-imagify">'; |
| 20 |
echo __( 'Invalid API key', 'imagify' ); |
| 21 |
echo '<br/>'; |
| 22 |
echo '<a href="' . get_imagify_admin_url( 'options-general' ) . '">' . __( 'Check your Settings', 'imagify' ) . '</a>'; |
| 23 |
echo '</div>'; |
| 24 |
} elseif ( $attachment->is_optimized() || $attachment->has_error() ) { |
| 25 |
echo '<div class="misc-pub-section misc-pub-imagify"><h4>' . __( 'Imagify', 'imagify' ) . '</h4></div>'; |
| 26 |
echo get_imagify_attachment_optimization_text( $post->ID ); |
| 27 |
} else { |
| 28 |
$url = get_imagify_admin_url( 'manual-upload', $post->ID ); |
| 29 |
printf( '<div class="misc-pub-section misc-pub-imagify"><a class="button-primary" href="%s">%s</a></div>', $url, __( 'Optimize', 'imagify' ) ); |
| 30 |
} |
| 31 |
} |
| 32 |
} |