PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.3.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.3.3
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
← All changes | includes/Core/Importer/Runners/DownloadZip.php +16 -32 3.7.1 → 3.3.3 View file →
@@ -5,21 +5,11 @@
5 5 use Exception;
6 6 use Templately\Core\Importer\Form;
7 7 use Templately\Core\Importer\Runners\BaseRunner;
8 8 use Templately\Core\Importer\Utils\Utils;
9 -use Templately\Core\Importer\Utils\SessionData;
10 9
11 10 class DownloadZip extends BaseRunner {
12 - /**
13 - * @var string
14 - */
15 - private $download_key;
16 11
17 - /**
18 - * @var string
19 - */
20 - private $filePath;
21 -
22 12 public function get_name(): string {
23 13 return 'downloadzip';
24 14 }
25 15
@@ -49,9 +39,12 @@
49 39 * Download the zip
50 40 */
51 41 $this->download_zip( $_id );
52 42
53 - SessionData::mark_step_complete($this->session_id, 'download_zip');
43 + $progress['download_zip'] = true;
44 + $this->update_session_data( [
45 + 'progress' => $progress,
46 + ] );
54 47 $this->sse_message( [
55 48 'type' => 'continue',
56 49 'action' => 'continue',
57 50 'info' => 'download_zip',
@@ -65,27 +58,16 @@
65 58 * @throws Exception
66 59 */
67 60 private function download_zip( $id ) {
68 61 $this->sse_log( 'download', __( 'Downloading Template Pack', 'templately' ), 1 );
69 -
70 - // Forward the host platform (e.g. 'ai-builder') so the cloud scopes the
71 - // pack download the same way as the REST/AJAX calls — without it this
72 - // binary download bypasses Helper::make_api_request() and the cloud
73 - // defaults to 'templately', re-gating AI Builder packs. Sourced from the
74 - // request param to match the param-only resolution in Helper.
75 - $requested_platform = isset( $_REQUEST['requested_platform'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
76 - ? sanitize_text_field( wp_unslash( $_REQUEST['requested_platform'] ) )
77 - : 'templately';
78 -
79 62 $response = wp_remote_get( $this->get_api_url( "v2", "import/pack/$id" ), [
80 63 'timeout' => 30,
81 64 'headers' => [
82 - 'Content-Type' => 'application/json',
83 - 'Authorization' => 'Bearer ' . $this->api_key,
84 - 'x-templately-ip' => Helper::get_ip(),
85 - 'x-templately-url' => home_url('/'),
86 - 'x-templately-version' => TEMPLATELY_VERSION,
87 - 'x-templately-requested-platform' => $requested_platform,
65 + 'Content-Type' => 'application/json',
66 + 'Authorization' => 'Bearer ' . $this->api_key,
67 + 'x-templately-ip' => Helper::get_ip(),
68 + 'x-templately-url' => home_url('/'),
69 + 'x-templately-version' => TEMPLATELY_VERSION,
88 70 ]
89 71 ]);
90 72
91 73 $response_code = wp_remote_retrieve_response_code($response);
@@ -101,10 +83,10 @@
101 83
102 84 // If the response body is JSON and it contains an error, throw an exception with the error message
103 85 if (isset($response_body['status']) && $response_body['status'] === 'error') {
104 86 $support_message = '';
105 - if(strpos($response_body['message'], 'https://templately.com/?support=open') === false){
106 - $support_message = sprintf(__(" Please try again or contact <a href='%s' target='_blank'>support</a>.", "templately"), 'https://templately.com/?support=open');
87 + if(strpos($response_body['message'], 'https://wpdeveloper.com/support') === false){
88 + $support_message = sprintf(__(" Please try again or contact <a href='%s' target='_blank'>support</a>.", "templately"), 'https://wpdeveloper.com/support');
107 89 }
108 90 $this->throw_non_retryable($response_body['message'] . $support_message);
109 91 }
110 92 }
@@ -117,11 +99,13 @@
117 99 $this->dir_path = $this->tmp_dir . $this->session_id . DIRECTORY_SEPARATOR;
118 100 $this->filePath = $this->tmp_dir . "{$this->session_id}.zip";
119 101 // $this->session_id = $session_id;
120 102
121 - SessionData::set($this->session_id, 'session_id', $this->session_id);
122 - SessionData::set($this->session_id, 'dir_path', $this->dir_path);
123 - SessionData::set($this->session_id, 'download_key', $this->download_key);
103 + $this->update_session_data([
104 + 'session_id' => $this->session_id,
105 + 'dir_path' => $this->dir_path,
106 + 'download_key' => $this->download_key,
107 + ]);
124 108
125 109 if (file_put_contents($this->filePath, $response['body'])) { // phpcs:ignore
126 110 $this->sse_log('download', __('Downloading Template Pack', 'templately'), 100);
127 111