Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0d5a058
Merge branch 'master' into develop
Jun 19, 2023
4e594ae
update title
bruckercloud Jun 19, 2023
dc35023
Merge branch 'master' into uat
Jun 19, 2023
4e4280c
Improve readability
Jul 11, 2023
f61f315
Ignore veted rules
Jul 11, 2023
773a9a0
Fix indentation
Jul 11, 2023
fb749d2
Leverage cache while converting attachment url to post id
Jul 11, 2023
7a31a29
Improve the code logic
Jul 11, 2023
ea55b9e
On VIP only the temp and uploads folder are writtable, so lets ensure…
Jul 11, 2023
c40a695
Improve the code logic
Jul 11, 2023
77f6611
Increase sensibility of PHPCS to match WPVIP
Jul 11, 2023
eb5e749
Update dependencies
Jul 11, 2023
4379c64
Bump word-wrap from 1.2.3 to 1.2.4
dependabot[bot] Jul 19, 2023
2d3b172
Merge pull request #891 from cloudinary/dependabot/npm_and_yarn/word-…
pereirinha Jul 31, 2023
51fc5a2
Declare variable
Aug 14, 2023
5f5def1
Fix the cache logic to get attachment ID from URl
Aug 21, 2023
f869ee2
Merge pull request #895 from cloudinary/fix/php-8.2-warning
pereirinha Aug 21, 2023
6f235bc
Merge pull request #893 from cloudinary/fix/vip-feedback
pereirinha Aug 22, 2023
506f8e2
Merge branch 'develop' into uat
Aug 22, 2023
0809816
Bump plugin version
Aug 22, 2023
8640eb0
Update translation template
Aug 22, 2023
2a24450
The property needs to be public as it is used in other parts of the code
Aug 22, 2023
27feeb9
Bump plugin version
Aug 22, 2023
b368627
Merge pull request #898 from cloudinary/fix/protected-property
pereirinha Aug 22, 2023
53fe2e9
version 3.1.4
bruckercloud Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.1.4
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
},
"require-dev": {
"wp-coding-standards/wpcs": "^2.3",
"automattic/vipwpcs": "^2.2",
"automattic/vipwpcs": "dev-develop",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpcompatibility/phpcompatibility-wp": "dev-master",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99"
},
"config": {
Expand Down
129 changes: 69 additions & 60 deletions composer.lock

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions languages/cloudinary.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Cloudinary STABLETAG\n"
"Report-Msgid-Bugs-To: https://github.com/cloudinary/cloudinary_wordpress\n"
"POT-Creation-Date: 2023-06-15 08:49:55+00:00\n"
"POT-Creation-Date: 2023-08-22 09:32:35+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down Expand Up @@ -63,11 +63,11 @@ msgstr[1] ""
msgid "No items found."
msgstr ""

#: php/cache/class-cache-point.php:958 php/class-assets.php:1142
#: php/cache/class-cache-point.php:962 php/class-assets.php:1142
msgid "Cloudinary Asset"
msgstr ""

#: php/cache/class-cache-point.php:959 php/class-assets.php:1143
#: php/cache/class-cache-point.php:963 php/class-assets.php:1143
msgid "Post type to represent a non-media library asset."
msgstr ""

Expand Down Expand Up @@ -502,66 +502,66 @@ msgstr ""
msgid "Unsynced"
msgstr ""

#: php/class-media.php:453
#: php/class-media.php:455
#. translators: variable is file size.
msgid ""
"File size exceeds the maximum of %s. This media asset will be served from "
"WordPress."
msgstr ""

#: php/class-media.php:2033
#: php/class-media.php:2035
msgid "Import"
msgstr ""

#. Plugin Name of the plugin/theme
msgid "Cloudinary"
msgstr ""

#: php/class-media.php:2389
#: php/class-media.php:2391
msgid "The delivery for this asset is disabled."
msgstr ""

#: php/class-media.php:2393
#: php/class-media.php:2395
msgid "Not syncable. This is an external media."
msgstr ""

#: php/class-media.php:2397
#: php/class-media.php:2399
msgid "This media is Fetch type."
msgstr ""

#: php/class-media.php:2401
#: php/class-media.php:2403
msgid "This media is Sprite type."
msgstr ""

#: php/class-media.php:2411
#: php/class-media.php:2413
msgid "Not Synced"
msgstr ""

#: php/class-media.php:2416
#: php/class-media.php:2418
msgid "Synced"
msgstr ""

#: php/class-media.php:3057
#: php/class-media.php:3061
msgid "No Cloudinary filters"
msgstr ""

#: php/class-media.php:3157
#: php/class-media.php:3161
msgid "Media Settings"
msgstr ""

#: php/class-media.php:3160
#: php/class-media.php:3164
msgid "Media Display"
msgstr ""

#: php/class-media.php:3164 php/media/class-global-transformations.php:620
#: php/class-media.php:3168 php/media/class-global-transformations.php:620
#: php/ui/component/class-asset-preview.php:73
#: php/ui/component/class-plan-details.php:119
#: php/ui/component/class-plan-status.php:128
#: ui-definitions/settings-sidebar.php:36
msgid "Transformations"
msgstr ""

#: php/class-media.php:3165
#: php/class-media.php:3169
msgid ""
"Cloudinary allows you to easily transform your images on-the-fly to any "
"required format, style and dimension, and also optimizes images for minimal "
Expand All @@ -570,12 +570,12 @@ msgid ""
"transformation and delivery URLs."
msgstr ""

#: php/class-media.php:3170 ui-definitions/settings-image.php:164
#: php/class-media.php:3174 ui-definitions/settings-image.php:164
#: ui-definitions/settings-video.php:216
msgid "See examples"
msgstr ""

#: php/class-plugin.php:755
#: php/class-plugin.php:762
msgid "Visit plugin site"
msgstr ""

Expand Down Expand Up @@ -1100,26 +1100,26 @@ msgstr ""
msgid "No posts"
msgstr ""

#: php/sync/class-sync-queue.php:560
#: php/sync/class-sync-queue.php:561
#. translators: variable is queue type.
msgid "Stopping queue: %s."
msgstr ""

#: php/sync/class-sync-queue.php:599
#: php/sync/class-sync-queue.php:600
#. translators: variable is queue type.
msgid "Queue: %s - not running."
msgstr ""

#: php/sync/class-sync-queue.php:651
#: php/sync/class-sync-queue.php:652
#. translators: variable is thread name.
msgid "Starting thread %s."
msgstr ""

#: php/sync/class-sync-queue.php:905
#: php/sync/class-sync-queue.php:906
msgid "Resuming Maybe"
msgstr ""

#: php/sync/class-sync-queue.php:914
#: php/sync/class-sync-queue.php:915
#. translators: variable is thread name.
msgid "Thread %s Stopped."
msgstr ""
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions php/cache/class-cache-point.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,13 @@ public function query_cached_items( $urls ) {
foreach ( $indexes as $key ) {
$url = $urls[ $key ];

if ( ! isset( $meta[ self::META_KEYS['cached_urls'] ][ $url ] )
|| $url === $meta[ self::META_KEYS['cached_urls'] ][ $url ]
&& $meta[ self::META_KEYS['last_updated'] ] < time() - MINUTE_IN_SECONDS * 10 ) {
if (
! isset( $meta[ self::META_KEYS['cached_urls'] ][ $url ] )
|| (
$url === $meta[ self::META_KEYS['cached_urls'] ][ $url ]
&& $meta[ self::META_KEYS['last_updated'] ] < time() - MINUTE_IN_SECONDS * 10
)
) {
// Send to upload prep.
$this->prepare_for_sync( $post->ID );
$meta[ self::META_KEYS['cached_urls'] ][ $url ] = $url;
Expand Down Expand Up @@ -972,6 +976,6 @@ protected function register_post_type() {
'rewrite' => false,
'capability_type' => 'page',
);
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args );
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args ); // phpcs:ignore WordPress.NamingConventions.ValidPostTypeSlug.NotStringLiteral
}
}
2 changes: 1 addition & 1 deletion php/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ protected function register_post_type() {
'rewrite' => false,
'capability_type' => 'page',
);
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args );
$this->post_type = register_post_type( self::POST_TYPE_SLUG, $args ); // phpcs:ignore WordPress.NamingConventions.ValidPostTypeSlug.NotStringLiteral
}

