<?php
/*
Template Name: Sign Successful
*/

/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
global $post;
global $current_user;
global $give_receipt_args, $donation;

$give_prefix        = '_give_';

$fundraising_mode = isset($campoal_options['conikal_fundraising_mode_field']) ? $campoal_options['conikal_fundraising_mode_field'] : 0;
$sign_without_login = isset($campoal_options['conikal_sign_petition_without_login_field']) ? $campoal_options['conikal_sign_petition_without_login_field'] : 0;
$hashtag = isset($campoal_options['conikal_social_hastag_field']) ? $campoal_options['conikal_social_hastag_field'] : '';
$embed_code = isset($campoal_options['conikal_embed_code_field']) ? $campoal_options['conikal_embed_code_field'] : 0;
$social_buttons_sortable = isset($campoal_options['conikal_social_buttons_sortable_field']) ? $campoal_options['conikal_social_buttons_sortable_field'] : 0;
$fb_app_id = isset($campoal_options['conikal_fb_id_field']) ? $campoal_options['conikal_fb_id_field'] : '';
$fb_login = isset($campoal_options['conikal_fb_login_field']) ? $campoal_options['conikal_fb_login_field'] : 0;
$primary_share_button = isset($campoal_options['conikal_primary_share_button_field']) ? $campoal_options['conikal_primary_share_button_field'] : 'facebook';
$share_url_copiable = isset($campoal_options['conikal_share_url_copiable_field']) ? $campoal_options['conikal_share_url_copiable_field'] : 'short';

// redirect if user is not log in
if (!is_user_logged_in() && $sign_without_login == 0) {
    $login_page = isset($campoal_options['conikal_page_login_field']) ? $campoal_options['conikal_page_login_field'] : 0;

    if ($login_page != 0) {
        $login_page = get_permalink($login_page);
        wp_redirect($login_page);
    } else {
        wp_redirect(home_url('/'));
    }
}

// display header
get_header();

// get give donation session
if (class_exists('Give')) {
    $get_data     = give_clean( filter_input_array( INPUT_GET ) );
    $session      = give_get_purchase_session(); 
}

// check get petition id param exist and get data
if (isset($_GET['petition_id']) && !empty($_GET['petition_id'])) {
    $petition_id = (int) sanitize_text_field($_GET['petition_id']);
    $form_id = '';
} else if (class_exists('Give') && $fundraising_mode == 1 || (!empty($get_data['donation_id']) || isset($session['donation_id'])) ) {
    $donation_id  = false;
    $receipt_type = false;

    if ( ! empty( $get_data['donation_id'] ) ) {
        $donation_id = $get_data['donation_id'];
    } elseif ( ! empty( $get_data['action'] ) && 'view_in_browser' === $get_data['action'] ) {
        $receipt_type = 'view_in_browser';
        $donation_id  = $get_data['_give_hash'];
    } elseif ( isset( $session['donation_id'] ) ) {
        $donation_id = $session['donation_id'];
    } elseif ( ! empty( $give_receipt_args['id'] ) ) {
        $donation_id = $give_receipt_args['id'];
    }

    $payment    = new Give_Payment( $donation_id );
    $form_id    = $payment->form_id;

    $petition_id = conikal_get_petition_by_form_id($form_id);
} else {
    $petition_id = false;
}
?>

