| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | use Elementor\Plugin; |
| 7 | 7 | use Elementor\Core\Base\Module as BaseModule; |
| 8 | 8 | use Elementor\Modules\CloudKitLibrary\Connect\Cloud_Kits; |
| 9 | 9 | use Elementor\Core\Common\Modules\Connect\Module as ConnectModule; |
| 10 | -use Elementor\App\Modules\ImportExportCustomization\Module as ImportExportCustomization_Module; | |
| 10 | +use Elementor\App\Modules\ImportExport\Module as ImportExport_Module; | |
| 11 | 11 | use Elementor\App\Modules\KitLibrary\Connect\Kit_Library as Kit_Library_Api; |
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 14 | exit; // Exit if accessed directly. |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) { |
| 27 | 27 | $connect_module->register_app( 'cloud-kits', Cloud_Kits::get_class_name() ); |
| 28 | 28 | } ); |
| 29 | 29 | |
| 30 | - add_filter( 'elementor/export/kit/export-result', [ $this, 'handle_export_kit_result' ], 10, 6 ); | |
| 30 | + add_filter( 'elementor/export/kit/export-result', [ $this, 'handle_export_kit_result' ], 10, 5 ); | |
| 31 | 31 | add_filter( 'elementor/import/kit/result/cloud', [ $this, 'handle_import_kit_from_cloud' ], 10, 1 ); |
| 32 | 32 | add_filter( 'elementor/import/kit_thumbnail', [ $this, 'handle_import_kit_thumbnail' ], 10, 3 ); |
| 33 | 33 | |
| 34 | 34 | add_action( 'elementor/kit_library/registered', function () { |
| @@ -36,9 +36,9 @@ | ||
| 36 | 36 | } ); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function handle_import_kit_thumbnail( $thumbnail, $kit_id, $referrer ) { |
| 40 | - if ( ImportExportCustomization_Module::REFERRER_KIT_LIBRARY === $referrer ) { | |
| 40 | + if ( ImportExport_Module::REFERRER_KIT_LIBRARY === $referrer ) { | |
| 41 | 41 | |
| 42 | 42 | if ( empty( $kit_id ) ) { |
| 43 | 43 | return ''; |
| 44 | 44 | } |
| @@ -52,9 +52,9 @@ | ||
| 52 | 52 | |
| 53 | 53 | return $kit->thumbnail; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( ImportExportCustomization_Module::REFERRER_CLOUD === $referrer ) { | |
| 56 | + if ( ImportExport_Module::REFERRER_CLOUD === $referrer ) { | |
| 57 | 57 | if ( empty( $kit_id ) ) { |
| 58 | 58 | return ''; |
| 59 | 59 | } |
| 60 | 60 | |
| @@ -69,10 +69,10 @@ | ||
| 69 | 69 | |
| 70 | 70 | return $thumbnail; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function handle_export_kit_result( $result, $source, $export, $settings, $file, $file_size ) { | |
| 74 | - if ( ImportExportCustomization_Module::EXPORT_SOURCE_CLOUD !== $source ) { | |
| 73 | + public function handle_export_kit_result( $result, $source, $export, $settings, $file ) { | |
| 74 | + if ( ImportExport_Module::EXPORT_SOURCE_CLOUD !== $source ) { | |
| 75 | 75 | return $result; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | unset( $result['file'] ); |
| @@ -86,10 +86,8 @@ | ||
| 86 | 86 | $description, |
| 87 | 87 | $file, |
| 88 | 88 | $raw_screen_shot, |
| 89 | 89 | $settings['include'], |
| 90 | - $settings['customization']['content']['mediaFormat'] ?? 'link', | |
| 91 | - $file_size, | |
| 92 | 90 | ); |
| 93 | 91 | |
| 94 | 92 | if ( is_wp_error( $kit ) ) { |
| 95 | 93 | return $kit; |
| @@ -105,46 +103,37 @@ | ||
| 105 | 103 | 'id' => $args['kit_id'], |
| 106 | 104 | ] ); |
| 107 | 105 | |
| 108 | 106 | if ( is_wp_error( $kit ) ) { |
| 109 | - throw new \Error( ImportExportCustomization_Module::CLOUD_KIT_LIBRARY_ERROR_LOADING_RESOURCE ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 107 | + return $kit; | |
| 110 | 108 | } |
| 111 | 109 | |
| 112 | 110 | if ( empty( $kit['downloadUrl'] ) ) { |
| 113 | - throw new \Error( ImportExportCustomization_Module::KIT_LIBRARY_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 111 | + throw new \Error( ImportExport_Module::KIT_LIBRARY_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 114 | 112 | } |
| 115 | 113 | |
| 116 | - $data = [ | |
| 114 | + return [ | |
| 117 | 115 | 'file_name' => self::get_remote_kit_zip( $kit['downloadUrl'] ), |
| 118 | - 'referrer' => ImportExportCustomization_Module::REFERRER_CLOUD, | |
| 116 | + 'referrer' => ImportExport_Module::REFERRER_CLOUD, | |
| 119 | 117 | 'file_url' => $kit['downloadUrl'], |
| 120 | 118 | 'kit' => $kit, |
| 121 | 119 | ]; |
| 122 | - | |
| 123 | - if ( ! empty( $kit['mediaDownloadUrl'] ) ) { | |
| 124 | - $media_zip = self::get_remote_kit_zip( $kit['mediaDownloadUrl'], 'media.zip' ); | |
| 125 | - $data['media_file_name'] = $media_zip; | |
| 126 | - } | |
| 127 | - | |
| 128 | - return $data; | |
| 129 | 120 | } |
| 130 | 121 | |
| 131 | - public static function get_remote_kit_zip( $url, $file_name = 'kit.zip' ) { | |
| 132 | - $remote_zip_request = wp_safe_remote_get( $url, [ | |
| 133 | - 'timeout' => 300, | |
| 134 | - ] ); | |
| 122 | + public static function get_remote_kit_zip( $url ) { | |
| 123 | + $remote_zip_request = wp_safe_remote_get( $url ); | |
| 135 | 124 | |
| 136 | 125 | if ( is_wp_error( $remote_zip_request ) ) { |
| 137 | 126 | Plugin::$instance->logger->get_logger()->error( $remote_zip_request->get_error_message() ); |
| 138 | - throw new \Error( ImportExportCustomization_Module::CLOUD_KIT_LIBRARY_ERROR_LOADING_RESOURCE ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 127 | + throw new \Error( ImportExport_Module::KIT_LIBRARY_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 139 | 128 | } |
| 140 | 129 | |
| 141 | 130 | if ( 200 !== $remote_zip_request['response']['code'] ) { |
| 142 | 131 | Plugin::$instance->logger->get_logger()->error( $remote_zip_request['response']['message'] ); |
| 143 | - throw new \Error( ImportExportCustomization_Module::CLOUD_KIT_LIBRARY_ERROR_LOADING_RESOURCE ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 132 | + throw new \Error( ImportExport_Module::KIT_LIBRARY_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 144 | 133 | } |
| 145 | 134 | |
| 146 | - return Plugin::$instance->uploads_manager->create_temp_file( $remote_zip_request['body'], $file_name ); | |
| 135 | + return Plugin::$instance->uploads_manager->create_temp_file( $remote_zip_request['body'], 'kit.zip' ); | |
| 147 | 136 | } |
| 148 | 137 | |
| 149 | 138 | public static function get_app(): Cloud_Kits { |
| 150 | 139 | $cloud_kits_app = Plugin::$instance->common->get_component( 'connect' )->get_app( 'cloud-kits' ); |