is_valid() || ! $attachment->is_image() ) { wp_send_json_error(); } // Optimize. $attachment->reoptimize_thumbnails( wp_unslash( $_POST['sizes'] ) ); // Put the optimized original file back. $this->put_optimized_file_back( $attachment_id ); wp_send_json_success(); } /** * Set the Imagify attachment. * * @since 1.7.1 * @since 1.9 Deprecated. * @access protected * @author Grégory Viguier * @deprecated * * @param int $attachment_id Attachment ID. * @return object|false An Imagify attachment object. False on failure. */ protected function set_attachment( $attachment_id ) { _deprecated_function( get_class( $this ) . '::' . __FUNCTION__ . '()', '1.9', '\\Imagify\\ThirdParty\\RegenerateThumbnails\\Main::get_instance()->set_process()' ); if ( ! $attachment_id || ! Imagify_Requirements::is_api_key_valid() ) { return false; } $attachment = get_imagify_attachment( 'wp', $attachment_id, 'regenerate_thumbnails' ); if ( ! $attachment->is_valid() || ! $attachment->is_image() || ! $attachment->is_optimized() ) { return false; } // This attachment can be optimized. $this->attachments[ $attachment_id ] = $attachment; return $this->attachments[ $attachment_id ]; } /** * Unset the Imagify attachment. * * @since 1.7.1 * @since 1.9 Deprecated. * @access protected * @author Grégory Viguier * @deprecated * * @param int $attachment_id Attachment ID. */ protected function unset_attachment( $attachment_id ) { _deprecated_function( get_class( $this ) . '::' . __FUNCTION__ . '()', '1.9', '\\Imagify\\ThirdParty\\RegenerateThumbnails\\Main::get_instance()->unset_process()' ); unset( $this->attachments[ $attachment_id ] ); } /** * Get the Imagify attachment. * * @since 1.7.1 * @since 1.9 Deprecated. * @access protected * @author Grégory Viguier * @deprecated * * @param int $attachment_id Attachment ID. * @return object|false An Imagify attachment object. False on failure. */ protected function get_attachment( $attachment_id ) { _deprecated_function( get_class( $this ) . '::' . __FUNCTION__ . '()', '1.9', '\\Imagify\\ThirdParty\\RegenerateThumbnails\\Main::get_instance()->get_process()' ); return ! empty( $this->attachments[ $attachment_id ] ) ? $this->attachments[ $attachment_id ] : false; } /** * Get the name of the nonce used for the ajax callback. * * @since 1.7.1 * @since 1.9 Deprecated. * @access public * @author Grégory Viguier * @deprecated * * @param int $media_id The media ID. * @param string $context The context. * @return string */ public static function get_nonce_name( $media_id, $context ) { _deprecated_function( get_called_class() . '::' . __FUNCTION__ . '()', '1.9' ); return static::ACTION . '-' . $media_id . '-' . $context; } }