get_data(); $output = ( 'post.php' != $pagenow ) ? ''; $output .= '

' . __( 'View details', 'imagify' ) . '

'; $output .= '' : ''; // actions section $output .= ( 'post.php' != $pagenow ) ? '' : $output_before; $output .= ''; $output .= ( 'post.php' != $pagenow ) ? '' : $output_after; return $output; } /* * Get the error message for a specific attachment. * * @since 1.0 * * @param int $attachment_id The attachement ID. * @return string The output to print. */ function get_imagify_attachment_error_text( $attachment_id ) { global $pagenow; $data = get_post_meta( $attachment_id, '_imagify_data', true ); $output = ''; if ( isset( $data['sizes']['full']['success'] ) && ! $data['sizes']['full']['success'] ) { $class = ( 'post.php' !== $pagenow ) ? 'button-imagify-manual-upload' : ''; $output .= '' . $data['sizes']['full']['error'] . '
' . __( 'Try again', 'imagify' ) . ''; } return $output; } /* * Get the re-optimize link for a specific attachment. * * @since 1.0 * * @param int $attachment_id The attachement ID. * @return string The output to print. */ function get_imagify_attachment_reoptimize_link( $attachment_id ) { global $pagenow; $attachment = new Imagify_Attachment( $attachment_id ); $level = (int) $attachment->get_optimization_level(); $args = array( 'attachment_id' => $attachment_id ); $output = ''; if ( $attachment->has_backup() ) { $class = ( 'post.php' !== $pagenow ) ? 'button-imagify-manual-override-upload' : ''; // Re-optimize to Ultra if ( 1 === $level || 0 === $level ) { $args['optimization_level'] = 2; $output .= '' . sprintf( __( 'Re-Optimize to %s', 'imagify' ), __( 'Ultra', 'imagify' ) ) . ''; } // Re-optimize to Aggressive if ( 2 === $level || 0 === $level ) { $args['optimization_level'] = 1; $output .= '' . sprintf( __( 'Re-Optimize to %s', 'imagify' ), __( 'Aggressive', 'imagify' ) ) . ''; } // Re-optimize to Normal if ( 2 === $level || 1 === $level ) { $args['optimization_level'] = 0; $output .= '' . sprintf( __( 'Re-Optimize to %s', 'imagify' ), __( 'Normal', 'imagify' ) ) . ''; } } return $output; } /* * Get all data to diplay for a specific attachment. * * @since 1.2 * * @param int $attachment_id The attachement ID. * @return string The output to print. */ function get_imagify_media_column_content( $attachment_id ) { $output = ''; $attachment = new Imagify_Attachment( $attachment_id ); $attachment_ext = $attachment->get_extension(); // Check if the attachment extension is allowed if ( ! wp_attachment_is_image( $attachment_id ) ) { $output = sprintf( __( '%s can\'t be optimized', 'imagify' ), strtoupper( $attachment_ext ) ); return $output; } // Check if the API key is valid if ( ! imagify_valid_key() && ! $attachment->is_optimized() ) { $output .= __( 'Invalid API key', 'imagify' ); $output .= '
'; $output .= '' . __( 'Check your Settings', 'imagify' ) . ''; return $output; } if ( false !== get_transient( 'imagify-async-in-progress-' . $attachment_id ) ) { $output = '
' . __( 'Optimizing...', 'imagify' ) . '
'; return $output; } // Check if the image was optimized if ( ! $attachment->is_optimized() && ! $attachment->has_error() ) { $output .= '' . __( 'Optimize', 'imagify' ) . ''; return $output; } $output .= get_imagify_attachment_optimization_text( $attachment_id ); return $output; }