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-pages-components.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-pages-components.php
241 lines
1 <?php
2
3 namespace WBCR\Factory_Templates_759\Pages;
4
5 /**
6 * This file is the add-ons page.
7 *
8 * @since 1.0.0
9 */
10
11 // Exit if accessed directly
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 class Components extends \WBCR\Factory_Templates_759\Pages\PageBase {
17
18 /**
19 * The id of the page in the admin menu.
20 *
21 * Mainly used to navigate between pages.
22 *
23 * @since 1.0.0
24 * @see FactoryPages600_AdminPage
25 *
26 * @var string
27 */
28 public $id = 'components';
29
30 public $page_menu_position = 0;
31
32 public $page_menu_dashicon = 'dashicons-admin-plugins';
33
34 public $type = 'page';
35
36 public $show_right_sidebar_in_options = false;
37
38 public $available_for_multisite = true;
39
40 /**
41 * @param \Wbcr_Factory600_Plugin $plugin
42 */
43 public function __construct( \Wbcr_Factory600_Plugin $plugin ) {
44 $this->menu_title = __( 'Components', 'robin-image-optimizer' );
45 $this->page_menu_short_description = __( 'More features for plugin', 'robin-image-optimizer' );
46
47 parent::__construct( $plugin );
48
49 $this->plugin = $plugin;
50 }
51
52 /**
53 * Requests assets (js and css) for the page.
54 *
55 * @return void
56 * @since 1.0.0
57 * @see FactoryPages600_AdminPage
58 */
59 public function assets( $scripts, $styles ) {
60 parent::assets( $scripts, $styles );
61
62 $this->styles->add( FACTORY_TEMPLATES_459_URL . '/assets/css/components.css' );
63
64 /**
65 * @param \Wbcr_Factory600_StyleList $styles
66 * @param \Wbcr_Factory600_ScriptList $scripts
67 * @since 1.4.0
68 */
69 do_action( 'wbcr/clearfy/components/page_assets', $scripts, $styles );
70 }
71
72 /**
73 * We register notifications for some actions
74 *
75 * @param $notices
76 * @param \Wbcr_Factory600_Plugin $plugin
77 *
78 * @return array
79 * @see libs\factory\pages\themplates\FactoryPages600_ImpressiveThemplate
80 */
81 public function getActionNotices( $notices ) {
82 $notices[] = [
83 'conditions' => [
84 'wbcr-force-update-components-success' => 1,
85 ],
86 'type' => 'success',
87 'message' => __( 'Components have been successfully updated to the latest version.', 'robin-image-optimizer' ),
88 ];
89
90 $notices[] = [
91 'conditions' => [
92 'wbcr-force-update-components-error' => 'inactive_licence',
93 ],
94 'type' => 'danger',
95 'message' => __( 'To use premium components, you need activate a license!', 'robin-image-optimizer' ) . '<a href="admin.php?page=license-wbcr_clearfy" class="btn btn-gold">' . __( 'Activate license', 'robin-image-optimizer' ) . '</a>',
96 ];
97
98 $notices[] = [
99 'conditions' => [
100 'wbcr-force-update-components-error' => 'unknown_error',
101 ],
102 'type' => 'danger',
103 'message' => __( 'An unknown error occurred while updating plugin components. Please contact the plugin support team to resolve this issue.', 'robin-image-optimizer' ),
104 ];
105
106 return $notices;
107 }
108
109 public function get_components() {
110 return [];
111 }
112
113 /**
114 * This method simply sorts the list of components.
115 *
116 * @param $components
117 *
118 * @return array
119 */
120 public function order( $components ) {
121 $deactivate_components = $this->plugin->getPopulateOption( 'deactive_preinstall_components', [] );
122
123 $ordered_components = [
124 'premium_active' => [],
125 'premium_deactive' => [],
126 'other' => [],
127 ];
128
129 foreach ( (array) $components as $component ) {
130
131 if ( ( 'premium' === $component['build'] || 'freemium' === $component['build'] ) && 'internal' === $component['type'] ) {
132 if ( in_array( $component['name'], $deactivate_components ) ) {
133 // free component is deactivated
134 $order_key = 'premium_deactive';
135 } else {
136 // free component activated
137 $order_key = 'premium_active';
138 }
139 } else {
140 $order_key = 'other';
141 }
142
143 $ordered_components[ $order_key ][] = $component;
144 }
145
146 return array_merge( $ordered_components['premium_active'], $ordered_components['premium_deactive'], $ordered_components['other'] );
147 }
148
149 /**
150 * This method simply show contents of the component page.
151 *
152 * @throws \Exception
153 */
154 public function showPageContent() {
155 $components = $this->order( $this->get_components() );
156
157 /**
158 * @param array $components
159 * @since 1.4.0
160 */
161 $components = apply_filters( 'wbcr/clearfy/components/items_list', $components );
162
163 ?>
164 <div class="wbcr-factory-page-group-header">
165 <strong>
166 <?php _e( 'Plugin Components.', 'robin-image-optimizer' ); ?>
167 </strong>
168 <p>
169 <?php _e( 'These are components of the plugin bundle. When you activate the plugin, all the components turned on by default. If you don’t need some function, you can easily turn it off on this page.', 'robin-image-optimizer' ); ?>
170 </p>
171 </div>
172 <div class="wbc-factory-templates-459-components">
173 <?php
174 /**
175 * @since 1.4.0
176 */
177 do_action( 'wbcr/clearfy/components/custom_plugins_card', $components );
178 ?>
179
180 <?php foreach ( (array) $components as $component ) : ?>
181 <?php
182
183 $slug = $component['name'];
184
185 if ( $component['type'] == 'WordPress' || $component['type'] == 'creativemotion' ) {
186 $slug = $component['base_path'];
187 }
188
189 $install_button = $this->plugin->get_install_component_button( $component['type'], $slug );
190
191 $status_class = '';
192 if ( ! $install_button->is_plugin_activate() ) {
193 $status_class = ' plugin-status-deactive';
194 }
195
196 $install_button->add_class( 'install-now' );
197
198 // Delete button
199 $delete_button = $this->plugin->get_delete_component_button( $component['type'], $slug );
200 $delete_button->add_class( 'delete-now' );
201
202 ?>
203 <div class="plugin-card<?php echo esc_attr( $status_class ); ?>">
204 <?php if ( isset( $component['build'] ) ) : ?>
205 <div class="plugin-card-<?php echo esc_attr( $component['build'] ); ?>-ribbon"><?php echo ucfirst( esc_html( $component['build'] ) ); ?></div>
206 <?php endif; ?>
207 <div class="plugin-card-top">
208 <div class="name column-name">
209 <h3>
210 <a href="<?php echo esc_url( $component['url'] ); ?>" class="thickbox open-plugin-details-modal">
211 <?php echo esc_html( $component['title'] ); ?>
212 <img src="<?php echo esc_attr( $component['icon'] ); ?>" class="plugin-icon" alt="<?php echo esc_attr( $component['title'] ); ?>">
213 </a>
214 </h3>
215 </div>
216 <div class="desc column-description">
217 <p><?php echo esc_html( $component['description'] ); ?></p>
218 </div>
219 </div>
220 <div class="plugin-card-bottom">
221 <?php if ( ! ( isset( $component['disable_button'] ) && $component['disable_button'] ) ) : ?>
222 <?php if ( 'premium' === $component['build'] && ! ( $this->plugin->premium->is_activate() && $this->plugin->premium->is_install_package() ) ) : ?>
223 <a target="_blank" href="<?php echo esc_url( $component['url'] ); ?>" class="button button-default install-now"><?php _e( 'Read more', 'robin-image-optimizer' ); ?></a>
224 <?php else : ?>
225 <?php $delete_button->render_button(); ?><?php $install_button->render_button(); ?>
226 <?php endif; ?>
227 <?php else : ?>
228 <?php echo( isset( $component['disable_button_reason'] ) ? esc_html( $component['disable_button_reason'] ) : '' ); ?>
229 <?php endif; ?>
230
231 </div>
232 </div>
233 <?php endforeach; ?>
234 <div class="clearfix"></div>
235 </div>
236 <?php
237 }
238 }
239
240
241