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"; ?>
evolve - Multipurpose WordPress Theme evolve on wordpress
'.__( 'Options Reset', 'evolve' ).'
', 'updated fade' ); return evolve_get_default_values(); } /* * Udpdate Settings. */ if ( 1==1 ) {//isset( $_POST['update'] ) $clean = array(); $options = evolve_options(); foreach ( $options as $option ) { if ( ! isset( $option['id'] ) ) { continue; } if ( ! isset( $option['type'] ) ) { continue; } $id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) ); // Set checkbox to false if it wasn't sent in the $_POST if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) { $input[$id] = '0'; } // Set each item in the multicheck to false if it wasn't sent in the $_POST if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) { foreach ( $option['options'] as $key => $value ) { $input[$id][$key] = '0'; } } // For a value to be submitted to database it must pass through a sanitization filter if ( has_filter( 'evolve_sanitize_' . $option['type'] ) ) { $clean[$id] = apply_filters( 'evolve_sanitize_' . $option['type'], $input[$id], $option ); } } add_settings_error( 'theme_options', 'save_options', '
'.__( 'Options Updated', 'evolve' ).'
', 'updated fade' ); return $clean; } /* * Request Not Recognized. */ return evolve_get_default_values(); } /** * Format Configuration Array. * * Get an array of all default values as set in * options.php. The 'id','std' and 'type' keys need * to be defined in the configuration array. In the * event that these keys are not present the option * will not be included in this function's output. * * @return array Rey-keyed options configuration array. * * @access private */ function evolve_get_default_values() { $output = array(); $config = evolve_options(); foreach ( (array) $config as $option ) { if ( ! isset( $option['id'] ) ) { continue; } if ( ! isset( $option['std'] ) ) { continue; } if ( ! isset( $option['type'] ) ) { continue; } if ( has_filter( 'evolve_sanitize_' . $option['type'] ) ) { $output[$option['id']] = apply_filters( 'evolve_sanitize_' . $option['type'], $option['std'], $option ); } } return $output; } /** * Add Theme Options menu item to Admin Bar. */ add_action( 'wp_before_admin_bar_render', 'evolve_adminbar' ); function evolve_adminbar() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'evolve_theme_options', 'title' => __( 'Theme Options', 'evolve' ), 'href' => admin_url( 'themes.php?page=theme_options' ) )); } if ( ! function_exists( 'evolve_get_option' ) ) { /** * Get Option. * * Helper function to return the theme option value. * If no value has been saved, it returns $default. * Needed because options are as serialized strings. */ function evolve_get_option( $name, $default = false ) { $config = get_option( 'evolve' ); if ( ! isset( $config['id'] ) ) { return $default; } $options = get_option( $config['id'] ); if ( isset( $options[$name] ) ) { return $options[$name]; } return $default; } }