<?php

global $wp_roles;
$menu_locations = get_registered_nav_menus();
$saved_menus = cjtheme_navigation_menus();
$roles = $wp_roles->role_names;
$roles['non-user'] = __('Visitor', 'cjtheme');
$cjtheme_role_menus = cjtheme_get_option('cjtheme_role_menus');
if (isset($_POST['cjtheme_save_menus'])) {
    cjtheme_update_option('cjtheme_role_menus', $_POST['data']);
    $location = cjtheme_string(cjtheme_callback_url()) . 'msg=saved';
    wp_safe_redirect($location);
    exit;
}
if (isset($_GET['msg']) && $_GET['msg'] == 'saved') {
    echo cjtheme_show_message('success', __('Menu options saved successfully.', 'cjtheme'));
}
?>
<form action="" method="post">
<table width="100%" cellpadding="0" cellspacing="0">
<thead>
	<tr>
		<th colspan="3"><h2 class="main-heading"><?php 
_e('Role Based Menus', 'cjtheme');
?>
</h2></th>
	</tr>
	<tr>
		<td width="15%"><?php 
_e('User Role', 'cjtheme');
?>
        } 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') {
    ?>
	<form action="" method="post">
		<table class="enable-search margin-30-bottom" cellspacing="0" cellpadding="0" width="100%">
				<tbody>
					<tr>
						<th colspan="5"><h2 class="main-heading"><?php 
    _e('Register New Sidebar', 'cjtheme');