PluginProbe ʕ •ᴥ•ʔ
Disable Admin Notices – Hide Dashboard Notifications / 1.4.6
Disable Admin Notices – Hide Dashboard Notifications v1.4.6
1.4.7 1.4.6 1.4.5 trunk 1.0.0 1.0.2 1.0.3 1.0.5 1.0.6 1.1.1 1.1.3 1.1.4 1.2.0 1.2.2 1.2.3 1.2.4 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4
disable-admin-notices / libs / factory / templates / pages / class-page-setup.php
disable-admin-notices / libs / factory / templates / pages Last commit date
setup-parts 1 year ago templates 4 months ago class-page-more-features.php 1 year ago class-page-setup.php 1 year ago class-pages-components.php 1 year ago index.php 4 years ago
class-page-setup.php
185 lines
1 <?php
2
3 namespace WBCR\Factory_Templates_134\Pages;
4
5 // Exit if accessed directly
6 if( !defined('ABSPATH') ) {
7 exit;
8 }
9
10 /**
11 * Класс страницы, которая реализует функции мастера установки.
12 *
13 * Этот класс унаследован от стандартного шаблона страницы \Wbcr_FactoryPages480_ImpressiveThemplate,
14 * поэтому все его инструменты могут быть применены и в этом классе. Но вы должны учитывать, что
15 * поведение экшенов страницы было изменено. В данной реализации экшены используется для пагинации шагов.
16 *
17 * @package WBCR\Factory_Templates_134\Pages
18 * @author Alex Kovalev <alex.kovalevv@gmail.com>, Github: https://github.com/alexkovalevv
19 * @since 2.2.2
20 */
21 class Setup extends \WBCR\Factory_Templates_134\Impressive {
22
23 const DEFAULT_STEP = 'step0';
24
25 /**
26 * @var string
27 */
28 public $type = 'page';
29
30 /**
31 * {@inheritDoc}
32 *
33 * @since 2.2.2 - добавлен
34 * @var bool
35 */
36 public $page_parent_page = 'none';
37
38 /**
39 * @var string
40 */
41 public $menu_target = 'options-general.php';
42
43 /**
44 * {@inheritDoc}
45 *
46 * @since 2.2.2 - добавлен
47 * @var bool
48 */
49 public $show_right_sidebar_in_options = false;
50
51 /**
52 * {@inheritDoc}
53 *
54 * @since 2.2.2 - добавлен
55 * @var bool
56 */
57 public $available_for_multisite = false;
58
59 /**
60 * {@inheritDoc}
61 *
62 * @since 2.2.2 - добавлен
63 * @var bool
64 */
65 public $internal = true;
66
67 private $current_step = 'step0';
68 private $steps = [];
69
70 /**
71 * @param \Wbcr_Factory480_Plugin $plugin
72 */
73 public function __construct(\Wbcr_Factory480_Plugin $plugin)
74 {
75 $this->id = 'setup';
76
77 $this->menu_title = __('Setup master', 'wbcr_factory_templates_134');
78 $this->page_menu_short_description = __('Setup master', 'wbcr_factory_templates_134');
79 parent::__construct($plugin);
80 }
81
82 public function getPageTitle()
83 {
84 return __('Setup', 'wbcr_factory_templates_134');
85 }
86
87 public function get_close_wizard_url()
88 {
89 return $this->plugin->getPluginPageUrl('quick_start');
90 }
91
92 /**
93 * Поведение экшенов страницы было изменено. В данной реализации экшены используется для пагинации шагов.
94 *
95 * @param string $action
96 *
97 * @throws \Exception
98 */
99 public function executeByName($action)
100 {
101 $step = self::DEFAULT_STEP;
102
103 if( false !== strpos($action, 'step') && isset($this->steps[$action]) ) {
104 $step = $this->current_step = $action;
105 }
106
107 ob_start();
108 $this->steps[$step]->html();
109 $step_content = ob_get_clean();
110
111 $this->showPage($step_content);
112 }
113
114 /**
115 * Регистрируем класс обработчик шага
116 *
117 * Класс обработчик полностью отвечает за шаблон и функционально шага.
118 *
119 * @param string $path
120 * @param string $class_name
121 * @throws \Exception
122 */
123 protected function register_step($path, $class_name)
124 {
125 require_once $path;
126
127 if( !class_exists($class_name) ) {
128 throw new \Exception("Class {$class_name} is not found!");
129 }
130
131 $step = new $class_name($this);
132 $this->steps[$step->get_id()] = $step;
133 }
134
135 /**
136 * Requests assets (js and css) for the page.
137 *
138 * @param \Wbcr_Factory480_ScriptList $scripts
139 * @param \Wbcr_Factory480_StyleList $styles
140 *
141 * @return void
142 * @see Wbcr_FactoryPages480_AdminPage
143 *
144 */
145 public function assets($scripts, $styles)
146 {
147 parent::assets($scripts, $styles);
148
149 $this->styles->add(FACTORY_TEMPLATES_134_URL . '/assets/css/page-setup.css');
150
151 // Require step assets
152 if( isset($_GET['action']) && false !== strpos($_GET['action'], 'step') && isset($this->steps[$_GET['action']]) ) {
153 $this->steps[$_GET['action']]->assets($scripts, $styles);
154 }
155 }
156
157 /**
158 * {@inheritDoc}
159 *
160 * @param string $content
161 * @since 2.2.2 - добавлен
162 */
163 protected function showPage($content = null)
164 {
165 ?>
166 <div class="w-factory-templates-134-setup">
167 <ol class="w-factory-templates-134-setup-steps">
168 <?php foreach($this->steps as $step): ?>
169 <?php if( self::DEFAULT_STEP === $step->get_id() ) {
170 continue;
171 } ?>
172 <li <?php if($this->current_step === $step->get_id()): ?>class="active"<?php endif; ?>><?php echo $step->get_title(); ?></li>
173 <?php endforeach; ?>
174 </ol>
175 <div class="w-factory-templates-134-setup-content">
176 <?php echo $content; ?>
177 </div>
178 <a class="w-factory-templates-134-setup-footer-links" href="<?php echo esc_url($this->get_close_wizard_url()); ?>">
179 <?php _e('Not now', 'wbcr_factory_templates_134') ?>
180 </a>
181 </div>
182 <?php
183 }
184 }
185