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