Skip to content

Commit 499a1ab

Browse files
committed
🐛 fix: Addons Initialization
1 parent eeb98ee commit 499a1ab

File tree

4 files changed

+12
-89
lines changed

4 files changed

+12
-89
lines changed

classes/class-helper-functions.php

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -10,92 +10,6 @@ public static function mighty_addons() {
1010

1111
$widgets = get_option( 'mighty_addons_status' );
1212

13-
if ( empty($widgets) ) {
14-
$widgets = [
15-
16-
'testimonial' => [
17-
'title' => 'MT Testimonial',
18-
'description' => '',
19-
'enable' => true,
20-
'class' => 'MT_Testimonial',
21-
'slug' => 'testimonial',
22-
'icon' => 'mf mf-testimonial'
23-
],
24-
'team' => [
25-
'title' => 'MT Team',
26-
'description' => '',
27-
'enable' => true,
28-
'class' => 'MT_Team',
29-
'slug' => 'team',
30-
'icon' => 'mf mf-team'
31-
],
32-
'progressbar' => [
33-
'title' => 'MT Progress Bar',
34-
'description' => '',
35-
'enable' => true,
36-
'class' => 'MT_Progressbar',
37-
'slug' => 'progressbar',
38-
'icon' => 'mf mf-progressbar'
39-
],
40-
'counter' => [
41-
'title' => 'MT Counter',
42-
'description' => '',
43-
'enable' => true,
44-
'class' => 'MT_Counter',
45-
'slug' => 'counter',
46-
'icon' => 'mf mf-counter'
47-
],
48-
'buttongroup' => [
49-
'title' => 'MT Button Group',
50-
'description' => '',
51-
'enable' => true,
52-
'class' => 'MT_Buttongroup',
53-
'slug' => 'buttongroup',
54-
'icon' => 'mf mf-button'
55-
],
56-
'accordion' => [
57-
'title' => 'MT Accordion',
58-
'description' => '',
59-
'enable' => true,
60-
'class' => 'MT_Accordion',
61-
'slug' => 'accordion',
62-
'icon' => 'mf mf-accordion'
63-
],
64-
'beforeafter' => [
65-
'title' => 'MT Before After',
66-
'description' => '',
67-
'enable' => true,
68-
'class' => 'MT_Beforeafter',
69-
'slug' => 'beforeafter',
70-
'icon' => 'mf mf-beforeafter'
71-
],
72-
'gradientheading' => [
73-
'title' => 'MT Gradient Heading',
74-
'description' => '',
75-
'enable' => true,
76-
'class' => 'MT_Gradientheading',
77-
'slug' => 'gradientheading',
78-
'icon' => 'mf mf-heading'
79-
],
80-
'flipbox' => [
81-
'title' => 'MT Flip Box',
82-
'description' => '',
83-
'enable' => true,
84-
'class' => 'MT_Flipbox',
85-
'slug' => 'flipbox',
86-
'icon' => 'mf mf-flipbox'
87-
],
88-
'openinghours' => [
89-
'title' => 'MT Opening Hours',
90-
'description' => '',
91-
'enable' => true,
92-
'class' => 'MT_Openinghours',
93-
'slug' => 'openinghours',
94-
'icon' => 'mf mf-openinghours'
95-
],
96-
];
97-
}
98-
9913
return $widgets;
10014
}
10115

classes/mighty-elementor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public function register_widgets() {
106106
$widgets = HelperFunctions::mighty_addons();
107107

108108
foreach( $widgets as $widget => $props ) {
109-
if( $props['enable'] === 1 ) {
109+
if( $props['enable'] ) {
110+
110111
// Including Plugin
111112
require_once( MIGHTY_ADDONS_DIR_PATH . 'widgets/' . $widget .'.php' );
112113

classes/panel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public static function mighty_addons_status() {
262262
return;
263263
}
264264

265-
// For compactness
265+
// TO-DO: For compactness
266266
// foreach ( self::$ma_settings as $widget ) {
267267
// self::$ma_settings[$settings[$widget['slug']]['enable']] = intval( $settings[$widget['slug']] ? 1 : 0 );
268268
// }

mighty-addons.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Mighty_Addons;
1313

14+
use MightyAddons\Classes\DashboardPanel;
15+
1416
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
1517

1618
define( 'MIGHTY_ADDONS_VERSION', '1.2.0' );
@@ -160,7 +162,13 @@ public function init() {
160162

161163
// Including Admin Widget
162164
if ( is_admin() ) {
163-
require_once ( MIGHTY_ADDONS_DIR_PATH . 'classes/panel.php' );
165+
166+
require_once ( MIGHTY_ADDONS_DIR_PATH . 'classes/panel.php' );
167+
168+
$dashboard = new DashboardPanel;
169+
$widgets = $dashboard->get_enabled_addons();
170+
171+
update_option( 'mighty_addons_status', $widgets );
164172
}
165173
}
166174

0 commit comments

Comments
 (0)