$sidebar_name = $_POST['name'];
        $sidebar_class = $_POST['class'];
        $sidebar_description = $_POST['description'];
        $new_sidebar_data[$sidebar_id] = array('id' => $sidebar_id, 'name' => $sidebar_name, 'description' => $sidebar_description, 'class' => sanitize_title($sidebar_class));
        if (!empty($saved_sidebar_data) && is_array($saved_sidebar_data)) {
            $saved_sidebars = $saved_sidebar_data;
            $new_value = array_merge($saved_sidebars, $new_sidebar_data);
        } else {
            $new_value = $new_sidebar_data;
        }
        cjtheme_update_option('dynamic_sidebars', $new_value);
        $location = cjtheme_callback_url('dynamic_sidebars');
        wp_redirect($location, $status = 302);
        exit;
    } else {
        echo cjtheme_message('error', __('Sidebar Name is required.', 'cjtheme'));
    }
}
// Remove Sidebar
if (isset($_GET['cj_action']) && $_GET['cj_action'] == 'delete_sidebar' && $_GET['id'] != '') {
    $id = $_GET['id'];
    unset($saved_sidebar_data[$id]);
    cjtheme_update_option('dynamic_sidebars', $saved_sidebar_data);
    $location = cjtheme_callback_url('dynamic_sidebars');
    wp_redirect($location, $status = 302);
    exit;
}
?>
<div class="dynamic_sidebars">
	<?php 
if (isset($_GET['cj_action']) && $_GET['cj_action'] == 'add_sidebar') {
_e('Javascript must be enabled.', 'cjtheme');
?>
	</noscript>

	<?php 
do_action('cjtheme_message_hook');
?>

	<div id="cj-admin-content" class="clearfix">
		<?php 
if (isset($_GET['page']) && isset($_GET['callback']) && $_GET['callback'] != '') {
    $callback = $_GET['callback'];
    $check_item_options_folder = file_exists(sprintf('%s/' . $callback . '.php', cjtheme_item_path('options_dir')));
    $check_core_options_folder = file_exists(sprintf('%s/includes/options/' . $callback . '.php', cjtheme_item_path('framework_dir')));
    if (!$check_item_options_folder && !$check_core_options_folder && !$cjtheme_addon_options) {
        echo cjtheme_message('error', sprintf(__('<b>%s.php</b> not found in options or addons directory.', 'cjtheme'), $callback));
    } else {
        if ($check_item_options_folder) {
            require_once sprintf('%s/' . $callback . '.php', cjtheme_item_path('options_dir'));
            global $cjtheme_item_options;
            if (!empty($cjtheme_item_options) && !empty($cjtheme_item_options[$callback])) {
                cjtheme_admin_form($cjtheme_item_options[$callback]);
            }
        } elseif ($check_core_options_folder) {
            require_once sprintf('%s/includes/options/' . $callback . '.php', cjtheme_item_path('framework_dir'));
            global $cjtheme_item_options;
            if (!empty($cjtheme_item_options) && !empty($cjtheme_item_options[$callback])) {
                cjtheme_admin_form($cjtheme_item_options[$callback]);
            }
        } elseif ($cjtheme_addon_options) {
            require_once $cjtheme_addon_tabs;
                } else {
                    $update_value = $value;
                }
                //$wpdb->query("UPDATE {$options_table} SET option_value = '{$update_value}' WHERE option_name = '{$key}'");
                $wpdb->update($options_table, array("option_value" => $update_value), array("option_name" => $key), array("%s"), array("%s"));
            }
        }
        $location = cjtheme_string(cjtheme_current_url()) . 'cjtheme_options=saved';
        wp_redirect($location);
    }
} else {
    print __('Sorry, your nonce did not verify.', 'cjtheme');
    exit;
}
if (isset($_GET['cjtheme_options']) && $_GET['cjtheme_options'] == 'saved') {
    $cj_message = cjtheme_message('success', __('Settings saved successfully.', 'cjtheme'));
    $display[] = $cj_message;
}
// Reset section settings
if (isset($_GET['cjtheme_reset']) && $_GET['cjtheme_reset'] == $_GET['callback']) {
    foreach ($options as $key => $value) {
        $wpdb->query("DELETE FROM {$options_table} WHERE option_name = '{$value['id']}'");
    }
    $location = cjtheme_callback_url($_GET['callback']);
    wp_redirect($location);
    exit;
}
// Reset section all
if (isset($_GET['cjtheme_reset']) && $_GET['cjtheme_reset'] == 'all') {
    foreach ($options as $key => $value) {
        $wpdb->query("TRUNCATE TABLE {$options_table}");