From a7902d475e489e92fc7279e058701cdfea44f79a Mon Sep 17 00:00:00 2001 From: Thomas Zwirner Date: Fri, 5 Jul 2024 17:03:22 +0200 Subject: [PATCH] update compatibility for WordPress 6.6 & fixed potential error on attachment pages --- classes/eml/Controller/class-external-files.php | 4 ++-- classes/eml/Controller/class-init.php | 11 +++++++---- readme.txt | 9 +++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/classes/eml/Controller/class-external-files.php b/classes/eml/Controller/class-external-files.php index dc4c87b..d5c1504 100644 --- a/classes/eml/Controller/class-external-files.php +++ b/classes/eml/Controller/class-external-files.php @@ -709,7 +709,7 @@ public function get_file_by_url( string $url ): ?External_File { $result = new WP_Query( $query ); if ( 1 === $result->post_count ) { $external_file_obj = $this->get_file( $result->posts[0] ); - if ( $external_file_obj->is_valid() ) { + if ( $external_file_obj && $external_file_obj->is_valid() ) { return $external_file_obj; } } @@ -742,7 +742,7 @@ public function get_file_by_title( string $title ): bool|External_File { $result = new WP_Query( $query ); if ( 1 === $result->post_count ) { $external_file_obj = $this->get_file( $result->posts[0] ); - if ( $external_file_obj->is_valid() ) { + if ( $external_file_obj && $external_file_obj->is_valid() ) { return $external_file_obj; } } diff --git a/classes/eml/Controller/class-init.php b/classes/eml/Controller/class-init.php index 770c774..27d452a 100644 --- a/classes/eml/Controller/class-init.php +++ b/classes/eml/Controller/class-init.php @@ -286,7 +286,8 @@ public function image_downsize( array|bool $result, int $attachment_id ): bool|a // check if the file is an external file, an image and if it is really external hosted. if ( - $external_file_obj->is_valid() + $external_file_obj + && $external_file_obj->is_valid() && false === $external_file_obj->is_locally_saved() && $external_file_obj->is_image() ) { @@ -324,7 +325,8 @@ public function wp_calculate_image_srcset( array $sources, array $size_array, st // check if the file is an external file, an image and if it is really external hosted. if ( - $external_file_obj->is_valid() + $external_file_obj + && $external_file_obj->is_valid() && false === $external_file_obj->is_locally_saved() && $external_file_obj->is_image() ) { @@ -349,7 +351,8 @@ public function prevent_external_attachment_in_export( array $value, array $para // check if the file is an external file, an image and if it is really external hosted. if ( - $external_file_obj->is_valid() + $external_file_obj + && $external_file_obj->is_valid() && false === $external_file_obj->is_locally_saved() && $external_file_obj->is_image() ) { @@ -424,7 +427,7 @@ public function wp_get_attachment_metadata( array $data, int $attachment_id ): a $external_file_obj = $this->external_files_obj->get_file( $attachment_id ); // check if the file is an external file. - if ( $external_file_obj->is_valid() ) { + if ( $external_file_obj && $external_file_obj->is_valid() ) { $data['file'] = get_permalink( $attachment_id ); } return $data; diff --git a/readme.txt b/readme.txt index bd93a60..8ada61c 100644 --- a/readme.txt +++ b/readme.txt @@ -2,11 +2,11 @@ Contributors: threadi Tags: external files, media library, media Requires at least: 6.2 -Tested up to: 6.5.3 +Tested up to: 6.6 Requires PHP: 8.0 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html -Stable tag: 1.2.1 +Stable tag: 1.2.2 Add external files to your media library to link or embed them in your website. They will be integrated as if they were locally available. @@ -88,3 +88,8 @@ No, only public files can be used. * Added support for hook of plugin "Download List Block with Icons" for mark external files with rel-external * Updated compatibility-flag for WordPress 6.5.3 * Updated dependencies + += 1.2.2 = +* Updated compatibility-flag for WordPress 6.6 +* Updated dependencies +* Fixed potential error on attachment pages