Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This rule was showing several warnings in our JS. However it is really only needed in the context of a React application (see here) so I believe it can be disabled

}
}
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ '5.6', '7.4', '8.3' ]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: PHP 5.6 is still marked as supported on the wordpress.org plugin page so I think it makes sense to test it.
Testing 8.3 as well because it's currently the latest PHP version officially supported by WP.

Included 7.4 as well so we can confirm it works on the latest minor version of PHP 7. Arguably this one could be skipped?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding 8.3 is great, let us keep the other versions for now. We might reduce them at some point.


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'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Using Node 16 as this is the version specific in the .nvmrc file. We might want to consider upgrading it as it's quite an old version, but that's probably out of the scope for this task.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have a separate task to upgrade that.

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
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion cloudinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions php/cache/class-cache-point.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ public function init() {
$this->registered_cache_points[ $post->post_title ] = $post;
}
do_action( 'cloudinary_cache_init_cache_points' );

}

/**
Expand Down Expand Up @@ -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() );
}
Expand Down Expand Up @@ -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() );

Expand Down
4 changes: 2 additions & 2 deletions php/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion php/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions php/class-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ protected function get_plugins_table() {
'title' => __( 'Plugin', 'cloudinary' ),
'root_paths' => $rows,
);

}

/**
Expand Down Expand Up @@ -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' );
};
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion php/class-delivery-feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public function register_assets() {
* Enqueue Assets.
*/
public function enqueue_assets() {

}

/**
Expand Down
2 changes: 1 addition & 1 deletion php/class-delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down
2 changes: 1 addition & 1 deletion php/class-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion php/class-media-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions php/class-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: We could consider renaming all the variables using a reserved keyword... But I'm always a bit wary to do these type of refactor without properly testing (things could easily go wrong if the IDE misses something like a string interpolation, or dynamic calling the variable perhaps). And testing all of these could take a significant amount of time.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, let us keep the previous names


$config = $this->settings->get_value( 'image_settings' );

Expand All @@ -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'] );
Expand Down Expand Up @@ -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 ) ) {
Expand Down
4 changes: 2 additions & 2 deletions php/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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(
'<a href="%s">%s</a>',
Expand Down
2 changes: 1 addition & 1 deletion php/class-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
4 changes: 2 additions & 2 deletions php/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 ];
Expand Down
4 changes: 2 additions & 2 deletions php/class-string-replace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
}

Expand All @@ -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 );
}

Expand Down
6 changes: 3 additions & 3 deletions php/class-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,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' )
)
Expand Down
1 change: 0 additions & 1 deletion php/class-url.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function init_settings() {
* Set up the object.
*/
public function setup() {

}

/**
Expand Down
4 changes: 2 additions & 2 deletions php/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down Expand Up @@ -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
}
}

Expand Down
1 change: 0 additions & 1 deletion php/component/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ interface Config {
* Retrive config from class.
*/
public function get_config();

}
1 change: 0 additions & 1 deletion php/component/class-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ interface Notice {
* @return array
*/
public function get_notices();

}
1 change: 0 additions & 1 deletion php/component/class-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ interface Setup {
* Setup the object.
*/
public function setup(); // phpcs:ignore

}
6 changes: 3 additions & 3 deletions php/connect/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
);

Expand Down Expand Up @@ -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 ) {
Expand Down
1 change: 0 additions & 1 deletion php/cron/class-lock-object.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

}
2 changes: 1 addition & 1 deletion php/integrations/class-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
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 @@ -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 );
Expand Down
Loading