<?php

if ($register = get_event_registration_method()) {
    wp_enqueue_script('gam-event-manager-event-registration');
    ?>
	<div class="event_registration registration">
		<?php 
    do_action('event_registration_start', $register);
    ?>
		
		<input type="button" class="registration_button button" value="<?php 
    _e('Register for event', 'gam-event-manager');
    ?>
" />
		
		<div class="registration_details">
			<?php 
    /**
     * event_manager_registration_details_email or event_manager_registration_details_url hook
     */
    do_action('event_manager_registration_details_' . $register->type, $register);
    ?>
		</div>
		<?php 
    do_action('event_registration_end', $register);
    ?>
	</div>
<?php 
}
    /**
     * Show the registration area
     */
    public function output_event_register($atts)
    {
        extract(shortcode_atts(array('id' => ''), $atts));
        ob_start();
        $args = array('post_type' => 'event_listing', 'post_status' => 'publish');
        if (!$id) {
            return '';
        } else {
            $args['p'] = absint($id);
        }
        $events = new WP_Query($args);
        if ($events->have_posts()) {
            ?>

			<?php 
            while ($events->have_posts()) {
                $events->the_post();
                ?>

				<div class="event-manager-registration-wrapper">
					<?php 
                $register = get_event_registration_method();
                do_action('event_manager_registration_details_' . $register->type, $register);
                ?>
				</div>

			<?php 
            }
            ?>

		<?php 
        }
        wp_reset_postdata();
        return ob_get_clean();
    }