"radio", "std" => "1","options" => array( "Disable comments ", "Enable comments ")), array( "id" => "mobile_enabled", "std" => "1","options" => array( "on", "off")), array( "id" => "mobile_feature", "std" => "1","options" => array( "on", "off")), array( "id" => "feature_home", "std" => "1", "options" => array( "on", "off")), array( "id" => "feature_posts","std" => "1","options" => array( "on", "off")), array( "id" => "feature_pages", "std" => "1", "options" => array( "on", "off")), array( "id" => "feature_text", "std" => "1", "options" => array( "on", "off")), array( "id" => "header_home", "std" => "1", "options" => array( "on", "off")), array( "id" => "header_posts","std" => "1","options" => array( "on", "off")), array( "id" => "header_pages", "std" => "1", "options" => array( "on", "off")), array( "id" => "upload_image", "std" => "1", "options" => array( "on", "off") ), array( "id" => "main_color", "std" => "1", "options" => array( "on", "off") ), array( "id" => "secondary_color", "std" => "1", "options" => array( "on", "off")), array( "id" => "text_color", "std" => "1", "options" => array( "on", "off") ), array( "id" => "selected_item","std" => "1", "options" => array( "on", "off")), array( "id" => "menu_font","std" => "1", "options" => array( "on", "off")), array( "id" => "header_font","std" => "1", "options" => array( "on", "off")), array( "id" => "body_font","std" => "1", "options" => array( "on", "off")), array( "id" => "menu_font_size","std" => "1", "options" => array( "on", "off")), array( "id" => "header_font_size","std" => "1", "options" => array( "on", "off")), array( "id" => "body_font_size","std" => "1", "options" => array( "on", "off")) ); function set_theme_defaults() { //first run options aka. default options $first_flag = get_option("first_run"); if ( $first_flag != "activated" ) { //all options default states are set here. This is also used to reset options add_option("radio", 'Enable comments'); add_option("mobile_enabled", 'on'); add_option("feature_home", 'on'); add_option("header_posts", 'on'); add_option("header_pages", 'on'); add_option("feature_text", 'FEATURED'); add_option("menu_font_size", ''); add_option("header_font_size", ''); add_option("body_font_size", ''); add_option('mobile_feature', 'on'); add_option('main_color', ''); add_option('secondary_color', ''); add_option('text_color', ''); add_option('selected_item', ''); add_option("first_run", "activated"); } } function reset_defaults(){ //this function resets various settings to their default state update_option("radio", 'Enable comments'); update_option("mobile_enabled", 'on'); update_option("feature_home", 'on'); update_option("header_posts", 'on'); update_option("header_pages", 'on'); update_option("feature_text", 'FEATURED'); update_option("menu_font_size", ''); update_option("header_font_size", ''); update_option("body_font_size", ''); update_option('mobile_feature', 'on'); update_option('main_color', ''); update_option('secondary_color', ''); update_option('text_color', ''); update_option('selected_item', ''); } function theme_options() { global $options; //funtions to run when save button is pressed if (isset ($_REQUEST['action']) && 'theme_save' == $_REQUEST['action'] ) { foreach ($options as $value) { if( !isset( $_REQUEST[ $value['id'] ] ) ) { delete_option( $value['id'] ); } else { update_option( $value['id'], stripslashes($_REQUEST[ $value['id']])); } } if(stristr($_SERVER['REQUEST_URI'],'&saved=true')) { $location = $_SERVER['REQUEST_URI']; } else { $location = $_SERVER['REQUEST_URI'] . "&saved=true"; } header("Location: $location"); die; } //functions to run when reset button is pressed if (isset ($_REQUEST['action2']) && 'theme_reset'== $_REQUEST['action2'] ) { reset_defaults(); if(stristr($_SERVER['REQUEST_URI'],'&reset=true')) { $location = $_SERVER['REQUEST_URI']; } else { $location = $_SERVER['REQUEST_URI'] . "&reset=true"; } header("Location: $location"); die; } //adding theme and setting the name add_theme_page('Avum Settings', 'Avum Settings', 'edit_theme_options', 'avum-theme-settings', 'theme_admin'); } //styling the options and inserting the specific forms function theme_admin() { global $options; ?>
Setting Saved