From 7de2a48603880656c973c826914f8c2b7453ee3d Mon Sep 17 00:00:00 2001 From: Daryl Chymko Date: Tue, 15 Oct 2024 17:00:57 -0700 Subject: [PATCH 1/7] Update array functions for Statamic 5 --- src/Helpers/Migrator.php | 12 ++++++------ src/Helpers/Preparer.php | 4 ++-- src/Helpers/WpImporter.php | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Helpers/Migrator.php b/src/Helpers/Migrator.php index 7a668de..c5ef4a0 100644 --- a/src/Helpers/Migrator.php +++ b/src/Helpers/Migrator.php @@ -59,7 +59,7 @@ private function prepareMigration($migration) { $migration['pages'] = collect( $this->sortDeepest( - array_get($migration, 'pages', [])->all() + \Arr::get($migration, 'pages', [])->all() ) ); @@ -93,7 +93,7 @@ private function sortDeepest($arr) */ private function createTaxonomies() { - foreach (array_get($this->migration, 'taxonomies', []) as $taxonomy_slug => $taxonomy_data) { + foreach (\Arr::get($this->migration, 'taxonomies', []) as $taxonomy_slug => $taxonomy_data) { $taxonomy = Taxonomy::findByHandle($taxonomy_slug); if (! $taxonomy) { @@ -115,7 +115,7 @@ private function createTaxonomies() */ private function createTaxonomyTerms() { - foreach (array_get($this->migration, 'terms', []) as $taxonomy_slug => $terms) { + foreach (\Arr::get($this->migration, 'terms', []) as $taxonomy_slug => $terms) { foreach ($terms as $term_slug => $term_data) { // Skip if this term was not checked in the summary. if (! $this->summary['taxonomies'][$taxonomy_slug]['terms'][$term_slug]['_checked']) { @@ -144,7 +144,7 @@ private function createTaxonomyTerms() */ private function createCollections() { - foreach (array_get($this->migration, 'collections', []) as $handle => $data) { + foreach (\Arr::get($this->migration, 'collections', []) as $handle => $data) { $collection = Collection::findByHandle($handle); if (! $collection) { @@ -181,7 +181,7 @@ private function createEntries() $entry->date($meta['order']); - array_set($meta, 'data.slug', $slug); + \Arr::set($meta, 'data.slug', $slug); foreach ($meta['data'] as $key => $value) { $entry->set($key, $value); @@ -222,7 +222,7 @@ private function createPages() $page = Entry::make()->collection('pages')->slug($slug); } - array_set($meta, 'data.slug', $slug); + \Arr::set($meta, 'data.slug', $slug); foreach ($meta['data'] as $key => $value) { $page->set($key, $value); diff --git a/src/Helpers/Preparer.php b/src/Helpers/Preparer.php index 5728038..a79221b 100644 --- a/src/Helpers/Preparer.php +++ b/src/Helpers/Preparer.php @@ -85,7 +85,7 @@ private function createCollections() return; } - foreach (array_get($this->data, 'collections', []) as $name => $entries) { + foreach (\Arr::get($this->data, 'collections', []) as $name => $entries) { $this->createCollection($name, $entries); $this->createEntries($name, $entries); } @@ -161,7 +161,7 @@ private function replaceTaxonomies($data) foreach ($value as $i => $slug) { // Replace the slug with the ID. If it's not found for whatever reason, // we'll just leave the slug as-is. - $value[$i] = array_get($this->migration['terms'][$field_name]->get($slug), 'id', $slug); + $value[$i] = \Arr::get($this->migration['terms'][$field_name]->get($slug), 'id', $slug); } if ($is_string) { diff --git a/src/Helpers/WpImporter.php b/src/Helpers/WpImporter.php index 6009e27..e4745d8 100644 --- a/src/Helpers/WpImporter.php +++ b/src/Helpers/WpImporter.php @@ -10,7 +10,7 @@ class WpImporter { public function prepare($data) { - if (! $data = json_decode($data, true)) { + if (!$data = json_decode($data, true)) { throw new Exception('Invalid export data format.'); } @@ -24,7 +24,7 @@ public function summary($prepared) foreach ($prepared['pages'] as $page_url => $page) { $summary['pages'][$page_url] = [ 'url' => $page_url, - 'title' => array_get($page['data'], 'title'), + 'title' => \Arr::get($page['data'], 'title'), 'exists' => (bool) Entry::findByUri($page_url), '_checked' => true, ]; From 06d2d84ebd0629717678f0973d0667e03d7376d3 Mon Sep 17 00:00:00 2001 From: Daryl Chymko Date: Tue, 15 Oct 2024 22:04:20 -0700 Subject: [PATCH 2/7] update plugin namespaces to match composer slug --- README.md | 2 +- src/Helpers/Migrator.php | 30 +++++++++++------------ src/Helpers/Preparer.php | 14 +++++------ src/Http/Controllers/ImportController.php | 4 +-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 55978b9..1971884 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ You can use the events above to do your own downloading of images and what not. You can search for this addon in the `Tools > Addons` section of the Statamic control panel and click **install**, or run the following command from your project root: ``` bash -composer require RadPack/statamic-wp-import +composer require RadPack/wp-import ``` ## How to Use diff --git a/src/Helpers/Migrator.php b/src/Helpers/Migrator.php index c5ef4a0..64d4dda 100644 --- a/src/Helpers/Migrator.php +++ b/src/Helpers/Migrator.php @@ -96,7 +96,7 @@ private function createTaxonomies() foreach (\Arr::get($this->migration, 'taxonomies', []) as $taxonomy_slug => $taxonomy_data) { $taxonomy = Taxonomy::findByHandle($taxonomy_slug); - if (! $taxonomy) { + if (!$taxonomy) { $taxonomy = Taxonomy::make($taxonomy_slug); } @@ -118,13 +118,13 @@ private function createTaxonomyTerms() foreach (\Arr::get($this->migration, 'terms', []) as $taxonomy_slug => $terms) { foreach ($terms as $term_slug => $term_data) { // Skip if this term was not checked in the summary. - if (! $this->summary['taxonomies'][$taxonomy_slug]['terms'][$term_slug]['_checked']) { + if (!$this->summary['taxonomies'][$taxonomy_slug]['terms'][$term_slug]['_checked']) { continue; } $term = Term::findBySlug($term_slug, $taxonomy_slug); - if (! $term) { + if (!$term) { $term = Term::make($term_slug)->taxonomy($taxonomy_slug); } @@ -147,7 +147,7 @@ private function createCollections() foreach (\Arr::get($this->migration, 'collections', []) as $handle => $data) { $collection = Collection::findByHandle($handle); - if (! $collection) { + if (!$collection) { $collection = Collection::make($handle); } @@ -169,13 +169,13 @@ private function createEntries() foreach ($this->migration['entries'] as $collection => $entries) { foreach ($entries as $slug => $meta) { // Skip if this entry was not checked in the summary. - if (! $this->summary['collections'][$collection]['entries'][$slug]['_checked']) { + if (!$this->summary['collections'][$collection]['entries'][$slug]['_checked']) { continue; } $entry = Entry::query()->where('collection', $collection)->where('slug', $slug)->first(); - if (! $entry) { + if (!$entry) { $entry = Entry::make()->collection($collection)->slug($slug); } @@ -187,7 +187,7 @@ private function createEntries() $entry->set($key, $value); } - if (config('statamic-wp-import.download_images')) { + if (config('wp-import.download_images')) { $asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', $collection, $slug); if ($asset) { @@ -209,7 +209,7 @@ private function createPages() { foreach ($this->migration['pages'] as $url => $meta) { // Skip if this page was not checked in the summary. - if (! $this->summary['pages'][$url]['_checked']) { + if (!$this->summary['pages'][$url]['_checked']) { continue; } @@ -218,7 +218,7 @@ private function createPages() $page = Entry::query()->where('collection', 'pages')->where('slug', $slug)->first(); - if (! $page) { + if (!$page) { $page = Entry::make()->collection('pages')->slug($slug); } @@ -228,7 +228,7 @@ private function createPages() $page->set($key, $value); } - if (config('statamic-wp-import.download_images')) { + if (config('wp-import.download_images')) { $asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', 'pages', $slug); if ($asset) { @@ -245,7 +245,7 @@ private function createPages() */ private function downloadAsset(?string $url, string $collection, string $slug): Asset|bool { - if (! $url) { + if (!$url) { return false; } @@ -256,15 +256,15 @@ private function downloadAsset(?string $url, string $collection, string $slug): Storage::put($tempFile = 'temp', $image); - $assetContainer = AssetContainer::findByHandle(config('statamic-wp-import.assets_container')); + $assetContainer = AssetContainer::findByHandle(config('wp-import.assets_container')); $asset = $assetContainer->makeAsset("{$collection}/{$slug}/{$originalImageName}"); - if ($asset->exists() && config('statamic-wp-import.skip_existing_images')) { + if ($asset->exists() && config('wp-import.skip_existing_images')) { return $asset; } - if ($asset->exists() && config('statamic-wp-import.overwrite_images')) { + if ($asset->exists() && config('wp-import.overwrite_images')) { $asset->delete(); } @@ -279,7 +279,7 @@ private function downloadAsset(?string $url, string $collection, string $slug): return $asset; } catch (Exception $e) { - logger('Image download failed: '.$e->getMessage()); + logger('Image download failed: ' . $e->getMessage()); return false; } diff --git a/src/Helpers/Preparer.php b/src/Helpers/Preparer.php index a79221b..e3bb5ea 100644 --- a/src/Helpers/Preparer.php +++ b/src/Helpers/Preparer.php @@ -15,7 +15,7 @@ public function prepare(array $data) { $this->data = $data; - if (! isset($this->data['pages']) || ! is_array($this->data['pages'])) { + if (!isset($this->data['pages']) || !is_array($this->data['pages'])) { $this->data['pages'] = []; } @@ -32,7 +32,7 @@ public function prepare(array $data) $this->createTaxonomies(); $this->createCollections(); - if (config('statamic-wp-import.exclude_underscore_data')) { + if (config('wp-import.exclude_underscore_data')) { $this->filterMetaData(); } @@ -54,14 +54,14 @@ protected function filterMetaData() private function createTaxonomies() { - if (! isset($this->data['taxonomies'])) { + if (!isset($this->data['taxonomies'])) { return; } foreach ($this->data['taxonomies'] as $taxonomy_name => $terms) { $this->migration['taxonomies']->put($taxonomy_name, [ 'title' => Str::title($taxonomy_name), - 'route' => '/'.$taxonomy_name.'/{slug}', + 'route' => '/' . $taxonomy_name . '/{slug}', ]); $this->migration['terms']->put($taxonomy_name, collect()); @@ -81,7 +81,7 @@ private function createTaxonomies() private function createCollections() { - if (! isset($this->data['collections'])) { + if (!isset($this->data['collections'])) { return; } @@ -100,7 +100,7 @@ private function createCollections() */ private function createCollection($collection, $entries) { - $route = '/'.$collection.'/{slug}'; + $route = '/' . $collection . '/{slug}'; $collection = str_replace('/', '-', $collection); @@ -148,7 +148,7 @@ private function createEntries($collection, $entries) private function replaceTaxonomies($data) { foreach ($data as $field_name => &$value) { - if (! $this->isTaxonomyField($field_name)) { + if (!$this->isTaxonomyField($field_name)) { continue; } diff --git a/src/Http/Controllers/ImportController.php b/src/Http/Controllers/ImportController.php index c154fdc..afcb766 100644 --- a/src/Http/Controllers/ImportController.php +++ b/src/Http/Controllers/ImportController.php @@ -32,11 +32,11 @@ public function upload(Request $request) public function summary() { - if (! $data = Cache::get('wp-import.statamic.prepared')) { + if (!$data = Cache::get('wp-import.statamic.prepared')) { return redirect()->to(cp_route('wp-import.index')); } - return view('statamic-wp-import::summary', [ + return view('wp-import::summary', [ 'summary' => $this->importer()->summary($data), ]); } From 084855f79fbfb5bf2dc014f2a971ddf4770c92d0 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 16 Oct 2024 07:07:04 +0100 Subject: [PATCH 3/7] use import --- src/Helpers/Migrator.php | 13 +++++++------ src/Helpers/Preparer.php | 5 +++-- src/Helpers/WpImporter.php | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Helpers/Migrator.php b/src/Helpers/Migrator.php index 64d4dda..0a936f4 100644 --- a/src/Helpers/Migrator.php +++ b/src/Helpers/Migrator.php @@ -12,6 +12,7 @@ use Statamic\Facades\Stache; use Statamic\Facades\Taxonomy; use Statamic\Facades\Term; +use Statamic\Support\Arr; use Symfony\Component\HttpFoundation\File\UploadedFile; class Migrator @@ -59,7 +60,7 @@ private function prepareMigration($migration) { $migration['pages'] = collect( $this->sortDeepest( - \Arr::get($migration, 'pages', [])->all() + Arr::get($migration, 'pages', [])->all() ) ); @@ -93,7 +94,7 @@ private function sortDeepest($arr) */ private function createTaxonomies() { - foreach (\Arr::get($this->migration, 'taxonomies', []) as $taxonomy_slug => $taxonomy_data) { + foreach (Arr::get($this->migration, 'taxonomies', []) as $taxonomy_slug => $taxonomy_data) { $taxonomy = Taxonomy::findByHandle($taxonomy_slug); if (!$taxonomy) { @@ -115,7 +116,7 @@ private function createTaxonomies() */ private function createTaxonomyTerms() { - foreach (\Arr::get($this->migration, 'terms', []) as $taxonomy_slug => $terms) { + foreach (Arr::get($this->migration, 'terms', []) as $taxonomy_slug => $terms) { foreach ($terms as $term_slug => $term_data) { // Skip if this term was not checked in the summary. if (!$this->summary['taxonomies'][$taxonomy_slug]['terms'][$term_slug]['_checked']) { @@ -144,7 +145,7 @@ private function createTaxonomyTerms() */ private function createCollections() { - foreach (\Arr::get($this->migration, 'collections', []) as $handle => $data) { + foreach (Arr::get($this->migration, 'collections', []) as $handle => $data) { $collection = Collection::findByHandle($handle); if (!$collection) { @@ -181,7 +182,7 @@ private function createEntries() $entry->date($meta['order']); - \Arr::set($meta, 'data.slug', $slug); + Arr::set($meta, 'data.slug', $slug); foreach ($meta['data'] as $key => $value) { $entry->set($key, $value); @@ -222,7 +223,7 @@ private function createPages() $page = Entry::make()->collection('pages')->slug($slug); } - \Arr::set($meta, 'data.slug', $slug); + Arr::set($meta, 'data.slug', $slug); foreach ($meta['data'] as $key => $value) { $page->set($key, $value); diff --git a/src/Helpers/Preparer.php b/src/Helpers/Preparer.php index e3bb5ea..0ea6dab 100644 --- a/src/Helpers/Preparer.php +++ b/src/Helpers/Preparer.php @@ -3,6 +3,7 @@ namespace RadPack\StatamicWpImport\Helpers; use Statamic\Facades\URL; +use Statamic\Support\Arr; use Statamic\Support\Str; class Preparer @@ -85,7 +86,7 @@ private function createCollections() return; } - foreach (\Arr::get($this->data, 'collections', []) as $name => $entries) { + foreach (Arr::get($this->data, 'collections', []) as $name => $entries) { $this->createCollection($name, $entries); $this->createEntries($name, $entries); } @@ -161,7 +162,7 @@ private function replaceTaxonomies($data) foreach ($value as $i => $slug) { // Replace the slug with the ID. If it's not found for whatever reason, // we'll just leave the slug as-is. - $value[$i] = \Arr::get($this->migration['terms'][$field_name]->get($slug), 'id', $slug); + $value[$i] = Arr::get($this->migration['terms'][$field_name]->get($slug), 'id', $slug); } if ($is_string) { diff --git a/src/Helpers/WpImporter.php b/src/Helpers/WpImporter.php index e4745d8..1c9a118 100644 --- a/src/Helpers/WpImporter.php +++ b/src/Helpers/WpImporter.php @@ -5,6 +5,7 @@ use Exception; use Statamic\Facades\Entry; use Statamic\Facades\Term; +use Statamic\Support\Arr; class WpImporter { @@ -24,7 +25,7 @@ public function summary($prepared) foreach ($prepared['pages'] as $page_url => $page) { $summary['pages'][$page_url] = [ 'url' => $page_url, - 'title' => \Arr::get($page['data'], 'title'), + 'title' => Arr::get($page['data'], 'title'), 'exists' => (bool) Entry::findByUri($page_url), '_checked' => true, ]; From 7290972cf973011514b52f935a79d18785bd786c Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 16 Oct 2024 07:29:49 +0100 Subject: [PATCH 4/7] Undo config name change --- src/Helpers/Migrator.php | 10 +++++----- src/Helpers/Preparer.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Helpers/Migrator.php b/src/Helpers/Migrator.php index 0a936f4..9ee48d7 100644 --- a/src/Helpers/Migrator.php +++ b/src/Helpers/Migrator.php @@ -188,7 +188,7 @@ private function createEntries() $entry->set($key, $value); } - if (config('wp-import.download_images')) { + if (config('statamic-wp-import.download_images')) { $asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', $collection, $slug); if ($asset) { @@ -229,7 +229,7 @@ private function createPages() $page->set($key, $value); } - if (config('wp-import.download_images')) { + if (config('statamic-wp-import.download_images')) { $asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', 'pages', $slug); if ($asset) { @@ -257,15 +257,15 @@ private function downloadAsset(?string $url, string $collection, string $slug): Storage::put($tempFile = 'temp', $image); - $assetContainer = AssetContainer::findByHandle(config('wp-import.assets_container')); + $assetContainer = AssetContainer::findByHandle(config('statamic-wp-import.assets_container')); $asset = $assetContainer->makeAsset("{$collection}/{$slug}/{$originalImageName}"); - if ($asset->exists() && config('wp-import.skip_existing_images')) { + if ($asset->exists() && config('statamic-wp-import.skip_existing_images')) { return $asset; } - if ($asset->exists() && config('wp-import.overwrite_images')) { + if ($asset->exists() && config('statamic-wp-import.overwrite_images')) { $asset->delete(); } diff --git a/src/Helpers/Preparer.php b/src/Helpers/Preparer.php index 0ea6dab..8a418b3 100644 --- a/src/Helpers/Preparer.php +++ b/src/Helpers/Preparer.php @@ -33,7 +33,7 @@ public function prepare(array $data) $this->createTaxonomies(); $this->createCollections(); - if (config('wp-import.exclude_underscore_data')) { + if (config('statamic-wp-import.exclude_underscore_data')) { $this->filterMetaData(); } From eaa672727f051bac3a2ba9b1e8522027ed7f7636 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 16 Oct 2024 07:30:12 +0100 Subject: [PATCH 5/7] :beer: --- src/Helpers/Migrator.php | 20 ++++++++++---------- src/Helpers/Preparer.php | 12 ++++++------ src/Helpers/WpImporter.php | 2 +- src/Http/Controllers/ImportController.php | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Helpers/Migrator.php b/src/Helpers/Migrator.php index 9ee48d7..750ace0 100644 --- a/src/Helpers/Migrator.php +++ b/src/Helpers/Migrator.php @@ -97,7 +97,7 @@ private function createTaxonomies() foreach (Arr::get($this->migration, 'taxonomies', []) as $taxonomy_slug => $taxonomy_data) { $taxonomy = Taxonomy::findByHandle($taxonomy_slug); - if (!$taxonomy) { + if (! $taxonomy) { $taxonomy = Taxonomy::make($taxonomy_slug); } @@ -119,13 +119,13 @@ private function createTaxonomyTerms() foreach (Arr::get($this->migration, 'terms', []) as $taxonomy_slug => $terms) { foreach ($terms as $term_slug => $term_data) { // Skip if this term was not checked in the summary. - if (!$this->summary['taxonomies'][$taxonomy_slug]['terms'][$term_slug]['_checked']) { + if (! $this->summary['taxonomies'][$taxonomy_slug]['terms'][$term_slug]['_checked']) { continue; } $term = Term::findBySlug($term_slug, $taxonomy_slug); - if (!$term) { + if (! $term) { $term = Term::make($term_slug)->taxonomy($taxonomy_slug); } @@ -148,7 +148,7 @@ private function createCollections() foreach (Arr::get($this->migration, 'collections', []) as $handle => $data) { $collection = Collection::findByHandle($handle); - if (!$collection) { + if (! $collection) { $collection = Collection::make($handle); } @@ -170,13 +170,13 @@ private function createEntries() foreach ($this->migration['entries'] as $collection => $entries) { foreach ($entries as $slug => $meta) { // Skip if this entry was not checked in the summary. - if (!$this->summary['collections'][$collection]['entries'][$slug]['_checked']) { + if (! $this->summary['collections'][$collection]['entries'][$slug]['_checked']) { continue; } $entry = Entry::query()->where('collection', $collection)->where('slug', $slug)->first(); - if (!$entry) { + if (! $entry) { $entry = Entry::make()->collection($collection)->slug($slug); } @@ -210,7 +210,7 @@ private function createPages() { foreach ($this->migration['pages'] as $url => $meta) { // Skip if this page was not checked in the summary. - if (!$this->summary['pages'][$url]['_checked']) { + if (! $this->summary['pages'][$url]['_checked']) { continue; } @@ -219,7 +219,7 @@ private function createPages() $page = Entry::query()->where('collection', 'pages')->where('slug', $slug)->first(); - if (!$page) { + if (! $page) { $page = Entry::make()->collection('pages')->slug($slug); } @@ -246,7 +246,7 @@ private function createPages() */ private function downloadAsset(?string $url, string $collection, string $slug): Asset|bool { - if (!$url) { + if (! $url) { return false; } @@ -280,7 +280,7 @@ private function downloadAsset(?string $url, string $collection, string $slug): return $asset; } catch (Exception $e) { - logger('Image download failed: ' . $e->getMessage()); + logger('Image download failed: '.$e->getMessage()); return false; } diff --git a/src/Helpers/Preparer.php b/src/Helpers/Preparer.php index 8a418b3..08bbcfc 100644 --- a/src/Helpers/Preparer.php +++ b/src/Helpers/Preparer.php @@ -16,7 +16,7 @@ public function prepare(array $data) { $this->data = $data; - if (!isset($this->data['pages']) || !is_array($this->data['pages'])) { + if (! isset($this->data['pages']) || ! is_array($this->data['pages'])) { $this->data['pages'] = []; } @@ -55,14 +55,14 @@ protected function filterMetaData() private function createTaxonomies() { - if (!isset($this->data['taxonomies'])) { + if (! isset($this->data['taxonomies'])) { return; } foreach ($this->data['taxonomies'] as $taxonomy_name => $terms) { $this->migration['taxonomies']->put($taxonomy_name, [ 'title' => Str::title($taxonomy_name), - 'route' => '/' . $taxonomy_name . '/{slug}', + 'route' => '/'.$taxonomy_name.'/{slug}', ]); $this->migration['terms']->put($taxonomy_name, collect()); @@ -82,7 +82,7 @@ private function createTaxonomies() private function createCollections() { - if (!isset($this->data['collections'])) { + if (! isset($this->data['collections'])) { return; } @@ -101,7 +101,7 @@ private function createCollections() */ private function createCollection($collection, $entries) { - $route = '/' . $collection . '/{slug}'; + $route = '/'.$collection.'/{slug}'; $collection = str_replace('/', '-', $collection); @@ -149,7 +149,7 @@ private function createEntries($collection, $entries) private function replaceTaxonomies($data) { foreach ($data as $field_name => &$value) { - if (!$this->isTaxonomyField($field_name)) { + if (! $this->isTaxonomyField($field_name)) { continue; } diff --git a/src/Helpers/WpImporter.php b/src/Helpers/WpImporter.php index 1c9a118..40fde6a 100644 --- a/src/Helpers/WpImporter.php +++ b/src/Helpers/WpImporter.php @@ -11,7 +11,7 @@ class WpImporter { public function prepare($data) { - if (!$data = json_decode($data, true)) { + if (! $data = json_decode($data, true)) { throw new Exception('Invalid export data format.'); } diff --git a/src/Http/Controllers/ImportController.php b/src/Http/Controllers/ImportController.php index afcb766..3669d59 100644 --- a/src/Http/Controllers/ImportController.php +++ b/src/Http/Controllers/ImportController.php @@ -32,7 +32,7 @@ public function upload(Request $request) public function summary() { - if (!$data = Cache::get('wp-import.statamic.prepared')) { + if (! $data = Cache::get('wp-import.statamic.prepared')) { return redirect()->to(cp_route('wp-import.index')); } From ec977c7a8bb539e04a05588e7785bdba883c7cbf Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 16 Oct 2024 07:45:20 +0100 Subject: [PATCH 6/7] Fix no hint paths issue --- src/ServiceProvider.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 2f3aeb4..4974bb8 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -17,6 +17,8 @@ public function boot() { parent::boot(); + $this->mergeConfigFrom(__DIR__.'/../config/shopify-wp-import.php', 'statamic-wp-import'); + Nav::extend(function ($nav) { $nav->tools('WP Import') ->route('wp-import.index') From b3feeb2ca859e1a3e83cb2aa0bdd033fff575d89 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 16 Oct 2024 20:27:22 +0100 Subject: [PATCH 7/7] oops --- src/ServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 4974bb8..c96d258 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -17,7 +17,7 @@ public function boot() { parent::boot(); - $this->mergeConfigFrom(__DIR__.'/../config/shopify-wp-import.php', 'statamic-wp-import'); + $this->mergeConfigFrom(__DIR__.'/../config/statamic-wp-import.php', 'statamic-wp-import'); Nav::extend(function ($nav) { $nav->tools('WP Import')