Skip to content

Commit ee46a70

Browse files
committed
Version 1.8.6
1 parent c5f564a commit ee46a70

9 files changed

+176
-143
lines changed

includes/class-options-framework-admin.php

+117-95
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
class Options_Framework_Admin {
1111

1212
/**
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() {
2626

2727
// Gets options to load
28-
$options = & Options_Framework::_optionsframework_options();
28+
$options = & Options_Framework::_optionsframework_options();
2929

3030
// Checks if options are available
31-
if ( $options ) {
31+
if ( $options ) {
3232

3333
// Add the options page and menu item.
3434
add_action( 'admin_menu', array( $this, 'add_custom_options_page' ) );
@@ -49,27 +49,27 @@ public function init() {
4949
add_action( 'admin_init', array( $this, 'options_notice_ignore' ) );
5050
}
5151

52-
}
52+
}
5353

5454
/**
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() {
5858
global $pagenow;
59-
if ( !is_multisite() && ( $pagenow == 'plugins.php' || $pagenow == 'themes.php' ) ) {
59+
if ( !is_multisite() && ( $pagenow == 'plugins.php' || $pagenow == 'themes.php' ) ) {
6060
global $current_user ;
6161
$user_id = $current_user->ID;
6262
if ( ! get_user_meta($user_id, 'optionsframework_ignore_notice') ) {
6363
echo '<div class="updated optionsframework_setup_nag"><p>';
6464
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');
6565
echo "</p></div>";
6666
}
67-
}
67+
}
6868
}
6969

7070
/**
71-
* Allows the user to hide the options notice
72-
*/
71+
* Allows the user to hide the options notice
72+
*/
7373
function options_notice_ignore() {
7474
global $current_user;
7575
$user_id = $current_user->ID;
@@ -79,22 +79,22 @@ function options_notice_ignore() {
7979
}
8080

8181
/**
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() {
8787

88-
// Load Options Framework Settings
89-
$optionsframework_settings = get_option( 'optionsframework' );
88+
// Load Options Framework Settings
89+
$optionsframework_settings = get_option( 'optionsframework' );
9090

9191
// Registers the settings fields and callback
9292
register_setting( 'optionsframework', $optionsframework_settings['id'], array ( $this, 'validate_options' ) );
9393

9494
// Displays notice after options save
9595
add_action( 'optionsframework_after_validate', array( $this, 'save_options_notice' ) );
9696

97-
}
97+
}
9898

9999
/*
100100
* Define menu options (still limited to appearance section)
@@ -115,87 +115,99 @@ static function menu_settings() {
115115
$menu = array(
116116

117117
// Modes: submenu, menu
118-
'mode' => 'submenu',
118+
'mode' => 'submenu',
119119

120-
// Submenu default settings
121-
'page_title' => __( 'Theme Options', 'options-framework'),
120+
// Submenu default settings
121+
'page_title' => __( 'Theme Options', 'options-framework'),
122122
'menu_title' => __('Theme Options', 'options-framework'),
123123
'capability' => 'edit_theme_options',
124124
'menu_slug' => 'options-framework',
125-
'parent_slug' => 'themes.php',
125+
'parent_slug' => 'themes.php',
126126

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'
130130

131131
);
132132

133133
return apply_filters( 'optionsframework_menu', $menu );
134134
}
135135

136136
/**
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+
*/
141141
function add_custom_options_page() {
142142

143143
$menu = $this->menu_settings();
144144

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+
}
171171
}
172172

173173
/**
174-
* Loads the required stylesheets
175-
*
176-
* @since 1.7.0
177-
*/
174+
* Loads the required stylesheets
175+
*
176+
* @since 1.7.0
177+
*/
178178
function enqueue_admin_styles( $hook ) {
179179

180-
if ( $this->options_screen != $hook )
181-
return;
180+
if ( $this->options_screen != $hook ) {
181+
return;
182+
}
182183

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+
);
184190
wp_enqueue_style( 'wp-color-picker' );
185191
}
186192

187193
/**
188-
* Loads the required javascript
189-
*
190-
* @since 1.7.0
191-
*/
194+
* Loads the required javascript
195+
*
196+
* @since 1.7.0
197+
*/
192198
function enqueue_admin_scripts( $hook ) {
193199

194-
if ( $this->options_screen != $hook )
195-
return;
200+
if ( $this->options_screen != $hook ) {
201+
return;
202+
}
196203

197204
// 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+
);
199211

200212
// Inline scripts from options-interface.php
201213
add_action( 'admin_head', array( $this, 'of_admin_head' ) );
@@ -207,32 +219,32 @@ function of_admin_head() {
207219
}
208220

209221
/**
210-
* Builds out the options panel.
211-
*
222+
* Builds out the options panel.
223+
*
212224
* If we were using the Settings API as it was intended we would use
213225
* do_settings_sections here. But as we don't want the settings wrapped in a table,
214226
* we'll call our own custom optionsframework_fields. See options-interface.php
215227
* for specifics on how each individual field is generated.
216228
*
217229
* Nonces are provided using the settings_fields()
218230
*
219-
* @since 1.7.0
220-
*/
231+
* @since 1.7.0
232+
*/
221233
function options_page() { ?>
222234

223235
<div id="optionsframework-wrap" class="wrap">
224236

225237
<?php $menu = $this->menu_settings(); ?>
226238
<h2><?php echo esc_html( $menu['page_title'] ); ?></h2>
227239

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>
231243

232-
<?php settings_errors( 'options-framework' ); ?>
244+
<?php settings_errors( 'options-framework' ); ?>
233245

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">
236248
<form action="options.php" method="post">
237249
<?php settings_fields( 'optionsframework' ); ?>
238250
<?php Options_Framework_Interface::optionsframework_fields(); /* Settings */ ?>
@@ -269,7 +281,12 @@ function validate_options( $input ) {
269281
*/
270282

271283
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+
);
273290
return $this->get_default_values();
274291
}
275292

@@ -323,7 +340,12 @@ function validate_options( $input ) {
323340
*/
324341

325342
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+
);
327349
}
328350

329351
/**
@@ -385,4 +407,4 @@ function optionsframework_admin_bar() {
385407
$wp_admin_bar->add_menu( apply_filters( 'optionsframework_admin_bar', $args ) );
386408
}
387409

388-
}
410+
}

0 commit comments

Comments
 (0)