get_option_name(); // Registers the settings fields and callback register_setting( 'optionsframework', $name, array ( $this, 'validate_options' ) ); // Displays notice after options save add_action( 'optionsframework_after_validate', array( $this, 'save_options_notice' ) ); } /* * Define menu options * * Examples usage: * * add_filter( 'optionsframework_menu', function( $menu ) { * $menu['page_title'] = 'The Options'; * $menu['menu_title'] = 'The Options'; * return $menu; * }); * * @since 1.7.0 * */ static function menu_settings() { $menu = array( // Modes: submenu, menu 'mode' => 'submenu', // Submenu default settings 'page_title' => __( 'Theme Options', 'accesspress-root' ), 'menu_title' => __( 'Theme Options', 'accesspress-root' ), 'capability' => 'edit_theme_options', 'menu_slug' => 'theme_options', 'parent_slug' => 'themes.php', // Menu default settings 'icon_url' => 'dashicons-admin-generic', 'position' => '61' ); return apply_filters( 'optionsframework_menu', $menu ); } /** * Add a subpage called "Theme Options" to the appearance menu. * * @since 1.7.0 */ function add_custom_options_page() { $menu = $this->menu_settings(); // If you want a top level menu, see this Gist: // https://gist.github.com/devinsays/884d6abe92857a329d99 // Code removed because it conflicts with .org theme check. $this->options_screen = add_theme_page( $menu['page_title'], $menu['menu_title'], $menu['capability'], $menu['menu_slug'], array( $this, 'options_page' ) ); } /** * Loads the required stylesheets * * @since 1.7.0 */ function enqueue_admin_styles( $hook ) { if ( $this->options_screen != $hook ) return; wp_enqueue_style('accesspress-font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), Options_Framework::VERSION); wp_enqueue_style( 'optionsframework', OPTIONS_FRAMEWORK_DIRECTORY . 'css/optionsframework.css', array(), Options_Framework::VERSION ); wp_enqueue_style( 'wp-color-picker' ); } /** * Loads the required javascript * * @since 1.7.0 */ function enqueue_admin_scripts( $hook ) { if ( $this->options_screen != $hook ) return; // Enqueue custom option panel JS wp_enqueue_script('options-custom', OPTIONS_FRAMEWORK_DIRECTORY . 'js/options-custom.js', array( 'jquery','wp-color-picker' ), Options_Framework::VERSION); // Inline scripts from options-interface.php add_action( 'admin_head', array( $this, 'of_admin_head' ) ); } function of_admin_head() { // Hook to add custom scripts do_action( 'optionsframework_custom_scripts' ); } /** * Builds out the options panel. * * If we were using the Settings API as it was intended we would use * do_settings_sections here. But as we don't want the settings wrapped in a table, * we'll call our own custom optionsframework_fields. See options-interface.php * for specifics on how each individual field is generated. * * Nonces are provided using the settings_fields() * * @since 1.7.0 */ function options_page() { ?>