<?php if ( !empty($petition_id) || !empty($form_id) || (class_exists('Give') && $fundraising_mode == 1 && (!empty($get_data['donation_id']) || isset($session['donation_id'])) ) ) {
    if ($petition_id) {
        $approve = get_post_status($petition_id);
        $title = get_the_title($petition_id);
        $heading = get_post_meta($petition_id, 'petition_heading', true);
        $title = ($heading != '' ? $heading : $title);
        $excerpt = conikal_get_excerpt_by_id($petition_id);
        $link = get_permalink($petition_id);
        $date = get_the_date('', $petition_id);
        $time = human_time_diff(get_the_time('U', $petition_id), current_time('timestamp'));
        $goal = get_post_meta($petition_id, 'petition_goal', true);
        $sign_num = get_post_meta($petition_id, 'petition_sign', true);
        $sign_num = isset($sign_num) ? intval($sign_num) : 0;
        $status = get_post_meta($petition_id, 'petition_status', true);
        $topics =  wp_get_post_terms($petition_id, 'petition_topics');

        // get form option
        $form_id            = conikal_get_petition_form_id($petition_id);

        $give_prefix        = '_give_';
        $reveal_label       = get_post_meta($form_id, $give_prefix . 'reveal_label', true);
        $goal_option        = get_post_meta($form_id, $give_prefix . 'goal_option', true);

        if ($form_id != '' && class_exists('Give')) {
            $donation_num       = give_get_form_sales_stats( $form_id );
            $donation_needed    = intval($goal) - intval($donation_num);
            $donation_needed    = (intval($donation_num) < intval($goal) ? $donation_needed : 0);

            $total_incom        = give_get_form_earnings_stats( $form_id );
            $total_raised       = give_currency_filter( give_format_amount( $total_incom, array( 'sanitize' => false ) ) );

            if (give_is_setting_enabled( $goal_option )) {
                $goal_stats         = give_goal_progress_stats( $form_id );
                $goal_stats         = ($goal_stats['raw_goal'] != 0 ? $goal_stats['raw_goal'] : $goal);
                $goal_stats_label   = give_currency_filter( give_format_amount( $goal_stats, array( 'sanitize' => false ) ) );

                $amount_needed       = intval($goal_stats) - intval($total_incom);
                $amount_needed_label = give_currency_filter( give_format_amount( $amount_needed, array( 'sanitize' => false ) ) );
            }
        }

        $copiable_url       = conikal_get_shorten_link($petition_id);

        // get post thumbnail
        $thumbnail 			= conikal_get_petition_thumbnail($petition_id, 'thumbnail', false);
    } else if ($form_id) {
        $give_prefix        = '_give_';
        $goal_option        = get_post_meta($form_id, $give_prefix . 'goal_option', true);
        $set_goal           = get_post_meta($form_id, $give_prefix . 'set_goal', true);
        $goal_format        = get_post_meta($form_id, $give_prefix . 'goal_format', true);
        $close_form_when_goal_achieved = get_post_meta($form_id, $give_prefix . 'close_form_when_goal_achieved', true);
        $goal_achieved_message = get_post_meta($form_id, $give_prefix . 'form_goal_achieved_message', true);
        $custom_amount_minimum = get_post_meta($form_id, $give_prefix . 'custom_amount_minimum', true);
        $donation_levels    = get_post_meta($form_id, $give_prefix . 'donation_levels', true);
        $reveal_label       = get_post_meta($form_id, $give_prefix . 'reveal_label', true);
        $form_content       = get_post_meta($form_id, $give_prefix . 'form_content', true);
        $post_author_id     = get_post_field( 'post_author', $form_id );
        $donation_num       = give_get_form_sales_stats( $form_id );

        $title              = get_the_title($form_id);
        $link               = get_permalink($form_id);    
        $prices             = give_get_variable_prices($form_id);
        $display_style      = give_get_meta($form_id, $give_prefix . 'display_style', true);
        $custom_amount      = give_get_meta($form_id, $give_prefix . 'custom_amount', true);
        $custom_amount_text = give_get_meta($form_id, $give_prefix . 'custom_amount_text', true);
        $content            = get_post_meta($form_id, $give_prefix . 'form_content', true);
        $time               = human_time_diff(get_the_time('U', $form_id), current_time('timestamp'));
        $excerpt            = conikal_get_excerpt_by_id($form_id, 30, $content);

        $payment_total      = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ) );
        $payment_needed     = (intval($set_goal) - intval($payment->total));
        $payment_needed     = give_currency_filter( give_format_amount( $payment_needed, array( 'sanitize' => false ) ) );

        $copiable_url       = conikal_get_shorten_link($form_id);

        // get post thumbnail
        $thumbnail 			= conikal_get_petition_thumbnail($form_id, 'thumbnail', false);
    }

    $goal_option        = get_post_meta($form_id, $give_prefix . 'goal_option', true);
    $raise_number       = conikal_get_supporter_donors_number($form_id, 'donor', true);

    $give_attrs['id']           = $form_id;
    $give_attrs['show_goal']    = false;

    $lazy_placeholder   = conikal_lazy_load_placeholder('thumbnail-square');

    // column button
    $share_column_number = 5;
    $share_column_class  = 'six';
    if (wp_is_mobile()) {
        $share_column_number = 4;
        $share_column_class  = 'five';
    }

    if (!is_singular('give_forms')) {
        $share_classes =  esc_attr($share_column_class) . ' column grid social-share';
        $button_classes = 'basic icon button';
    } else {
        if (wp_is_mobile() && is_singular('give_forms')) {
            $share_column_number = 3;
            $share_column_class  = 'three';
        }
        $share_classes = 'social-share';
        $button_classes = 'basic icon circular small button';
    }
 ?>
    <div id="wrapper" class="wrapper read success">
		<div class="ui container">
            <div class="sign-success">
                <div class="ui basic center aligned segment">
                    <?php if (class_exists('Give') && $fundraising_mode == 1 && (!empty($get_data['donation_id']) || isset($session['donation_id'])) || !isset($_GET['petition_id'])) : ?>
                        <h1 class="ui icon green header">
                            <i class="circular checkmark icon"></i>
                            <?php esc_html_e('Thank you for donating!' ,'campoal') ?>
                        </h1>
                        <p class="font large">
                            <?php if ($petition_id != '') {
                                // add signature to petition when donate as member
                                if (is_user_logged_in()) {
                                    conikal_add_to_signatures_plus($current_user->ID, $petition_id);
                                }

                                // print success message
                                if (give_is_setting_enabled( $goal_option ) && intval($amount_needed) > 0) {
                                    if (give_is_setting_enabled( $goal_option )) {
                                        echo sprintf(esc_html__('You’re one of %2$s people who have donated %5$s this fund. Now help find %1$s more people donate the remaining %3$s to reach the goal %4$s.', 'campoal'), conikal_format_number('%!,0i', $donation_needed ), conikal_format_number('%!,0i', $donation_num), $amount_needed_label, $goal_stats_label, $total_raised);
                                    } else {
                                        echo sprintf(esc_html__('You’re one of %2$s people who have donated %3$s this fund. Now help find %1$s more people donate to finish the campaign.', 'campoal'), conikal_format_number('%!,0i', $donation_needed ), conikal_format_number('%!,0i', $donation_num), $total_raised);
                                    }
                                } else {
                                    echo sprintf(esc_html__('You along with %1$s other people donated %2$s to this campaign to make it a success.', 'campoal'), $donation_num, $total_raised);
                                }
                            } else { 
                                // add signature to project when donate as member
                                if (is_user_logged_in()) {
                                    $sendinblue_list = get_post_meta($form_id, $give_prefix . 'sendinblue_list', true);
                                    conikal_sendinblue_users_list($sendinblue_list, $current_user->ID, 'add', 1);
                                }

                                if (give_is_setting_enabled( $goal_option )) {
                                    echo sprintf(esc_html__('You have donated %2$s to this fund. Help find more people donating %1$s to reach the goal.', 'campoal'), $payment_needed, $payment_total);
                                } else {
                                    echo sprintf(esc_html__('You have successfully paid %1$s to this fund. A confirmation email has been sent to your inbox.', 'campoal'), $payment_total);
                                }
                            } ?>
                        </p>
                    <?php else : ?>
                        <h1 class="ui icon green header">
                            <i class="circular checkmark icon"></i>
                            <?php esc_html_e('You are signed Successfully!' ,'campoal') ?>
                        </h1>
                        <p class="font large">
                            <?php echo sprintf(esc_html__('You’re one of %2$s people to sign this petition. Now help find %1$s more people to reach the goal.', 'campoal'), conikal_format_number('%!,0i', (intval($goal) - $sign_num) ), conikal_format_number('%!,0i', $sign_num)) ?>
                        </p>
                    <?php endif; ?>
                </div>
            </div>

            <?php conikal_ads_banner('conikal_success_page_banner_1_field') ?>

            <?php 
            // get form id if petition id is empty
            $petition_id = !empty($petition_id) ? $petition_id : $form_id;

            // Get social meta
            $social_meta = conikal_social_meta($petition_id);

            // Get social button data
            $social_buttons = conikal_social_buttons_data($social_meta, ($fb_login && !empty($fb_app_id) ? $fb_app_id : false));

            // Get primary button data
            $primary_button = $social_buttons[$primary_share_button];

            $mail_sharing_subject   = conikal_user_email_sharing($social_meta->id, 'subject');
            $mail_sharing_content   = conikal_user_email_sharing($social_meta->id, 'message');
            $mail_sharing_custom    = conikal_user_email_sharing($social_meta->id, 'custom');   

            // Get share counter 
            $share_counter = conikal_get_share_counter($petition_id);
            ?>

            <div class="sign-success-alert">
    			<div class="ui centered grid">
                    <div class="sixteen wide mobile eight wide tablet seven wide computer left aligned column share-column">
                        <?php if (class_exists('Give') && $fundraising_mode == 1 && (!empty($get_data['donation_id']) || isset($session['donation_id'])) || !isset($_GET['petition_id'])) : ?>
                        <?php echo give_receipt_shortcode(array()); ?>
                        <div class="ui hidden divider"></div>
                        <?php endif; ?>

                        <!-- FACEBOOK SHARE -->
                        <h2 class="ui header">
                        <i class="dropdown icon"></i>
                        <?php esc_html_e('Share this campaign', 'campoal') ?>
                        </h2>
                        <div class="ui form">
                            <div class="field">
                                <div class="ui pointing below fluid basic large label">
                                    <textarea name="sign-comment" id="sign-comment<?php echo esc_attr($petition_id) ?>" class="sign-comment<?php echo esc_attr(wp_is_mobile() ? ' ui large input' : '') ?>" rows="3" placeholder="<?php esc_attr_e('Add a personal message', 'campoal') ?>" data-id="<?php echo esc_attr($petition_id) ?>"></textarea>
                                    <div class="ui horizontal divider">
                                        <i class="share alternate icon"></i>
                                        <span id="share-number<?php echo esc_attr($petition_id) ?>">
                                            <?php echo esc_html( conikal_format_number('%!,0i', (!empty($share_counter['total']) ? $share_counter['total'] : 0), true) ) ?>
                                        </span>
                                        <?php esc_html_e('Shares', 'campoal') ?>
                                    </div>
                                    <div class="ui grid">
                                        <div class="four wide column">
                                            <img class="ui fluid rounded image lazy" id="thumbnail-share<?php echo esc_attr($petition_id) ?>" data-src="<?php echo esc_url($thumbnail) ?>" src="<?php echo esc_url($lazy_placeholder) ?>" alt="<?php echo esc_attr($title) ?>">
                                        </div>
                                        <div class="twelve wide column">
                                            <h3><?php echo esc_html($title) ?></h3>
                                        </div>
                                    </div>
                                </div>
                                <!-- PRIMARY SHARE BUTTON -->
                                <a href="<?php echo esc_attr($primary_button['onclick'] ? $primary_button['link'] : $primary_button['link']) ?>" 
                                    id="<?php echo esc_attr($primary_share_button . '-primary-button') . esc_attr($petition_id) ?>" 
                                    class="ui fluid <?php echo esc_attr($primary_share_button) ?> big button primary-share-button <?php echo esc_attr(in_array($primary_share_button, array('facebook', 'messenger')) ? '' : 'share-button-counter ') ?><?php echo esc_attr($primary_button['classes']) ?>" 
                                    <?php if ($primary_button['onclick']) : ?>
                                    onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=<?php echo esc_attr($primary_button['popup']['height']) ?>,width=<?php echo esc_attr($primary_button['popup']['width']) ?>');return false;" 
                                    <?php endif; ?>
                                    data-id="<?php echo esc_attr($petition_id) ?>" 
                                    data-heading="<?php echo esc_attr(urlencode($social_meta->title)) ?>" 
                                    data-link="<?php echo esc_attr($social_meta->link) ?>" 
                                    <?php if ($primary_share_button == 'mail' || $primary_share_button == 'gmail') : ?>
                                    data-subject="<?php echo esc_attr($mail_sharing_subject) ?>" 
                                    data-mail="<?php echo esc_attr($mail_sharing_content) ?>" 
                                    data-custom="<?php echo esc_attr($mail_sharing_custom) ?>" 
                                    <?php endif; ?>>
                                        <i class="<?php echo esc_attr($primary_button['icon']) ?>"></i>
                                        <?php echo esc_html($primary_button['label']) ?>
                                </a>
                            </div>
                        </div>

                        <div class="ui hidden divider"></div>
                        
                        <!-- SOCIAL SHARE BUTTON -->
                        <div class="ui <?php echo esc_attr($share_classes) ?>">
                            <?php 
                                $i = 1;
                                foreach ($social_buttons_sortable as $social => $status) {
                                    if ($status && $i <= $share_column_number && array_key_exists($social, $social_buttons)) {
                                        $button_data = $social_buttons[$social]; ?>

                                        <?php if (!is_singular('give_forms')) : ?>
                                        <div class="column">
                                        <?php endif; ?>

                                            <a href="<?php echo esc_attr($button_data['onclick'] ? $button_data['link'] : $button_data['link']) ?>" 
                                                class="ui <?php echo esc_attr($button_classes) ?> <?php echo esc_attr(in_array($social, array('facebook', 'messenger')) ? '' : 'share-button-counter ') ?><?php echo esc_attr($button_data['classes']) ?>" 
                                                id="<?php echo esc_attr($social . '-share-button' . $social_meta->id) ?>" 
                                                <?php if ($button_data['onclick']) : ?>
                                                onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=<?php echo esc_attr($button_data['popup']['height']) ?>,width=<?php echo esc_attr($button_data['popup']['width']) ?>');return false;"
                                                <?php endif; ?>
                                                data-content="<?php echo esc_attr($button_data['label']) ?><?php echo sprintf(' (%s)', esc_attr($button_data['counter'])) ?>" 
                                                data-variation="small" 
                                                data-position="top center"
                                                data-id="<?php echo esc_attr($social_meta->id) ?>" 
                                                data-heading="<?php echo esc_attr(urlencode($social_meta->title)) ?>" 
                                                data-link="<?php echo esc_attr($social_meta->link) ?>" 
                                                <?php if ($social == 'mail' || $social == 'gmail') : ?>
                                                data-subject="<?php echo esc_attr($mail_sharing_subject) ?>" 
                                                data-mail="<?php echo esc_attr($mail_sharing_content) ?>" 
                                                data-custom="<?php echo esc_attr($mail_sharing_custom) ?>" 
                                                <?php endif; ?>>
                                                    <i class="<?php echo esc_attr($button_data['icon']) ?>"></i>
                                            </a>

                                        <?php if (!is_singular('give_forms')) : ?>
                                        </div>
                                        <?php endif; ?>
                                    <?php 
                                    }
                                    $i++;
                                }
                            ?>

                            <?php if (!is_singular('give_forms')) : ?>
                            <div class="column">
                            <?php endif; ?>
                                <div class="ui icon top right pointing dropdown <?php echo esc_attr($button_classes) ?> more-share">
                                    <i class="ellipsis horizontal icon"></i>
                                    <div class="menu">
                                        <?php 
                                            $i_dropdown = 1;
                                            foreach ($social_buttons_sortable as $social => $status) {
                                                if ($status && $i_dropdown > $share_column_number && array_key_exists($social, $social_buttons)) {
                                                    $button_data = $social_buttons[$social];
                                                    ?>
                                                        <a href="<?php echo esc_attr($button_data['onclick'] ? $button_data['link'] : $button_data['link']) ?>" 
                                                            class="item <?php echo esc_attr(in_array($social, array('facebook', 'messenger')) ? '' : 'share-button-counter ') ?><?php echo esc_attr($button_data['classes']) ?>" 
                                                            id="<?php echo esc_attr($social . '-share-button' . $social_meta->id) ?>" 
                                                            <?php if ($button_data['onclick']) : ?>
                                                            onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=<?php echo esc_attr($button_data['popup']['height']) ?>,width=<?php echo esc_attr($button_data['popup']['width']) ?>');return false;"
                                                            <?php endif; ?>
                                                            data-social="<?php echo esc_attr($social) ?>" 
                                                            data-id="<?php echo esc_attr($social_meta->id) ?>" 
                                                            data-heading="<?php echo esc_attr(urlencode($social_meta->title)) ?>" 
                                                            data-link="<?php echo esc_attr($social_meta->link) ?>" 
                                                            <?php if ($social == 'mail' || $social == 'gmail') : ?>
                                                            data-subject="<?php echo esc_attr($mail_sharing_subject) ?>" 
                                                            data-mail="<?php echo esc_attr($mail_sharing_content) ?>" 
                                                            data-custom="<?php echo esc_attr($mail_sharing_custom) ?>" 
                                                            <?php endif; ?>>
                                                                <i class="<?php echo esc_attr($button_data['icon']) ?>"></i>
                                                                <?php echo esc_attr($button_data['name']) ?>
                                                                <span id="<?php echo esc_attr($social) ?>-share-counter<?php echo esc_attr($social_meta->id) ?>">
                                                                    <?php echo sprintf(esc_html__(' (%s)', 'campoal'), esc_html( $button_data['counter']) ) ?>
                                                                </span>
                                                        </a>
                                                <?php 
                                                }
                                                $i_dropdown++;
                                            }
                                        ?>
                                    </div>
                                </div>
                            <?php if (!is_singular('give_forms')) : ?>
                            </div>
                            <?php endif; ?>
                        </div>

                        <!-- SHORT URL -->
                        <div class="ui divider"></div>
                        <div class="ui right action left icon fluid input">
                            <i class="linkify icon"></i>
                            <input type="text" class="short-link" id="short-link<?php echo esc_attr($petition_id) ?>" data-id="<?php echo esc_attr($petition_id) ?>" value="<?php echo esc_attr($copiable_url); ?>" data-load="0" readonly>
                            <button class="ui basic button copy-link" id="copy-link<?php echo esc_attr($petition_id) ?>" data-id="<?php echo esc_attr($petition_id) ?>"><i class="copy icon"></i><?php esc_html_e('Copy', 'campoal') ?></button>
                        </div>
                        <div id="msg-copy<?php echo esc_attr($petition_id) ?>"></div>
                    </div>
                    <?php if (class_exists('Give') && $fundraising_mode == 0 && isset($form_id) && $form_id != '' && $reveal_label != '' && isset($_GET['petition_id'])) { ?>
                    <div class="sixteen wide mobile eight wide tablet seven wide computer left aligned column contribute-column">
                        
                        <h2 class="ui header">
                        <i class="dropdown icon"></i>
                        <?php echo sprintf(esc_html__('%s to campaign', 'campoal'), $reveal_label) ?>
                        </h2>

                        <?php if ($fundraising_mode == 0) : ?>
                            <?php if (give_is_setting_enabled( $goal_option )) : ?>
                                <div class="ui tiny header">
                                    <?php echo sprintf( esc_html__('%1$s of %2$s raised', 'campoal'), esc_html($raise_number->sign_format), esc_html($raise_number->goal_format) ) ?>
                                </div>
                                <div class="ui tiny primary progress petition-goal" data-value="<?php echo esc_attr($raise_number->sign) ?>" data-total="<?php echo esc_attr($raise_number->goal) ?>">
                                    <div class="bar">
                                        <div class="progress"></div>
                                    </div>
                                </div>
                            <?php endif; ?>
                        <?php endif; ?>
                        <?php echo give_form_shortcode($give_attrs) ?>
                    </div>
                    <?php } ?>
    		    </div>
            </div>
            <div class="ui hidden section divider"></div>
            <div class="ui grid">
                <div class="sixteen wide center aligned column">
                    <a href="<?php echo esc_url($link) ?>" class="ui basic large button" data-bjax><i class="angle left icon"></i><?php esc_html_e('Back', 'campoal') ?></a>
                    <a href="<?php echo esc_url(home_url('/')) ?>" class="ui basic large button" data-bjax><?php esc_html_e('Home', 'campoal') ?><i class="angle right icon"></i></a>
                </div>
            </div>

            <?php conikal_ads_banner('conikal_success_page_banner_2_field') ?>

            <?php wp_nonce_field('share_ajax_nonce', 'securityShare' . $petition_id, true); ?>
            <input type="hidden" id="petition_id<?php echo esc_attr($petition_id) ?>" value="<?php echo esc_attr($petition_id) ?>">
            <input type="hidden" id="petition_url<?php echo esc_attr($petition_id) ?>" value="<?php echo esc_attr($link) ?>">
            <input type="hidden" name="hashtag" value="<?php echo esc_attr($hashtag) ?>" id="hashtag<?php echo esc_attr($petition_id) ?>">
		</div>
	</div>
    <?php if (!empty($embed_code)) {
        get_template_part('templates/embed/embed-modal');
    } ?>
<?php } else { ?>
    <?php get_template_part('404') ?>
<?php } ?>

<?php get_footer(); ?>