← All changes
|
includes/template-library/classes/class-import-images.php
+1
-49
4.2.1
→
3.32.0-dev2
View file →
| @@ -159,9 +159,9 @@ | ||
| 159 | 159 | |
| 160 | 160 | $svg_handler = Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' ); |
| 161 | 161 | |
| 162 | 162 | $file_content = $svg_handler->sanitizer( $file_content ); |
| 163 | - } | |
| 163 | + }; | |
| 164 | 164 | |
| 165 | 165 | $upload = wp_upload_bits( |
| 166 | 166 | $filename, |
| 167 | 167 | null, |
| @@ -211,56 +211,8 @@ | ||
| 211 | 211 | $this->_replace_image_ids[ $attachment['id'] ] = $new_attachment; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return $new_attachment; |
| 215 | - } | |
| 216 | - | |
| 217 | - /** | |
| 218 | - * Import local file. | |
| 219 | - * | |
| 220 | - * Import a local file directly to WordPress media library. | |
| 221 | - * Used for importing files that are already downloaded locally (e.g., from extracted ZIP). | |
| 222 | - * | |
| 223 | - * @since 3.33.0 | |
| 224 | - * @access public | |
| 225 | - * | |
| 226 | - * @param string $local_file_path The local file path. | |
| 227 | - * @param int $parent_post_id Optional. Parent post ID. | |
| 228 | - * | |
| 229 | - * @return false|array Imported image data, or false on failure. | |
| 230 | - */ | |
| 231 | - public function import_local_file( $local_file_path, $parent_post_id = null ) { | |
| 232 | - global $wp_filesystem; | |
| 233 | - | |
| 234 | - if ( ! $wp_filesystem->exists( $local_file_path ) ) { | |
| 235 | - return false; | |
| 236 | - } | |
| 237 | - | |
| 238 | - if ( ! function_exists( 'media_handle_sideload' ) ) { | |
| 239 | - require_once ABSPATH . 'wp-admin/includes/media.php'; | |
| 240 | - } | |
| 241 | - | |
| 242 | - if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) { | |
| 243 | - require_once ABSPATH . 'wp-admin/includes/image.php'; | |
| 244 | - } | |
| 245 | - | |
| 246 | - $file_array = [ | |
| 247 | - 'name' => basename( $local_file_path ), | |
| 248 | - 'tmp_name' => $local_file_path, | |
| 249 | - ]; | |
| 250 | - | |
| 251 | - $attachment_id = media_handle_sideload( $file_array, $parent_post_id ); | |
| 252 | - | |
| 253 | - if ( is_wp_error( $attachment_id ) ) { | |
| 254 | - return false; | |
| 255 | - } | |
| 256 | - | |
| 257 | - apply_filters( 'elementor/template_library/import_images/new_attachment', $attachment_id ); | |
| 258 | - | |
| 259 | - return [ | |
| 260 | - 'id' => $attachment_id, | |
| 261 | - 'url' => wp_get_attachment_url( $attachment_id ), | |
| 262 | - ]; | |
| 263 | 215 | } |
| 264 | 216 | |
| 265 | 217 | /** |
| 266 | 218 | * Template library import images constructor. |