@@ -161,14 +161,14 @@ public static function get_tag_attributes( $tag ) {
161161 /**
162162 * Get the depth of an array.
163163 *
164- * @param array $array The array to check.
164+ * @param array $data The array to check.
165165 *
166166 * @return int
167167 */
168- public static function array_depth ( array $ array ) {
168+ public static function array_depth ( array $ data ) {
169169 $ depth = 0 ;
170170
171- foreach ( $ array as $ value ) {
171+ foreach ( $ data as $ value ) {
172172 if ( is_array ( $ value ) ) {
173173 $ level = self ::array_depth ( $ value ) + 1 ;
174174
@@ -205,15 +205,15 @@ public static function user_can( $task, $capability = 'manage_options', $context
205205 *
206206 * // Enforce `manage_options` to download an asset from Cloudinary.
207207 * add_filter(
208- * 'cloudinary_task_capability_manage_assets',
209- * function( $task, $context ) {
210- * if ( 'download' === $context ) {
211- * $capability = 'manage_options';
212- * }
213- * return $capability;
214- * },
215- * 10,
216- * 2
208+ * 'cloudinary_task_capability_manage_assets',
209+ * function( $task, $context ) {
210+ * if ( 'download' === $context ) {
211+ * $capability = 'manage_options';
212+ * }
213+ * return $capability;
214+ * },
215+ * 10,
216+ * 2
217217 * );
218218 *
219219 * @param $capability {string} The capability.
@@ -236,15 +236,15 @@ public static function user_can( $task, $capability = 'manage_options', $context
236236 *
237237 * // Enforce `manage_options` to download an asset from Cloudinary.
238238 * add_filter(
239- * 'cloudinary_task_capability',
240- * function( $capability, $task, $context ) {
241- * if ( 'manage_assets' === $task && 'download' === $context ) {
242- * $capability = 'manage_options';
243- * }
244- * return $capability;
245- * },
246- * 10,
247- * 3
239+ * 'cloudinary_task_capability',
240+ * function( $capability, $task, $context ) {
241+ * if ( 'manage_assets' === $task && 'download' === $context ) {
242+ * $capability = 'manage_options';
243+ * }
244+ * return $capability;
245+ * },
246+ * 10,
247+ * 3
248248 * );
249249 *
250250 * @param $capability {string} The current capability for the task.
@@ -415,7 +415,6 @@ public static function upgrade_3_0_1() {
415415
416416 // Set DB Version.
417417 update_option ( Sync::META_KEYS ['db_version ' ], get_plugin_instance ()->version );
418-
419418 }
420419
421420 /**
@@ -469,19 +468,19 @@ public static function print_inline_tag( $javascript ) {
469468
470469 $ javascript = "\n" . trim ( $ javascript , "\n\r " ) . "\n" ;
471470
472- echo sprintf ( "<script type='text/javascript'>%s</script> \n" , $ javascript ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
471+ printf ( "<script type='text/javascript'>%s</script> \n" , $ javascript ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
473472 }
474473
475474 /**
476475 * Get a sanitized input text field.
477476 *
478- * @param string $var The value to get.
479- * @param int $type The type to get.
477+ * @param string $var_name The value to get.
478+ * @param int $type The type to get.
480479 *
481480 * @return mixed
482481 */
483- public static function get_sanitized_text ( $ var , $ type = INPUT_GET ) {
484- return filter_input ( $ type , $ var , FILTER_CALLBACK , array ( 'options ' => 'sanitize_text_field ' ) );
482+ public static function get_sanitized_text ( $ var_name , $ type = INPUT_GET ) {
483+ return filter_input ( $ type , $ var_name , FILTER_CALLBACK , array ( 'options ' => 'sanitize_text_field ' ) );
485484 }
486485
487486 /**
@@ -662,15 +661,16 @@ public static function get_post_parent( $post = null ) {
662661 */
663662 public static function download_fragment ( $ url , $ size = 1048576 ) {
664663
665- $ pointer = tmpfile ();
666- $ file = false ;
664+ $ temp_file = wp_tempnam ( basename ( $ url ) );
665+ $ pointer = fopen ( $ temp_file , 'wb ' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen
666+ $ file = false ;
667667 if ( $ pointer ) {
668668 // Prep to purge.
669669 $ index = count ( self ::$ file_fragments );
670670 if ( empty ( $ index ) ) {
671671 add_action ( 'shutdown ' , array ( __CLASS__ , 'purge_fragments ' ) );
672672 }
673- self ::$ file_fragments [ $ index ] = $ pointer ;
673+ self ::$ file_fragments [ $ index ] = $ temp_file ;
674674 // Get the metadata of the stream.
675675 $ data = stream_get_meta_data ( $ pointer );
676676 // Stream the content to the temp file.
0 commit comments