class-wizard-item-extensions.php
105 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SuperbAddons\Data\Utils\Wizard; |
| 4 | |
| 5 | defined('ABSPATH') || exit(); |
| 6 | |
| 7 | class WizardItemFile extends WizardItem |
| 8 | { |
| 9 | public function __construct($slug, $type, $title) |
| 10 | { |
| 11 | $file_template = get_block_file_template(get_stylesheet() . '//' . $slug, $type); |
| 12 | |
| 13 | parent::__construct($file_template); |
| 14 | $this->title = $title; |
| 15 | $this->type = $type; |
| 16 | $this->is_file_template = true; |
| 17 | |
| 18 | if ($type === WizardItemTypes::WP_TEMPLATE_PART) { |
| 19 | $this->no_reload = true; |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | class WizardItemPage extends WizardItem |
| 25 | { |
| 26 | public function __construct($page) |
| 27 | { |
| 28 | parent::__construct($page); |
| 29 | $this->type = WizardItemTypes::PAGE; |
| 30 | $this->datatype = WizardItemTypes::PAGE; |
| 31 | $this->is_premium = isset($page->package) && $page->package === 'premium'; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | class WizardItemPattern extends WizardItem |
| 36 | { |
| 37 | public function __construct($pattern) |
| 38 | { |
| 39 | parent::__construct($pattern); |
| 40 | $this->type = WizardItemTypes::PATTERN; |
| 41 | $this->datatype = WizardItemTypes::PATTERN; |
| 42 | $this->is_premium = isset($pattern->package) && $pattern->package === 'premium'; |
| 43 | $this->no_reload = true; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | |
| 48 | class WizardItemTemplate extends WizardItem |
| 49 | { |
| 50 | public function __construct($part, $regularTitle, $modifiedTitle, $hasModifiedTemplate) |
| 51 | { |
| 52 | parent::__construct($part); |
| 53 | $this->title = $hasModifiedTemplate ? $modifiedTitle : $regularTitle; |
| 54 | $this->no_reload = $this->type === WizardItemTypes::WP_TEMPLATE_PART; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | class WizardItemStatic extends WizardItem |
| 59 | { |
| 60 | public function __construct($title, $pageId) |
| 61 | { |
| 62 | parent::__construct(false); |
| 63 | $this->id = 'spb-static-page'; |
| 64 | $this->SetSlug('spb-static-page'); |
| 65 | $this->title = $title; |
| 66 | $this->type = 'static'; |
| 67 | $this->datatype = 'static'; |
| 68 | $this->permalink = get_permalink($pageId); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | class WizardItemIgnore extends WizardItem |
| 73 | { |
| 74 | public function __construct($title) |
| 75 | { |
| 76 | parent::__construct(false); |
| 77 | $this->id = false; |
| 78 | $this->SetSlug('spb-ignore-selection'); |
| 79 | $this->title = $title; |
| 80 | $this->type = 'ignore'; |
| 81 | $this->datatype = 'ignore'; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | class WizarditemRestorationPoint extends WizardItem |
| 86 | { |
| 87 | public $timestamp; |
| 88 | |
| 89 | public function __construct($restorationPointId, $restorationPointArray) |
| 90 | { |
| 91 | $time_format = get_option('time_format'); |
| 92 | $date_format = get_option('date_format'); |
| 93 | $datetime_format = $time_format && $date_format ? $time_format . ', ' . $date_format : 'H:i, F j, Y'; |
| 94 | |
| 95 | parent::__construct(false); |
| 96 | $this->timestamp = $restorationPointArray['timestamp']; |
| 97 | $this->id = $restorationPointId; |
| 98 | $this->SetSlug($restorationPointArray['slug']); |
| 99 | $this->title = gmdate($datetime_format, $restorationPointArray['timestamp']); |
| 100 | $this->type = $restorationPointArray['type']; |
| 101 | $this->datatype = $this->type; |
| 102 | $this->is_restoration_point = true; |
| 103 | } |
| 104 | } |
| 105 |