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

371 lines 14.5 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 add_action( 'admin_menu', [ $this, 'add_menu' ], 20 );
49
50 add_filter('plugin_action_links_'.EVERCOMPARE_BASE, [ $this, 'action_links' ] );
51
52 // Add a post display state for special EverCompare page.
53 add_filter( 'display_post_states', [ $this, 'add_display_post_states' ], 10, 2 );
54
55 // Redirect Option page
56 $this->redirect_option_page();
57
58 // Recommended plugin
59 $this->plugin_recommendations();
60
61 }
62
63 /**
64 * [action_links] add plugin action link
65 * @param [array] $links default plugin action link
66 * @return [array] plugin action link
67 */
68 public function action_links( $links ) {
69
70 if ( ! current_user_can( self::MENU_CAPABILITY ) ) {
71 return $links;
72 }
73
74 $settings_link = '<a href="'.admin_url( 'admin.php?page='.self::MENU_PAGE_SLUG ).'">'.esc_html__( 'Settings', 'ever-compare' ).'</a>';
75
76 array_unshift( $links, $settings_link );
77
78 return $links;
79 }
80
81 /**
82 * [add_menu] Admin Menu
83 */
84 public function add_menu(){
85
86 global $submenu;
87
88 self::$parent_menu_hook = add_menu_page(
89 esc_html__( 'Ever Compare', 'ever-compare' ),
90 esc_html__( 'Ever Compare', 'ever-compare' ),
91 self::MENU_CAPABILITY,
92 self::MENU_PAGE_SLUG,
93 [ $this,'dashboard' ],
94 'dashicons-update-alt',
95 59
96 );
97
98 if ( current_user_can( self::MENU_CAPABILITY ) ) {
99
100 foreach ( $this->sub_menu_nav() as $menukey => $menu ) {
101 $submenu[ self::MENU_PAGE_SLUG ][] = array(
102 esc_html__( $menu['title'], 'ever-compare' ),
103 self::MENU_CAPABILITY,
104 'admin.php?page='.self::MENU_PAGE_SLUG.'#'.$menukey,
105 );
106 }
107
108 }
109
110 add_action( 'load-' . self::$parent_menu_hook, [ $this, 'init_hooks'] );
111
112
113 }
114
115 /**
116 * Initialize our hooks for the admin page
117 *
118 * @return void
119 */
120 public function init_hooks() {
121 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
122 }
123
124 /**
125 * [enqueue_scripts] Add Scripts Base Menu Slug
126 * @param [string] $hook
127 * @return [void]
128 */
129 public function enqueue_scripts() {
130 wp_enqueue_style( 'evercompare-admin' );
131 wp_enqueue_script( 'evercompare-admin' );
132 }
133
134 /**
135 * [dashboard] Dashboard plugin page
136 * @return [HTML]
137 */
138 public function dashboard(){
139 Admin_Fields::instance()->plugin_page();
140 }
141
142 /**
143 * [sub_menu_nav]
144 * @return [array]
145 */
146 public function sub_menu_nav() {
147
148 $submenu = [
149 'settings' => [
150 'title' => esc_html__( 'Settings', 'ever-compare' ),
151 'subtitle' => esc_html__( 'Settings', 'ever-compare' ),
152 'icon' => '',
153 'class' => '',
154 ],
155 ];
156
157 return apply_filters( 'ever_compare_dashboard_submenu', $submenu );
158
159 }
160
161 /**
162 * [redirect_option_page] After Active the plugin then redirect to option page
163 * @return [void]
164 */
165 public function redirect_option_page() {
166 if ( get_option( 'evercompare_do_activation_redirect', FALSE ) ) {
167 delete_option('evercompare_do_activation_redirect');
168 if( !isset( $_GET['activate-multi'] ) ){
169 wp_redirect( admin_url( "admin.php?page=".self::MENU_PAGE_SLUG ) );
170 }
171 }
172 }
173
174 /**
175 * Add a post display state for special WishSuite page in the page list table.
176 *
177 * @param array $post_states An array of post display states.
178 * @param WP_Post $post The current post object.
179 */
180 public function add_display_post_states( $post_states, $post ){
181 if ( (int)ever_compare_get_option( 'compare_page', 'ever_compare_table_settings_tabs' ) === $post->ID ) {
182 $post_states['evercompare_page_for_compare_table'] = __( 'EverCompare', 'ever-compare' );
183 }
184 return $post_states;
185 }
186
187 /**
188 * [plugin_recommendations]
189 * @return [void]
190 */
191 public function plugin_recommendations(){
192
193 $get_instance = Recommended_Plugins::instance(
194 array(
195 'text_domain' => 'ever-compare',
196 'parent_menu_slug' => self::MENU_PAGE_SLUG,
197 'menu_capability' => self::MENU_CAPABILITY,
198 'menu_page_slug' => 'everrecommendations',
199 'priority' => 25,
200 'assets_url' => EVERCOMPARE_ASSETS,
201 'hook_suffix' => 'ever-compare_page_everrecommendations'
202 )
203 );
204
205 $get_instance->add_new_tab( array(
206
207 'title' => esc_html__( 'Recommended', 'ever-compare' ),
208 'active' => true,
209 'plugins' => array(
210 array(
211 'slug' => 'woolentor-addons',
212 'location' => 'woolentor_addons_elementor.php',
213 'name' => esc_html__( 'WooLentor', 'ever-compare' )
214 ),
215 array(
216 'slug' => 'wc-builder',
217 'location' => 'wc-builder.php',
218 'name' => esc_html__( 'WC Builder', 'ever-compare' )
219 ),
220 array(
221 'slug' => 'wishsuite',
222 'location' => 'wishsuite.php',
223 'name' => esc_html__( 'WishSuite', 'ever-compare' )
224 ),
225 array(
226 'slug' => 'quickswish',
227 'location' => 'quickswish.php',
228 'name' => esc_html__( 'QuickSwish', 'ever-compare' )
229 ),
230 array(
231 'slug' => 'whols',
232 'location' => 'whols.php',
233 'name' => esc_html__( 'Whols', 'ever-compare' )
234 ),
235 array(
236 'slug' => 'just-tables',
237 'location' => 'just-tables.php',
238 'name' => esc_html__( 'JustTables', 'ever-compare' )
239 ),
240 array(
241 'slug' => 'wc-multi-currency',
242 'location' => 'wcmilticurrency.php',
243 'name' => esc_html__( 'Multi Currency', 'ever-compare' )
244 )
245 )
246
247 ) );
248
249 $get_instance->add_new_tab(array(
250 'title' => esc_html__( 'You May Also Like', 'ever-compare' ),
251 'plugins' => array(
252
253 array(
254 'slug' => 'woolentor-addons-pro',
255 'location' => 'woolentor_addons_pro.php',
256 'name' => esc_html__( 'WooLentor Pro', 'ever-compare' ),
257 'link' => 'https://hasthemes.com/plugins/woolentor-pro-woocommerce-page-builder/',
258 'author_link'=> 'https://hasthemes.com/',
259 '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' ),
260 ),
261
262 array(
263 'slug' => 'just-tables-pro',
264 'location' => 'just-tables-pro.php',
265 'name' => esc_html__( 'JustTables Pro', 'ever-compare' ),
266 'link' => 'https://hasthemes.com/wp/justtables/',
267 'author_link'=> 'https://hasthemes.com/',
268 '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' ),
269 ),
270
271 array(
272 'slug' => 'whols-pro',
273 'location' => 'whols-pro.php',
274 'name' => esc_html__( 'Whols Pro', 'ever-compare' ),
275 'link' => 'https://hasthemes.com/plugins/whols-woocommerce-wholesale-prices/',
276 'author_link'=> 'https://hasthemes.com/',
277 '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' ),
278 ),
279
280 array(
281 'slug' => 'multicurrencypro',
282 'location' => 'multicurrencypro.php',
283 'name' => esc_html__( 'Multi Currency Pro for WooCommerce', 'ever-compare' ),
284 'link' => 'https://hasthemes.com/plugins/multi-currency-pro-for-woocommerce/',
285 'author_link'=> 'https://hasthemes.com/',
286 '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' ),
287 ),
288
289 array(
290 'slug' => 'email-candy-pro',
291 'location' => 'email-candy-pro.php',
292 'name' => esc_html__( 'Email Candy Pro', 'ever-compare' ),
293 'link' => 'https://hasthemes.com/plugins/email-candy-pro/',
294 'author_link'=> 'https://hasthemes.com/',
295 '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' ),
296 ),
297 )
298 ));
299
300 $get_instance->add_new_tab(array(
301 'title' => esc_html__( 'Others', 'ever-compare' ),
302 'plugins' => array(
303
304 array(
305 'slug' => 'ht-mega-for-elementor',
306 'location' => 'htmega_addons_elementor.php',
307 'name' => esc_html__( 'HT Mega', 'ever-compare' )
308 ),
309
310 array(
311 'slug' => 'ht-slider-for-elementor',
312 'location' => 'ht-slider-for-elementor.php',
313 'name' => esc_html__( 'HT Slider For Elementor', 'ever-compare' )
314 ),
315
316 array(
317 'slug' => 'wp-plugin-manager',
318 'location' => 'plugin-main.php',
319 'name' => esc_html__( 'WP Plugin Manager', 'ever-compare' )
320 ),
321
322 array(
323 'slug' => 'ht-contactform',
324 'location' => 'contact-form-widget-elementor.php',
325 'name' => esc_html__( 'HT Contact Form 7', 'ever-compare' )
326 ),
327
328 array(
329 'slug' => 'ht-wpform',
330 'location' => 'wpform-widget-elementor.php',
331 'name' => esc_html__( 'HT WPForms', 'ever-compare' )
332 ),
333
334 array(
335 'slug' => 'hashbar-wp-notification-bar',
336 'location' => 'init.php',
337 'name' => esc_html__( 'HashBar', 'ever-compare' )
338 ),
339
340 array(
341 'slug' => 'ht-menu-lite',
342 'location' => 'ht-mega-menu.php',
343 'name' => esc_html__( 'HT Menu', 'ever-compare' )
344 ),
345
346 array(
347 'slug' => 'htmega-pro',
348 'location' => 'htmega_pro.php',
349 'name' => esc_html__( 'HT Mega Pro', 'ever-compare' ),
350 'link' => 'https://hasthemes.com/plugins/ht-mega-pro/',
351 'author_link'=> 'https://hasthemes.com/',
352 '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' ),
353 ),
354
355 array(
356 'slug' => 'hashbar-pro',
357 'location' => 'init.php',
358 'name' => esc_html__( 'HashBar Pro', 'ever-compare' ),
359 'link' => 'https://hasthemes.com/plugins/wordpress-notification-bar-plugin/',
360 'author_link'=> 'https://hasthemes.com/',
361 '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' ),
362 ),
363
364 )
365 ));
366
367
368 }
369
370
371 }