PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
← All changes | app/Agent/WooProductImages.php +4 -8 3.1.4 → 3.2.2 View file →
@@ -3,8 +3,10 @@
3 3 namespace Extendify\Agent;
4 4
5 5 defined('ABSPATH') || die('No direct access.');
6 6
7 +use Extendify\Shared\Services\Import\ImageUploader;
8 +
7 9 /**
8 10 * Adds an `images` field to WooCommerce's product abilities, which ship with no
9 11 * way to set a product image at all.
10 12 */
@@ -176,17 +178,11 @@
176 178 if (!\current_user_can('upload_files')) {
177 179 return false;
178 180 }
179 181
180 - if (!function_exists('\media_sideload_image')) {
181 - require_once ABSPATH . 'wp-admin/includes/media.php';
182 - require_once ABSPATH . 'wp-admin/includes/file.php';
183 - require_once ABSPATH . 'wp-admin/includes/image.php';
184 - }
182 + $uploaded = (new ImageUploader())->uploadImage($url);
185 183
186 - $id = \media_sideload_image($url, 0, null, 'id');
187 -
188 - return \is_wp_error($id) ? false : $id;
184 + return \is_wp_error($uploaded) ? false : $uploaded['attachment_id'];
189 185 }
190 186
191 187 private static function inputSchema()
192 188 {