1010use Timber \Image \Operation \Letterbox ;
1111
1212use Timber \URLHelper ;
13+ use Timber \PathHelper ;
1314
1415/**
1516 * Implements the Twig image filters:
@@ -163,7 +164,7 @@ public static function is_svg( $file_path ) {
163164 * SVG images are not allowed by default in WordPress, so we have to pass a default mime
164165 * type for SVG images.
165166 */
166- $ mime = wp_check_filetype_and_ext ( $ file_path , basename ( $ file_path ), array (
167+ $ mime = wp_check_filetype_and_ext ( $ file_path , PathHelper:: basename ( $ file_path ), array (
167168 'svg ' => 'image/svg+xml ' ,
168169 ) );
169170
@@ -281,7 +282,7 @@ static function delete_generated_files( $local_file ) {
281282 if ( URLHelper::is_absolute ($ local_file ) ) {
282283 $ local_file = URLHelper::url_to_file_system ($ local_file );
283284 }
284- $ info = pathinfo ($ local_file );
285+ $ info = PathHelper:: pathinfo ($ local_file );
285286 $ dir = $ info ['dirname ' ];
286287 $ ext = $ info ['extension ' ];
287288 $ filename = $ info ['filename ' ];
@@ -348,7 +349,7 @@ public static function get_sideloaded_file_loc( $file ) {
348349 $ dir = $ upload ['path ' ];
349350 $ filename = $ file ;
350351 $ file = parse_url ($ file );
351- $ path_parts = pathinfo ($ file ['path ' ]);
352+ $ path_parts = PathHelper:: pathinfo ($ file ['path ' ]);
352353 $ basename = md5 ($ filename );
353354 $ ext = 'jpg ' ;
354355 if ( isset ($ path_parts ['extension ' ]) ) {
@@ -375,15 +376,15 @@ public static function sideload_image( $file ) {
375376 $ tmp = download_url ($ file );
376377 preg_match ('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i ' , $ file , $ matches );
377378 $ file_array = array ();
378- $ file_array ['name ' ] = basename ($ matches [0 ]);
379+ $ file_array ['name ' ] = PathHelper:: basename ($ matches [0 ]);
379380 $ file_array ['tmp_name ' ] = $ tmp ;
380381 // If error storing temporarily, unlink
381382 if ( is_wp_error ($ tmp ) ) {
382383 @unlink ($ file_array ['tmp_name ' ]);
383384 $ file_array ['tmp_name ' ] = '' ;
384385 }
385386 // do the validation and storage stuff
386- $ locinfo = pathinfo ($ loc );
387+ $ locinfo = PathHelper:: pathinfo ($ loc );
387388 $ file = wp_upload_bits ($ locinfo ['basename ' ], null , file_get_contents ($ file_array ['tmp_name ' ]));
388389 return $ file ['url ' ];
389390 }
@@ -432,7 +433,7 @@ public static function analyze_url( $url ) {
432433 $ tmp = URLHelper::remove_url_component ($ tmp , WP_CONTENT_DIR );
433434 }
434435 }
435- $ parts = pathinfo ($ tmp );
436+ $ parts = PathHelper:: pathinfo ($ tmp );
436437 $ result ['subdir ' ] = ($ parts ['dirname ' ] === '/ ' ) ? '' : $ parts ['dirname ' ];
437438 $ result ['filename ' ] = $ parts ['filename ' ];
438439 $ result ['extension ' ] = strtolower ($ parts ['extension ' ]);
0 commit comments