PluginProbe
Hello Plus / 1.2.0
Hello Plus v1.2.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / template-parts / classes / runners / revert.php

revert.php in Hello Plus 1.2.0, at modules/template-parts/classes/runners/revert.php

52 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HelloPlus\Modules\TemplateParts\Classes\Runners;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 use Elementor\App\Modules\ImportExport\Runners\Revert\Revert_Runner_Base;
10 use Elementor\Core\Base\Document;
11
12 use Elementor\TemplateLibrary\Source_Local;
13 use HelloPlus\Includes\Utils;
14
15 class Revert extends Revert_Runner_Base {
16
17 public static function get_name(): string {
18 return 'templates';
19 }
20
21 public function should_revert( array $data ): bool {
22 return isset( $data['runners'][ static::get_name() ] );
23 }
24
25 public function revert( array $data ) {
26 $template_types = array_values( Source_Local::get_template_types() );
27
28 $query_args = [
29 'post_type' => Source_Local::CPT,
30 'post_status' => 'any',
31 'posts_per_page' => -1,
32 'meta_query' => [
33 [
34 'key' => Document::TYPE_META_KEY,
35 'value' => $template_types,
36 ],
37 [
38 'key' => static::META_KEY_ELEMENTOR_IMPORT_SESSION_ID,
39 'value' => $data['session_id'],
40 ],
41 ],
42 ];
43
44 $templates_query = new \WP_Query( $query_args );
45
46 foreach ( $templates_query->posts as $template_post ) {
47 $template_document = Utils::elementor()->documents->get( $template_post->ID );
48 $template_document->delete();
49 }
50 }
51 }
52