/**
Expand Down
10 changes: 7 additions & 3 deletions php/class-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ public function maybe_file_exist_in_url( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return false;
}
// phpcs:disable WordPress.WP.AlternativeFunctions
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_NOBODY, true );
curl_exec( $ch );
Expand All @@ -368,6 +369,7 @@ public function maybe_file_exist_in_url( $url ) {
}

curl_close( $ch );
// phpcs:enable

return $status;
}
Expand Down Expand Up @@ -990,8 +992,8 @@ public function get_transformations( $attachment_id, $transformations = array(),
*/
public function get_crop_transformations( $attachment_id, $size ) {
static $transformations = array();
$size_dim = $size['width'] . 'x' . $size['height'];
$key = $attachment_id . $size_dim;
$size_dim = $size['width'] . 'x' . $size['height'];
$key = $attachment_id . $size_dim;
if ( empty( $transformations[ $key ] ) ) {

if ( empty( $size['transformation'] ) ) {
Expand Down Expand Up @@ -3033,13 +3035,15 @@ public function apply_media_library_filters( $query ) {
if ( SYNC::META_KEYS['unsynced'] === $request ) {
global $wpdb;
$wpdb->cld_table = Utils::get_relationship_table();
$result = $wpdb->get_col( "SELECT post_id FROM $wpdb->cld_table WHERE public_id IS NULL" );
$result = $wpdb->get_col( "SELECT post_id FROM $wpdb->cld_table WHERE public_id IS NULL" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching

// phpcs:disable WordPressVIPMinimum.Hooks.PreGetPosts.PreGetPosts
if ( ! empty( $result ) ) {
$query->set( 'post__in', $result );
} else {
$query->set( 'post__in', array( 0 ) );
}
// phpcs:enable
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion php/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ final class Plugin {
*/
public $dir_url;

/**
* The plugin file.
*
* @var string
*/
public $plugin_file;

/**
* Directory in plugin containing autoloaded classes.
*
Expand Down Expand Up @@ -190,7 +197,7 @@ private function get_settings_page_structure() {

foreach ( $parts as $slug => $part ) {
if ( file_exists( $this->dir_path . "ui-definitions/settings-{$slug}.php" ) ) {
$parts[ $slug ] = include $this->dir_path . "ui-definitions/settings-{$slug}.php";
$parts[ $slug ] = include $this->dir_path . "ui-definitions/settings-{$slug}.php"; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
}
}

Expand Down
2 changes: 1 addition & 1 deletion php/class-report.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static function( &$row ) {
"SELECT * FROM {$wpdb->cld_table} WHERE post_id = %d;",
$post->ID
);
$relationship = $wpdb->get_row( $prepare ); // phpcs:ignore WordPress.DB.PreparedSQL
$relationship = $wpdb->get_row( $prepare ); // phpcs:ignore WordPress.DB.PreparedSQL,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching

ksort( $attachment );
ksort( $meta );
Expand Down
2 changes: 1 addition & 1 deletion php/class-string-replace.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function init_debug( $template ) {
if ( defined( 'CLD_DEBUG' ) && true === CLD_DEBUG && ! Utils::get_sanitized_text( '_bypass' ) ) {
$this->context = 'view';
ob_start();
include $template;
include $template; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
$html = ob_get_clean();
echo $this->replace_strings( $html ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$template = $this->plugin->template_path . 'blank-template.php';
Expand Down
26 changes: 25 additions & 1 deletion php/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public static function pathinfo( $path, $flags = 15 ) {
*
* @see wp-includes/formatting.php
*/
$path = str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) );
$path = str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode

$pathinfo = pathinfo( $path, $flags );

Expand Down Expand Up @@ -914,4 +914,28 @@ public static function get_registered_sizes( $attachment_id = null ) {
*/
return apply_filters( 'cloudinary_registered_sizes', $all_sizes );
}

/**
* Get the attachment ID from the attachment URL.
*
* @param string $url The attachment URL.
*
* @return int
*/
public static function attachment_url_to_postid( $url ) {
$key = "postid_{$url}";

if ( function_exists( 'wpcom_vip_attachment_url_to_postid' ) ) {
$attachment_id = wpcom_vip_attachment_url_to_postid( $url );
} else {
$attachment_id = wp_cache_get( $key, 'cloudinary' );
}

if ( empty( $attachment_id ) ) {
$attachment_id = attachment_url_to_postid( $url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.attachment_url_to_postid_attachment_url_to_postid
wp_cache_set( $key, $attachment_id, 'cloudinary' );
}

return $attachment_id;
}
}
2 changes: 1 addition & 1 deletion php/connect/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ protected static function get_hostname( $upload_prefix ) {
$hostname = $upload_prefix;

if ( filter_var( $upload_prefix, FILTER_VALIDATE_URL ) ) {
$hostname = parse_url( $upload_prefix, PHP_URL_HOST );
$hostname = wp_parse_url( $upload_prefix, PHP_URL_HOST );
}

return $hostname;
Expand Down
2 changes: 1 addition & 1 deletion php/media/class-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public function filter_video_embeds( $html, $id, $attachment ) {
public function pre_filter_rest_content( $response, $post, $request ) {
$context = $request->get_param( 'context' );
if ( 'edit' === $context ) {
$data = $response->get_data();
$data = $response->get_data();
// Handle meta if missing due to custom-fields not being supported.
if ( ! isset( $data['meta'] ) ) {
$data['meta'] = $request->get_param( 'meta' );
Expand Down
2 changes: 1 addition & 1 deletion php/media/class-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function enqueue_admin_scripts() {
* @return array
*/
private function get_asset() {
$asset = require $this->plugin->dir_path . 'js/gallery.asset.php';
$asset = require $this->plugin->dir_path . 'js/gallery.asset.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable

$asset['dependencies'] = array_filter(
$asset['dependencies'],
Expand Down
Loading