From 4a56c58b5ade49ad897ecc343e8d7e992dad8631 Mon Sep 17 00:00:00 2001 From: Aleksandar Atanasov Date: Fri, 25 Jul 2025 12:53:26 +0300 Subject: [PATCH 01/22] Skip audio source tags --- php/class-delivery.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/php/class-delivery.php b/php/class-delivery.php index 70361812..507a0d4b 100644 --- a/php/class-delivery.php +++ b/php/class-delivery.php @@ -1461,6 +1461,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-' ) ) { From 1581a5d6767e172fd37b6eed39523cfec18bf8d0 Mon Sep 17 00:00:00 2001 From: Aleksandar Atanasov Date: Fri, 25 Jul 2025 15:18:03 +0300 Subject: [PATCH 02/22] Fix print_script_data --- php/class-plugin.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php/class-plugin.php b/php/class-plugin.php index 8ed2765b..364c3509 100644 --- a/php/class-plugin.php +++ b/php/class-plugin.php @@ -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. From 3094049ead00d8252ca77facc82f61dbe16d518d Mon Sep 17 00:00:00 2001 From: Aleksandar Atanasov Date: Thu, 7 Aug 2025 11:58:43 +0300 Subject: [PATCH 03/22] Fix webm audio files --- php/class-delivery.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php/class-delivery.php b/php/class-delivery.php index 70361812..79f8c040 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 ) { From 23764dad6488dba6b5bcf34d09d088aa868fc772 Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Thu, 14 Aug 2025 13:17:29 +0900 Subject: [PATCH 04/22] Fix disable additional assets AJAX callback --- php/assets/class-rest-assets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/assets/class-rest-assets.php b/php/assets/class-rest-assets.php index 15d4e1fe..a7502de6 100644 --- a/php/assets/class-rest-assets.php +++ b/php/assets/class-rest-assets.php @@ -258,8 +258,8 @@ public function rest_handle_state( $request ) { $state = $request['state']; foreach ( $ids as $id ) { $where = array( - 'post_id' => $id, - 'post_state' => 'asset', + 'post_id' => $id, + 'sync_type' => 'asset', ); if ( 'delete' === $state ) { $data = array( From 6aa20200d2eabeea531be828b78d127209ef24e7 Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Wed, 20 Aug 2025 12:58:44 +0900 Subject: [PATCH 05/22] Ensure disabled assets aren't delivered --- php/class-delivery.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php/class-delivery.php b/php/class-delivery.php index 564f967a..bbb796df 100644 --- a/php/class-delivery.php +++ b/php/class-delivery.php @@ -1064,6 +1064,11 @@ public function convert_tags( $content, $context = 'view' ) { if ( empty( $relation['public_id'] || $url === $relation['public_id'] ) ) { continue; // We don't need the public_id relation item. } + + if ( 'disable' === $relation['post_state'] ) { + continue; // We should not deliver disabled items. + } + $base = $type . ':' . $url; $public_id = ! is_admin() ? $relation['public_id'] . '.' . $relation['format'] : null; $cloudinary_url = $this->media->cloudinary_url( $relation['post_id'], array(), $relation['transformations'], $public_id ); From 7e817a17ae1f96335c24d74c37f3c1b57f6dd3e9 Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Thu, 21 Aug 2025 12:42:42 +0900 Subject: [PATCH 06/22] Ensure disabled assets aren't re-enabled after a plugin update --- php/class-assets.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/php/class-assets.php b/php/class-assets.php index 52287e99..84bf1dff 100644 --- a/php/class-assets.php +++ b/php/class-assets.php @@ -273,9 +273,32 @@ public function can_sync( $can, $asset_id ) { $can = false; } + // If the asset is set to a 'disable' state, we do not allow syncing. + if ( $can && self::is_asset_type( $asset_id ) && $this->is_disable_state( $asset_id ) ) { + $can = false; + } + return $can; } + /** + * Verify if the asset is set to a 'disable' state. + * + * @param int $asset_id The asset ID to check. + * + * @return bool + */ + protected function is_disable_state( $asset_id ) { + global $wpdb; + + $wpdb->cld_table = Utils::get_relationship_table(); + $media_context = Utils::get_media_context( $asset_id ); + $prepare = $wpdb->prepare( "SELECT `post_state` FROM $wpdb->cld_table WHERE post_id = %d AND media_context = %s;", (int) $asset_id, $media_context ); // phpcs:ignore WordPress.DB.PreparedSQL + $state = $wpdb->get_var( $prepare ); // phpcs:ignore WordPress.DB + + return 'disable' === $state; + } + /** * Check if the post is a asset post type. * From 8b6c2e9600c74fa8dd140cc153682ec03086d62a Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Thu, 21 Aug 2025 14:24:39 +0900 Subject: [PATCH 07/22] Initialize sync_types array This ensures that even if the sync types aren't loaded, there's no fatal errors due to sync_types being null --- php/class-sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-sync.php b/php/class-sync.php index 4ec29f34..fed8cf38 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. From b262935f1629137f6629a8629211cde2370abaa6 Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Fri, 22 Aug 2025 13:37:59 +0900 Subject: [PATCH 08/22] Add Github Actions --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..268917da --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [ '5.6', '7.4', '8.4' ] + + 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 From 683ce97435b0f517ebe04e7b205e698f219c407d Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Mon, 25 Aug 2025 13:55:23 +0900 Subject: [PATCH 09/22] Fix linting issues using phpcbf --- php/cache/class-cache-point.php | 5 ++--- php/class-cache.php | 3 +-- php/class-delivery-feature.php | 1 - php/class-delivery.php | 2 +- php/class-extensions.php | 2 +- php/class-sync.php | 4 ++-- php/class-url.php | 1 - php/component/class-config.php | 1 - php/component/class-notice.php | 1 - php/component/class-setup.php | 1 - php/connect/class-api.php | 4 ++-- php/cron/class-lock-object.php | 1 - php/integrations/class-wpml.php | 2 +- php/media/class-video.php | 2 +- php/settings/class-setting.php | 2 +- php/settings/storage/class-storage.php | 1 - php/sync/class-push-sync.php | 2 +- php/sync/class-upload-sync.php | 2 +- php/ui/class-branch.php | 1 - php/ui/component/class-asset-preview.php | 1 - php/ui/component/class-asset.php | 16 ++++++++-------- php/ui/component/class-chart-stat.php | 1 - php/ui/component/class-column.php | 1 - php/ui/component/class-connect.php | 1 - php/ui/component/class-cron.php | 1 - php/ui/component/class-frame.php | 1 - php/ui/component/class-group.php | 1 - php/ui/component/class-icon-toggle.php | 1 - php/ui/component/class-info-box.php | 1 - php/ui/component/class-line-stat.php | 1 - php/ui/component/class-meta-box.php | 1 - php/ui/component/class-opt-level.php | 2 +- php/ui/component/class-page.php | 1 - php/ui/component/class-panel-short.php | 1 - php/ui/component/class-panel.php | 1 - php/ui/component/class-progress-bar.php | 1 - php/ui/component/class-progress-ring.php | 1 - php/ui/component/class-row.php | 1 - php/ui/component/class-table.php | 5 ++--- php/ui/component/class-tabs.php | 1 - php/ui/component/class-tags-input.php | 1 - 41 files changed, 25 insertions(+), 55 deletions(-) diff --git a/php/cache/class-cache-point.php b/php/cache/class-cache-point.php index d649235b..dcdd8590 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-cache.php b/php/class-cache.php index f79ceba4..ee6d1821 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 da08b1c7..3f2b8468 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 564f967a..a350081e 100644 --- a/php/class-delivery.php +++ b/php/class-delivery.php @@ -1958,7 +1958,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 22099f4d..488f27cc 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-sync.php b/php/class-sync.php index 4ec29f34..1ff3e146 100644 --- a/php/class-sync.php +++ b/php/class-sync.php @@ -1108,8 +1108,8 @@ public function maybe_cleanup_errored() { 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 a5bbcdff..91fa7e43 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/component/class-config.php b/php/component/class-config.php index 28fef636..8bd8b30a 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 d0fcee01..79d3c268 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 d6086171..2f5f49e3 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 91e272f5..635e76b3 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', ), ); diff --git a/php/cron/class-lock-object.php b/php/cron/class-lock-object.php index a5383595..b218ff12 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 dc0468e9..56199c03 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-video.php b/php/media/class-video.php index 72d57041..04f77a3f 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 ); diff --git a/php/settings/class-setting.php b/php/settings/class-setting.php index f3e514da..5190aa1a 100644 --- a/php/settings/class-setting.php +++ b/php/settings/class-setting.php @@ -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 1189024e..fa74bfd6 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-push-sync.php b/php/sync/class-push-sync.php index 4d0d085f..7c54079e 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 a48b2045..6eb9b9ae 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/ui/class-branch.php b/php/ui/class-branch.php index 4e48cd25..b8ca6c2b 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/component/class-asset-preview.php b/php/ui/component/class-asset-preview.php index 180f41a4..2d4272db 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 be564c50..08607936 100644 --- a/php/ui/component/class-asset.php +++ b/php/ui/component/class-asset.php @@ -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 47b657c3..fa94ba8d 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-column.php b/php/ui/component/class-column.php index 090450af..eafd938c 100644 --- a/php/ui/component/class-column.php +++ b/php/ui/component/class-column.php @@ -42,5 +42,4 @@ protected function wrap( $struct ) { return $struct; } - } diff --git a/php/ui/component/class-connect.php b/php/ui/component/class-connect.php index 71d1b62d..5c113588 100644 --- a/php/ui/component/class-connect.php +++ b/php/ui/component/class-connect.php @@ -99,4 +99,3 @@ protected function connect( array $struct ) { return $struct; } } - diff --git a/php/ui/component/class-cron.php b/php/ui/component/class-cron.php index 8a6b06e0..94cb377a 100644 --- a/php/ui/component/class-cron.php +++ b/php/ui/component/class-cron.php @@ -137,7 +137,6 @@ protected function make_row( $name, $item ) { $tr['children']['next_run'] = $next_run; return $tr; - } /** diff --git a/php/ui/component/class-frame.php b/php/ui/component/class-frame.php index 85683c49..88978dd5 100644 --- a/php/ui/component/class-frame.php +++ b/php/ui/component/class-frame.php @@ -22,5 +22,4 @@ class Frame extends Component { * @var string */ protected $blueprint = 'settings'; - } diff --git a/php/ui/component/class-group.php b/php/ui/component/class-group.php index 4a2a41bf..7bdf201b 100644 --- a/php/ui/component/class-group.php +++ b/php/ui/component/class-group.php @@ -54,4 +54,3 @@ protected function title( $struct ) { return $struct; } } - diff --git a/php/ui/component/class-icon-toggle.php b/php/ui/component/class-icon-toggle.php index c77d8f86..7b6ea577 100644 --- a/php/ui/component/class-icon-toggle.php +++ b/php/ui/component/class-icon-toggle.php @@ -31,5 +31,4 @@ protected function slider( $struct ) { return $struct; } - } diff --git a/php/ui/component/class-info-box.php b/php/ui/component/class-info-box.php index 98d0e8b6..cdbccc02 100644 --- a/php/ui/component/class-info-box.php +++ b/php/ui/component/class-info-box.php @@ -102,5 +102,4 @@ protected function body( $struct ) { return $struct; } - } diff --git a/php/ui/component/class-line-stat.php b/php/ui/component/class-line-stat.php index fbfb92fe..9675425f 100644 --- a/php/ui/component/class-line-stat.php +++ b/php/ui/component/class-line-stat.php @@ -199,5 +199,4 @@ protected function line( $struct ) { return $struct; } - } diff --git a/php/ui/component/class-meta-box.php b/php/ui/component/class-meta-box.php index 321ec236..ad7a9123 100644 --- a/php/ui/component/class-meta-box.php +++ b/php/ui/component/class-meta-box.php @@ -82,4 +82,3 @@ protected function page_actions() { return $inputs; } } - diff --git a/php/ui/component/class-opt-level.php b/php/ui/component/class-opt-level.php index f99d834e..24beccd1 100644 --- a/php/ui/component/class-opt-level.php +++ b/php/ui/component/class-opt-level.php @@ -210,7 +210,7 @@ public function calculate_percentage() { } } if ( $meet_depends && 'on' === $this->plugin_settings->get_value( $slug ) ) { - $enabled ++; + ++$enabled; } } diff --git a/php/ui/component/class-page.php b/php/ui/component/class-page.php index 39e0d25f..e3a87078 100644 --- a/php/ui/component/class-page.php +++ b/php/ui/component/class-page.php @@ -250,4 +250,3 @@ protected function settings( $struct ) { return parent::settings( $struct ); } } - diff --git a/php/ui/component/class-panel-short.php b/php/ui/component/class-panel-short.php index 5b718a41..3a02b2e4 100644 --- a/php/ui/component/class-panel-short.php +++ b/php/ui/component/class-panel-short.php @@ -13,4 +13,3 @@ * @package Cloudinary\UI */ class Panel_Short extends Panel {} - diff --git a/php/ui/component/class-panel.php b/php/ui/component/class-panel.php index f03975fa..1c99d4c6 100644 --- a/php/ui/component/class-panel.php +++ b/php/ui/component/class-panel.php @@ -216,4 +216,3 @@ protected function section( $struct ) { return $struct; } } - diff --git a/php/ui/component/class-progress-bar.php b/php/ui/component/class-progress-bar.php index 63010d63..94931901 100644 --- a/php/ui/component/class-progress-bar.php +++ b/php/ui/component/class-progress-bar.php @@ -102,5 +102,4 @@ protected function value( $struct ) { return $struct; } - } diff --git a/php/ui/component/class-progress-ring.php b/php/ui/component/class-progress-ring.php index 6d432e6c..f7ce4a54 100644 --- a/php/ui/component/class-progress-ring.php +++ b/php/ui/component/class-progress-ring.php @@ -41,5 +41,4 @@ protected function wrap( $struct ) { return $struct; } - } diff --git a/php/ui/component/class-row.php b/php/ui/component/class-row.php index f900b807..5a468ef1 100644 --- a/php/ui/component/class-row.php +++ b/php/ui/component/class-row.php @@ -39,5 +39,4 @@ protected function wrap( $struct ) { return $struct; } - } diff --git a/php/ui/component/class-table.php b/php/ui/component/class-table.php index ed4e96dc..95060bee 100644 --- a/php/ui/component/class-table.php +++ b/php/ui/component/class-table.php @@ -149,10 +149,10 @@ protected function body_row( $slug, $row ) { 'colspan' => 0, ); } - $columns[ $previous ]['attributes']['colspan'] ++; + ++$columns[ $previous ]['attributes']['colspan']; continue; } else { - $next_colspan ++; + ++$next_colspan; } $previous = $col_slug; @@ -163,5 +163,4 @@ protected function body_row( $slug, $row ) { return $params; } - } diff --git a/php/ui/component/class-tabs.php b/php/ui/component/class-tabs.php index 65bd5e4f..78d8817a 100644 --- a/php/ui/component/class-tabs.php +++ b/php/ui/component/class-tabs.php @@ -71,5 +71,4 @@ protected function get_tabs() { return $tabs; } - } diff --git a/php/ui/component/class-tags-input.php b/php/ui/component/class-tags-input.php index f4f11af9..696fa153 100644 --- a/php/ui/component/class-tags-input.php +++ b/php/ui/component/class-tags-input.php @@ -189,6 +189,5 @@ protected function host( $value ) { } return wp_parse_url( $value, PHP_URL_HOST ); - } } From 2725e57686505603014e5460ce4de678230d75d5 Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Mon, 25 Aug 2025 14:52:04 +0900 Subject: [PATCH 10/22] Fix or ignore existing PHP styling issues --- cloudinary.php | 2 +- php/class-admin.php | 4 ++-- php/class-assets.php | 2 +- php/class-media-library.php | 2 +- php/class-media.php | 6 +++--- php/class-plugin.php | 4 ++-- php/class-rest-api.php | 2 +- php/class-settings.php | 4 ++-- php/class-string-replace.php | 4 ++-- php/class-sync.php | 2 +- php/class-utils.php | 4 ++-- php/connect/class-api.php | 2 +- php/media/class-filter.php | 2 +- php/media/class-gallery.php | 2 +- php/media/class-video.php | 6 +++--- php/relate/class-relationship.php | 2 +- php/settings/class-setting.php | 2 +- php/sync/class-download-sync.php | 2 +- php/traits/trait-cli.php | 2 +- php/traits/trait-params.php | 2 +- php/ui/class-component.php | 2 +- php/ui/class-state.php | 4 ++-- php/ui/component/class-asset.php | 2 +- php/ui/component/class-color.php | 2 +- php/ui/component/class-connect.php | 2 +- php/ui/component/class-media-status.php | 2 +- php/ui/component/class-notice.php | 2 +- php/ui/component/class-plan-status.php | 2 +- php/ui/component/class-plan.php | 2 +- phpcs.xml.dist | 4 +++- ui-definitions/settings-pages.php | 4 ++-- 31 files changed, 44 insertions(+), 42 deletions(-) diff --git a/cloudinary.php b/cloudinary.php index 94bc8629..828e1b2e 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/php/class-admin.php b/php/class-admin.php index fe37dc29..eccbe977 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 52287e99..34349c5d 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-media-library.php b/php/class-media-library.php index 2241995e..bcb2ba53 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 182782b3..f14db174 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 8ed2765b..03a94a8a 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 ); @@ -744,7 +744,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 0200ce98..76975dcd 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 ba655448..9948400a 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 f749a62f..5b099d62 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-sync.php b/php/class-sync.php index 1ff3e146..a8d8f0cd 100644 --- a/php/class-sync.php +++ b/php/class-sync.php @@ -1105,7 +1105,7 @@ 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', diff --git a/php/class-utils.php b/php/class-utils.php index f88c307e..6fa569ae 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/connect/class-api.php b/php/connect/class-api.php index 635e76b3..3b6e370a 100644 --- a/php/connect/class-api.php +++ b/php/connect/class-api.php @@ -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/media/class-filter.php b/php/media/class-filter.php index 0831a358..0867c9cc 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 1d91a4e7..c7f8f236 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 04f77a3f..fd21e7dd 100644 --- a/php/media/class-video.php +++ b/php/media/class-video.php @@ -532,7 +532,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 +555,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 +664,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 072d7dd5..11afe910 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 5190aa1a..28de73f2 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; } diff --git a/php/sync/class-download-sync.php b/php/sync/class-download-sync.php index 83816e27..f0cc2127 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/traits/trait-cli.php b/php/traits/trait-cli.php index c5a23d3b..2cbbfd02 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 7b8e7e71..a653885f 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-component.php b/php/ui/class-component.php index 2af822f1..fe8918db 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 a7f07064..a7cd1cda 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.php b/php/ui/component/class-asset.php index 08607936..85209fcb 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. diff --git a/php/ui/component/class-color.php b/php/ui/component/class-color.php index 7c82d3e2..c49d5240 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 ); ?>