function bizway_options() { // VARIABLES $themename = get_theme_data(get_template_directory() . '/style.css'); $themename = $themename['Name']; $shortname = "of"; // Populate OptionsFramework option in array for use in theme global $of_options; $of_options = bizway_get_option('of_options'); // Background Defaults $background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat', 'position' => 'top center', 'attachment' => 'scroll'); //Front page on/off $file_rename = array("on" => "On", "off" => "Off"); //Stylesheet Reader $alt_stylesheets = array("default" => "default", "blue" => "blue", "coffee" => "coffee", "green" => "green", "brown" => "brown", "pink" => "pink", "orange" => "orange", "purple" => "purple", "red" => "red", "forrest-green" => "forrest-green", "yellow" => "yellow"); // Pull all the categories into an array $options_categories = array(); $options_categories_obj = get_categories(); foreach ($options_categories_obj as $category) { $options_categories[$category->cat_ID] = $category->cat_name; } // Pull all the pages into an array $options_pages = array(); $options_pages_obj = get_pages('sort_column=post_parent,menu_order'); $options_pages[''] = 'Select a page:'; foreach ($options_pages_obj as $page) { $options_pages[$page->ID] = $page->post_title; } // If using image radio buttons, define a directory path $imagepath = get_stylesheet_directory_uri() . '/images/'; $options = array(array("name" => "General Settings", "type" => "heading"), array("name" => "Custom Logo", "desc" => "Choose your own logo. Optimal Size: 300px Wide by 90px Height.", "id" => "bizway_logo", "type" => "upload"), array("name" => "Custom Favicon", "desc" => "Specify a 16px x 16px image that will represent your website's favicon.", "id" => "bizway_favicon", "type" => "upload"), array("name" => "Tracking Code", "desc" => "Paste your Google Analytics (or other) tracking code here.", "id" => "bizway_analytics", "std" => "", "type" => "textarea"), array("name" => "Homepage Settings", "type" => "heading"), array("name" => "First Heading", "desc" => "Enter your text for first heading.", "id" => "bizway_first_head", "std" => "", "type" => "textarea"), array("name" => "Second Heading", "desc" => "Enter your text for second heading.", "id" => "bizway_second_head", "std" => "", "type" => "textarea"), array("name" => "Slider Settings", "type" => "heading"), array("name" => "Slider Image1", "desc" => "Choose your image for first slider. Optimal size is 950px wide and 350px height.", "id" => "bizway_slideimage1", "std" => "", "type" => "upload"), array("name" => "Slide 1 Link", "desc" => "Enter your link url for slide1", "id" => "bizway_slidelink1", "std" => "", "type" => "text"), array("name" => "Slider Image2", "desc" => "Choose your image for second slider. Optimal size is 950px wide and 350px height.", "id" => "bizway_slideimage2", "std" => "", "type" => "upload"), array("name" => "Slide 2 Link", "desc" => "Enter your link url for slide2", "id" => "bizway_slidelink2", "std" => "", "type" => "text"), array("name" => "Homepage Feature Area", "type" => "heading"), array("name" => "Homepage Feature Area First Image", "desc" => "Choose your image for homepage feature area first image.", "id" => "bizway_featureimg1", "std" => "", "type" => "upload"), array("name" => "First Feature Heading", "desc" => "Enter your text for first col heading.", "id" => "bizway_firsthead", "std" => "", "type" => "textarea"), array("name" => "First Feature Description", "desc" => "Enter your text for first col description.", "id" => "bizway_firstdesc", "std" => "", "type" => "textarea"), array("name" => "First Feature Link URL", "desc" => "Enter your link url for fourth feature section.", "id" => "bizway_link1", "std" => "", "type" => "text"), array("name" => "Second Feature Starts From Here.", "type" => "saperate", "class" => "saperator"), array("name" => "Homepage Feature Area Second Image", "desc" => "Choose your image for homepage Feature area second image.", "id" => "bizway_featureimg2", "std" => "", "type" => "upload"), array("name" => "Second Feature Heading", "desc" => "Enter your text for second col heading.", "id" => "bizway_secondhead", "std" => "", "type" => "textarea"), array("name" => "Second Col Description", "desc" => "Enter your text for second col description.", "id" => "bizway_seconddesc", "std" => "", "type" => "textarea"), array("name" => "Second Feature Link URL", "desc" => "Enter your link url for fourth feature section.", "id" => "bizway_link2", "std" => "", "type" => "text"), array("name" => "Third Feature Starts From Here.", "type" => "saperate", "class" => "saperator"), array("name" => "Homepage Third Feature Image", "desc" => "Choose your image for homepage Feature area third image.", "id" => "bizway_featureimg3", "std" => "", "type" => "upload"), array("name" => "Third Feature Heading", "desc" => "Enter your text for second col heading.", "id" => "bizway_thirdhead", "std" => "", "type" => "textarea"), array("name" => "Third Feature Description", "desc" => "Enter your text for Third Feature description.", "id" => "bizway_thirddesc", "std" => "", "type" => "textarea"), array("name" => "Third Feature Link URL", "desc" => "Enter your link url for fourth feature section.", "id" => "bizway_link3", "std" => "", "type" => "text"), array("name" => "Styling Options", "type" => "heading"), array("name" => "Custom CSS", "desc" => "Quickly add some CSS to your theme by adding it to this block.", "id" => "bizway_customcss", "std" => "", "type" => "textarea")); bizway_update_option('of_template', $options); bizway_update_option('of_themename', $themename); bizway_update_option('of_shortname', $shortname); }
function bizway_option_setup() { //Update EMPTY options $of_array = array(); add_option('of_options', $of_array); $template = bizway_get_option('of_template'); $saved_options = bizway_get_option('of_options'); $std = ''; foreach ($template as $option) { if ($option['type'] != 'heading') { if (isset($option['id'])) { $id = $option['id']; } if (isset($option['std'])) { $std = $option['std']; } $db_option = bizway_get_option($id); if (empty($db_option)) { if (is_array($option['type'])) { foreach ($option['type'] as $child) { $c_id = $child['id']; $c_std = $child['std']; bizway_update_option($c_id, $c_std); $of_array[$c_id] = $c_std; } } else { bizway_update_option($id, $std); $of_array[$id] = $std; } } else { //So just store the old values over again. $of_array[$id] = $db_option; } } } bizway_update_option('of_options', $of_array); }
function bizway_ajax_callback() { global $wpdb; // this is how you get access to the database $save_type = $_POST['type']; //Uploads if ($save_type == 'upload') { $clickedID = $_POST['data']; // Acts as the name $filename = $_FILES[$clickedID]; $filename['name'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', $filename['name']); $override['test_form'] = false; $override['action'] = 'wp_handle_upload'; $uploaded_file = wp_handle_upload($filename, $override); $upload_tracking[] = $clickedID; bizway_update_option($clickedID, $uploaded_file['url']); if (!empty($uploaded_file['error'])) { echo 'Upload Error: ' . $uploaded_file['error']; } else { echo $uploaded_file['url']; } // Is the Response } elseif ($save_type == 'image_reset') { $id = $_POST['data']; // Acts as the name bizway_delete_option($id); } elseif ($save_type == 'options' or $save_type == 'framework') { $data = $_POST['data']; parse_str($data, $output); //print_r($output); //Pull options $options = bizway_get_option('of_template'); foreach ($options as $option_array) { $id = $option_array['id']; $old_value = bizway_get_option($id); $new_value = ''; if (isset($output[$id])) { $new_value = $output[$option_array['id']]; } if (isset($option_array['id'])) { // Non - Headings... $type = $option_array['type']; if (is_array($type)) { foreach ($type as $array) { if ($array['type'] == 'text') { $id = $array['id']; $std = $array['std']; $new_value = $output[$id]; if ($new_value == '') { $new_value = $std; } bizway_update_option($id, stripslashes($new_value)); } } } elseif ($new_value == '' && $type == 'checkbox') { // Checkbox Save bizway_update_option($id, 'false'); } elseif ($new_value == 'true' && $type == 'checkbox') { // Checkbox Save bizway_update_option($id, 'true'); } elseif ($type == 'multicheck') { // Multi Check Save $option_options = $option_array['options']; foreach ($option_options as $options_id => $options_value) { $multicheck_id = $id . "_" . $options_id; if (!isset($output[$multicheck_id])) { bizway_update_option($multicheck_id, 'false'); } else { bizway_update_option($multicheck_id, 'true'); } } } elseif ($type == 'typography') { $typography_array = array(); $typography_array['size'] = $output[$option_array['id'] . '_size']; $typography_array['face'] = stripslashes($output[$option_array['id'] . '_face']); $typography_array['style'] = $output[$option_array['id'] . '_style']; $typography_array['color'] = $output[$option_array['id'] . '_color']; bizway_update_option($id, $typography_array); } elseif ($type == 'border') { $border_array = array(); $border_array['width'] = $output[$option_array['id'] . '_width']; $border_array['style'] = $output[$option_array['id'] . '_style']; $border_array['color'] = $output[$option_array['id'] . '_color']; bizway_update_option($id, $border_array); } elseif ($type != 'upload_min') { bizway_update_option($id, stripslashes($new_value)); } } } } die; }