PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / 1.2.3
Ever Compare – Products Compare Plugin for WooCommerce v1.2.3
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.3, at includes/classes/Admin/Dashboard.php

542 lines 24.1 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
233 array(
234 'slug' => 'woolentor-addons',
235 'location' => 'woolentor_addons_elementor.php',
236 'name' => esc_html__( 'WooLentor', 'ever-compare' )
237 ),
238
239 array(
240 'slug' => 'ht-mega-for-elementor',
241 'location' => 'htmega_addons_elementor.php',
242 'name' => esc_html__( 'HT Mega', 'ever-compare' )
243 ),
244
245 array(
246 'slug' => 'hashbar-wp-notification-bar',
247 'location' => 'init.php',
248 'name' => esc_html__( 'HashBar', 'ever-compare' )
249 ),
250
251 array(
252 'slug' => 'ht-slider-for-elementor',
253 'location' => 'ht-slider-for-elementor.php',
254 'name' => esc_html__( 'HT Slider For Elementor', 'ever-compare' )
255 ),
256
257 array(
258 'slug' => 'ht-contactform',
259 'location' => 'contact-form-widget-elementor.php',
260 'name' => esc_html__( 'HT Contact Form 7', 'ever-compare' )
261 ),
262
263 array(
264 'slug' => 'ht-wpform',
265 'location' => 'wpform-widget-elementor.php',
266 'name' => esc_html__( 'HT WPForms', 'ever-compare' )
267 ),
268
269 array(
270 'slug' => 'ht-menu-lite',
271 'location' => 'ht-mega-menu.php',
272 'name' => esc_html__( 'HT Menu', 'ever-compare' )
273 ),
274
275 array(
276 'slug' => 'insert-headers-and-footers-script',
277 'location' => 'init.php',
278 'name' => esc_html__( 'HT Script', 'ever-compare' )
279 ),
280
281 array(
282 'slug' => 'wp-plugin-manager',
283 'location' => 'plugin-main.php',
284 'name' => esc_html__( 'WP Plugin Manager', 'ever-compare' )
285 ),
286
287 array(
288 'slug' => 'wc-builder',
289 'location' => 'wc-builder.php',
290 'name' => esc_html__( 'WC Builder', 'ever-compare' )
291 ),
292
293 array(
294 'slug' => 'whols',
295 'location' => 'whols.php',
296 'name' => esc_html__( 'Whols', 'ever-compare' )
297 ),
298
299 array(
300 'slug' => 'just-tables',
301 'location' => 'just-tables.php',
302 'name' => esc_html__( 'JustTables', 'ever-compare' )
303 ),
304
305 array(
306 'slug' => 'wc-multi-currency',
307 'location' => 'wcmilticurrency.php',
308 'name' => esc_html__( 'Multi Currency', 'ever-compare' )
309 )
310 )
311
312 ) );
313
314 $get_instance->add_new_tab(array(
315 'title' => esc_html__( 'You May Also Like', 'ever-compare' ),
316 'plugins' => array(
317
318 array(
319 'slug' => 'woolentor-addons-pro',
320 'location' => 'woolentor_addons_pro.php',
321 'name' => esc_html__( 'WooLentor Pro', 'ever-compare' ),
322 'link' => 'https://hasthemes.com/plugins/woolentor-pro-woocommerce-page-builder/',
323 'author_link'=> 'https://hasthemes.com/',
324 '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' ),
325 ),
326
327 array(
328 'slug' => 'htmega-pro',
329 'location' => 'htmega_pro.php',
330 'name' => esc_html__( 'HT Mega Pro', 'ever-compare' ),
331 'link' => 'https://hasthemes.com/plugins/ht-mega-pro/',
332 'author_link'=> 'https://hasthemes.com/',
333 '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' ),
334 ),
335
336 array(
337 'slug' => 'swatchly-pro',
338 'location' => 'swatchly-pro.php',
339 'name' => esc_html__( 'Product Variation Swatches', 'ever-compare' ),
340 'link' => 'https://hasthemes.com/plugins/swatchly-product-variation-swatches-for-woocommerce-products/',
341 'author_link'=> 'https://hasthemes.com/',
342 'description'=> esc_html__( 'Are you getting frustrated with WooCommerce’s current way of presenting the variants for your products? Well, say goodbye to dropdowns and start showing the product variations in a whole new light with Swatchly.', 'ever-compare' ),
343 ),
344
345 array(
346 'slug' => 'whols-pro',
347 'location' => 'whols-pro.php',
348 'name' => esc_html__( 'Whols Pro', 'ever-compare' ),
349 'link' => 'https://hasthemes.com/plugins/whols-woocommerce-wholesale-prices/',
350 'author_link'=> 'https://hasthemes.com/',
351 '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' ),
352 ),
353
354 array(
355 'slug' => 'just-tables-pro',
356 'location' => 'just-tables-pro.php',
357 'name' => esc_html__( 'JustTables Pro', 'ever-compare' ),
358 'link' => 'https://hasthemes.com/wp/justtables/',
359 'author_link'=> 'https://hasthemes.com/',
360 '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' ),
361 ),
362
363 array(
364 'slug' => 'multicurrencypro',
365 'location' => 'multicurrencypro.php',
366 'name' => esc_html__( 'Multi Currency Pro for WooCommerce', 'ever-compare' ),
367 'link' => 'https://hasthemes.com/plugins/multi-currency-pro-for-woocommerce/',
368 'author_link'=> 'https://hasthemes.com/',
369 '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' ),
370 ),
371
372 array(
373 'slug' => 'cf7-extensions-pro',
374 'location' => 'cf7-extensions-pro.php',
375 'name' => esc_html__( 'Extensions For CF7 Pro', 'ever-compare' ),
376 'link' => 'https://hasthemes.com/plugins/cf7-extensions/',
377 'author_link'=> 'https://hasthemes.com/',
378 'description'=> esc_html__( 'Contact Form7 Extensions plugin is a fantastic WordPress plugin that enriches the functionalities of Contact Form 7.This all-in-one WordPress plugin will help you turn any contact page into a well-organized, engaging tool for communicating with your website visitors by providing tons of advanced features like drag and drop file upload, repeater field, trigger error for already submitted forms, popup form response, country flags and dial codes with a telephone input field and acceptance field, etc. in addition to its basic features.', 'ever-compare' ),
379 ),
380
381 array(
382 'slug' => 'hashbar-pro',
383 'location' => 'init.php',
384 'name' => esc_html__( 'HashBar Pro', 'ever-compare' ),
385 'link' => 'https://hasthemes.com/plugins/wordpress-notification-bar-plugin/',
386 'author_link'=> 'https://hasthemes.com/',
387 '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' ),
388 ),
389
390 array(
391 'slug' => 'wp-plugin-manager-pro',
392 'location' => 'plugin-main.php',
393 'name' => esc_html__( 'WP Plugin Manager Pro', 'ever-compare' ),
394 'link' => 'https://hasthemes.com/plugins/wp-plugin-manager-pro/',
395 'author_link'=> 'https://hasthemes.com/',
396 'description'=> esc_html__( 'WP Plugin Manager Pro is a specialized WordPress Plugin that helps you to deactivate unnecessary WordPress Plugins page wise and boosts the speed of your WordPress site to improve the overall site performance.', 'ever-compare' ),
397 ),
398
399 array(
400 'slug' => 'ht-script-pro',
401 'location' => 'plugin-main.php',
402 'name' => esc_html__( 'HT Script Pro', 'ever-compare' ),
403 'link' => 'https://hasthemes.com/plugins/insert-headers-and-footers-code-ht-script/',
404 'author_link'=> 'https://hasthemes.com/',
405 'description'=> esc_html__( 'Insert Headers and Footers Code allows you to insert Google Analytics, Facebook Pixel, custom CSS, custom HTML, JavaScript code to your website header and footer without modifying your theme code.This plugin has the option to add any custom code to your theme in one place, no need to edit the theme code. It will save your time and remove the hassle for the theme update.', 'ever-compare' ),
406 ),
407
408 array(
409 'slug' => 'ht-menu',
410 'location' => 'ht-mega-menu.php',
411 'name' => esc_html__( 'HT Menu Pro', 'ever-compare' ),
412 'link' => 'https://hasthemes.com/plugins/ht-menu-pro/',
413 'author_link'=> 'https://hasthemes.com/',
414 'description'=> esc_html__( 'WordPress Mega Menu Builder for Elementor', 'ever-compare' ),
415 ),
416
417 array(
418 'slug' => 'ht-slider-addons-pro',
419 'location' => 'ht-slider-addons-pro.php',
420 'name' => esc_html__( 'HT Slider Pro For Elementor', 'ever-compare' ),
421 'link' => 'https://hasthemes.com/plugins/ht-slider-pro-for-elementor/',
422 'author_link'=> 'https://hasthemes.com/',
423 'description'=> esc_html__( 'HT Slider Pro is a plugin to create a slider for WordPress websites easily using the Elementor page builder. 80+ prebuild slides/templates are included in this plugin. There is the option to create a post slider, WooCommerce product slider, Video slider, image slider, etc. Fullscreen, full width and box layout option are included.', 'ever-compare' ),
424 ),
425
426 array(
427 'slug' => 'ht-google-place-review',
428 'location' => 'ht-google-place-review.php',
429 'name' => esc_html__( 'Google Place Review', 'ever-compare' ),
430 'link' => 'https://hasthemes.com/plugins/google-place-review-plugin-for-wordpress/',
431 'author_link'=> 'https://hasthemes.com/',
432 'description'=> esc_html__( 'If you are searching for a modern and excellent google places review WordPress plugin to showcase reviews from Google Maps and strengthen trust between you and your site visitors, look no further than HT Google Place Review', 'ever-compare' ),
433 ),
434
435 array(
436 'slug' => 'was-this-helpful',
437 'location' => 'was-this-helpful.php',
438 'name' => esc_html__( 'Was This Helpful?', 'ever-compare' ),
439 'link' => 'https://hasthemes.com/plugins/was-this-helpful/',
440 'author_link'=> 'https://hasthemes.com/',
441 'description'=> esc_html__( "Was this helpful? is a WordPress plugin that allows you to take visitors' feedback on your post/pages or any article. A visitor can share his feedback by like/dislike/yes/no", 'ever-compare' ),
442 ),
443
444 array(
445 'slug' => 'ht-click-to-call',
446 'location' => 'ht-click-to-call.php',
447 'name' => esc_html__( 'HT Click To Call', 'ever-compare' ),
448 'link' => 'https://hasthemes.com/plugins/ht-click-to-call/',
449 'author_link'=> 'https://hasthemes.com/',
450 'description'=> esc_html__( "HT – Click to Call is a lightweight WordPress plugin that allows you to add a floating click to call button on your website. It will offer your website visitors an opportunity to call your business immediately at the right moment, especially when they are interested in your products or services and seeking more information.", 'ever-compare' ),
451 ),
452
453 array(
454 'slug' => 'docus-pro',
455 'location' => 'docus-pro.php',
456 'name' => esc_html__( 'Docus Pro', 'ever-compare' ),
457 'link' => 'https://hasthemes.com/plugins/docus-pro-youtube-video-playlist/',
458 'author_link'=> 'https://hasthemes.com/',
459 'description'=> esc_html__( "Embedding a YouTube playlist into your website plays a vital role to curate your content into several categories and make your web content more engaging and popular by keeping the visitors on your website for a longer period.", 'ever-compare' ),
460 ),
461
462 )
463 ));
464
465 $get_instance->add_new_tab(array(
466 'title' => esc_html__( 'Others', 'ever-compare' ),
467 'plugins' => array(
468
469 array(
470 'slug' => 'really-simple-google-tag-manager',
471 'location' => 'really-simple-google-tag-manager.php',
472 'name' => esc_html__( 'Really Simple Google Tag Manager', 'ever-compare' )
473 ),
474
475 array(
476 'slug' => 'ht-instagram',
477 'location' => 'ht-instagram.php',
478 'name' => esc_html__( 'HT Feed', 'ever-compare' )
479 ),
480
481 array(
482 'slug' => 'faster-youtube-embed',
483 'location' => 'faster-youtube-embed.php',
484 'name' => esc_html__( 'Faster YouTube Embed', 'ever-compare' )
485 ),
486
487 array(
488 'slug' => 'wc-sales-notification',
489 'location' => 'wc-sales-notification.php',
490 'name' => esc_html__( 'WC Sales Notification', 'ever-compare' )
491 ),
492
493 array(
494 'slug' => 'preview-link-generator',
495 'location' => 'preview-link-generator.php',
496 'name' => esc_html__( 'Preview Link Generator', 'ever-compare' )
497 ),
498
499 array(
500 'slug' => 'quickswish',
501 'location' => 'quickswish.php',
502 'name' => esc_html__( 'QuickSwish', 'ever-compare' )
503 ),
504
505 array(
506 'slug' => 'docus',
507 'location' => 'docus.php',
508 'name' => esc_html__( 'Docus – YouTube Video Playlist', 'ever-compare' )
509 ),
510
511 array(
512 'slug' => 'data-captia',
513 'location' => 'data-captia.php',
514 'name' => esc_html__( 'DataCaptia', 'ever-compare' )
515 ),
516
517 array(
518 'slug' => 'coupon-zen',
519 'location' => 'coupon-zen.php',
520 'name' => esc_html__( 'Coupon Zen', 'ever-compare' )
521 ),
522
523 array(
524 'slug' => 'sirve',
525 'location' => 'sirve.php',
526 'name' => esc_html__( 'Sirve – Simple Directory Listing', 'ever-compare' )
527 ),
528
529 array(
530 'slug' => 'ht-social-share',
531 'location' => 'ht-social-share.php',
532 'name' => esc_html__( 'HT Social Share', 'ever-compare' )
533 ),
534
535 )
536 ));
537
538
539 }
540
541
542 }