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

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

$petition_comment   = isset($campoal_options['conikal_petition_comment_field']) ? $campoal_options['conikal_petition_comment_field'] : 1;
$show_donors 	    = isset($campoal_options['conikal_show_donors_section_field']) ? $campoal_options['conikal_show_donors_section_field'] : 0;

$id = $post->ID;

// get petition citation status
$citation = conikal_citation_status($id);

// get bookmarked
$bookmarks = get_user_meta($current_user->ID, 'project_bookmark', true);
?>

<!-- MENU NAVIGATION -->
<?php if (!wp_is_mobile()) { ?>
<div class="ui sticky navigation-sticky" id="navigation-sticky<?php echo esc_attr($id) ?>" data-id="<?php echo esc_attr($id) ?>" data-init="0">
    <div class="ui pointing secondary menu navigation-menu" id="navigation-menu<?php echo esc_attr($id) ?>" data-id="<?php echo esc_attr($id) ?>">
        <a href="#story<?php echo esc_attr($id) ?>" id="navlink-story<?php echo esc_attr($id) ?>" class="item active"><?php esc_html_e('Project', 'campoal') ?></a>
        <?php if($show_donors == 1) { ?>
        <a href="#donors-section<?php echo esc_attr($id) ?>" id="navlink-donors<?php echo esc_attr($id) ?>" class="item"><?php esc_html_e('Backers', 'campoal') ?></a>
        <?php } ?>
        <a href="#updates<?php echo esc_attr($id) ?>" id="navlink-update<?php echo esc_attr($id) ?>" class="item"><?php esc_html_e('Updates', 'campoal') ?></a>
        <?php if(comments_open() && $petition_comment == 1) { ?>
        <a href="#comments<?php echo esc_attr($id) ?>" id="navlink-comments<?php echo esc_attr($id) ?>" class="item"><?php esc_html_e('Comments', 'campoal') ?></a>
        <?php } ?>
        <div class="right item">
        <?php if($bookmarks) {
                if(is_user_logged_in()) {
                    if(in_array($id, $bookmarks) === false) {
                        echo '<a href="javascript:void(0)" class="bookmark-popup bookmarkPetition bookmarkBtn" id="bookmark-' . esc_attr($id) . '" data-id="' . esc_attr($id) . '" data-content="' . esc_attr__('Save this campaign', 'campoal') . '" data-position="top center" data-type="project"><i class="bookmark outline icon"></i></a>';
                    } else {
                        echo '<a href="javascript:void(0)" class="bookmark-popup bookmarkedPetition bookmarkBtn" id="bookmark-' . esc_attr($id) . '" data-id="' . esc_attr($id) . '" data-content="' . esc_attr__('Unsave this campaign', 'campoal') . '" data-position="top center" data-type="project"><i class="bookmark icon"></i></a>';
                    }
                } else {
                    echo '<a href="javascript:void(0)" class="bookmark-popup signin-btn" data-content="' . esc_attr__('Save this campaign', 'campoal') . '" data-position="top center" data-type="project"><i class="bookmark outline icon"></i></a>';
                }
            } else {
                if(is_user_logged_in()) {
                    echo '<a href="javascript:void(0)" class="bookmark-popup bookmarkPetition bookmarkBtn" id="bookmark-' . esc_attr($id) . '" data-id="' . esc_attr($id) . '" data-content="' . esc_attr__('Save this campaign', 'campoal') . '" data-position="top center" data-type="project"><i class="bookmark outline icon"></i></a>';
                } else {
                    echo '<a href="javascript:void(0)" class="bookmark-popup signin-btn" data-content="' . esc_attr__('Save this campaign', 'campoal') . '" data-position="top center" data-type="project"><i class="bookmark outline icon"></i></a>';
                }
        } ?>
        </div>
    </div>
</div>
<?php } ?>