PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 4.0.0
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v4.0.0
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / data / utils / wizard / wizard-items / class-wizard-item.php
superb-blocks / src / data / utils / wizard / wizard-items Last commit date
class-wizard-item-extensions.php 2 months ago class-wizard-item.php 2 months ago
class-wizard-item.php
110 lines
1 <?php
2
3 namespace SuperbAddons\Data\Utils\Wizard;
4
5 use SuperbAddons\Admin\Controllers\Wizard\WizardTemplatePreviewController;
6
7 defined('ABSPATH') || exit();
8
9 class WizardItem
10 {
11 public $id;
12 private $slug;
13 public $type;
14 public $datatype;
15 public $title;
16 public $category;
17 public $permalink;
18 public $no_reload;
19 public $is_premium;
20 public $is_file_template;
21 public $is_restoration_point;
22 public $use_custom_page_template_preview;
23 public $plugin_update_required;
24 public $external_plugin_required;
25 public $required_plugin_names;
26 public $is_missing_navigation_block;
27 public $categories = array();
28 public $tags = array();
29 public $industries = array();
30 public $description = '';
31 public $style = null;
32 public $package;
33
34 public function __construct($template)
35 {
36 $this->id = isset($template->id) ? $template->id : false;
37 $this->slug = isset($template->slug) ? $template->slug : $this->id;
38 $this->category = isset($template->category) && is_string($template->category) ? $template->category : $this->slug;
39 $this->type = isset($template->type) ? $template->type : false;
40 $this->datatype = isset($template->datatype) ? $template->datatype : $this->type;
41 if ($this->slug === 'front-page') {
42 $this->datatype = 'front-page';
43 }
44 // v2 API items use 'name', WP templates use 'title'
45 $this->title = isset($template->title) ? $template->title : (isset($template->name) ? $template->name : false);
46 $this->permalink = isset($template->permalink) ? $template->permalink : get_home_url();
47 $this->no_reload = isset($template->no_reload) ? $template->no_reload : false;
48 $this->is_premium = isset($template->is_premium) ? $template->is_premium : false;
49 $this->plugin_update_required = isset($template->plugin_update_required) && $template->plugin_update_required;
50 $this->external_plugin_required = isset($template->external_plugin_required) && $template->external_plugin_required;
51 $this->required_plugin_names = isset($template->required_plugin_names) ? $template->required_plugin_names : array();
52 $this->is_file_template = false;
53 $this->is_restoration_point = false;
54 $this->is_missing_navigation_block = isset($template->is_missing_navigation_block) ? $template->is_missing_navigation_block : false;
55 $this->use_custom_page_template_preview = isset($template->use_custom_page_template_preview) ? $template->use_custom_page_template_preview : 0;
56 if (isset($template->categories) && is_array($template->categories)) {
57 $this->categories = $template->categories;
58 } else {
59 $this->categories = array();
60 }
61 $this->tags = isset($template->tags) && is_array($template->tags) ? $template->tags : array();
62 $this->industries = isset($template->industries) && is_array($template->industries) ? $template->industries : array();
63 $this->description = isset($template->description) && is_string($template->description) ? $template->description : '';
64 $this->style = isset($template->style) ? $template->style : null;
65 $this->package = isset($template->package) ? $template->package : ($this->is_premium ? 'premium' : 'free');
66 }
67
68 public function GetId()
69 {
70 if ($this->is_file_template) {
71 return $this->id . WizardItemIdAffix::FILE_TEMPLATE;
72 }
73 if ($this->is_restoration_point) {
74 return $this->id . WizardItemIdAffix::RESTORATION_POINT;
75 }
76 return $this->id;
77 }
78
79 public function GetSlug()
80 {
81 if ($this->is_file_template) {
82 return $this->slug . WizardItemIdAffix::FILE_TEMPLATE;
83 }
84 if ($this->is_restoration_point) {
85 return $this->GetId();
86 }
87 return $this->slug;
88 }
89
90 public function GetBaseSlug()
91 {
92 return $this->slug;
93 }
94
95 public function SetSlug($slug)
96 {
97 $this->slug = $slug;
98 }
99
100 public function IsPattern()
101 {
102 return $this->type === WizardItemTypes::PATTERN || $this->type === WizardItemTypes::WP_TEMPLATE_PART;
103 }
104
105 public function GetPreviewURL()
106 {
107 return add_query_arg(array(WizardTemplatePreviewController::TEMPLATE_PREVIEW_KEY => $this->GetId(), WizardTemplatePreviewController::TEMPLATE_TYPE_KEY => $this->type, WizardTemplatePreviewController::USE_PAGE_TEMPLATE_KEY => $this->use_custom_page_template_preview, 'superb-preview-time' => time(), WizardTemplatePreviewController::TEMPLATE_PREVIEW_NONCE => wp_create_nonce(WizardTemplatePreviewController::TEMPLATE_PREVIEW_NONCE_ACTION)), $this->permalink);
108 }
109 }
110