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
2 changes: 1 addition & 1 deletion php/class-delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public function create_delivery( $attachment_id ) {
// Preserve pre-existing transformations.
if ( $relationship instanceof Relationship ) {
$data = $relationship->get_data();
$transformations = $data['transformations'];
$transformations = isset( $data['transformations'] ) ? $data['transformations'] : null;
}
$this->delete_size_relationship( $attachment_id );
$size = $this->get_sized( $attachment_id );
Expand Down
60 changes: 30 additions & 30 deletions php/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ public static function get_tag_attributes( $tag ) {
/**
* Get the depth of an array.
*
* @param array $array The array to check.
* @param array $data The array to check.
*
* @return int
*/
public static function array_depth( array $array ) {
public static function array_depth( array $data ) {
$depth = 0;

foreach ( $array as $value ) {
foreach ( $data as $value ) {
if ( is_array( $value ) ) {
$level = self::array_depth( $value ) + 1;

Expand Down Expand Up @@ -205,15 +205,15 @@ public static function user_can( $task, $capability = 'manage_options', $context
*
* // Enforce `manage_options` to download an asset from Cloudinary.
* add_filter(
* 'cloudinary_task_capability_manage_assets',
* function( $task, $context ) {
* if ( 'download' === $context ) {
* $capability = 'manage_options';
* }
* return $capability;
* },
* 10,
* 2
* 'cloudinary_task_capability_manage_assets',
* function( $task, $context ) {
* if ( 'download' === $context ) {
* $capability = 'manage_options';
* }
* return $capability;
* },
* 10,
* 2
* );
*
* @param $capability {string} The capability.
Expand All @@ -236,15 +236,15 @@ public static function user_can( $task, $capability = 'manage_options', $context
*
* // Enforce `manage_options` to download an asset from Cloudinary.
* add_filter(
* 'cloudinary_task_capability',
* function( $capability, $task, $context ) {
* if ( 'manage_assets' === $task && 'download' === $context ) {
* $capability = 'manage_options';
* }
* return $capability;
* },
* 10,
* 3
* 'cloudinary_task_capability',
* function( $capability, $task, $context ) {
* if ( 'manage_assets' === $task && 'download' === $context ) {
* $capability = 'manage_options';
* }
* return $capability;
* },
* 10,
* 3
* );
*
* @param $capability {string} The current capability for the task.
Expand Down Expand Up @@ -415,7 +415,6 @@ public static function upgrade_3_0_1() {

// Set DB Version.
update_option( Sync::META_KEYS['db_version'], get_plugin_instance()->version );

}

/**
Expand Down Expand Up @@ -469,19 +468,19 @@ public static function print_inline_tag( $javascript ) {

$javascript = "\n" . trim( $javascript, "\n\r " ) . "\n";

echo sprintf( "<script type='text/javascript'>%s</script>\n", $javascript ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
printf( "<script type='text/javascript'>%s</script>\n", $javascript ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/**
* Get a sanitized input text field.
*
* @param string $var The value to get.
* @param int $type The type to get.
* @param string $var_name The value to get.
* @param int $type The type to get.
*
* @return mixed
*/
public static function get_sanitized_text( $var, $type = INPUT_GET ) {
return filter_input( $type, $var, FILTER_CALLBACK, array( 'options' => 'sanitize_text_field' ) );
public static function get_sanitized_text( $var_name, $type = INPUT_GET ) {
return filter_input( $type, $var_name, FILTER_CALLBACK, array( 'options' => 'sanitize_text_field' ) );
}

/**
Expand Down Expand Up @@ -662,15 +661,16 @@ public static function get_post_parent( $post = null ) {
*/
public static function download_fragment( $url, $size = 1048576 ) {

$pointer = tmpfile();
$file = false;
$temp_file = wp_tempnam( basename( $url ) );
$pointer = fopen( $temp_file, 'wb' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen
$file = false;
if ( $pointer ) {
// Prep to purge.
$index = count( self::$file_fragments );
if ( empty( $index ) ) {
add_action( 'shutdown', array( __CLASS__, 'purge_fragments' ) );
}
self::$file_fragments[ $index ] = $pointer;
self::$file_fragments[ $index ] = $temp_file;
// Get the metadata of the stream.
$data = stream_get_meta_data( $pointer );
// Stream the content to the temp file.
Expand Down