id; $data = $attachment->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 * @author Jonathan Buttigieg * * @param object $attachment The attachement object. * @return string The output to print. */ function get_imagify_attachment_error_text( $attachment, $context = 'wp' ) { global $pagenow; $attachment_id = $attachment->id; $data = $attachment->get_data(); $output = ''; $args = array( 'attachment_id' => $attachment_id, 'context' => $context ); 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 * @author Jonathan Buttigieg * * @param int $attachment_id The attachement ID. * @return string The output to print. */ function get_imagify_attachment_reoptimize_link( $attachment, $context = 'wp' ) { global $pagenow; $attachment_id = $attachment->id; $level = (int) $attachment->get_optimization_level(); $args = array( 'attachment_id' => $attachment_id, 'context' => $context ); $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 * @author Jonathan Buttigieg * * @param object $attachment The attachement object. * @return string The output to print. */ function get_imagify_media_column_content( $attachment, $context = 'wp' ) { $attachment_id = $attachment->id; $attachment_ext = $attachment->get_extension(); $output = ''; // Check if the attachment extension is allowed if ( 'wp' === $context && ! 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; } $transient_context = ( 'wp' !== $context ) ? strtolower( $context ) . '-' : ''; $transient_name = 'imagify-' . $transient_context . 'async-in-progress-' . $attachment_id; if ( false !== get_transient( $transient_name ) ) { $output = '
' . __( 'Optimizing...', 'imagify' ) . '
'; return $output; } // Check if the image was optimized if ( ! $attachment->is_optimized() && ! $attachment->has_error() ) { $args = array( 'attachment_id' => $attachment_id, 'context' => $context ); $output .= '' . __( 'Optimize', 'imagify' ) . ''; return $output; } $output .= get_imagify_attachment_optimization_text( $attachment, $context ); return $output; } /** * Add a small section with button * * @return string HTML * * @since 1.5 * @author Geoffrey * * @todo add only for no-payable users? */ function get_imagify_new_to_imagify() { if ( apply_filters( 'imagify_show_new_to_imagify', true ) ) { return '

' . esc_html__( 'You\'re new to Imagify?', 'imagify' ) . '

' . esc_html__( 'Let us help you by analyzing your existing images and determinate the best plan for you', 'imagify' ) . '

'; } } /** * Return the formatted price present in pricing tables * * @param float $value the price value * @return string the markuped price * * @since 1.5 * @author Geoffrey */ function get_imagify_price_table_format( $value ) { $v = explode( '.', (string) $value ); return '' . $v[0] . ' .' . ( strlen( $v[1] ) === 1 ? $v[1] . '0' : $v[1] ) . ''; } /** * Return the payment modal HTML * @return string HTML code for payement modal * * @since 1.5 * @author Geoffrey */ function imagify_payment_modal() { ?>