-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathFloatingNotificationBarModule.php
More file actions
142 lines (123 loc) · 2.78 KB
/
FloatingNotificationBarModule.php
File metadata and controls
142 lines (123 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
* File for Floating_Notification_Bar_Module class.
*
* @package SBFW
*/
namespace STOREGROWTH\SPSB\Modules\FloatingNotificationBar;
use STOREGROWTH\SPSB\Interfaces\ModuleSkeleton;
use STOREGROWTH\SPSB\Traits\Singleton;
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Floating notification bar module initiator class.
*/
class FloatingNotificationBarModule implements ModuleSkeleton {
use Singleton;
/**
* Unique ID for a module.
*
* @return string
*/
public function get_id() {
return 'floating-notification-bar';
}
/**
* directory Name for a module.
*
* @return string
*/
public function get_dir() {
return 'FloatingNotificationBar';
}
/**
* Icon for a module.
*
* @return string
*/
public function get_icon() {
return sgsb_modules_url( 'FloatingNotificationBar/assets/images/floating-bar-icon.svg' );
}
/**
* Banner for a module.
*
* @return string
*/
public function get_banner() {
return sgsb_modules_url( 'FloatingNotificationBar/assets/images/floating-bar-feature-image.webp' );
}
/**
* Unique name for a module.
*
* @return string
*/
public function get_name() {
return 'Floating Bar';
}
/**
* Description for the module.
*
* @return string
*/
public function get_description() {
return 'Captivate with announcements. Customizable bars draw attention to special offers, discounts, and important news.';
}
/**
* Category for a module.
*
* @return string
*/
public function get_module_category() {
return 'Discount Banner';
}
/**
* Module activation function.
*
* @return void
*/
public function activate() {
// TODO: Implement activate() method.
}
/**
* Module deactivation function.
*
* @return void
*/
public function deactivate() {
// TODO: Implement deactivate() method.
}
/**
* Setting Initial Banner Data.
*
* @return void
*/
public function set_initial_banner_data() {
$flags = get_option( 'sgsb_discount_banner_flags', array() );
if ( isset( $flags['done_setting_initial_banner_data'] ) ) {
return;
}
$default_data = array(
'default_banner_text' => 'Shop more than $100 to get free shipping.',
);
delete_option( 'sgsb_floating_notification_bar_settings' );
$result = update_option( 'sgsb_floating_notification_bar_settings', $default_data );
if ( $result ) {
update_option( 'sgsb_discount_banner_flags', array( 'done_setting_initial_banner_data' => true ) );
}
}
/**
* Starting point of the module.
*
* @return void
*/
public function init() {
Includes\Ajax::instance();
Includes\CommonHooks::instance();
Includes\EnqueueScript::instance();
do_action( 'storegrowth_floating_bar_module_init' );
}
}
// Create object and return.
return FloatingNotificationBarModule::instance();