PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / trunk
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF vtrunk
2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / libs / factory / templates / pages / class-page-setup.php
robin-image-optimizer / libs / factory / templates / pages Last commit date
setup-parts 5 months ago templates 2 months ago class-page-license.php 5 months ago class-page-more-features.php 5 months ago class-page-setup.php 5 months ago class-pages-components.php 5 months ago index.php 6 months ago
class-page-setup.php
182 lines
1 <?php
2
3 namespace WBCR\Factory_Templates_759\Pages;
4
5 // Exit if accessed directly
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 /**
11 * Класс страницы, которая реализует функции мастера установки.
12 *
13 * Этот класс унаследован от стандартного шаблона страницы \Wbcr_FactoryPages600_ImpressiveThemplate,
14 * поэтому все его инструменты могут быть применены и в этом классе. Но вы должны учитывать, что
15 * поведение экшенов страницы было изменено. В данной реализации экшены используется для пагинации шагов.
16 *
17 * @package WBCR\Factory_Templates_759\Pages
18 * @since 2.2.2
19 */
20 class Setup extends \WBCR\Factory_Templates_759\Impressive {
21
22 const DEFAULT_STEP = 'step0';
23
24 /**
25 * @var string
26 */
27 public $type = 'page';
28
29 /**
30 * {@inheritDoc}
31 *
32 * @since 2.2.2 - добавлен
33 * @var bool
34 */
35 public $page_parent_page = 'none';
36
37 /**
38 * @var string
39 */
40 public $menu_target = 'options-general.php';
41
42 /**
43 * {@inheritDoc}
44 *
45 * @since 2.2.2 - добавлен
46 * @var bool
47 */
48 public $show_right_sidebar_in_options = false;
49
50 /**
51 * {@inheritDoc}
52 *
53 * @since 2.2.2 - добавлен
54 * @var bool
55 */
56 public $available_for_multisite = false;
57
58 /**
59 * {@inheritDoc}
60 *
61 * @since 2.2.2 - добавлен
62 * @var bool
63 */
64 public $internal = true;
65
66 private $current_step = 'step0';
67 private $steps = [];
68
69 /**
70 * @param \Wbcr_Factory600_Plugin $plugin
71 */
72 public function __construct( \Wbcr_Factory600_Plugin $plugin ) {
73 $this->id = 'setup';
74
75 $this->menu_title = __( 'Setup master', 'robin-image-optimizer' );
76 $this->page_menu_short_description = __( 'Setup master', 'robin-image-optimizer' );
77 parent::__construct( $plugin );
78 }
79
80 public function getPageTitle() {
81 return __( 'Setup', 'robin-image-optimizer' );
82 }
83
84 public function get_close_wizard_url() {
85 return $this->plugin->getPluginPageUrl( 'quick_start' );
86 }
87
88 /**
89 * Поведение экшенов страницы было изменено. В данной реализации экшены используется для пагинации шагов.
90 *
91 * @param string $action
92 *
93 * @throws \Exception
94 */
95 public function executeByName( $action ) {
96 $step = self::DEFAULT_STEP;
97
98 if ( false !== strpos( $action, 'step' ) && isset( $this->steps[ $action ] ) ) {
99 $step = $this->current_step = $action;
100 }
101
102 ob_start();
103 $this->steps[ $step ]->html();
104 $step_content = ob_get_clean();
105
106 $this->showPage( $step_content );
107 }
108
109 /**
110 * Регистрируем класс обработчик шага
111 *
112 * Класс обработчик полностью отвечает за шаблон и функционально шага.
113 *
114 * @param string $path
115 * @param string $class_name
116 * @throws \Exception
117 */
118 protected function register_step( $path, $class_name ) {
119 require_once $path;
120
121 if ( ! class_exists( $class_name ) ) {
122 throw new \Exception( "Class {$class_name} is not found!" );
123 }
124
125 $step = new $class_name( $this );
126 $this->steps[ $step->get_id() ] = $step;
127 }
128
129 /**
130 * Requests assets (js and css) for the page.
131 *
132 * @param \Wbcr_Factory600_ScriptList $scripts
133 * @param \Wbcr_Factory600_StyleList $styles
134 *
135 * @return void
136 * @see Wbcr_FactoryPages600_AdminPage
137 */
138 public function assets( $scripts, $styles ) {
139 parent::assets( $scripts, $styles );
140
141 $this->styles->add( FACTORY_TEMPLATES_459_URL . '/assets/css/page-setup.css' );
142
143 // Require step assets
144 if ( isset( $_GET['action'] ) && false !== strpos( $_GET['action'], 'step' ) && isset( $this->steps[ $_GET['action'] ] ) ) {
145 $this->steps[ $_GET['action'] ]->assets( $scripts, $styles );
146 }
147 }
148
149 /**
150 * {@inheritDoc}
151 *
152 * @param string $content
153 * @since 2.2.2 - добавлен
154 */
155 protected function showPage( $content = null ) {
156 ?>
157 <div class="w-factory-templates-459-setup">
158 <ol class="w-factory-templates-459-setup-steps">
159 <?php foreach ( $this->steps as $step ) : ?>
160 <?php
161 if ( self::DEFAULT_STEP === $step->get_id() ) {
162 continue;
163 }
164 ?>
165 <li
166 <?php
167 if ( $this->current_step === $step->get_id() ) :
168 ?>
169 class="active"<?php endif; ?>><?php echo $step->get_title(); ?></li>
170 <?php endforeach; ?>
171 </ol>
172 <div class="w-factory-templates-459-setup-content">
173 <?php echo $content; ?>
174 </div>
175 <a class="w-factory-templates-459-setup-footer-links" href="<?php echo esc_url( $this->get_close_wizard_url() ); ?>">
176 <?php _e( 'Not now', 'robin-image-optimizer' ); ?>
177 </a>
178 </div>
179 <?php
180 }
181 }
182