PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / 1.2.0
Ever Compare – Products Compare Plugin for WooCommerce v1.2.0
1.3.7 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 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.3.6 trunk 1.0.0 1.0.1 1.0.2 All 31 releases
ever-compare / includes / classes / Admin / Dashboard.php

Dashboard.php in Ever Compare – Products Compare Plugin for WooCommerce 1.2.0, at includes/classes/Admin/Dashboard.php

393 lines 15.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace EverCompare\Admin;
3 /**
4 * Dashboard handlers class
5 */
6 class Dashboard {
7
8 /**
9 * Menu capability
10 */
11 const MENU_CAPABILITY = 'manage_options';
12
13 /**
14 * Parent Menu Page Slug
15 */
16 const MENU_PAGE_SLUG = 'evercompare';
17
18 /**
19 * [$parent_menu_hook] Parent Menu Hook
20 * @var string
21 */
22 static $parent_menu_hook = '';
23
24 /**
25 * [$_instance]
26 * @var null
27 */
28 private static $_instance = null;
29
30 /**
31 * [instance] Initializes a singleton instance
32 * @return [Admin]
33 */
34 public static function instance() {
35 if ( is_null( self::$_instance ) ) {
36 self::$_instance = new self();
37 }
38 return self::$_instance;
39 }
40
41 /**
42 * Initialize the class
43 */
44 private function __construct() {
45
46 Admin_Fields::instance();
47
48 if( isset( get_option('woolentor_others_tabs')['compare'] ) && get_option('woolentor_others_tabs')['compare'] == 'on' ){
49 add_action( 'admin_menu', [ $this, 'add_menu_if_woolentor' ], 226 );
50 }else{
51 add_action( 'admin_menu', [ $this, 'add_menu' ], 20 );
52 }
53
54 add_filter('plugin_action_links_'.EVERCOMPARE_BASE, [ $this, 'action_links' ] );
55
56 // Add a post display state for special EverCompare page.
57 add_filter( 'display_post_states', [ $this, 'add_display_post_states' ], 10, 2 );
58
59 // Redirect Option page
60 $this->redirect_option_page();
61
62 // Recommended plugin
63 $this->plugin_recommendations();
64
65 }
66
67 /**
68 * [action_links] add plugin action link
69 * @param [array] $links default plugin action link
70 * @return [array] plugin action link
71 */
72 public function action_links( $links ) {
73
74 if ( ! current_user_can( self::MENU_CAPABILITY ) ) {
75 return $links;
76 }
77
78 $settings_link = '<a href="'.admin_url( 'admin.php?page='.self::MENU_PAGE_SLUG ).'">'.esc_html__( 'Settings', 'ever-compare' ).'</a>';
79
80 array_unshift( $links, $settings_link );
81
82 return $links;
83 }
84
85 /**
86 * [add_menu_if_woolentor] Admin Menu If WooLentor active
87 */
88 public function add_menu_if_woolentor(){
89
90 self::$parent_menu_hook = add_submenu_page(
91 'woolentor_page',
92 esc_html__( 'Compare', 'ever-compare' ),
93 esc_html__( 'Compare', 'ever-compare' ),
94 'manage_options',
95 self::MENU_PAGE_SLUG,
96 [ $this,'dashboard' ]
97 );
98
99 add_action( 'load-' . self::$parent_menu_hook, [ $this, 'init_hooks'] );
100
101 }
102
103 /**
104 * [add_menu] Admin Menu
105 */
106 public function add_menu(){
107
108 global $submenu;
109
110 self::$parent_menu_hook = add_menu_page(
111 esc_html__( 'Ever Compare', 'ever-compare' ),
112 esc_html__( 'Ever Compare', 'ever-compare' ),
113 self::MENU_CAPABILITY,
114 self::MENU_PAGE_SLUG,
115 [ $this,'dashboard' ],
116 'dashicons-update-alt',
117 59
118 );
119
120 if ( current_user_can( self::MENU_CAPABILITY ) ) {
121
122 foreach ( $this->sub_menu_nav() as $menukey => $menu ) {
123 $submenu[ self::MENU_PAGE_SLUG ][] = array(
124 esc_html__( $menu['title'], 'ever-compare' ),
125 self::MENU_CAPABILITY,
126 'admin.php?page='.self::MENU_PAGE_SLUG.'#'.$menukey,
127 );
128 }
129
130 }
131
132 add_action( 'load-' . self::$parent_menu_hook, [ $this, 'init_hooks'] );
133
134
135 }
136
137 /**
138 * Initialize our hooks for the admin page
139 *
140 * @return void
141 */
142 public function init_hooks() {
143 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
144 }
145
146 /**
147 * [enqueue_scripts] Add Scripts Base Menu Slug
148 * @param [string] $hook
149 * @return [void]
150 */
151 public function enqueue_scripts() {
152 wp_enqueue_style( 'evercompare-admin' );
153 wp_enqueue_script( 'evercompare-admin' );
154 }
155
156 /**
157 * [dashboard] Dashboard plugin page
158 * @return [HTML]
159 */
160 public function dashboard(){
161 Admin_Fields::instance()->plugin_page();
162 }
163
164 /**
165 * [sub_menu_nav]
166 * @return [array]
167 */
168 public function sub_menu_nav() {
169
170 $submenu = [
171 'settings' => [
172 'title' => esc_html__( 'Settings', 'ever-compare' ),
173 'subtitle' => esc_html__( 'Settings', 'ever-compare' ),
174 'icon' => '',
175 'class' => '',
176 ],
177 ];
178
179 return apply_filters( 'ever_compare_dashboard_submenu', $submenu );
180
181 }
182
183 /**
184 * [redirect_option_page] After Active the plugin then redirect to option page
185 * @return [void]
186 */
187 public function redirect_option_page() {
188 if ( get_option( 'evercompare_do_activation_redirect', FALSE ) ) {
189 delete_option('evercompare_do_activation_redirect');
190 if( !isset( $_GET['activate-multi'] ) ){
191 wp_redirect( admin_url( "admin.php?page=".self::MENU_PAGE_SLUG ) );
192 }
193 }
194 }
195
196 /**
197 * Add a post display state for special WishSuite page in the page list table.
198 *
199 * @param array $post_states An array of post display states.
200 * @param WP_Post $post The current post object.
201 */
202 public function add_display_post_states( $post_states, $post ){
203 if ( (int)ever_compare_get_option( 'compare_page', 'ever_compare_table_settings_tabs' ) === $post->ID ) {
204 $post_states['evercompare_page_for_compare_table'] = __( 'EverCompare', 'ever-compare' );
205 }
206 return $post_states;
207 }
208
209 /**
210 * [plugin_recommendations]
211 * @return [void]
212 */
213 public function plugin_recommendations(){
214
215 $get_instance = Recommended_Plugins::instance(
216 array(
217 'text_domain' => 'ever-compare',
218 'parent_menu_slug' => self::MENU_PAGE_SLUG,
219 'menu_capability' => self::MENU_CAPABILITY,
220 'menu_page_slug' => 'everrecommendations',
221 'priority' => 25,
222 'assets_url' => EVERCOMPARE_ASSETS,
223 'hook_suffix' => 'ever-compare_page_everrecommendations'
224 )
225 );
226
227 $get_instance->add_new_tab( array(
228
229 'title' => esc_html__( 'Recommended', 'ever-compare' ),
230 'active' => true,
231 'plugins' => array(
232 array(
233 'slug' => 'woolentor-addons',
234 'location' => 'woolentor_addons_elementor.php',
235 'name' => esc_html__( 'WooLentor', 'ever-compare' )
236 ),
237 array(
238 'slug' => 'wc-builder',
239 'location' => 'wc-builder.php',
240 'name' => esc_html__( 'WC Builder', 'ever-compare' )
241 ),
242 array(
243 'slug' => 'wishsuite',
244 'location' => 'wishsuite.php',
245 'name' => esc_html__( 'WishSuite', 'ever-compare' )
246 ),
247 array(
248 'slug' => 'quickswish',
249 'location' => 'quickswish.php',
250 'name' => esc_html__( 'QuickSwish', 'ever-compare' )
251 ),
252 array(
253 'slug' => 'whols',
254 'location' => 'whols.php',
255 'name' => esc_html__( 'Whols', 'ever-compare' )
256 ),
257 array(
258 'slug' => 'just-tables',
259 'location' => 'just-tables.php',
260 'name' => esc_html__( 'JustTables', 'ever-compare' )
261 ),
262 array(
263 'slug' => 'wc-multi-currency',
264 'location' => 'wcmilticurrency.php',
265 'name' => esc_html__( 'Multi Currency', 'ever-compare' )
266 )
267 )
268
269 ) );
270
271 $get_instance->add_new_tab(array(
272 'title' => esc_html__( 'You May Also Like', 'ever-compare' ),
273 'plugins' => array(
274
275 array(
276 'slug' => 'woolentor-addons-pro',
277 'location' => 'woolentor_addons_pro.php',
278 'name' => esc_html__( 'WooLentor Pro', 'ever-compare' ),
279 'link' => 'https://hasthemes.com/plugins/woolentor-pro-woocommerce-page-builder/',
280 'author_link'=> 'https://hasthemes.com/',
281 'description'=> esc_html__( 'WooLentor is one of the most popular WooCommerce Elementor Addons on WordPress.org. It has been downloaded more than 672,148 times and 60,000 stores are using WooLentor plugin. Why not you?', 'ever-compare' ),
282 ),
283
284 array(
285 'slug' => 'just-tables-pro',
286 'location' => 'just-tables-pro.php',
287 'name' => esc_html__( 'JustTables Pro', 'ever-compare' ),
288 'link' => 'https://hasthemes.com/wp/justtables/',
289 'author_link'=> 'https://hasthemes.com/',
290 'description'=> esc_html__( 'JustTables is an incredible WordPress plugin that lets you showcase all your WooCommerce products in a sortable and filterable table view. It allows your customers to easily navigate through different attributes of the products and compare them on a single page. This plugin will be of great help if you are looking for an easy solution that increases the chances of landing a sale on your online store.', 'ever-compare' ),
291 ),
292
293 array(
294 'slug' => 'whols-pro',
295 'location' => 'whols-pro.php',
296 'name' => esc_html__( 'Whols Pro', 'ever-compare' ),
297 'link' => 'https://hasthemes.com/plugins/whols-woocommerce-wholesale-prices/',
298 'author_link'=> 'https://hasthemes.com/',
299 'description'=> esc_html__( 'Whols is an outstanding WordPress plugin for WooCommerce that allows store owners to set wholesale prices for the products of their online stores. This plugin enables you to show special wholesale prices to the wholesaler. Users can easily request to become a wholesale customer by filling out a simple online registration form. Once the registration is complete, the owner of the store will be able to review the request and approve the request either manually or automatically.', 'ever-compare' ),
300 ),
301
302 array(
303 'slug' => 'multicurrencypro',
304 'location' => 'multicurrencypro.php',
305 'name' => esc_html__( 'Multi Currency Pro for WooCommerce', 'ever-compare' ),
306 'link' => 'https://hasthemes.com/plugins/multi-currency-pro-for-woocommerce/',
307 'author_link'=> 'https://hasthemes.com/',
308 'description'=> esc_html__( 'Multi-Currency Pro for WooCommerce is a prominent currency switcher plugin for WooCommerce. This plugin allows your website or online store visitors to switch to their preferred currency or their country’s currency.', 'ever-compare' ),
309 ),
310
311 array(
312 'slug' => 'email-candy-pro',
313 'location' => 'email-candy-pro.php',
314 'name' => esc_html__( 'Email Candy Pro', 'ever-compare' ),
315 'link' => 'https://hasthemes.com/plugins/email-candy-pro/',
316 'author_link'=> 'https://hasthemes.com/',
317 'description'=> esc_html__( 'Email Candy is an outstanding WordPress plugin that allows you to customize the default WooCommerce email templates and give a professional look to your WooCommerce emails. If you are tired of using the boring design of WooCommerce emails and want to create customized emails, then this plugin will come in handy.', 'ever-compare' ),
318 ),
319 )
320 ));
321
322 $get_instance->add_new_tab(array(
323 'title' => esc_html__( 'Others', 'ever-compare' ),
324 'plugins' => array(
325
326 array(
327 'slug' => 'ht-mega-for-elementor',
328 'location' => 'htmega_addons_elementor.php',
329 'name' => esc_html__( 'HT Mega', 'ever-compare' )
330 ),
331
332 array(
333 'slug' => 'ht-slider-for-elementor',
334 'location' => 'ht-slider-for-elementor.php',
335 'name' => esc_html__( 'HT Slider For Elementor', 'ever-compare' )
336 ),
337
338 array(
339 'slug' => 'wp-plugin-manager',
340 'location' => 'plugin-main.php',
341 'name' => esc_html__( 'WP Plugin Manager', 'ever-compare' )
342 ),
343
344 array(
345 'slug' => 'ht-contactform',
346 'location' => 'contact-form-widget-elementor.php',
347 'name' => esc_html__( 'HT Contact Form 7', 'ever-compare' )
348 ),
349
350 array(
351 'slug' => 'ht-wpform',
352 'location' => 'wpform-widget-elementor.php',
353 'name' => esc_html__( 'HT WPForms', 'ever-compare' )
354 ),
355
356 array(
357 'slug' => 'hashbar-wp-notification-bar',
358 'location' => 'init.php',
359 'name' => esc_html__( 'HashBar', 'ever-compare' )
360 ),
361
362 array(
363 'slug' => 'ht-menu-lite',
364 'location' => 'ht-mega-menu.php',
365 'name' => esc_html__( 'HT Menu', 'ever-compare' )
366 ),
367
368 array(
369 'slug' => 'htmega-pro',
370 'location' => 'htmega_pro.php',
371 'name' => esc_html__( 'HT Mega Pro', 'ever-compare' ),
372 'link' => 'https://hasthemes.com/plugins/ht-mega-pro/',
373 'author_link'=> 'https://hasthemes.com/',
374 'description'=> esc_html__( 'HTMega is an absolute addon for elementor that includes 80+ elements & 360 Blocks with unlimited variations. HT Mega brings limitless possibilities. Embellish your site with the elements of HT Mega.', 'ever-compare' ),
375 ),
376
377 array(
378 'slug' => 'hashbar-pro',
379 'location' => 'init.php',
380 'name' => esc_html__( 'HashBar Pro', 'ever-compare' ),
381 'link' => 'https://hasthemes.com/plugins/wordpress-notification-bar-plugin/',
382 'author_link'=> 'https://hasthemes.com/',
383 'description'=> esc_html__( 'HashBar is a WordPress Notification / Alert / Offer Bar plugin which allows you to create unlimited notification bars to notify your customers. This plugin has option to show email subscription form (sometimes it increases up to 500% email subscriber), Offer text and buttons about your promotions. This plugin has the options to add unlimited background colors and images to make your notification bar more professional.', 'ever-compare' ),
384 ),
385
386 )
387 ));
388
389
390 }
391
392
393 }