Skip to content

Commit 29a6f11

Browse files
fix (design library): move require once to only where the functions are used
1 parent b682a46 commit 29a6f11

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/design-library/init.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@
1111
exit;
1212
}
1313

14-
if ( ! function_exists( 'media_handle_sideload' ) ) {
15-
require_once ABSPATH . 'wp-admin/includes/media.php';
16-
}
17-
if ( ! function_exists( 'download_url' ) ) {
18-
require_once ABSPATH . 'wp-admin/includes/file.php';
19-
}
20-
if ( ! function_exists( 'wp_read_image_metadata' ) ) {
21-
require_once ABSPATH . 'wp-admin/includes/image.php';
22-
}
23-
2414
if ( ! class_exists( 'Stackable_Design_Library' ) ) {
2515
/**
2616
* Class Stackable Design Library
@@ -141,6 +131,16 @@ public function delete_cache() {
141131
}
142132

143133
public function get_design_library_image( $request ) {
134+
if ( ! function_exists( 'media_handle_sideload' ) ) {
135+
require_once ABSPATH . 'wp-admin/includes/media.php';
136+
}
137+
if ( ! function_exists( 'download_url' ) ) {
138+
require_once ABSPATH . 'wp-admin/includes/file.php';
139+
}
140+
if ( ! function_exists( 'wp_read_image_metadata' ) ) {
141+
require_once ABSPATH . 'wp-admin/includes/image.php';
142+
}
143+
144144
$url = $request->get_param( 'image_url' );
145145

146146
$basename = sanitize_file_name( wp_basename( parse_url( $url, PHP_URL_PATH ) ) );

0 commit comments

Comments
 (0)