Example #1
0
function of_option_setup()
{
    //Update EMPTY options
    $of_array = array();
    add_option('of_options', $of_array);
    $template = salejunction_get_option('of_template');
    $saved_options = salejunction_get_option('of_options');
    $std = '';
    foreach ($template as $option) {
        if ($option['type'] != 'heading') {
            $id = $option['id'];
            if (isset($option['std'])) {
                $std = $option['std'];
            }
            $db_option = salejunction_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'];
                        salejunction_update_option($c_id, $c_std);
                        $of_array[$c_id] = $c_std;
                    }
                } else {
                    salejunction_update_option($id, $std);
                    $of_array[$id] = $std;
                }
            } else {
                //So just store the old values over again.
                $of_array[$id] = $db_option;
            }
        }
    }
    salejunction_update_option('of_options', $of_array);
}
Example #2
0
 function of_options()
 {
     // VARIABLES
     $themename = 'Salejunction Theme';
     $shortname = "of";
     // Populate OptionsFramework option in array for use in theme
     global $of_options;
     $of_options = salejunction_get_option('of_options');
     // Background Defaults
     $background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat', 'position' => 'top center', 'attachment' => 'scroll');
     //Color Stylesheet
     // 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 Product categories into an array
     $product_categories = array();
     $product_categories_obj = get_terms("product_cat");
     if ($product_categories_obj) {
         foreach ($product_categories_obj as $product_category) {
             if (isset($product_category->name)) {
                 $product_categories[$product_category->term_id] = $product_category->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', 'slejunction'), "type" => "heading"), array("name" => __('Custom Logo', 'slejunction'), "desc" => __('Choose your own logo. Optimal Size: 200px Wide by 90px Height.', 'slejunction'), "id" => "salejunction_logo", "type" => "upload"), array("name" => __('Custom Favicon', 'slejunction'), "desc" => __('Specify a 16px x 16px image that will represent your websites favicon.', 'slejunction'), "id" => "salejunction_favicon", "type" => "upload"), array("name" => __('Top Feature Settings', 'slejunction'), "type" => "heading"), array("name" => __('Top Feature Image', 'slejunction'), "desc" => __('The optimal size of the image is 1920 px wide x 654 px height, but it can be varied as per your requirement.', 'slejunction'), "id" => "salejunction_slideimage1", "std" => "", "type" => "upload"), array("name" => __('Top Feature Heading', 'slejunction'), "desc" => __('Mention the heading for the Top Feature.', 'slejunction'), "id" => "salejunction_sliderheading1", "std" => "", "type" => "textarea"), array("name" => __('Link for Top Feature', 'slejunction'), "desc" => __('Mention the URL for Top Feature image.', 'slejunction'), "id" => "salejunction_Sliderlink1", "std" => "", "type" => "text"), array("name" => __('Top Feature Description', 'slejunction'), "desc" => __('Here mention a short description for the First Top Feature.', 'slejunction'), "id" => "salejunction_sliderdes1", "std" => "", "type" => "textarea"), array("name" => __('Button Text for Top Feature', 'slejunction'), "desc" => __('Mention the text for Top Feature Button.', 'slejunction'), "id" => "salejunction_slider_button1", "std" => "", "type" => "text"), array("name" => __('Home Page Category', 'slejunction'), "type" => "heading"), array("name" => __('Select WooCommerce Category List', 'slejunction'), "desc" => __('Select your product category to display your products on home page.', 'slejunction'), "id" => "salejunction_woo_cat", "std" => "false", "type" => "multicheck", "options" => $product_categories), array("name" => __('Home Page Blog Feature Section', 'slejunction'), "type" => "heading"), array("name" => __('Home Blog Heading', 'slejunction'), "desc" => __('Enter your home blog heading', 'slejunction'), "id" => "salejunction_blog_heading", "std" => "", "type" => "textarea"), array("name" => __('Home Blog Description', 'slejunction'), "desc" => __('Enter your home blog description', 'slejunction'), "id" => "salejunction_blog_desc", "std" => "", "type" => "textarea"), array("name" => __('Styling Options', 'slejunction'), "type" => "heading"), array("name" => __('Custom CSS', 'slejunction'), "desc" => __('Quickly add some CSS to your theme by adding it to this block.', 'slejunction'), "id" => "salejunction_customcss", "std" => "", "type" => "textarea"));
     salejunction_update_option('of_template', $options);
     salejunction_update_option('of_themename', $themename);
     salejunction_update_option('of_shortname', $shortname);
 }
Example #3
0
function salejunction_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;
        salejunction_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
        salejunction_delete_option($id);
    } elseif ($save_type == 'options' or $save_type == 'framework') {
        $data = $_POST['data'];
        parse_str($data, $output);
        //print_r($output);
        //Pull options
        $options = salejunction_get_option('of_template');
        foreach ($options as $option_array) {
            $id = $option_array['id'];
            $old_value = salejunction_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;
                            }
                            salejunction_update_option($id, stripslashes($new_value));
                        }
                    }
                } elseif ($new_value == '' && $type == 'checkbox') {
                    // Checkbox Save
                    salejunction_update_option($id, 'false');
                } elseif ($new_value == 'true' && $type == 'checkbox') {
                    // Checkbox Save
                    salejunction_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])) {
                            salejunction_update_option($multicheck_id, 'false');
                        } else {
                            salejunction_update_option($multicheck_id, 'true');
                        }
                    }
                } elseif ($type == 'color') {
                    salejunction_update_option($id, salejunction_validate_hex($new_value));
                } 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'];
                    salejunction_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'];
                    salejunction_update_option($id, $border_array);
                } elseif ($type != 'upload_min') {
                    salejunction_update_option($id, stripslashes($new_value));
                }
            }
        }
    }
    die;
}