| 1 |
<?php |
| 2 |
|
| 3 |
namespace Templately\Modules\FullSiteImport\Concerns; |
| 4 |
|
| 5 |
use Elementor\Plugin; |
| 6 |
use Error; |
| 7 |
use Exception; |
| 8 |
use Templately\Modules\FullSiteImport\Exception\FatalErrorException; |
| 9 |
use Templately\Modules\FullSiteImport\Exception\RetryableErrorException; |
| 10 |
use Templately\Modules\FullSiteImport\Exception\UnknownErrorException; |
| 11 |
use Templately\Modules\FullSiteImport\Runners\Finalizer; |
| 12 |
use Templately\Modules\FullSiteImport\Utils\LogHandler; |
| 13 |
use Templately\Modules\FullSiteImport\Utils\Utils; |
| 14 |
use Templately\Modules\FullSiteImport\Utils\SessionData; |
| 15 |
use Templately\Modules\FullSiteImport\Utils\AIUtils; |
| 16 |
use Templately\Utils\Helper; |
| 17 |
use Templately\Utils\Options; |
| 18 |
|
| 19 |
/** |
| 20 |
* TracksRevert — extracted verbatim from FullSiteImport (behavior-preserving). |
| 21 |
* Composed back into FullSiteImport via `use`; $this and method resolution unchanged. |
| 22 |
*/ |
| 23 |
trait TracksRevert { |
| 24 |
// === DEPRECATED / UNUSED (kept intentionally) === |
| 25 |
public function redirect_for_archives($link, $post_id) { |
| 26 |
$archive_settings = get_option('templately_post_archive'); |
| 27 |
if (!empty($archive_settings) && intval($archive_settings['post_id']) === intval($post_id)) { |
| 28 |
$link = str_replace($post_id, $archive_settings['archive_id'], $link); |
| 29 |
} |
| 30 |
|
| 31 |
return $link; |
| 32 |
} |
| 33 |
|
| 34 |
public function update_imported_list($type, $id) { |
| 35 |
$imported_list = get_option('templately_fsi_imported_list', []); |
| 36 |
if(!in_array($id, $imported_list[$type] ?? [])){ |
| 37 |
$imported_list[$type][] = $id; |
| 38 |
update_option('templately_fsi_imported_list', $imported_list, false); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* |
| 44 |
* |
| 45 |
* @return void |
| 46 |
*/ |
| 47 |
protected function add_revert_hooks() { |
| 48 |
add_action('wp_insert_post', function ($post_id) { |
| 49 |
$this->update_imported_list('posts', $post_id); |
| 50 |
}); |
| 51 |
add_action('add_attachment', function ($post_id) { |
| 52 |
$this->update_imported_list('attachment', $post_id); |
| 53 |
}); |
| 54 |
add_action('created_term', function ($term_id, $tt_id, $taxonomy, $args) { |
| 55 |
$this->update_imported_list('term', [$term_id, $taxonomy]); |
| 56 |
}, 10, 4); |
| 57 |
add_action('registered_taxonomy', function ($taxonomy, $object_type, $taxonomy_object) { |
| 58 |
$this->update_imported_list('taxonomy', $taxonomy); |
| 59 |
}, 10, 3); |
| 60 |
add_action('fluentform/form_imported', function ($formId){ |
| 61 |
$this->update_imported_list('fluentform', $formId); |
| 62 |
}, 10, 1); |
| 63 |
} |
| 64 |
|
| 65 |
} |
| 66 |
|