init(); } /* * Adds default options to the database if they aren't already present. * May update this later to load only on plugin activation, or theme * activation since most people won't be editing the options.php * on a regular basis. * * http://codex.wordpress.org/Function_Reference/add_option * */ function evolve_setdefaults() { $evolve_settings = get_option('evolve'); // Gets the unique option id $option_name = $evolve_settings['id']; /* * Each theme will hopefully have a unique id, and all of its options saved * as a separate option set. We need to track all of these option sets so * it can be easily deleted if someone wishes to remove the plugin and * its associated data. No need to clutter the database. * */ if ( isset($evolve_settings['knownoptions']) ) { $knownoptions = $evolve_settings['knownoptions']; if ( !in_array($option_name, $knownoptions) ) { array_push( $knownoptions, $option_name ); $evolve_settings['knownoptions'] = $knownoptions; update_option('evolve', $evolve_settings); } } else { $newoptionname = array($option_name); $evolve_settings['knownoptions'] = $newoptionname; update_option('evolve', $evolve_settings); } // Gets the default options data from the array in options.php $options = evolve_options(); // If the options haven't been added to the database yet, they are added now $values = evolve_get_default_values(); if ( isset($values) ) { add_option( $option_name, $values ); // Add option with default settings } } /* Add a subpage called "Theme Options" to the appearance menu. */ if ( !function_exists( 'evolve_add_page' ) ) { function evolve_add_page() { global $evolve_themename; $page = add_theme_page( __( "Theme Options", "evolve" ), __( "Theme Options", "evolve" ), 'edit_theme_options', 'theme_options', 'evolve_theme_options_do_page'); // Adds actions to hook in the required css and javascript add_action("admin_print_styles-$page",'evolve_load_styles'); add_action("admin_print_scripts-$page", 'evolve_load_scripts'); } } /* Loads the CSS */ function evolve_load_styles() { wp_enqueue_style('theme-options', EVOLVE_DIRECTORY.'css/theme-options.css'); // ColorPicker wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style('thickbox', site_url() . '/' . WPINC . '/js/thickbox/thickbox.css'); wp_enqueue_style('google-fonts', "//fonts.googleapis.com/css?family=Roboto:r,b"); /** * If plugin "Benchmark Email Lite" active and we are on "Theme Options" page * dequeue "jquery-ui.css" which is causing conflict with Evolve theme options css * * @queued by Benchmark Email Lite * @jquery-ui.css * @since 3.1.5 * @by jerry */ if( class_exists( 'benchmarkemaillite_posts' ) ) { wp_dequeue_style( 'jquery-ui-theme' ); } } /* Loads the javascript */ function evolve_load_scripts() { // Inline scripts from options-interface.php add_action('admin_head', 'evolve_admin_head'); // Enqueued scripts wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script('options-custom', EVOLVE_DIRECTORY.'js/options-custom.js', array( 'jquery', 'iris' )); wp_enqueue_script('myjquerycookie', EVOLVE_DIRECTORY .'js/jquery-cookie.js', false); } function evolve_admin_head() { // Hook to add custom scripts do_action( 'evolve_custom_scripts' ); } /* * 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 evolve_fields. See options-interface.php * for specifics on how each individual field is generated. * * Nonces are provided using the settings_fields() * */ if ( !function_exists( 'evolve_theme_options_do_page' ) ) { function evolve_theme_options_do_page() { $return = evolve_fields(); settings_errors('theme_options'); $evolve_themename = "evolve"; ?>