diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php index a036384a1..65cb8434a 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php @@ -3,7 +3,7 @@ * Plugin Name: Cloudinary * Plugin URI: https://cloudinary.com/documentation/wordpress_integration * Description: With the Cloudinary plugin, you can upload and manage your media assets in the cloud, then deliver them to your users through a fast content delivery network, improving your website’s loading speed and overall user experience. Apply multiple transformations and take advantage of a full digital asset management solution without leaving WordPress. - * Version: 2.0.0 + * Version: 2.0.3 * Author: Cloudinary Ltd., XWP * Author URI: https://cloudinary.com/ * License: GPLv2+ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php index 3c654d76c..cd966dc35 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php @@ -497,7 +497,6 @@ public function apply_default_transformations( array $transformations, $type = ' $global = $this->global_transformations->globals[ $type ]; $default = array(); if ( 'video' === $type ) { - $default['quality'] = 'auto'; if ( isset( $global['video_limit_bitrate'] ) && 'on' === $global['video_limit_bitrate'] ) { $default['bit_rate'] = $global['video_bitrate'] . 'k'; } @@ -1243,7 +1242,9 @@ public function get_post_meta( $post_id, $key, $single = false ) { */ public function build_cached_meta( $post_id, $key, $single ) { $data = get_post_meta( $post_id, $key, $single ); - $this->update_post_meta( $post_id, $key, $data ); + if ( '' !== $data ) { + $this->update_post_meta( $post_id, $key, $data ); + } return $data; } @@ -1266,6 +1267,23 @@ public function update_post_meta( $post_id, $key, $data ) { update_post_meta( $post_id, $key, $data ); } + /** + * Delete cloudinary metadata. + * + * @param int $post_id The attachment ID. + * @param string $key The meta key to get. + */ + public function delete_post_meta( $post_id, $key ) { + $meta_data = wp_get_attachment_metadata( $post_id, true ); + if ( is_array( $meta_data ) && isset( $meta_data[ Sync::META_KEYS['cloudinary'] ] ) && is_array( $meta_data[ Sync::META_KEYS['cloudinary'] ] ) ) { + // Only do this side if has been set before. + unset( $meta_data[ Sync::META_KEYS['cloudinary'] ][ $key ] ); + wp_update_attachment_metadata( $post_id, $meta_data ); + } + // Delete meta data. + delete_post_meta( $post_id, $key ); + } + /** * Setup the hooks and base_url if configured. */ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-rest-api.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-rest-api.php index 90314aaa3..c857cc0dd 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-rest-api.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-rest-api.php @@ -63,11 +63,12 @@ public function background_request( $endpoint, $params, $method = 'POST' ) { // Setup a call for a background sync. $params['nonce'] = wp_create_nonce( 'wp_rest' ); $args = array( - 'timeout' => 1, - 'blocking' => false, - 'method' => $method, - 'headers' => array(), - 'body' => $params, + 'timeout' => 1, + 'blocking' => false, + 'sslverify' => false, + 'method' => $method, + 'headers' => array(), + 'body' => $params, ); if ( is_user_logged_in() ) { // Setup cookie. @@ -75,7 +76,7 @@ public function background_request( $endpoint, $params, $method = 'POST' ) { array_pop( $logged_cookie ); // remove the scheme. // Add logged in cookie to request. - $args['cookies'] = array( + $args['cookies'] = array( new \WP_Http_Cookie( array( 'name' => LOGGED_IN_COOKIE, @@ -85,8 +86,9 @@ public function background_request( $endpoint, $params, $method = 'POST' ) { $url ), ); - $args['headers']['X-WP-Nonce'] = $params['nonce']; + } + $args['headers']['X-WP-Nonce'] = $params['nonce']; // Send request. wp_safe_remote_request( $url, $args ); diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index 6d740dcd7..a2bcd3745 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -48,7 +48,6 @@ class Sync implements Setup, Assets { 'transformation' => '_transformations', 'sync_error' => '_sync_error', 'cloudinary' => '_cloudinary_v2', - 'attempts' => '_sync_attempts', ); /** diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php index 7621769eb..55517a0db 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php @@ -55,19 +55,8 @@ public function check_cloudinary_version( $cloudinary_id, $attachment_id ) { */ if ( ! empty( $meta['cloudinary'] ) && empty( $public_id ) ) { $cloudinary_id = $this->convert_cloudinary_version( $attachment_id ); - } elseif ( ! empty( $meta['cloudinary'] ) ) { - // Has public ID, but still has cloudinary, check pending status. - $is_pending = $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['pending'], true ); - $attempts = (int) $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['attempts'], true ); - if ( ( empty( $is_pending ) || $is_pending < time() - 5 * 60 ) && 10 > $attempts ) { - // Timeout. - $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['attempts'], $attempts + 1 ); - - // return proposed ID to allow front render. - return $this->convert_cloudinary_version( $attachment_id ); - } - $cloudinary_id = $public_id; - } else { + } elseif ( ! empty( $public_id ) ) { + // Has public ID, but not fully down synced. $cloudinary_id = $public_id; } } @@ -117,19 +106,7 @@ function ( $val ) use ( $media ) { // Remove extension. $path = pathinfo( $public_id ); $public_id = strstr( $public_id, '.' . $path['extension'], true ); - // Save public ID. $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id ); - // Set download started data. - $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['pending'], time() ); - - // Setup a call for a background sync. - $params = array( - 'attachment_id' => $attachment_id, - 'src' => $file, - 'transformations' => $media->get_transformations_from_string( $file ), - 'filename' => basename( $file ), - ); - $media->plugin->components['api']->background_request( 'asset', $params ); return $public_id; } @@ -138,7 +115,7 @@ function ( $val ) use ( $media ) { * Setup hooks for the filters. */ public function setup_hooks() { - add_filter( 'cloudinary_id', array( $this, 'check_cloudinary_version' ), 9, 2 ); // Priority 9, to take preference over prep_on_demand_upload. + add_filter( 'cloudinary_id', array( $this, 'check_cloudinary_version' ), 10, 2 ); // Priority 10, to allow prep_on_demand_upload. // Add a redirection to the new plugin settings, from the old plugin. if ( is_admin() ) { diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-delete-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-delete-sync.php index 47387dba4..3852f38a4 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-delete-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-delete-sync.php @@ -95,7 +95,7 @@ public function delete_asset( $post_id ) { } // Next we need to check that the file is in the cloudinary folder. $parts = explode( '/', $public_id ); - $cloudinary_folder = $this->plugin->config['settings']['general']['cloudinary_folder']; + $cloudinary_folder = $this->plugin->config['settings']['sync_media']['cloudinary_folder'] ? $this->plugin->config['settings']['sync_media']['cloudinary_folder'] : ''; if ( $cloudinary_folder === $parts[0] ) { $type = $this->plugin->components['sync']->managers['push']->get_resource_type( $post_id ); $options = array( diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php index 92de295ba..cb4c9e6c6 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php @@ -72,33 +72,22 @@ public function rest_endpoints( $endpoints ) { public function rest_can_upload_files( \WP_REST_Request $request ) { // This would have been from an ajax call. Therefore verify based on capability. - if ( is_user_logged_in() ) { - return current_user_can( 'upload_files' ); - } - - // If we get here, this is a background post, which will have a bg post nonce created. - $nonce = $request->get_param( 'nonce' ); - - return wp_verify_nonce( $nonce, 'wp_rest' ); + return current_user_can( 'upload_files' ); } /** - * Handle a failed download by deleting teh temp attachment and returning the error in json. + * Handle a failed download by deleting the temp attachment and returning the error in json. * * @param int $attachment_id The attachment ID. * @param string $error The error text to return. + * + * @return \WP_Error */ public function handle_failed_download( $attachment_id, $error ) { // @todo: Place a handler to catch the error for logging. + // Delete attachment temp. + wp_delete_attachment( $attachment_id, true ); - $is_pending = $this->plugin->components['media']->get_post_meta( $attachment_id, Sync::META_KEYS['pending'], true ); - if ( ! empty( $is_pending ) ) { - // Dont delete if it's a downsync. - $this->plugin->components['media']->update_post_meta( $attachment_id, Sync::META_KEYS['sync_error'], $error ); - } else { - // Delete attachment temp. - wp_delete_attachment( $attachment_id, true ); - } // Send error. wp_send_json_error( $error ); } @@ -117,6 +106,73 @@ public function rest_download_asset( \WP_REST_Request $request ) { $file_name = $request->get_param( 'filename' ); $transformations = (array) $request->get_param( 'transformations' ); + $response = $this->download_asset( $attachment_id, $file_path, $file_name, $transformations ); + if ( is_wp_error( $response ) ) { + $this->handle_failed_download( $attachment_id, $response->get_error_message() ); + } + + return rest_ensure_response( $response ); + } + + /** + * Prepare and sync down an asset stored remotely. + * + * @param $attachment_id + * + * @return array|\WP_Error + */ + public function down_sync( $attachment_id ) { + $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); + $path = wp_parse_url( $file, PHP_URL_PATH ); + $media = $this->plugin->components['media']; + $parts = explode( '/', $path ); + $parts = array_map( + function ( $val ) use ( $media ) { + if ( empty( $val ) ) { + return false; + } + if ( $val === $media->credentials['cloud_name'] ) { + return false; + } + if ( in_array( $val, [ 'image', 'video', 'upload' ], true ) ) { + return false; + } + $transformation_maybe = $media->get_transformations_from_string( $val ); + if ( ! empty( $transformation_maybe ) ) { + return false; + } + if ( substr( $val, 0, 1 ) === 'v' && is_numeric( substr( $val, 1 ) ) ) { + return false; + } + + return $val; + }, + $parts + ); + // Build public_id. + $parts = array_filter( $parts ); + $public_id = implode( '/', $parts ); + // Remove extension. + $path = pathinfo( $public_id ); + $public_id = strstr( $public_id, '.' . $path['extension'], true ); + // Save public ID. + $media->update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id ); + + return $this->download_asset( $attachment_id, $file, basename( $file ), $media->get_transformations_from_string( $file ) ); + } + + /** + * Download an attachment source to the file system. + * + * @param int $attachment_id The attachment ID. + * @param string $file_path The path of the file. + * @param string $file_name The filename. + * @param array|null $transformations + * + * @return array|\WP_Error + */ + public function download_asset( $attachment_id, $file_path, $file_name, $transformations = null ) { + // Get the image and update the attachment. require_once ABSPATH . WPINC . '/class-http.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; @@ -128,8 +184,7 @@ public function rest_download_asset( \WP_REST_Request $request ) { // Prime a file to stream to. $upload = wp_upload_bits( $file_name, null, 'temp' ); if ( ! empty( $upload['error'] ) ) { - $this->handle_failed_download( $attachment_id, $upload['error'] ); - wp_send_json_error( $upload['error'] ); + return new \WP_Error( 'download_error', $upload['error'] ); } // If the public_id of an asset includes a file extension, a derived item will have the extension duplicated, but not in the source URL. // This creates a 404. So, instead, we get the actual file name, and use that over the file name that the source url has. @@ -145,7 +200,7 @@ public function rest_download_asset( \WP_REST_Request $request ) { ); if ( is_wp_error( $response ) ) { - $this->handle_failed_download( $attachment_id, $response->get_error_message() ); + return $response; } if ( 200 !== $response['response']['code'] ) { $header_error = wp_remote_retrieve_header( $response, 'x-cld-error' ); @@ -154,7 +209,8 @@ public function rest_download_asset( \WP_REST_Request $request ) { } else { $error = __( 'Could not download the Cloudinary asset.', 'cloudinary' ); } - $this->handle_failed_download( $attachment_id, $error ); + + return new \WP_Error( 'download_error', $error ); } // Prepare the asset. @@ -165,7 +221,7 @@ public function rest_download_asset( \WP_REST_Request $request ) { wp_update_attachment_metadata( $attachment_id, $meta ); } catch ( \Exception $e ) { - $this->handle_failed_download( $attachment_id, $e->getMessage() ); + return new \WP_Error( 'download_error', $e->getMessage() ); } $attachment = wp_prepare_attachment_for_js( $attachment_id ); @@ -189,10 +245,6 @@ public function rest_download_asset( \WP_REST_Request $request ) { 'data' => $attachment, ); - // Remove pending. - delete_post_meta( $attachment_id, Sync::META_KEYS['pending'] ); - delete_post_meta( $attachment_id, Sync::META_KEYS['sync_error'] ); - - return rest_ensure_response( $response ); + return $response; } } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index fe98e4448..f69020e31 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -210,6 +210,7 @@ public function rest_push_attachments( \WP_REST_Request $request ) { // Check if there is a Cloudinary ID in case this was synced on-demand before being processed by the queue. add_filter( 'cloudinary_on_demand_sync_enabled', '__return_false' ); // Disable the on-demand sync since we want the status. + add_filter( 'cloudinary_id', '__return_false' ); // Disable the on-demand sync since we want the status. if ( false === $this->plugin->components['media']->cloudinary_id( $post_id ) ) { $stat = $this->push_attachments( array( $post_id ) ); if ( ! empty( $stat['processed'] ) ) { @@ -307,11 +308,12 @@ private function get_sync_type( $attachment ) { /** * Prepare an attachment for upload. * - * @param int|\WP_Post $post The attachment to prepare. + * @param int|\WP_Post $post The attachment to prepare. + * @param bool $down_sync Flag to determine if a missing file starts a downsync. * * @return array|\WP_Error */ - public function prepare_upload( $post ) { + public function prepare_upload( $post, $down_sync = false ) { if ( is_numeric( $post ) ) { $post = get_post( $post ); @@ -331,9 +333,28 @@ public function prepare_upload( $post ) { $file = get_attached_file( $post->ID ); if ( empty( $file ) ) { return new \WP_Error( 'attachment_no_file', __( 'Attachment did not have a file.', 'cloudinary' ) ); + } elseif ( ! file_exists( $file ) ) { + // May be an old upload type. + $src = get_post_meta( $post->ID, '_wp_attached_file', true ); + if ( $this->plugin->components['media']->is_cloudinary_url( $src ) ) { + // Download first maybe. + if ( true === $down_sync ) { + $download = $this->plugin->components['sync']->managers['download']->down_sync( $post->ID ); + if ( is_wp_error( $download ) ) { + update_post_meta( $post->ID, Sync::META_KEYS['sync_error'], $download->get_error_message() ); + + return new \WP_Error( 'attachment_download_error', $download->get_error_message() ); + } + $file = get_attached_file( $post->ID ); + $file_size = filesize( $file ); + } else { + $file_size = 0; + } + } + } else { + $file_size = filesize( $file ); } - $file_size = filesize( $file ); $resource_type = $this->get_resource_type( $post ); $max_size = ( 'image' === $resource_type ? 'max_image_size' : 'max_video_size' ); @@ -341,7 +362,7 @@ public function prepare_upload( $post ) { $max_size_hr = size_format( $this->plugin->components['connect']->usage[ $max_size ] ); // translators: variable is file size. $error = sprintf( __( 'File size exceeds the maximum of %s. This media asset will be served from WordPress.', 'cloudinary' ), $max_size_hr ); - delete_post_meta( $post->ID, Sync::META_KEYS['pending'] ); // Remove Flag. + $this->plugin->components['media']->delete_post_meta( $post->ID, Sync::META_KEYS['pending'] ); // Remove Flag. return new \WP_Error( 'upload_error', $error ); } @@ -481,7 +502,7 @@ public function push_attachments( $attachments ) { // Go over each attachment. foreach ( $attachments as $attachment ) { $attachment = get_post( $attachment ); - $upload = $this->prepare_upload( $attachment->ID ); + $upload = $this->prepare_upload( $attachment->ID, true ); // Filter out any attachments with problematic options. if ( is_wp_error( $upload ) ) { @@ -555,8 +576,8 @@ public function push_attachments( $attachments ) { if ( ! empty( $result['version'] ) ) { $meta_data[ Sync::META_KEYS['version'] ] = $result['version']; } - delete_post_meta( $attachment->ID, Sync::META_KEYS['pending'] ); - $this->plugin->components['media']->update_post_meta( $attachment->ID, Sync::META_KEYS['sync_error'], false ); + $this->plugin->components['media']->delete_post_meta( $attachment->ID, Sync::META_KEYS['pending'] ); + $this->plugin->components['media']->delete_post_meta( $attachment->ID, Sync::META_KEYS['sync_error'], false ); if ( ! empty( $this->plugin->config['settings']['global_transformations']['enable_breakpoints'] ) ) { if ( ! empty( $result['responsive_breakpoints'] ) ) { // Images only. $meta_data[ Sync::META_KEYS['breakpoints'] ] = $result['responsive_breakpoints'][0]['breakpoints']; @@ -578,6 +599,7 @@ public function push_attachments( $attachments ) { $meta = wp_get_attachment_metadata( $attachment->ID, true ); $meta[ Sync::META_KEYS['cloudinary'] ] = $meta_data; wp_update_attachment_metadata( $attachment->ID, $meta ); + $this->plugin->components['media']->update_post_meta( $attachment->ID, Sync::META_KEYS['public_id'], $upload['options']['public_id'] ); // Search and update link references in content. $content_search = new \WP_Query( array( 's' => 'wp-image-' . $attachment->ID, 'fields' => 'ids', 'posts_per_page' => 1000 ) ); if ( ! empty( $content_search->found_posts ) ) { diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-queue.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-queue.php index df904c314..6d0b77683 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-queue.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-queue.php @@ -199,13 +199,6 @@ public function build_queue() { 'key' => Sync::META_KEYS['public_id'], 'compare' => 'NOT EXISTS', ), - array( - 'relation' => 'OR', - array( - 'key' => Sync::META_KEYS['signature'], - 'compare' => 'NOT EXISTS', - ), - ), ), 'ignore_sticky_posts' => false, 'no_found_rows' => true, diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php index d4ff3e4a1..2c4bc7f62 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php @@ -66,7 +66,7 @@ private function register_hooks() { // Add action to upload. add_action( 'add_attachment', array( $this, 'push_on_upload' ), 10 ); // Filter id for on-demand upload sync. - add_filter( 'cloudinary_id', array( $this, 'prep_on_demand_upload' ), 10, 2 ); + add_filter( 'cloudinary_id', array( $this, 'prep_on_demand_upload' ), 9, 2 ); // Show sync status. add_filter( 'cloudinary_media_status', array( $this, 'filter_status' ), 10, 2 ); // Hook for on demand upload push. @@ -119,6 +119,13 @@ public function prep_on_demand_upload( $cloudinary_id, $attachment_id ) { // Get the file size to make sure it can exist in cloudinary. if ( file_exists( $file ) && filesize( $file ) < $this->plugin->components['connect']->usage[ $max_size ] ) { $this->add_to_sync( $attachment_id ); + } else { + // Check if the src is a url. + $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); + if ( $this->plugin->components['media']->is_cloudinary_url( $file ) ) { + // Download sync. + $this->add_to_sync( $attachment_id ); + } } } } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt index dc5e236e9..3cde4c176 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt @@ -108,6 +108,15 @@ You can read the plugin [documentation](https://cloudinary.com/documentation/wor 9. Easily Configure Your Account == Changelog == += 2.0.3 (03 Apr 2020) = + * Fix migration issue + += 2.0.2 (03 Apr 2020) = + * Rollback last fix + += 2.0.1 (02 Apr 2020) = + * Fix an issue with v1 migrating + = 2.0.0 (31 Mar 2020) = * Release of a new major version of the plugin diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php index 7e3314634..2976aff2b 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php @@ -13,7 +13,7 @@ 'connect', ), 'sanitize_callback' => function ( $value ) { - if ( 'off' === $value['video_autoplay'] && 'off' === $value['video_controls'] && 'off' === $value['video_loop'] ) { + if ( 'off' === $value['video_autoplay_mode'] && 'off' === $value['video_controls'] && 'off' === $value['video_loop'] ) { return new WP_Error( 'cant_play', __( 'At least one of the video player settings must be set to "On".', 'cloudinary' ) ); } @@ -32,10 +32,10 @@ 'label' => __( 'Video player', 'cloudinary' ), 'description' => __( 'Which video player to use on all videos.', 'cloudinary' ), 'type' => 'select', - 'default' => 'cld', + 'default' => 'wp', 'choices' => array( - 'cld' => __( 'Cloudinary Player', 'cloudinary' ), 'wp' => __( 'WordPress Player', 'cloudinary' ), + 'cld' => __( 'Cloudinary Player', 'cloudinary' ), ), ), 'video_controls' => array(