10
10
class Options_Framework_Admin {
11
11
12
12
/**
13
- * Page hook for the options screen
14
- *
15
- * @since 1.7.0
16
- * @type string
17
- */
18
- protected $ options_screen = null ;
19
-
20
- /**
21
- * Hook in the scripts and styles
22
- *
23
- * @since 1.7.0
24
- */
25
- public function init () {
13
+ * Page hook for the options screen
14
+ *
15
+ * @since 1.7.0
16
+ * @type string
17
+ */
18
+ protected $ options_screen = null ;
19
+
20
+ /**
21
+ * Hook in the scripts and styles
22
+ *
23
+ * @since 1.7.0
24
+ */
25
+ public function init () {
26
26
27
27
// Gets options to load
28
- $ options = & Options_Framework::_optionsframework_options ();
28
+ $ options = & Options_Framework::_optionsframework_options ();
29
29
30
30
// Checks if options are available
31
- if ( $ options ) {
31
+ if ( $ options ) {
32
32
33
33
// Add the options page and menu item.
34
34
add_action ( 'admin_menu ' , array ( $ this , 'add_custom_options_page ' ) );
@@ -49,27 +49,27 @@ public function init() {
49
49
add_action ( 'admin_init ' , array ( $ this , 'options_notice_ignore ' ) );
50
50
}
51
51
52
- }
52
+ }
53
53
54
54
/**
55
- * Let's the user know that options aren't available for their theme
56
- */
57
- function options_notice () {
55
+ * Let's the user know that options aren't available for their theme
56
+ */
57
+ function options_notice () {
58
58
global $ pagenow ;
59
- if ( !is_multisite () && ( $ pagenow == 'plugins.php ' || $ pagenow == 'themes.php ' ) ) {
59
+ if ( !is_multisite () && ( $ pagenow == 'plugins.php ' || $ pagenow == 'themes.php ' ) ) {
60
60
global $ current_user ;
61
61
$ user_id = $ current_user ->ID ;
62
62
if ( ! get_user_meta ($ user_id , 'optionsframework_ignore_notice ' ) ) {
63
63
echo '<div class="updated optionsframework_setup_nag"><p> ' ;
64
64
printf ( __ ('Your current theme does not have support for the Options Framework plugin. <a href="%1$s" target="_blank">Learn More</a> | <a href="%2$s">Hide Notice</a> ' , 'options-framework ' ), 'http://wptheming.com/options-framework-plugin ' , '?optionsframework_nag_ignore=0 ' );
65
65
echo "</p></div> " ;
66
66
}
67
- }
67
+ }
68
68
}
69
69
70
70
/**
71
- * Allows the user to hide the options notice
72
- */
71
+ * Allows the user to hide the options notice
72
+ */
73
73
function options_notice_ignore () {
74
74
global $ current_user ;
75
75
$ user_id = $ current_user ->ID ;
@@ -79,22 +79,22 @@ function options_notice_ignore() {
79
79
}
80
80
81
81
/**
82
- * Registers the settings
83
- *
84
- * @since 1.7.0
85
- */
86
- function settings_init () {
82
+ * Registers the settings
83
+ *
84
+ * @since 1.7.0
85
+ */
86
+ function settings_init () {
87
87
88
- // Load Options Framework Settings
89
- $ optionsframework_settings = get_option ( 'optionsframework ' );
88
+ // Load Options Framework Settings
89
+ $ optionsframework_settings = get_option ( 'optionsframework ' );
90
90
91
91
// Registers the settings fields and callback
92
92
register_setting ( 'optionsframework ' , $ optionsframework_settings ['id ' ], array ( $ this , 'validate_options ' ) );
93
93
94
94
// Displays notice after options save
95
95
add_action ( 'optionsframework_after_validate ' , array ( $ this , 'save_options_notice ' ) );
96
96
97
- }
97
+ }
98
98
99
99
/*
100
100
* Define menu options (still limited to appearance section)
@@ -115,87 +115,99 @@ static function menu_settings() {
115
115
$ menu = array (
116
116
117
117
// Modes: submenu, menu
118
- 'mode ' => 'submenu ' ,
118
+ 'mode ' => 'submenu ' ,
119
119
120
- // Submenu default settings
121
- 'page_title ' => __ ( 'Theme Options ' , 'options-framework ' ),
120
+ // Submenu default settings
121
+ 'page_title ' => __ ( 'Theme Options ' , 'options-framework ' ),
122
122
'menu_title ' => __ ('Theme Options ' , 'options-framework ' ),
123
123
'capability ' => 'edit_theme_options ' ,
124
124
'menu_slug ' => 'options-framework ' ,
125
- 'parent_slug ' => 'themes.php ' ,
125
+ 'parent_slug ' => 'themes.php ' ,
126
126
127
- // Menu default settings
128
- 'icon_url ' => 'dashicons-admin-generic ' ,
129
- 'position ' => '61 '
127
+ // Menu default settings
128
+ 'icon_url ' => 'dashicons-admin-generic ' ,
129
+ 'position ' => '61 '
130
130
131
131
);
132
132
133
133
return apply_filters ( 'optionsframework_menu ' , $ menu );
134
134
}
135
135
136
136
/**
137
- * Add a subpage called "Theme Options" to the appearance menu.
138
- *
139
- * @since 1.7.0
140
- */
137
+ * Add a subpage called "Theme Options" to the appearance menu.
138
+ *
139
+ * @since 1.7.0
140
+ */
141
141
function add_custom_options_page () {
142
142
143
143
$ menu = $ this ->menu_settings ();
144
144
145
- switch ( $ menu ['mode ' ] ) {
146
-
147
- case 'menu ' :
148
- // http://codex.wordpress.org/Function_Reference/add_menu_page
149
- $ this ->options_screen = add_menu_page (
150
- $ menu ['page_title ' ],
151
- $ menu ['menu_title ' ],
152
- $ menu ['capability ' ],
153
- $ menu ['menu_slug ' ],
154
- array ( $ this , 'options_page ' ),
155
- $ menu ['icon_url ' ],
156
- $ menu ['position ' ]
157
- );
158
- break ;
159
-
160
- default :
161
- // http://codex.wordpress.org/Function_Reference/add_submenu_page
162
- $ this ->options_screen = add_submenu_page (
163
- $ menu ['parent_slug ' ],
164
- $ menu ['page_title ' ],
165
- $ menu ['menu_title ' ],
166
- $ menu ['capability ' ],
167
- $ menu ['menu_slug ' ],
168
- array ( $ this , 'options_page ' ) );
169
- break ;
170
- }
145
+ switch ( $ menu ['mode ' ] ) {
146
+
147
+ case 'menu ' :
148
+ // http://codex.wordpress.org/Function_Reference/add_menu_page
149
+ $ this ->options_screen = add_menu_page (
150
+ $ menu ['page_title ' ],
151
+ $ menu ['menu_title ' ],
152
+ $ menu ['capability ' ],
153
+ $ menu ['menu_slug ' ],
154
+ array ( $ this , 'options_page ' ),
155
+ $ menu ['icon_url ' ],
156
+ $ menu ['position ' ]
157
+ );
158
+ break ;
159
+
160
+ default :
161
+ // http://codex.wordpress.org/Function_Reference/add_submenu_page
162
+ $ this ->options_screen = add_submenu_page (
163
+ $ menu ['parent_slug ' ],
164
+ $ menu ['page_title ' ],
165
+ $ menu ['menu_title ' ],
166
+ $ menu ['capability ' ],
167
+ $ menu ['menu_slug ' ],
168
+ array ( $ this , 'options_page ' ) );
169
+ break ;
170
+ }
171
171
}
172
172
173
173
/**
174
- * Loads the required stylesheets
175
- *
176
- * @since 1.7.0
177
- */
174
+ * Loads the required stylesheets
175
+ *
176
+ * @since 1.7.0
177
+ */
178
178
function enqueue_admin_styles ( $ hook ) {
179
179
180
- if ( $ this ->options_screen != $ hook )
181
- return ;
180
+ if ( $ this ->options_screen != $ hook ) {
181
+ return ;
182
+ }
182
183
183
- wp_enqueue_style ( 'optionsframework ' , plugin_dir_url ( dirname (__FILE__ ) ) . 'css/optionsframework.css ' , array (), Options_Framework::VERSION );
184
+ wp_enqueue_style (
185
+ 'optionsframework ' ,
186
+ plugin_dir_url ( dirname (__FILE__ ) ) . 'css/optionsframework.css ' ,
187
+ array (),
188
+ Options_Framework::VERSION
189
+ );
184
190
wp_enqueue_style ( 'wp-color-picker ' );
185
191
}
186
192
187
193
/**
188
- * Loads the required javascript
189
- *
190
- * @since 1.7.0
191
- */
194
+ * Loads the required javascript
195
+ *
196
+ * @since 1.7.0
197
+ */
192
198
function enqueue_admin_scripts ( $ hook ) {
193
199
194
- if ( $ this ->options_screen != $ hook )
195
- return ;
200
+ if ( $ this ->options_screen != $ hook ) {
201
+ return ;
202
+ }
196
203
197
204
// Enqueue custom option panel JS
198
- wp_enqueue_script ( 'options-custom ' , plugin_dir_url ( dirname (__FILE__ ) ) . 'js/options-custom.js ' , array ( 'jquery ' ,'wp-color-picker ' ), Options_Framework::VERSION );
205
+ wp_enqueue_script (
206
+ 'options-custom ' ,
207
+ plugin_dir_url ( dirname (__FILE__ ) ) . 'js/options-custom.js ' ,
208
+ array ( 'jquery ' ,'wp-color-picker ' ),
209
+ Options_Framework::VERSION
210
+ );
199
211
200
212
// Inline scripts from options-interface.php
201
213
add_action ( 'admin_head ' , array ( $ this , 'of_admin_head ' ) );
@@ -207,32 +219,32 @@ function of_admin_head() {
207
219
}
208
220
209
221
/**
210
- * Builds out the options panel.
211
- *
222
+ * Builds out the options panel.
223
+ *
212
224
* If we were using the Settings API as it was intended we would use
213
225
* do_settings_sections here. But as we don't want the settings wrapped in a table,
214
226
* we'll call our own custom optionsframework_fields. See options-interface.php
215
227
* for specifics on how each individual field is generated.
216
228
*
217
229
* Nonces are provided using the settings_fields()
218
230
*
219
- * @since 1.7.0
220
- */
231
+ * @since 1.7.0
232
+ */
221
233
function options_page () { ?>
222
234
223
235
<div id="optionsframework-wrap" class="wrap">
224
236
225
237
<?php $ menu = $ this ->menu_settings (); ?>
226
238
<h2><?php echo esc_html ( $ menu ['page_title ' ] ); ?> </h2>
227
239
228
- <h2 class="nav-tab-wrapper">
229
- <?php echo Options_Framework_Interface::optionsframework_tabs (); ?>
230
- </h2>
240
+ <h2 class="nav-tab-wrapper">
241
+ <?php echo Options_Framework_Interface::optionsframework_tabs (); ?>
242
+ </h2>
231
243
232
- <?php settings_errors ( 'options-framework ' ); ?>
244
+ <?php settings_errors ( 'options-framework ' ); ?>
233
245
234
- <div id="optionsframework-metabox" class="metabox-holder">
235
- <div id="optionsframework" class="postbox">
246
+ <div id="optionsframework-metabox" class="metabox-holder">
247
+ <div id="optionsframework" class="postbox">
236
248
<form action="options.php" method="post">
237
249
<?php settings_fields ( 'optionsframework ' ); ?>
238
250
<?php Options_Framework_Interface::optionsframework_fields (); /* Settings */ ?>
@@ -269,7 +281,12 @@ function validate_options( $input ) {
269
281
*/
270
282
271
283
if ( isset ( $ _POST ['reset ' ] ) ) {
272
- add_settings_error ( 'options-framework ' , 'restore_defaults ' , __ ( 'Default options restored. ' , 'options-framework ' ), 'updated fade ' );
284
+ add_settings_error (
285
+ 'options-framework ' ,
286
+ 'restore_defaults ' ,
287
+ __ ( 'Default options restored. ' , 'options-framework ' ),
288
+ 'updated fade '
289
+ );
273
290
return $ this ->get_default_values ();
274
291
}
275
292
@@ -323,7 +340,12 @@ function validate_options( $input ) {
323
340
*/
324
341
325
342
function save_options_notice () {
326
- add_settings_error ( 'options-framework ' , 'save_options ' , __ ( 'Options saved. ' , 'options-framework ' ), 'updated fade ' );
343
+ add_settings_error (
344
+ 'options-framework ' ,
345
+ 'save_options ' ,
346
+ __ ( 'Options saved. ' , 'options-framework ' ),
347
+ 'updated fade '
348
+ );
327
349
}
328
350
329
351
/**
@@ -385,4 +407,4 @@ function optionsframework_admin_bar() {
385
407
$ wp_admin_bar ->add_menu ( apply_filters ( 'optionsframework_admin_bar ' , $ args ) );
386
408
}
387
409
388
- }
410
+ }
0 commit comments