PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / trunk
Ever Compare – Products Compare Plugin for WooCommerce vtrunk
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_Widget.php

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

67 lines 1.8 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 defined( 'ABSPATH' ) || exit;
5
6 class Dashboard_Widget {
7
8 public function __construct() {
9 // Priority 1 WooLentor, priority 2 HT Mega — defer to either if active.
10 if ( ! is_plugin_active( 'woolentor-addons/woolentor_addons_elementor.php' ) &&
11 ! is_plugin_active( 'ht-mega-for-elementor/htmega_addons_elementor.php' ) ) {
12 add_action( 'wp_dashboard_setup', [ $this, 'dashboard_widget' ], 9999 );
13 }
14 }
15
16 /**
17 * Register Dashboard Widget
18 * @return void
19 */
20 public function dashboard_widget() {
21 // Another HasThemes plugin already registered this widget — skip.
22 global $wp_meta_boxes;
23 if ( isset( $wp_meta_boxes['dashboard']['normal']['core']['hasthemes-dashboard-stories'] ) ) {
24 return;
25 }
26
27 wp_add_dashboard_widget(
28 'hasthemes-dashboard-stories',
29 esc_html__( 'HasThemes Stories', 'ever-compare' ),
30 [ $this, 'dashboard_hasthemes_widget' ]
31 );
32
33 $dashboard_widget_list = $wp_meta_boxes['dashboard']['normal']['core'];
34
35 $hastheme_dashboard_widget = [
36 'hasthemes-dashboard-stories' => $dashboard_widget_list['hasthemes-dashboard-stories']
37 ];
38
39 $all_dashboard_widget = array_merge( $hastheme_dashboard_widget, $dashboard_widget_list );
40
41 $wp_meta_boxes['dashboard']['normal']['core'] = $all_dashboard_widget;
42 }
43
44 /**
45 * Dashboard Stories Widget
46 * @return void
47 */
48 public function dashboard_hasthemes_widget() {
49 ob_start();
50 self::load_template( 'widget' );
51 echo ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
52 }
53
54 /**
55 * Template load
56 * @param string $template template suffix
57 * @return void
58 */
59 private static function load_template( $template ) {
60 $tmp_file = EVERCOMPARE_PATH . '/includes/templates/dashboard-' . $template . '.php';
61 if ( file_exists( $tmp_file ) ) {
62 include_once( $tmp_file );
63 }
64 }
65
66 }
67