PluginProbe
Whols – Wholesale Prices and B2B Store Solution for WooCommerce / trunk
Whols – Wholesale Prices and B2B Store Solution for WooCommerce vtrunk
2.4.12 2.4.11 trunk 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 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 All 55 releases
whols / includes / Admin / class-dashboard-widget.php

class-dashboard-widget.php in Whols – Wholesale Prices and B2B Store Solution for WooCommerce trunk, at includes/Admin/class-dashboard-widget.php

69 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 Whols\Admin;
3
4 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
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', 'whols' ),
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 = WHOLS_PATH . '/includes/Admin/templates/dashboard-' . $template . '.php';
61 if ( file_exists( $tmp_file ) ) {
62 include_once( $tmp_file );
63 }
64 }
65
66 }
67
68 new Dashboard_Widget();
69