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
4 changes: 2 additions & 2 deletions php/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function rest_save_settings( WP_REST_Request $request ) {
$data = array_filter(
$data,
function ( $key ) use ( $settings ) {
return $settings->get_setting( $key, false );
return (bool) $settings->get_setting( $key, false );
},
ARRAY_FILTER_USE_KEY
);
Expand Down Expand Up @@ -210,7 +210,7 @@ public function register_admin( $page ) {
$page['slug'],
'',
$page['icon'],
'81.5'
81.5
);
$connected = $this->settings->get_param( 'connected' );
// Setup the Child page handles.
Expand Down
4 changes: 2 additions & 2 deletions php/class-connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ function ( $a ) {
$cname_str = $this->extract_cname( $test );
$cname_valid = $this->validate_domain( $cname_str );

if ( $cname_str && ( ! substr_count( $cname_valid, '.' ) || false === $cname_valid ) ) {
if ( $cname_str && ( false === $cname_valid || ! substr_count( $cname_valid, '.' ) ) ) {
$result['type'] = 'invalid_cname';
$result['message'] = __( 'CNAME is not a valid domain name.', 'cloudinary' );

Expand Down Expand Up @@ -632,7 +632,7 @@ protected function extract_cname( $parsed_url ) {
*
* @param string $domain The domain.
*
* @return bool
* @return string|false
*/
protected function validate_domain( $domain ) {
$is_valid = false;
Expand Down
6 changes: 3 additions & 3 deletions php/class-deactivation.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function render_connected() {

$is_cloudinary_only = 'cld' === $this->plugin->settings->get_value( 'offload' );
?>
<div id="cloudinary-deactivation" class="cld-modal" data-cloudinary-only="<?php echo esc_attr( $is_cloudinary_only ); ?>">
<div id="cloudinary-deactivation" class="cld-modal" data-cloudinary-only="<?php echo esc_attr( (string) $is_cloudinary_only ); ?>">
<div class="cloudinary-deactivation cld-modal-box">
<?php if ( $is_cloudinary_only ) : ?>
<div class="modal-header" id="modal-header">
Expand Down Expand Up @@ -495,7 +495,7 @@ protected function cleanup_user_data() {

foreach ( $user_meta_keys as $key ) {
// Inspired on https://developer.wordpress.org/reference/functions/delete_post_meta_by_key/.
delete_metadata( 'user', null, $key, '', true );
delete_metadata( 'user', 0, $key, '', true );
}
}

Expand Down Expand Up @@ -528,7 +528,7 @@ protected function cleanup_term_meta() {

foreach ( $term_meta_keys as $key ) {
// Inspired on https://developer.wordpress.org/reference/functions/delete_post_meta_by_key/.
delete_metadata( 'term', null, $key, '', true );
delete_metadata( 'term', 0, $key, '', true );
}
}

Expand Down
8 changes: 4 additions & 4 deletions php/class-delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ public function validate_url( $url ) {
/**
* Set url usability.
*
* @param object $item The item object result.
* @param array $item The item result.
* @param null|bool $auto_sync If auto_sync is on.
*/
protected function set_usability( $item, $auto_sync = null ) {
Expand All @@ -1841,9 +1841,9 @@ protected function set_usability( $item, $auto_sync = null ) {
* @hook cloudinary_set_usable_asset
* @since 3.0.2
*
* @param object $item The found asset object.
* @param array $item The found asset.
*
* @return object
* @return array
*/
$item = apply_filters( 'cloudinary_set_usable_asset', $item );

Expand Down Expand Up @@ -1873,7 +1873,7 @@ protected function set_usability( $item, $auto_sync = null ) {
* @since 3.1.6
*
* @param string $url The URL to be searched for and prepared to be delivered by Cloudinary.
* @param object $item The found asset object.
* @param array $item The found asset.
* @param string $content_url The content URL.
*
* @return string
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 @@ -45,7 +45,7 @@ public function setup() {
self::MEDIA_LIBRARY_SLUG,
array( $this, 'render' ),
'dashicons-cloudinary-dam',
'81.6'
81.6
);
}

Expand Down
20 changes: 10 additions & 10 deletions php/class-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -1357,11 +1357,11 @@ protected function get_cache_key( $args ) {
/**
* Generate a Cloudinary URL based on attachment ID and required size.
*
* @param int $attachment_id The id of the attachment.
* @param array|string $size The wp size to set for the URL.
* @param array|string $transformations Set of transformations to apply to this url.
* @param string|null $cloudinary_id Optional forced cloudinary ID.
* @param bool $overwrite_transformations Flag url is a breakpoint URL to stop re-applying default transformations.
* @param int $attachment_id The id of the attachment.
* @param array|string|bool|null $size The wp size to set for the URL.
* @param array|string|bool|null $transformations Set of transformations to apply to this url.
* @param string|null $cloudinary_id Optional forced cloudinary ID.
* @param bool $overwrite_transformations Flag url is a breakpoint URL to stop re-applying default transformations.
*
* @return string|null The converted URL.
*/
Expand Down Expand Up @@ -2058,7 +2058,7 @@ public function editor_assets() {
$max_files = apply_filters( 'cloudinary_max_files_import', 20 );

// External assets.
wp_enqueue_script( 'cloudinary-media-modal', $this->plugin->dir_url . '/js/media-modal.js', null, $this->plugin->version, true );
wp_enqueue_script( 'cloudinary-media-modal', $this->plugin->dir_url . '/js/media-modal.js', array(), $this->plugin->version, true );
wp_enqueue_script( 'cloudinary-media-library', CLOUDINARY_ENDPOINTS_MEDIA_LIBRARY, $deps, $this->plugin->version, true );
wp_enqueue_script( 'cloudinary-terms-order', $this->plugin->dir_url . '/js/terms-order.js', array( 'jquery', 'wp-i18n' ), $this->plugin->version, true );
wp_enqueue_style( 'cloudinary' );
Expand Down Expand Up @@ -2638,7 +2638,7 @@ public function get_process_logs( $attachment_id, $raw = false ) {
$time = "_{$time}";
} else { // Readable request.
$to_unset = "_{$time}";
$time = gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time );
$time = gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), (int) $time );
}

// Maybe cleanup log entries.
Expand Down Expand Up @@ -2682,9 +2682,9 @@ public function build_cached_meta( $post_id, $key, $single ) {
/**
* Update cloudinary metadata.
*
* @param int $post_id The attachment ID.
* @param string $key The meta key to get.
* @param string|array $data $the meta data to update.
* @param int $post_id The attachment ID.
* @param string $key The meta key to get.
* @param mixed $data The meta data to update.
*
* @return bool
*/
Expand Down
9 changes: 7 additions & 2 deletions php/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ private function get_settings_page_structure() {
public function setup_settings() {
$params = $this->get_settings_page_structure();
$this->settings = new Settings( $this->slug, $params );
$components = array_filter( $this->components, array( $this, 'is_setting_component' ) );
/**
* Components implementing Settings_Component.
*
* @var Settings_Component[] $components
*/
$components = array_filter( $this->components, array( $this, 'is_setting_component' ) );
$this->init_component_settings( $components );

// Setup connection.
Expand Down Expand Up @@ -328,7 +333,7 @@ public function enqueue_assets() {
public function register_assets() {
// Register Main.
wp_register_script( 'cloudinary', $this->dir_url . 'js/cloudinary.js', array( 'jquery', 'wp-util' ), $this->version, true );
wp_register_style( 'cloudinary', $this->dir_url . 'css/cloudinary.css', null, $this->version );
wp_register_style( 'cloudinary', $this->dir_url . 'css/cloudinary.css', array(), $this->version );

$components = array_filter( $this->components, array( $this, 'is_asset_component' ) );
array_map(
Expand Down
6 changes: 3 additions & 3 deletions php/class-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,9 @@ public function sync_base( $attachment_id ) {
*
* @hook cloudinary_sync_base
*
* @param array $signatures The attachments required signatures.
* @param WP_Post $post The attachment post.
* @param Sync $sync The sync object instance.
* @param array $signatures The attachments required signatures.
* @param \WP_Post|null $post The attachment post.
* @param Sync $sync The sync object instance.
*
* @return array
*/
Expand Down
18 changes: 9 additions & 9 deletions php/connect/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ public function setup( Plugin $plugin ) {
/**
* Return an endpoint for a specific resource type.
*
* @param string $resource The resource type for the endpoint.
* @param string $function The function of the endpoint.
* @param bool $endpoint Flag to get an endpoint or an asset url.
* @param string|null $resource The resource type for the endpoint.
* @param string|null $function The function of the endpoint.
* @param bool $endpoint Flag to get an endpoint or an asset url.
*
* @return string
*/
Expand Down Expand Up @@ -437,7 +437,7 @@ public function upload_large( $attachment_id, $args ) {

// Since WP_Filesystem doesn't have a fread, we need to do it manually. However we'll still use it for writing.
$src = fopen( $args['file'], 'r' ); // phpcs:ignore
$temp_file_name = wp_tempnam( uniqid( time() ) . '.' . Utils::pathinfo( $args['file'], PATHINFO_EXTENSION ) );
$temp_file_name = wp_tempnam( uniqid( (string) time() ) . '.' . Utils::pathinfo( $args['file'], PATHINFO_EXTENSION ) );
$upload_id = substr( sha1( uniqid( $this->credentials['api_secret'] . wp_rand() ) ), 0, 16 );
$chunk_size = 20000000;
$index = 0;
Expand Down Expand Up @@ -500,10 +500,10 @@ public function copy( $attachment_id, $args ) {
/**
* Upload an asset.
*
* @param int $attachment_id Attachment ID to upload.
* @param array $args Array of upload options.
* @param array $headers Additional headers to use in upload.
* @param bool $try_remote Flag to try_remote upload.
* @param int|string $attachment_id Attachment ID to upload, or a file path for raw uploads.
* @param array $args Array of upload options.
* @param array $headers Additional headers to use in upload.
* @param bool $try_remote Flag to try_remote upload.
*
* @return array|\WP_Error
*/
Expand Down Expand Up @@ -1026,7 +1026,7 @@ private function call( $url, $args = array(), $method = 'get' ) {
return $request;
}
$body = wp_remote_retrieve_body( $request );
$result = json_decode( $body, ARRAY_A );
$result = json_decode( $body, true );
if ( empty( $result ) && ! empty( $body ) ) {
return $body; // not json.
}
Expand Down
14 changes: 7 additions & 7 deletions php/cron/class-lock-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Lock_File {
/**
* Get a lock data.
*
* @param string|null $file The lock name.
* @param string|int|null $file The lock name.
*
* @return false|mixed|string
*/
Expand All @@ -50,7 +50,7 @@ public function get_lock_file( $file = null ) {
/**
* Get the lock name.
*
* @param string|null $file_name The name of the transient.
* @param string|int|null $file_name The name of the transient.
*
* @return mixed|string|null
*/
Expand All @@ -66,7 +66,7 @@ public function get_lock_file_name( $file_name = null ) {
/**
* Check if a lock is in place.
*
* @param string|null $file The lock name.
* @param string|int|null $file The lock name.
*
* @return bool
*/
Expand All @@ -87,14 +87,14 @@ public function has_lock_file( $file = null ) {
/**
* Set a lock.
*
* @param string|null $file The name to set.
* @param mixed $data The data to set.
* @param string|int|null $file The name to set.
* @param mixed $data The data to set.
*
* @return mixed|string
*/
public function set_lock_file( $file = null, $data = null ) {
$time = time();
$bits = $data ? $data : uniqid( $time );
$bits = $data ? $data : uniqid( (string) $time );
if ( ! $this->has_lock_file( $file ) ) {
$file_path = $this->get_lock_file_name( $file );
file_put_contents( $file_path, $bits ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_file_put_contents
Expand All @@ -106,7 +106,7 @@ public function set_lock_file( $file = null, $data = null ) {
/**
* Delete a lock.
*
* @param string|null $file The name to set.
* @param string|int|null $file The name to set.
*/
public function delete_lock_file( $file = null ) {
$file = $this->get_lock_file_name( $file );
Expand Down
2 changes: 1 addition & 1 deletion php/cron/class-lock-object.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function has_lock_file( $file = null ) {
*/
public function set_lock_file( $file = null, $data = null ) {
$time = time();
$bits = $data ? json_decode( $data, true ) : uniqid( $time );
$bits = $data ? json_decode( $data, true ) : uniqid( (string) $time );
if ( ! $this->has_lock_file( $file ) ) {
set_transient( self::PREFIX . $this->get_lock_file_name( $file ), $bits, Cron::$daemon_watcher_interval );
}
Expand Down
4 changes: 2 additions & 2 deletions php/delivery/class-lazy-load.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function js_noscript( $tag, $tag_element ) {
'data-image' => wp_json_encode( $options ),
);

return HTML::build_tag( 'noscript', $atts ) . $tag . HTML::build_tag( 'noscript', null, 'close' );
return HTML::build_tag( 'noscript', $atts ) . $tag . HTML::build_tag( 'noscript', array(), 'close' );
}

/**
Expand Down Expand Up @@ -349,7 +349,7 @@ public function add_features( $tag_element ) {
* Register front end hooks.
*/
public function register_assets() {
wp_register_script( 'cld-lazy-load', $this->plugin->dir_url . 'js/lazy-load.js', null, $this->plugin->version, false );
wp_register_script( 'cld-lazy-load', $this->plugin->dir_url . 'js/lazy-load.js', array(), $this->plugin->version, false );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion php/integrations/class-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function language_switcher_items( $languages_links ) {
break;
}

$relationship = new Relationship( $args['asset'] );
$relationship = new Relationship( (int) $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 @@ -537,7 +537,7 @@ public function filter_video_embeds( $html, $id, $attachment ) {
$shortcodes = $this->get_video_shortcodes( $html );
foreach ( $shortcodes as $shortcode ) {
// Add ID.
$new_atts = $shortcode['args'] . ' id="' . esc_attr( $id ) . '"';
$new_atts = $shortcode['args'] . ' id="' . esc_attr( (string) $id ) . '"';

// Add defaults.
$settings = $this->media->get_settings()->get_value( 'video_settings' );
Expand Down
4 changes: 2 additions & 2 deletions php/media/class-global-transformations.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function get_transformations( $type ) {
switch ( $screen->base ) {
case 'term':
$term_id = filter_input( INPUT_GET, 'tag_ID', FILTER_SANITIZE_NUMBER_INT );
$transformations = $this->get_term_transformations( $term_id, $type );
$transformations = $this->get_term_transformations( (int) $term_id, $type );
break;
default:
$transformations = array();
Expand Down Expand Up @@ -428,7 +428,7 @@ function ( $term ) {
*/
public function make_term_sort_item( $id, $name ) {
$out = array(
'<li class="cld-tax-order-list-item" data-item="' . esc_attr( $id ) . '">',
'<li class="cld-tax-order-list-item" data-item="' . esc_attr( (string) $id ) . '">',
'<span class="dashicons dashicons-menu cld-tax-order-list-item-handle"></span>',
'<input class="cld-tax-order-list-item-input" type="hidden" name="cld_tax_order[]" value="' . $id . '">' . $name,
'</li>',
Expand Down
2 changes: 1 addition & 1 deletion php/media/class-upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function convert_cloudinary_version( $attachment_id ) {
// Check folder sync in order and if it's not a URL.
if ( ! wp_http_validate_url( $file ) && $this->media->is_folder_synced( $attachment_id ) ) {
$public_id_folder = ltrim( dirname( $this->media->get_public_id( $attachment_id ) ) );
$test_signature = md5( false );
$test_signature = md5( (string) false );
$folder_signature = md5( $public_id_folder );
$signature = $this->sync->get_signature( $attachment_id );
if ( $folder_signature !== $test_signature && $test_signature === $signature['folder'] ) {
Expand Down
4 changes: 2 additions & 2 deletions php/media/class-video.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ public function admin_enqueue_scripts() {
$player_style_url = sprintf( CLOUDINARY_ENDPOINTS_VIDEO_PLAYER_STYLE, CLOUDINARY_ENDPOINTS_VIDEO_PLAYER_VERSION );
$player_script_url = sprintf( CLOUDINARY_ENDPOINTS_VIDEO_PLAYER_SCRIPT, CLOUDINARY_ENDPOINTS_VIDEO_PLAYER_VERSION );

wp_register_style( 'cld-player', $player_style_url, null, CLOUDINARY_ENDPOINTS_VIDEO_PLAYER_VERSION );
wp_register_script( 'cld-core', $core_url, null, CLOUDINARY_ENDPOINTS_CORE_VERSION, true );
wp_register_style( 'cld-player', $player_style_url, array(), CLOUDINARY_ENDPOINTS_VIDEO_PLAYER_VERSION );
wp_register_script( 'cld-core', $core_url, array(), CLOUDINARY_ENDPOINTS_CORE_VERSION, true );
wp_register_script( 'cld-player', $player_script_url, array( 'cld-core' ), CLOUDINARY_ENDPOINTS_VIDEO_PLAYER_VERSION, true );
}
}
Expand Down
6 changes: 3 additions & 3 deletions php/sync/class-sync-queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ protected function get_thread_queue_details( $thread ) {
/**
* Add to a threads queue.
*
* @param int $thread Thread ID.
* @param array $attachment_ids The ID to add.
* @param string $thread Thread name.
* @param array $attachment_ids The ID to add.
*/
public function add_to_thread_queue( $thread, array $attachment_ids ) {

Expand Down Expand Up @@ -856,7 +856,7 @@ public function add_to_queue( array $attachment_ids, $type = 'queue' ) {

$attachment_ids = $been_synced;
if ( ! empty( $attachment_ids ) ) {
$chunk_size = ceil( count( $attachment_ids ) / count( $threads ) );
$chunk_size = (int) ceil( count( $attachment_ids ) / count( $threads ) );
$chunks = array_chunk( $attachment_ids, $chunk_size );
foreach ( $chunks as $index => $chunk ) {
$thread = array_shift( $threads );
Expand Down
4 changes: 2 additions & 2 deletions php/traits/trait-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ protected static function pad_name( $name, $max_length, $pad_char = '.', $concat
$diff = $name_length - $max_length;
$concat_length = $diff > 3 ? 3 : $diff;
$usable_length = $max_length - $concat_length;
$front = substr( $name, 0, floor( $usable_length / 2 ) );
$back = substr( $name, strlen( $name ) - ceil( $usable_length / 2 ) );
$front = substr( $name, 0, (int) floor( $usable_length / 2 ) );
$back = substr( $name, strlen( $name ) - (int) ceil( $usable_length / 2 ) );
$name = $front . implode( array_fill( 0, $concat_length, $concat_char ) ) . $back;
}
$used_length = $max_length - strlen( $name );
Expand Down
Loading
Loading