__( 'Avedon Theme', 'avedontheme'), 'menu_title' => __('Theme Options', 'avedontheme'), 'capability' => 'edit_theme_options', 'menu_slug' => 'options-framework', 'callback' => 'avedontheme_page' ); return apply_filters( 'avedontheme_menu', $menu ); } /* Add a subpage called "Theme Options" to the appearance menu. */ function avedontheme_add_page() { $menu = avedontheme_menu_settings(); $of_page = add_theme_page( $menu['page_title'], $menu['menu_title'], $menu['capability'], $menu['menu_slug'], $menu['callback'] ); // Load the required CSS and javscript add_action( 'admin_enqueue_scripts', 'avedontheme_load_scripts' ); add_action( 'admin_print_styles-' . $of_page, 'avedontheme_load_styles' ); } /* Loads the CSS */ function avedontheme_load_styles() { wp_enqueue_style( 'avedontheme', OPTIONS_FRAMEWORK_DIRECTORY.'css/avedontheme.css' ); if ( !wp_style_is( 'wp-color-picker','registered' ) ) { wp_register_style( 'wp-color-picker', OPTIONS_FRAMEWORK_DIRECTORY.'css/color-picker.min.css' ); } wp_enqueue_style( 'wp-color-picker' ); } /* Loads the javascript */ function avedontheme_load_scripts( $hook ) { $menu = avedontheme_menu_settings(); if ( 'appearance_page_' . $menu['menu_slug'] != $hook ) return; // Enqueue colorpicker scripts for versions below 3.5 for compatibility if ( !wp_script_is( 'wp-color-picker', 'registered' ) ) { wp_register_script( 'iris', OPTIONS_FRAMEWORK_DIRECTORY . 'js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); wp_register_script( 'wp-color-picker', OPTIONS_FRAMEWORK_DIRECTORY . 'js/color-picker.min.js', array( 'jquery', 'iris' ) ); $colorpicker_l10n = array( 'clear' => __( 'Clear','avedon_theme_options' ), 'defaultString' => __( 'Default', 'avedon_theme_options' ), 'pick' => __( 'Select Color', 'avedon_theme_options' ) ); wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n ); } // Enqueue custom option panel JS wp_enqueue_script( 'options-custom', OPTIONS_FRAMEWORK_DIRECTORY . 'js/options-custom.js', array( 'jquery','wp-color-picker' ) ); // Inline scripts from options-interface.php add_action( 'admin_head', 'of_admin_head' ); } function of_admin_head() { // Hook to add custom scripts do_action( 'avedontheme_custom_scripts' ); } /** * Returns an array of system fonts * Feel free to edit this, update the font fallbacks, etc. */ function options_typography_get_os_fonts() { // OS Font Defaults $os_faces = array( 'Arial, sans-serif' => 'Arial', '"Avant Garde", sans-serif' => 'Avant Garde', '"Helvetica Neue", Helvetica, sans-serif' => 'Helvetica Neue', 'Tahoma, Geneva, sans-serif' => 'Tahoma' ); return $os_faces; } /** * Returns a select list of Google fonts * Feel free to edit this, update the fallbacks, etc. */ function options_typography_get_google_fonts() { // Google Font Defaults $google_faces = array( 'Archivon Arrow, sans-serif' => 'Archivon Arrow', 'Bitter, sans-serif' => 'Bitter', 'Cabin, sans-serif' => 'Cabin', 'Comfortaa, sans-serif' => 'Comfortaa', 'Crete Round, sans-serif' => 'Crete Round', 'Comfortaa, sans-serif' => 'Comfortaa', 'Fauna One, sans-serif' => 'Fauna One', 'Gravitas One, sans-serif' => 'Gravitas One', 'Lato, sans-serif' => 'Lato', 'Montserrat, sans-serif' => 'Montserrat', 'Montserrat Alternates, sans-serif' => 'Montserrat Alternates', 'Nobile, sans-serif' => 'Nobile', 'Open Sans, sans-serif' => 'Open Sans', 'Orienta, sans-serif' => 'Orienta', 'Oxygen, sans-serif' => 'Oxygen', 'Paytone One, sans-serif' => 'Paytone One', 'Pontano Sans, sans-serif' => 'Pontano Sans', 'Questrial, sans-serif' => 'Questrial', 'Quicksand, sans-serif' => 'Quicksand', 'Raleway, sans-serif' => 'Raleway', 'Righteous, sans-serif' => 'Righteous', 'Roboto, sans-serif' => 'Roboto', 'Sintony, sans-serif' => 'Sintony' ); return $google_faces; } /* * Builds out the options panel. * * If we were using the Settings API as it was likely 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 avedontheme_fields. See options-interface.php * for specifics on how each individual field is generated. * * Nonces are provided using the settings_fields() * */ if ( !function_exists( 'avedontheme_page' ) ) : function avedontheme_page() { settings_errors(); ?>
* add_filter('of_options', function($options) {
* $options[] = array(
* 'name' => 'Input Text Mini',
* 'desc' => 'A mini text input field.',
* 'id' => 'example_text_mini',
* 'std' => 'Default',
* 'class' => 'mini',
* 'type' => 'text'
* );
*
* return $options;
* });
*
*
* Also allows for setting options via a return statement in the
* options.php file. For example (in options.php):
*
*
* return array(...);
*
*
* @return array (by reference)
*/
function &_avedontheme_options() {
static $options = null;
if ( !$options ) {
// Load options from options.php file (if it exists)
$location = apply_filters( 'options_framework_location', array('options.php') );
if ( $optionsfile = locate_template( $location ) ) {
$maybe_options = require_once $optionsfile;
if ( is_array($maybe_options) ) {
$options = $maybe_options;
} else if ( function_exists( 'avedontheme_options' ) ) {
$options = avedontheme_options();
}
}
// Allow setting/manipulating options via filters
$options = apply_filters('of_options', $options);
}
return $options;
}
/**
* Get Option.
*
* Helper function to return the theme option value.
* If no value has been saved, it returns $default.
* Needed because options are saved as serialized strings.
*/
if ( ! function_exists( 'of_get_option' ) ) {
function of_get_option( $name, $default = false ) {
$config = get_option( 'avedontheme' );
if ( ! isset( $config['id'] ) ) {
return $default;
}
$options = get_option( $config['id'] );
if ( isset( $options[$name] ) ) {
return $options[$name];
}
return $default;
}
}