Permalink
Browse files

Added switch to move options framework menu from the Appearances subm…

…enu to its own top level menu item
  • Loading branch information...
blobaugh committed May 8, 2012
1 parent 3d48880 commit 0587d9a8bbf266f7f86cfe4965bf630ad0475c69
Showing with 37 additions and 16 deletions.
  1. +37 −16 options-framework.php
View
53 options-framework.php 100644 → 100755
@@ -28,9 +28,18 @@
/* Basic plugin definitions */
define('OPTIONS_FRAMEWORK_VERSION', '1.1');
-define('OPTIONS_FRAMEWORK_URL', plugin_dir_url( __FILE__ ));
+//define('OPTIONS_FRAMEWORK_URL', plugin_dir_url( __FILE__ ));
+define( 'OPTIONS_FRAMEWORK_URL', get_bloginfo('template_directory') . '/options-framework2/');
-load_plugin_textdomain( 'optionsframework', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
+/*
+ * Determines where to show the options framework menu item
+ *
+ * Possible values:
+ * toplevel
+ * appearance
+ */
+define( 'OPTIONS_FRAMEWORK_MENU_LEVEL', 'toplevel' );
+define( 'OPTIONS_FRAMEWORK_MENU_TITLE', 'Theme Options' );
/* Make sure we don't expose any info if called directly */
@@ -68,7 +77,7 @@ function optionsframework_admin_notice() {
$user_id = $current_user->ID;
if ( ! get_user_meta($user_id, 'optionsframework_ignore_notice') ) {
echo '<div class="updated optionsframework_setup_nag"><p>';
- 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>', 'optionsframework'), 'http://wptheming.com/options-framework-plugin', '?optionsframework_nag_ignore=0');
+ 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>'), 'http://wptheming.com/options-framework-plugin', '?optionsframework_nag_ignore=0');
echo "</p></div>";
}
}
@@ -180,6 +189,8 @@ function optionsframework_init() {
register_setting( 'optionsframework', $optionsframework_settings['id'], 'optionsframework_validate' );
// Change the capability required to save the 'optionsframework' options group.
add_filter( 'option_page_capability_optionsframework', 'optionsframework_page_capability' );
+
+
}
/**
@@ -249,34 +260,43 @@ function optionsframework_setdefaults() {
if ( !function_exists( 'optionsframework_add_page' ) ) {
function optionsframework_add_page() {
- $of_page = add_theme_page(__('Theme Options', 'optionsframework'), __('Theme Options', 'optionsframework'), 'edit_theme_options', 'options-framework','optionsframework_page');
-
+ if( 'toplevel' == OPTIONS_FRAMEWORK_MENU_LEVEL ) {
+ $of_page = add_menu_page(OPTIONS_FRAMEWORK_MENU_TITLE, OPTIONS_FRAMEWORK_MENU_TITLE, 'edit_theme_options', 'options-framework','optionsframework_page');
+ } else {
+ // Default to the 'appearance' menu
+ $of_page = add_theme_page(OPTIONS_FRAMEWORK_MENU_TITLE, OPTIONS_FRAMEWORK_MENU_TITLE, 'edit_theme_options', 'options-framework','optionsframework_page');
+ }
+
+
// Load the required CSS and javscript
add_action('admin_enqueue_scripts', 'optionsframework_load_scripts');
add_action( 'admin_print_styles-' . $of_page, 'optionsframework_load_styles' );
}
-
+
}
/* Loads the CSS */
function optionsframework_load_styles() {
- wp_enqueue_style('optionsframework', OPTIONS_FRAMEWORK_URL.'css/optionsframework.css');
+ wp_enqueue_style('admin-style', OPTIONS_FRAMEWORK_URL.'css/admin-style.css');
wp_enqueue_style('color-picker', OPTIONS_FRAMEWORK_URL.'css/colorpicker.css');
}
/* Loads the javascript */
function optionsframework_load_scripts($hook) {
- if ( 'appearance_page_options-framework' != $hook )
- return;
-
+ // Ensure this is an options-framework page before adding additional
+ // JS elements
+ if( !strpos( $hook, 'options-framework' ))
+ return;
+
+
// Enqueued scripts
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('color-picker', OPTIONS_FRAMEWORK_URL .'js/colorpicker.js', array('jquery'));
wp_enqueue_script('options-custom', OPTIONS_FRAMEWORK_URL .'js/options-custom.js', array('jquery'));
-
+
// Inline scripts from options-interface.php
add_action('admin_head', 'of_admin_head');
}
@@ -318,8 +338,8 @@ function optionsframework_page() {
<?php optionsframework_fields(); /* Settings */ ?>
<div id="optionsframework-submit">
- <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options', 'optionsframework' ); ?>" />
- <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'optionsframework' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!', 'optionsframework' ) ); ?>' );" />
+ <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options' ); ?>" />
+ <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!' ) ); ?>' );" />
<div class="clear"></div>
</div>
</form>
@@ -342,6 +362,8 @@ function optionsframework_page() {
*/
function optionsframework_validate( $input ) {
+ //var_dump($input);
+
/*
* Restore Defaults.
*
@@ -446,10 +468,9 @@ function optionsframework_adminbar() {
global $wp_admin_bar;
- $wp_admin_bar->add_menu( array(
- 'parent' => 'appearance',
+ $wp_admin_bar->add_node( array(
'id' => 'of_theme_options',
- 'title' => __( 'Theme Options', 'optionsframework' ),
+ 'title' => __( OPTIONS_FRAMEWORK_MENU_TITLE ),
'href' => admin_url( 'themes.php?page=options-framework' )
));
}

0 comments on commit 0587d9a

Please sign in to comment.