-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwp-addon-settings.php
163 lines (136 loc) · 3.81 KB
/
wp-addon-settings.php
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
defined( 'ABSPATH' ) or exit;
class WP_Addon_Settings {
private static $instance;
public $file;
public $path;
public $url;
public $ver;
public $wp_plugin_name;
public $wp_plugin_slug;
private function __construct() {
$this->file = RW_FILE;
$this->path = RW_PLUGIN_DIR;
$this->url = RW_PLUGIN_URL;
$this->ver = '1.1.3';
add_action( 'plugins_loaded', [ $this, 'admin_init' ] );
add_action( 'admin_notices', [ $this, 'admin_notices' ], 11 );
add_action( 'network_admin_notices', [ $this, 'admin_notices' ], 11 );
add_action( 'admin_enqueue_scripts', [ $this, 'admin_assets' ], 20 );
add_action( 'plugins_loaded', function () {
load_plugin_textdomain( 'wp-addon', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}, 9 );
}
public static function getInstance() {
if ( static::$instance === null ) {
static::$instance = new self();
}
return static::$instance;
}
public function __clone() {
}
public function __wakeup() {
}
/**
* style and scripts in wp-admin
*
* @param $page
*/
public function admin_assets( $page ) {
if ( strpos( $page, $this->wp_plugin_slug ) === false ) {
return;
}
wp_enqueue_style( $this->wp_plugin_slug,
RW_PLUGIN_URL . 'assets/css/min/admin.min.css',
false,
$this->ver,
'all' );
}
public function admin_notices() {
$options = get_option( $this->wp_plugin_slug );
}
/**
* @see http://codestarframework.com/documentation/#/fields?id=checkbox
*/
public function admin_init() {
$this->wp_plugin_name = __( 'Wordpress Addon', 'wp-addon' );
$this->wp_plugin_slug = 'wp-addon';
// Check core class for avoid errors
if ( class_exists( 'CSF' ) ) :
// Set a unique slug-like ID
$prefix = $this->wp_plugin_slug;
// Create options
CSF::createOptions( $prefix, require_once 'settings/_options.php' );
// General Settings
CSF::createSection( $prefix, [
'title' => __( 'General Settings', 'wp-addon' ),
'icon' => 'fa fa-rocket',
'fields' => require_once 'settings/main.php',
] );
// Tweaks
CSF::createSection( $prefix, [
'title' => __( 'Tweaks', 'wp-addon' ),
'icon' => 'fa fa-wordpress',
'fields' => require_once 'settings/tweaks.php',
] );
// Shortcodes and Widgets
CSF::createSection( $prefix, [
'title' => __( 'Shortcodes and Widgets', 'wp-addon' ),
'icon' => 'fa fa-bolt',
'fields' => require_once 'settings/widgets.php',
] );
do_action( 'wp_addon_settings_section', $prefix );
// Custom Code
CSF::createSection( $prefix, [
'title' => __( 'Custom code', 'wp-addon' ),
'icon' => 'fa fa-code',
'fields' => [
[
'id' => 'rw_header_css',
'type' => 'code_editor',
'title' => __( 'CSS Code in Header', 'wp-addon' ),
'settings' => [
'theme' => 'mbo',
'mode' => 'css',
],
'sanitize' => false,
],
[
'id' => 'rw_header_html',
'type' => 'code_editor',
'title' => __( 'Any HTML code or Analytics code in header.', 'wp-addon' ),
'settings' => [
'theme' => 'monokai',
'mode' => 'htmlmixed',
],
'default' => '',
'sanitize' => false,
],
[
'id' => 'rw_footer_html',
'type' => 'code_editor',
'title' => __( 'Any HTML code in footer.', 'wp-addon' ),
'settings' => [
'theme' => 'monokai',
//'mode' => 'php',
],
'default' => '',
'sanitize' => false,
],
],// #fields
] );
// BackUp
CSF::createSection( $prefix, [
'title' => __( 'Backup Settings', 'wp-addon' ),
'icon' => 'fa fa-server',
'fields' => [
[
'title' => __( 'Download settings now', 'wp-addon' ),
'desc' => __( 'You can get or set settings from backup' ),
'type' => 'backup',
],
],
] );
endif;
}
}