<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $post;
global $campoal_options;
global $current_user;

$page_dashboard_petition 	= isset($campoal_options['conikal_page_dashboard_petition_field']) ? $campoal_options['conikal_page_dashboard_petition_field'] : 0;
$page_dashboard_petition 	= $page_dashboard_petition ? get_permalink($page_dashboard_petition) : ''; 

$give_prefix 		= '_give_';

$form_id 			= $post->ID;
?>

<?php if ( is_user_logged_in() && ($post->post_author == $current_user->ID || current_user_can('administrator') || current_user_can('editor')) || conikal_co_author_permission($form_id) ) { ?>
	<div class="color silver">
        <div class="ui large secondary pointing menu" id="control-menu">
            <div class="ui container">
            	<!-- Campaign link -->
            	<a href="javascript:void(0)" class="active item" data-bjax><?php esc_html_e('Campaign', 'campoal') ?></a>

                <!-- Dashboard link -->
                <?php if ($page_dashboard_petition) {
                    $page_dashboard = add_query_arg(array('section' => 'dashboard', 'id' => $form_id), $page_dashboard_petition); ?>
                    <a class="item" href="<?php echo esc_url($page_dashboard); ?>" data-bjax><?php esc_html_e('Dashboard', 'campoal') ?></a>
                <?php } ?>

                <!-- Donors list -->
                <?php if (class_exists('Give') && !empty($form_id)) {
                    $page_dashboard = add_query_arg(array('section' => 'donors', 'id' => $form_id, 'type' => 'donor'), $page_dashboard_petition); ?>
                    <a class="<?php echo esc_attr($section == 'donors' ? 'active ' : '') ?>item" href="<?php echo esc_url($page_dashboard); ?>" data-bjax><?php esc_html_e('Donors', 'campoal') ?></a>
                <?php } ?>

            	<!-- Update link -->
                <?php if ($page_dashboard_petition) {
                    $page_add_update = add_query_arg(array('section' => 'add_update', 'id' => $form_id, 'form_id' => $form_id, 'type' => 'update'), $page_dashboard_petition); ?>
                    <a class="item" href="<?php echo esc_url($page_add_update); ?>" data-bjax><?php esc_html_e('Add Update', 'campoal') ?></a>
                <?php } ?>

                <!-- Contribute link -->
                <?php if (class_exists('Give') && $page_dashboard_petition) {
                    $page_contribute = add_query_arg(array('section' => 'contribute', 'id' => $form_id, 'form_id' => $form_id), $page_dashboard_petition); ?>
                    <a class="item" href="<?php echo esc_url($page_contribute); ?>" data-bjax><?php esc_html_e('Fundraising', 'campoal') ?></a>
                <?php } ?>
            </div>
        </div>
    </div>
<?php } ?>