diff --git a/.eslintrc.json b/.eslintrc.json
index 20a1a2fd4..a8e71723b 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -24,6 +24,7 @@
"no-nested-ternary": "off",
"jsx-a11y/click-events-have-key-events": "off",
"react-hooks/rules-of-hooks": "error",
- "react-hooks/exhaustive-deps": "warn"
+ "react-hooks/exhaustive-deps": "warn",
+ "@wordpress/no-global-event-listener": "off"
}
}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..9c8656e79
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,43 @@
+name: CI
+
+on:
+ push:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ php-version: [ '5.6', '7.4', '8.3' ]
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php-version }}
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '16'
+ cache: 'npm'
+
+ - name: Cache Composer
+ uses: actions/cache@v4
+ with:
+ path: ~/.composer/cache
+ key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-composer-${{ matrix.php }}-
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Run linting
+ run: npm run lint
+
+ - name: Run build
+ run: npm run build
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 7c196ee81..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-dist: xenial
-
-language: php
-
-before_install:
- - nvm install
- - nvm use
-
-install:
- - npm ci
-
-jobs:
-
- include:
-
- - php: "5.6"
- script:
- - npm run lint
- - npm run build
-
- - php: "7.4"
- script:
- - npm run lint
- - npm run build
-
-notifications:
- email: false
-
-cache:
- npm: true
- directories:
- - "$HOME/.composer/cache"
diff --git a/cloudinary.php b/cloudinary.php
index 94bc8629a..828e1b2e2 100644
--- a/cloudinary.php
+++ b/cloudinary.php
@@ -39,7 +39,7 @@
if ( version_compare( phpversion(), '5.6', '>=' ) ) {
require_once __DIR__ . '/instance.php';
register_activation_hook( __FILE__, array( 'Cloudinary\Utils', 'install' ) );
-} else {
+} else { // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found
if ( defined( 'WP_CLI' ) ) {
WP_CLI::warning( php_version_text() );
} else {
diff --git a/languages/cloudinary.pot b/languages/cloudinary.pot
index 457551a5a..3b5dcf4a9 100644
--- a/languages/cloudinary.pot
+++ b/languages/cloudinary.pot
@@ -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: 2025-08-06 09:40:15+00:00\n"
+"POT-Creation-Date: 2025-09-02 13:12:16+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -43,31 +43,31 @@ msgid "Some transformations were invalid and were removed."
msgstr ""
#: php/assets/class-rest-assets.php:333 php/assets/class-rest-assets.php:361
-#: php/cache/class-cache-point.php:601
+#: php/cache/class-cache-point.php:600
msgid "No items cached."
msgstr ""
-#: php/assets/class-rest-assets.php:345 php/cache/class-cache-point.php:585
+#: php/assets/class-rest-assets.php:345 php/cache/class-cache-point.php:584
#. translators: The current page and total pages.
msgid "Page %1$d of %2$d"
msgstr ""
-#: php/assets/class-rest-assets.php:348 php/cache/class-cache-point.php:588
+#: php/assets/class-rest-assets.php:348 php/cache/class-cache-point.php:587
#. translators: The number of files.
msgid "%d cached file"
msgid_plural "%d cached files"
msgstr[0] ""
msgstr[1] ""
-#: php/assets/class-rest-assets.php:359 php/cache/class-cache-point.php:599
+#: php/assets/class-rest-assets.php:359 php/cache/class-cache-point.php:598
msgid "No items found."
msgstr ""
-#: php/cache/class-cache-point.php:962 php/class-assets.php:1239
+#: php/cache/class-cache-point.php:961 php/class-assets.php:1239
msgid "Cloudinary Asset"
msgstr ""
-#: php/cache/class-cache-point.php:963 php/class-assets.php:1240
+#: php/cache/class-cache-point.php:962 php/class-assets.php:1240
msgid "Post type to represent a non-media library asset."
msgstr ""
@@ -126,53 +126,53 @@ msgstr ""
msgid "Plugin"
msgstr ""
-#: php/class-assets.php:1429 php/class-cache.php:792
+#: php/class-assets.php:1429 php/class-cache.php:791
msgid "Plugins"
msgstr ""
-#: php/class-assets.php:1447 php/class-cache.php:809
+#: php/class-assets.php:1447 php/class-cache.php:808
msgid "Deliver assets from all plugin folders"
msgstr ""
-#: php/class-assets.php:1479 php/class-cache.php:652
+#: php/class-assets.php:1479 php/class-cache.php:651
msgid "Theme"
msgstr ""
-#: php/class-assets.php:1511 php/class-cache.php:843
+#: php/class-assets.php:1511 php/class-cache.php:842
msgid "Themes"
msgstr ""
-#: php/class-assets.php:1529 php/class-cache.php:860
+#: php/class-assets.php:1529 php/class-cache.php:859
msgid "Deliver all assets from active theme."
msgstr ""
-#: php/class-assets.php:1554 php/class-assets.php:1589 php/class-cache.php:684
-#: php/class-cache.php:895
+#: php/class-assets.php:1554 php/class-assets.php:1589 php/class-cache.php:683
+#: php/class-cache.php:894
msgid "WordPress"
msgstr ""
-#: php/class-assets.php:1563 php/class-cache.php:668
+#: php/class-assets.php:1563 php/class-cache.php:667
msgid "WordPress Admin"
msgstr ""
-#: php/class-assets.php:1570 php/class-cache.php:675
+#: php/class-assets.php:1570 php/class-cache.php:674
msgid "WordPress Includes"
msgstr ""
-#: php/class-assets.php:1607 php/class-cache.php:912
+#: php/class-assets.php:1607 php/class-cache.php:911
msgid "Deliver all assets from WordPress core."
msgstr ""
-#: php/class-assets.php:1633 php/class-assets.php:1659 php/class-cache.php:708
-#: php/class-cache.php:947
+#: php/class-assets.php:1633 php/class-assets.php:1659 php/class-cache.php:707
+#: php/class-cache.php:946
msgid "Content"
msgstr ""
-#: php/class-assets.php:1640 php/class-cache.php:699
+#: php/class-assets.php:1640 php/class-cache.php:698
msgid "Uploads"
msgstr ""
-#: php/class-assets.php:1677 php/class-cache.php:964
+#: php/class-assets.php:1677 php/class-cache.php:963
msgid "Deliver all content assets from WordPress Media Library."
msgstr ""
@@ -198,23 +198,23 @@ msgstr ""
msgid "Press ENTER or SPACE or type comma or tab to continue."
msgstr ""
-#: php/class-cache.php:1016 php/class-cache.php:1019
+#: php/class-cache.php:1015 php/class-cache.php:1018
msgid "Site Cache"
msgstr ""
-#: php/class-cache.php:1023
+#: php/class-cache.php:1022
msgid "Cache Settings"
msgstr ""
-#: php/class-cache.php:1039
+#: php/class-cache.php:1038
msgid "Full CDN"
msgstr ""
-#: php/class-cache.php:1040
+#: php/class-cache.php:1039
msgid "Deliver all assets from Cloudinary."
msgstr ""
-#: php/class-cache.php:1044
+#: php/class-cache.php:1043
msgid "Enable caching site assets."
msgstr ""
@@ -579,7 +579,7 @@ msgstr ""
msgid "See examples"
msgstr ""
-#: php/class-plugin.php:752
+#: php/class-plugin.php:757
msgid "Visit plugin site"
msgstr ""
@@ -658,56 +658,56 @@ msgid ""
"purchase?
Thank you!"
msgstr ""
-#: php/class-sync.php:480
+#: php/class-sync.php:483
msgid "Synchronizing asset with Cloudinary"
msgstr ""
-#: php/class-sync.php:500
+#: php/class-sync.php:503
msgid "Upgrading from previous version"
msgstr ""
-#: php/class-sync.php:511
+#: php/class-sync.php:514
msgid "Downloading from Cloudinary"
msgstr ""
-#: php/class-sync.php:526 php/class-sync.php:543
+#: php/class-sync.php:529 php/class-sync.php:546
msgid "Uploading to Cloudinary"
msgstr ""
-#: php/class-sync.php:556
+#: php/class-sync.php:559
#. translators: %s folder name
msgid "Copying to folder %s."
msgstr ""
-#: php/class-sync.php:571 php/class-sync.php:598
+#: php/class-sync.php:574 php/class-sync.php:601
msgid "Updating metadata"
msgstr ""
-#: php/class-sync.php:584
+#: php/class-sync.php:587
msgid "Updating breakpoints"
msgstr ""
-#: php/class-sync.php:619
+#: php/class-sync.php:622
msgid "Uploading to new cloud name."
msgstr ""
-#: php/class-sync.php:1091
+#: php/class-sync.php:1097
msgid "Sync errors cleaned up"
msgstr ""
-#: php/class-sync.php:1181
+#: php/class-sync.php:1187
msgid "Is Cloudinary synced."
msgstr ""
-#: php/class-sync.php:1238
+#: php/class-sync.php:1244
msgid "Media Library Sync Settings"
msgstr ""
-#: php/class-sync.php:1243
+#: php/class-sync.php:1249
msgid "Sync method"
msgstr ""
-#: php/class-sync.php:1246
+#: php/class-sync.php:1252
#. translators: The HTML break line, the link to Cloudinary documentation and
#. closing tag.
msgid ""
@@ -716,35 +716,35 @@ msgid ""
"Media Library.%3$s%4$sLearn more%5$s"
msgstr ""
-#: php/class-sync.php:1257
+#: php/class-sync.php:1263
msgid "Auto sync"
msgstr ""
-#: php/class-sync.php:1258
+#: php/class-sync.php:1264
msgid "Manual sync"
msgstr ""
-#: php/class-sync.php:1264
+#: php/class-sync.php:1270
msgid "Cloudinary folder path"
msgstr ""
-#: php/class-sync.php:1268
+#: php/class-sync.php:1274
msgid "e.g.: wordpress_assets/"
msgstr ""
-#: php/class-sync.php:1271
+#: php/class-sync.php:1277
msgid ""
"The folder in your Cloudinary account that WordPress assets are uploaded "
"to. Leave blank to use the root of your Cloudinary library."
msgstr ""
-#: php/class-sync.php:1280 php/ui/component/class-plan-details.php:118
+#: php/class-sync.php:1286 php/ui/component/class-plan-details.php:118
#: php/ui/component/class-plan-status.php:94
#: ui-definitions/settings-sidebar.php:38
msgid "Storage"
msgstr ""
-#: php/class-sync.php:1283
+#: php/class-sync.php:1289
#. translators: the HTML for opening and closing list and its items.
msgid ""
"Choose where your assets are stored.%1$sCloudinary and WordPress: Stores "
@@ -757,19 +757,19 @@ msgid ""
"compatibility.%4$s%5$sLearn more%6$s"
msgstr ""
-#: php/class-sync.php:1296
+#: php/class-sync.php:1302
msgid "Cloudinary and WordPress"
msgstr ""
-#: php/class-sync.php:1297
+#: php/class-sync.php:1303
msgid "Cloudinary and WordPress (low resolution)"
msgstr ""
-#: php/class-sync.php:1298
+#: php/class-sync.php:1304
msgid "Cloudinary only"
msgstr ""
-#: php/class-sync.php:1304 php/delivery/class-lazy-load.php:543
+#: php/class-sync.php:1310 php/delivery/class-lazy-load.php:543
#: php/media/class-gallery.php:425 ui-definitions/components/header.php:19
#: ui-definitions/settings-image.php:257 ui-definitions/settings-pages.php:206
#: ui-definitions/settings-pages.php:222 ui-definitions/settings-pages.php:223
@@ -777,7 +777,7 @@ msgstr ""
msgid "Need help?"
msgstr ""
-#: php/class-sync.php:1307
+#: php/class-sync.php:1313
#. Translators: The HTML for opening and closing link tags.
msgid ""
"Watch free lessons on how to use the Media Library Sync Settings in the "
diff --git a/php/cache/class-cache-point.php b/php/cache/class-cache-point.php
index d649235b8..dcdd85907 100644
--- a/php/cache/class-cache-point.php
+++ b/php/cache/class-cache-point.php
@@ -287,7 +287,6 @@ public function init() {
$this->registered_cache_points[ $post->post_title ] = $post;
}
do_action( 'cloudinary_cache_init_cache_points' );
-
}
/**
@@ -526,7 +525,7 @@ public function get_cache_items( $cache_point_id_url, $id_only = false ) {
do {
$found = $posts->get_posts();
$items = array_merge( $items, $found );
- $params['paged'] ++;
+ ++$params['paged'];
$posts = new \WP_Query( $params );
} while ( $posts->have_posts() );
}
@@ -884,7 +883,7 @@ public function query_cached_items( $urls ) {
$found_posts[ $url ] = $meta[ self::META_KEYS['cached_urls'] ][ $url ];
}
}
- $params['paged'] ++;
+ ++$params['paged'];
$posts = new \WP_Query( $params );
} while ( $posts->have_posts() );
diff --git a/php/class-admin.php b/php/class-admin.php
index fe37dc294..eccbe9776 100644
--- a/php/class-admin.php
+++ b/php/class-admin.php
@@ -203,7 +203,7 @@ public function register_admin( $page ) {
$page_handle = add_menu_page(
$page['page_title'],
$page['menu_title'],
- $page['capability'],
+ $page['capability'], // phpcs:ignore WordPress.WP.Capabilities.Undetermined
$page['slug'],
'',
$page['icon'],
@@ -245,7 +245,7 @@ public function register_admin( $page ) {
$page['slug'],
$page_title,
$menu_title,
- $capability,
+ $capability, // phpcs:ignore WordPress.WP.Capabilities.Undetermined
$render_slug,
$render_function,
$position
diff --git a/php/class-assets.php b/php/class-assets.php
index 52287e99f..34349c5df 100644
--- a/php/class-assets.php
+++ b/php/class-assets.php
@@ -1365,7 +1365,7 @@ public function is_asset( $url ) {
global $wpdb;
// Bail early if it's not an URL.
- if ( empty( parse_url( $url, PHP_URL_HOST ) ) ) {
+ if ( empty( parse_url( $url, PHP_URL_HOST ) ) ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url
return false;
}
diff --git a/php/class-cache.php b/php/class-cache.php
index f79ceba45..ee6d18211 100644
--- a/php/class-cache.php
+++ b/php/class-cache.php
@@ -615,7 +615,6 @@ protected function get_plugins_table() {
'title' => __( 'Plugin', 'cloudinary' ),
'root_paths' => $rows,
);
-
}
/**
@@ -987,7 +986,7 @@ public function add_content_cache_paths() {
if ( ! is_admin() ) {
// Exclude content replacement in admin.
$this->add_cache_paths( 'cache_content', 'content_files', 'cache_all_content' );
- };
+ }
}
/**
diff --git a/php/class-delivery-feature.php b/php/class-delivery-feature.php
index da08b1c75..3f2b8468d 100644
--- a/php/class-delivery-feature.php
+++ b/php/class-delivery-feature.php
@@ -157,7 +157,6 @@ public function register_assets() {
* Enqueue Assets.
*/
public function enqueue_assets() {
-
}
/**
diff --git a/php/class-delivery.php b/php/class-delivery.php
index 564f967a0..3b415685a 100644
--- a/php/class-delivery.php
+++ b/php/class-delivery.php
@@ -387,6 +387,11 @@ public function is_deliverable( $attachment_id ) {
if ( $is ) {
$meta = wp_get_attachment_metadata( $attachment_id, true );
$is = ! empty( $meta['width'] ) && ! empty( $meta['height'] );
+
+ // Webm audio files don't have width and height.
+ if ( ! $is && ! empty( $meta['mime_type'] ) && 'audio/webm' === $meta['mime_type'] ) {
+ $is = true;
+ }
}
if ( ! $is ) {
@@ -1478,6 +1483,12 @@ public function parse_element( $element ) {
// Break element up.
$attributes = shortcode_parse_atts( $element );
$tag_element['tag'] = array_shift( $attributes );
+
+ // Skip audio source tags.
+ if ( ! empty( $attributes['type'] ) && 0 === strpos( $attributes['type'], 'audio/' ) && 'source' === $tag_element['tag'] ) {
+ return null;
+ }
+
// Context Switch Check.
if ( 'article' === $tag_element['tag'] ) {
if ( ! empty( $attributes['id'] ) && false !== strpos( $attributes['id'], 'post-' ) ) {
@@ -1958,7 +1969,7 @@ protected function filter_unknown_urls( $urls ) {
return $urls;
}
- $known_lookup = array_flip( $known_keys );
+ $known_lookup = array_flip( $known_keys );
$potential_unknown = array_diff( $urls, $known_keys );
if ( empty( $potential_unknown ) ) {
diff --git a/php/class-extensions.php b/php/class-extensions.php
index 22099f4df..488f27ccc 100644
--- a/php/class-extensions.php
+++ b/php/class-extensions.php
@@ -115,7 +115,7 @@ public function get_active_count_text() {
$active = 0;
foreach ( $this->settings->get_value( $this->settings_slug ) as $value ) {
if ( 'on' === $value ) {
- $active ++;
+ ++$active;
}
}
diff --git a/php/class-media-library.php b/php/class-media-library.php
index 2241995ef..bcb2ba536 100644
--- a/php/class-media-library.php
+++ b/php/class-media-library.php
@@ -41,7 +41,7 @@ public function setup() {
$this->handle = add_menu_page(
__( 'Cloudinary Media Library', 'cloudinary' ),
__( 'Cloudinary DAM', 'cloudinary' ),
- Utils::user_can( 'manage_dam' ) ? 'exist' : false,
+ Utils::user_can( 'manage_dam' ) ? 'exist' : false, // phpcs:ignore WordPress.WP.Capabilities.Undetermined
self::MEDIA_LIBRARY_SLUG,
array( $this, 'render' ),
'dashicons-cloudinary-dam',
diff --git a/php/class-media.php b/php/class-media.php
index 182782b3d..f14db1748 100644
--- a/php/class-media.php
+++ b/php/class-media.php
@@ -1305,7 +1305,7 @@ public function apply_default_transformations( array $transformations, $attachme
*
* @return array
*/
- public function default_image_transformations( $default ) {
+ public function default_image_transformations( $default ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
$config = $this->settings->get_value( 'image_settings' );
@@ -1330,7 +1330,7 @@ public function default_image_transformations( $default ) {
*
* @return array
*/
- public function default_image_freeform_transformations( $default ) {
+ public function default_image_freeform_transformations( $default ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
$config = $this->settings->get_value( 'image_settings' );
if ( ! empty( $config['image_freeform'] ) ) {
$default[] = trim( $config['image_freeform'] );
@@ -2559,7 +2559,7 @@ public function get_transformation_from_meta( $post_id ) {
*
* @return mixed
*/
- public function get_post_meta( $post_id, $key = '', $single = false, $default = null ) {
+ public function get_post_meta( $post_id, $key = '', $single = false, $default = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
$meta = get_post_meta( $post_id, Sync::META_KEYS['cloudinary'], true );
if ( empty( $meta ) ) {
diff --git a/php/class-plugin.php b/php/class-plugin.php
index 8ed2765b7..2a775b2de 100644
--- a/php/class-plugin.php
+++ b/php/class-plugin.php
@@ -598,7 +598,7 @@ protected function setup_endpoints() {
*
* @return void
*/
- public function autoload( $class ) {
+ public function autoload( $class ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.classFound
// Assume we're using namespaces (because that's how the plugin is structured).
$namespace = explode( '\\', $class );
$root = array_shift( $namespace );
@@ -719,7 +719,12 @@ public function add_script_data( $slug, $value, $handle = null ) {
* Output script data if set.
*/
public function print_script_data() {
+ if ( ! isset( $this->settings ) || ! method_exists( $this->settings, 'get_param' ) ) {
+ return;
+ }
+
$handles = $this->settings->get_param( '@script' );
+
if ( ! empty( $handles ) ) {
foreach ( $handles as $handle => $data ) {
// We should never be using multiple handles. This is just for cases where data needs to be added where the main script is not loaded.
@@ -744,7 +749,7 @@ public function print_script_data() {
*
* @return array
*/
- public function force_visit_plugin_site_link( $plugin_meta, $plugin_file, $plugin_data, $status ) {
+ public function force_visit_plugin_site_link( $plugin_meta, $plugin_file, $plugin_data, $status ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
if ( 'Cloudinary' === $plugin_data['Name'] ) {
$plugin_site_link = sprintf(
'%s',
diff --git a/php/class-rest-api.php b/php/class-rest-api.php
index 0200ce98d..76975dcde 100644
--- a/php/class-rest-api.php
+++ b/php/class-rest-api.php
@@ -26,7 +26,7 @@ class REST_API {
*
* @param Plugin $plugin Instance of the global Plugin.
*/
- public function __construct( Plugin $plugin ) {
+ public function __construct( Plugin $plugin ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
add_action( 'rest_api_init', array( $this, 'rest_api_init' ), PHP_INT_MAX );
}
diff --git a/php/class-settings.php b/php/class-settings.php
index ba655448e..9948400a1 100644
--- a/php/class-settings.php
+++ b/php/class-settings.php
@@ -241,7 +241,7 @@ public function get_storage_key( $slug, $type = null ) {
*
* @return Setting|\WP_Error
*/
- public function add( $slug, $default = array(), $params = array() ) {
+ public function add( $slug, $default = array(), $params = array() ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
$default_params = array(
'type' => 'tag',
self::META_KEYS['storage'] => $slug,
@@ -294,7 +294,7 @@ public function add( $slug, $default = array(), $params = array() ) {
*
* @return mixed|Setting
*/
- protected function register( $slug, $default, $params ) {
+ protected function register( $slug, $default, $params ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
if ( isset( $this->settings[ $slug ] ) ) {
return $this->settings[ $slug ];
diff --git a/php/class-string-replace.php b/php/class-string-replace.php
index f749a62f7..5b099d628 100644
--- a/php/class-string-replace.php
+++ b/php/class-string-replace.php
@@ -195,7 +195,7 @@ public function init_debug( $template ) {
*
* @return bool
*/
- public static function string_set( $string ) {
+ public static function string_set( $string ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound
return isset( self::$replacements[ $string ] );
}
@@ -206,7 +206,7 @@ public static function string_set( $string ) {
*
* @return bool
*/
- public static function string_not_set( $string ) {
+ public static function string_not_set( $string ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound
return ! self::string_set( $string );
}
diff --git a/php/class-svg.php b/php/class-svg.php
index bc10760bb..acb912ade 100644
--- a/php/class-svg.php
+++ b/php/class-svg.php
@@ -217,6 +217,22 @@ public function is_active() {
return 'on' === $this->config[ $this->enable_slug ];
}
+ /**
+ * Disable SVG conversion.
+ * If SVG support is active, we don't want to convert SVGs to other formats.
+ *
+ * @param array $base_types The base types for conversion.
+ *
+ * @return array
+ */
+ public function disable_svg_conversion( $base_types ) {
+ if ( $this->is_active() && ! empty( $base_types['svg'] ) ) {
+ unset( $base_types['svg'] );
+ }
+
+ return $base_types;
+ }
+
/**
* Setup the component
*/
@@ -233,6 +249,7 @@ public function setup_hooks() {
add_filter( 'cloudinary_allowed_extensions', array( $this, 'allow_svg_for_cloudinary' ) );
add_filter( 'cloudinary_upload_options', array( $this, 'remove_svg_eagers' ), 10, 2 );
add_filter( 'cloudinary_upload_args', array( $this, 'upload_args' ), 10, 2 );
+ add_filter( 'cloudinary_convert_media_types', array( $this, 'disable_svg_conversion' ) );
// Add actions.
add_action( 'cloudinary_uploaded_asset', array( $this, 'maybe_setup_metadata' ), 10, 2 );
diff --git a/php/class-sync.php b/php/class-sync.php
index 4ec29f346..b5e3522fd 100644
--- a/php/class-sync.php
+++ b/php/class-sync.php
@@ -51,7 +51,7 @@ class Sync implements Setup, Assets {
*
* @var array
*/
- protected $sync_types;
+ protected $sync_types = array();
/**
* Holds a list of unsynced images to push on end.
@@ -372,10 +372,13 @@ public function get_signature( $attachment_id, $cached = true ) {
$signature = array();
}
- // Remove any old or outdated signature items. against the expected.
- $signature = array_intersect_key( $signature, $this->sync_types );
$signatures[ $attachment_id ] = $return;
- $return = wp_parse_args( $signature, $this->sync_types );
+
+ // Remove any old or outdated signature items. against the expected.
+ if ( ! empty( $this->sync_types ) ) {
+ $signature = array_intersect_key( $signature, $this->sync_types );
+ $return = wp_parse_args( $signature, $this->sync_types );
+ }
}
/**
@@ -789,9 +792,12 @@ public function sync_base( $attachment_id ) {
$return = array();
$asset_state = $this->get_asset_state( $attachment_id );
- foreach ( array_keys( $this->sync_types ) as $type ) {
- if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) {
- $return[ $type ] = $this->generate_type_signature( $type, $attachment_id );
+
+ if ( ! empty( $this->sync_types ) ) {
+ foreach ( array_keys( $this->sync_types ) as $type ) {
+ if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) {
+ $return[ $type ] = $this->generate_type_signature( $type, $attachment_id );
+ }
}
}
@@ -844,7 +850,7 @@ public function get_sync_type( $attachment_id, $cached = true ) {
$required_signature = $this->generate_signature( $attachment_id, $cached );
$attachment_signature = $this->get_signature( $attachment_id, $cached );
$attachment_signature = array_intersect_key( $attachment_signature, $required_signature );
- if ( is_array( $required_signature ) ) {
+ if ( is_array( $required_signature ) && ! empty( $this->sync_types ) ) {
$sync_items = array_filter(
$attachment_signature,
function ( $item, $key ) use ( $required_signature ) {
@@ -1105,11 +1111,11 @@ public function maybe_cleanup_errored() {
delete_post_meta_by_key( self::META_KEYS['sync_error'] );
- wp_redirect(
+ wp_redirect( // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
add_query_arg(
array(
- 'page' => 'cloudinary',
- 'action' => 'cleaned_up',
+ 'page' => 'cloudinary',
+ 'action' => 'cleaned_up',
),
admin_url( 'admin.php' )
)
diff --git a/php/class-url.php b/php/class-url.php
index a5bbcdffb..91fa7e43d 100644
--- a/php/class-url.php
+++ b/php/class-url.php
@@ -78,7 +78,6 @@ public function init_settings() {
* Set up the object.
*/
public function setup() {
-
}
/**
diff --git a/php/class-utils.php b/php/class-utils.php
index f88c307e8..6fa569aea 100644
--- a/php/class-utils.php
+++ b/php/class-utils.php
@@ -258,7 +258,7 @@ public static function user_can( $task, $capability = 'manage_options', $context
$capability = apply_filters( 'cloudinary_task_capability', $capability, $task, $context, ...$args );
// phpcs:enable WordPress.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed
- return current_user_can( $capability, ...$args );
+ return current_user_can( $capability, ...$args ); // phpcs:ignore WordPress.WP.Capabilities.Undetermined
}
/**
@@ -758,7 +758,7 @@ public static function purge_fragments() {
public static function purge_fragment( $index ) {
if ( isset( self::$file_fragments[ $index ] ) ) {
fclose( self::$file_fragments[ $index ]['pointer'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
- unlink( self::$file_fragments[ $index ]['file'] );
+ unlink( self::$file_fragments[ $index ]['file'] ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
}
}
diff --git a/php/component/class-config.php b/php/component/class-config.php
index 28fef6364..8bd8b30ae 100644
--- a/php/component/class-config.php
+++ b/php/component/class-config.php
@@ -16,5 +16,4 @@ interface Config {
* Retrive config from class.
*/
public function get_config();
-
}
diff --git a/php/component/class-notice.php b/php/component/class-notice.php
index d0fcee019..79d3c2688 100644
--- a/php/component/class-notice.php
+++ b/php/component/class-notice.php
@@ -18,5 +18,4 @@ interface Notice {
* @return array
*/
public function get_notices();
-
}
diff --git a/php/component/class-setup.php b/php/component/class-setup.php
index d6086171c..2f5f49e38 100644
--- a/php/component/class-setup.php
+++ b/php/component/class-setup.php
@@ -16,5 +16,4 @@ interface Setup {
* Setup the object.
*/
public function setup(); // phpcs:ignore
-
}
diff --git a/php/connect/class-api.php b/php/connect/class-api.php
index 91e272f54..3b6e370af 100644
--- a/php/connect/class-api.php
+++ b/php/connect/class-api.php
@@ -129,8 +129,8 @@ class Api {
'f' => 'fetch_format',
'q' => 'quality',
'if' => 'if',
- 'y' => 'y_axis',
- 'x' => 'x_axis',
+ 'y' => 'y_axis',
+ 'x' => 'x_axis',
),
);
@@ -186,7 +186,7 @@ public function setup( Plugin $plugin ) {
*
* @return string
*/
- public function url( $resource, $function = null, $endpoint = false ) {
+ public function url( $resource, $function = null, $endpoint = false ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames
$parts = array();
if ( $endpoint ) {
diff --git a/php/cron/class-lock-object.php b/php/cron/class-lock-object.php
index a53835950..b218ff122 100644
--- a/php/cron/class-lock-object.php
+++ b/php/cron/class-lock-object.php
@@ -83,5 +83,4 @@ public function set_lock_file( $file = null, $data = null ) {
public function delete_lock_file( $file = null ) {
delete_transient( self::PREFIX . $this->get_lock_file_name( $file ) );
}
-
}
diff --git a/php/integrations/class-wpml.php b/php/integrations/class-wpml.php
index dc0468e90..56199c037 100644
--- a/php/integrations/class-wpml.php
+++ b/php/integrations/class-wpml.php
@@ -243,7 +243,7 @@ public function language_switcher_items( $languages_links ) {
break;
}
- $relationship = new Relationship( $args['asset'] );
+ $relationship = new Relationship( $args['asset'] );
$contextual_relationship = $relationship->get_contextualized_relationship( $language );
if ( ! empty( $contextual_relationship ) ) {
diff --git a/php/media/class-filter.php b/php/media/class-filter.php
index 0831a358b..0867c9ccd 100644
--- a/php/media/class-filter.php
+++ b/php/media/class-filter.php
@@ -778,7 +778,7 @@ public function record_meta_update( $data, $id ) {
*
* @return bool
*/
- public function edit_match_src( $match, $image_location, $image_meta, $attachment_id ) {
+ public function edit_match_src( $match, $image_location, $image_meta, $attachment_id ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.matchFound
if ( $this->media->is_cloudinary_url( $image_location ) ) {
$test_id = $this->media->get_public_id_from_url( $image_location );
$public_id = $this->media->get_public_id( $attachment_id );
diff --git a/php/media/class-gallery.php b/php/media/class-gallery.php
index 1d91a4e75..c7f8f236b 100644
--- a/php/media/class-gallery.php
+++ b/php/media/class-gallery.php
@@ -707,7 +707,7 @@ public function setup_hooks() {
* @return bool
*/
if ( apply_filters( 'cloudinary_allow_glb_upload', false ) ) {
- add_filter( 'upload_mimes', array( $this, 'add_glb_mime' ), 20, 1 );
+ add_filter( 'upload_mimes', array( $this, 'add_glb_mime' ), 20, 1 ); // phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.upload_mimes
add_filter( 'wp_check_filetype_and_ext', array( $this, 'pass_glb_filetype_check' ), 10, 3 );
add_filter( 'cloudinary_allowed_extensions', array( $this, 'allow_glb_for_cloudinary' ) );
add_filter( 'cloudinary_is_deliverable', array( $this, 'allow_glb_delivery_from_cloudinary' ), 10, 2 );
diff --git a/php/media/class-video.php b/php/media/class-video.php
index 72d57041b..695aba782 100644
--- a/php/media/class-video.php
+++ b/php/media/class-video.php
@@ -295,7 +295,7 @@ public function filter_video_block_pre_render( $block, $source_block ) {
} elseif ( $this->player_enabled() ) {
foreach ( $block['innerContent'] as &$content ) {
$urls = Utils::extract_urls( $content );
- $url = reset( $urls );
+ $url = reset( $urls );
if ( wp_http_validate_url( $url ) ) {
$video_tags = $this->media->filter->get_media_tags( $content );
@@ -392,6 +392,7 @@ protected function build_video_embed( $source, $attributes = array(), $overwrite
// If it is an attachment, get the video metadata.
if ( $attachment_id ) {
+
// Check for transformations.
$transformations = $this->media->get_transformations( $attachment_id, array(), $overwrite_transformations );
if ( ! empty( $transformations ) ) {
@@ -413,6 +414,12 @@ protected function build_video_embed( $source, $attributes = array(), $overwrite
);
$params['source']['transformation'] = array_merge( $streaming_transform, $transformations );
}
+
+ $meta = wp_get_attachment_metadata( $attachment_id, true );
+
+ if ( ! empty( $meta['mime_type'] ) && 'audio/webm' === $meta['mime_type'] ) {
+ $params['source']['source_types'] = array( 'audio' );
+ }
}
$video_defaults = array(
@@ -532,7 +539,7 @@ protected function build_video_embed( $source, $attributes = array(), $overwrite
*
* @return array
*/
- public function default_video_transformations( $default ) {
+ public function default_video_transformations( $default ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
if ( 'on' === $this->config['video_optimization'] ) {
if ( 'auto' === $this->config['video_format'] ) {
@@ -555,7 +562,7 @@ public function default_video_transformations( $default ) {
*
* @return array
*/
- public function default_video_freeform_transformations( $default ) {
+ public function default_video_freeform_transformations( $default ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
if ( ! empty( $this->config['video_freeform'] ) ) {
$default[] = trim( $this->config['video_freeform'] );
}
@@ -664,7 +671,7 @@ function ( $atts ) {
*
* @return string
*/
- static function ( $return, $tag, $attr, $m ) {
+ static function ( $return, $tag, $attr, $m ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.returnFound
global $shortcode_tags;
if ( 'video' === $tag ) {
$supported_formats = array_merge(
diff --git a/php/relate/class-relationship.php b/php/relate/class-relationship.php
index 072d7dd52..11afe910c 100644
--- a/php/relate/class-relationship.php
+++ b/php/relate/class-relationship.php
@@ -213,7 +213,7 @@ public static function set_cache( $post_id, $media_context, $data ) {
public function delete() {
global $wpdb;
$table_name = Utils::get_relationship_table();
- $wpdb->delete(
+ $wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
$table_name,
array(
'post_id' => $this->post_id,
diff --git a/php/settings/class-setting.php b/php/settings/class-setting.php
index f3e514da2..28de73f29 100644
--- a/php/settings/class-setting.php
+++ b/php/settings/class-setting.php
@@ -85,7 +85,7 @@ public function __construct( $slug, $root = null, $params = array() ) {
*
* @param string $parent The slug of the parent setting.
*/
- public function set_parent( $parent ) {
+ public function set_parent( $parent ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound
$this->parent = $parent;
}
@@ -100,7 +100,7 @@ public function get_parent( $depth = 1 ) {
$slug = $this->slug;
while ( 0 < $depth ) {
$slug = substr( $slug, 0, strrpos( $slug, $this->separator ) );
- $depth --;
+ --$depth;
}
return $this->root->get_setting( $slug );
diff --git a/php/settings/storage/class-storage.php b/php/settings/storage/class-storage.php
index 1189024eb..fa74bfd61 100644
--- a/php/settings/storage/class-storage.php
+++ b/php/settings/storage/class-storage.php
@@ -115,5 +115,4 @@ abstract public function delete( $slug );
* @return bool
*/
abstract public function save( $slug );
-
}
diff --git a/php/sync/class-download-sync.php b/php/sync/class-download-sync.php
index 83816e27a..f0cc21272 100644
--- a/php/sync/class-download-sync.php
+++ b/php/sync/class-download-sync.php
@@ -84,7 +84,7 @@ public function rest_endpoints( $endpoints ) {
*
* @return bool
*/
- public function rest_can_upload_files( \WP_REST_Request $request ) {
+ public function rest_can_upload_files( \WP_REST_Request $request ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
// This would have been from an ajax call. Therefore verify based on capability.
return Utils::user_can( 'manage_assets', 'upload_files', 'download' );
diff --git a/php/sync/class-push-sync.php b/php/sync/class-push-sync.php
index 4d0d085f3..7c54079e1 100644
--- a/php/sync/class-push-sync.php
+++ b/php/sync/class-push-sync.php
@@ -275,7 +275,7 @@ public function process_queue( \WP_REST_Request $request ) {
$action_message = sprintf( __( '%1$s - cycle %3$s: Syncing asset %2$d', 'cloudinary' ), $thread, $attachment_id, $runs );
do_action( '_cloudinary_queue_action', $action_message, $thread );
$this->process_assets( $attachment_id );
- $runs ++;
+ ++$runs;
$last_id = $attachment_id;
}
$this->queue->stop_maybe( $thread_type );
diff --git a/php/sync/class-upload-sync.php b/php/sync/class-upload-sync.php
index a48b20455..6eb9b9aed 100644
--- a/php/sync/class-upload-sync.php
+++ b/php/sync/class-upload-sync.php
@@ -136,7 +136,7 @@ public function add_inline_action( $actions, $post ) {
esc_attr__( 'Sync and deliver from Cloudinary', 'cloudinary' ),
esc_html__( 'Sync and deliver from Cloudinary', 'cloudinary' )
);
- } else if ( file_exists( get_attached_file( $post->ID ) ) ) {
+ } elseif ( file_exists( get_attached_file( $post->ID ) ) ) {
$actions['cloudinary-push'] = sprintf(
'%s',
$action_url,
diff --git a/php/traits/trait-cli.php b/php/traits/trait-cli.php
index c5a23d3b2..2cbbfd024 100644
--- a/php/traits/trait-cli.php
+++ b/php/traits/trait-cli.php
@@ -501,7 +501,7 @@ protected function maybe_do_export( $unsynced_attachments, $errored_attachments
protected function export_csv( $data, $type ) {
$upload = wp_get_upload_dir();
$filename = trailingslashit( $upload['path'] ) . sanitize_file_name( 'cloudinary-' . $type . '-' . time() . '.csv' );
- $fp = fopen( $filename, 'wb+' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen
+ $fp = fopen( $filename, 'wb+' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen,WordPress.WP.AlternativeFunctions.file_system_operations_fopen
foreach ( $data as $fields ) {
fputcsv( $fp, $fields ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv
diff --git a/php/traits/trait-params.php b/php/traits/trait-params.php
index 7b8e7e715..a653885f8 100644
--- a/php/traits/trait-params.php
+++ b/php/traits/trait-params.php
@@ -213,7 +213,7 @@ public function has_params() {
*
* @return mixed|self
*/
- public function get_param( $param, $default = null ) {
+ public function get_param( $param, $default = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
$param = $this->sanitize_slug( $param );
$value = $this->get_array_param( $param );
diff --git a/php/ui/class-branch.php b/php/ui/class-branch.php
index 4e48cd254..b8ca6c2b9 100644
--- a/php/ui/class-branch.php
+++ b/php/ui/class-branch.php
@@ -359,5 +359,4 @@ public function get_ids() {
return $ids;
}
-
}
diff --git a/php/ui/class-component.php b/php/ui/class-component.php
index 2af822f14..fe8918db6 100644
--- a/php/ui/class-component.php
+++ b/php/ui/class-component.php
@@ -327,7 +327,7 @@ protected function is_enabled() {
*
* @return string
*/
- public function render( $echo = false ) {
+ public function render( $echo = false ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.echoFound
// Setup the component.
$this->pre_render();
diff --git a/php/ui/class-state.php b/php/ui/class-state.php
index a7f070649..a7cd1cda2 100644
--- a/php/ui/class-state.php
+++ b/php/ui/class-state.php
@@ -61,7 +61,7 @@ class State {
*
* @param Plugin $plugin Instance of the plugin.
*/
- public function __construct( Plugin $plugin ) {
+ public function __construct( Plugin $plugin ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
$this->plugin = get_plugin_instance();
$this->user_id = get_current_user_id();
@@ -158,7 +158,7 @@ public function set_state( \WP_REST_Request $request ) {
*
* @return mixed
*/
- public function get_state( $key, $default = null ) {
+ public function get_state( $key, $default = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound
// Add default if not set yet.
if ( empty( $this->state[ $key ] ) ) {
diff --git a/php/ui/component/class-asset-preview.php b/php/ui/component/class-asset-preview.php
index 180f41a45..2d4272db1 100644
--- a/php/ui/component/class-asset-preview.php
+++ b/php/ui/component/class-asset-preview.php
@@ -130,5 +130,4 @@ public function enqueue_scripts() {
$plugin = get_plugin_instance();
wp_enqueue_script( 'cloudinary-asset-edit', $plugin->dir_url . 'js/asset-edit.js', array(), $plugin->version, true );
}
-
}
diff --git a/php/ui/component/class-asset.php b/php/ui/component/class-asset.php
index be564c505..85209fcb8 100644
--- a/php/ui/component/class-asset.php
+++ b/php/ui/component/class-asset.php
@@ -11,8 +11,8 @@
use Cloudinary\Assets;
use Cloudinary\UI\Component;
use Cloudinary\Utils;
-use function Cloudinary\get_plugin_instance;
use Cloudinary\Settings\Setting;
+use function Cloudinary\get_plugin_instance;
/**
* HTML Component to render components only.
@@ -137,8 +137,8 @@ protected function get_item_row( $item ) {
$item_container['children']['row'] = $row;
// Content Row.
- $row = $this->get_part( 'tr' );
- $row['children']['assets'] = $this->get_part( 'td' );
+ $row = $this->get_part( 'tr' );
+ $row['children']['assets'] = $this->get_part( 'td' );
$row['children']['assets']['attributes']['id'] = $item->get_slug() . '.viewer';
$row['children']['assets']['attributes']['data-state'] = $state;
$row['children']['assets']['attributes']['class'] = array(
@@ -216,11 +216,11 @@ protected function get_manager( $item ) {
$header_search['children']['search_input'] = $search_box;
$header_search['children']['search_button'] = $search_button;
- $header_row['children']['search'] = $header_search;
- $header_row['children']['action'] = $this->get_part( 'th' );
- $apply = $this->get_part( 'button' );
- $apply['content'] = __( 'Apply Changes', 'cloudinary' );
- $apply['attributes'] = array(
+ $header_row['children']['search'] = $header_search;
+ $header_row['children']['action'] = $this->get_part( 'th' );
+ $apply = $this->get_part( 'button' );
+ $apply['content'] = __( 'Apply Changes', 'cloudinary' );
+ $apply['attributes'] = array(
'id' => 'apply_' . $slug,
'data-changes' => array(),
'class' => array(
@@ -231,7 +231,7 @@ protected function get_manager( $item ) {
'float: right; margin-left: 6px;',
),
);
- $apply['render'] = true;
+ $apply['render'] = true;
$header_row['children']['action']['children']['apply'] = $apply;
$header['children']['row'] = $header_row;
$manager['children']['header'] = $header;
diff --git a/php/ui/component/class-chart-stat.php b/php/ui/component/class-chart-stat.php
index 47b657c31..fa94ba8d4 100644
--- a/php/ui/component/class-chart-stat.php
+++ b/php/ui/component/class-chart-stat.php
@@ -89,5 +89,4 @@ protected function canvas( $struct ) {
return $struct;
}
-
}
diff --git a/php/ui/component/class-color.php b/php/ui/component/class-color.php
index 7c82d3e25..c49d52407 100644
--- a/php/ui/component/class-color.php
+++ b/php/ui/component/class-color.php
@@ -50,7 +50,7 @@ protected function input( $struct ) {
*
* @return string|null
*/
- public function render( $echo = false ) {
+ public function render( $echo = false ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.echoFound
$return = parent::render( $echo );
?>