/**
     * Print the post editor form.
     * 
     * @since 1.3
     * @access public
     * @uses edit-form.php
     */
    function print_form()
    {
        global $post_ID;
        global $user_ID;
        global $is_valid;
        global $is_created;
        global $is_error;
        //$kml_url = 'http://iceagetrail.staging.wpengine.com/wp-content/uploads/2015/11/iat-connector.kml';
        include_once GEO_MASHUP_DIR_PATH . '/edit-form.php';
        /*$args = array('echo' => 0);
        		wp_list_categories( $args );
        		if ( $cats = wp_list_categories( $args ) ) {
        			print $cats[0];
        		}*/
        $trail_story_post_category = !is_array($_POST['quick_post_cat']) ? array($_POST['quick_post_cat']) : $_POST['quick_post_cat'];
        $trail_story_user_id = !is_null($user_ID) ? $user_ID : '';
        if ($_POST['geo_mashup_add_location']) {
            $post = array('post_author' => $user_ID, 'post_content' => $_POST['quick_post_content'], 'post_date' => date_i18n('Y-m-d H:i:s'), 'post_status' => 'pending', 'post_title' => $_POST['quick_post_title'], 'post_type' => 'trail-story', 'tax_input' => array('trail-story-category' => 'trail-stories'));
            //include_once( 'class-trail-story-db.php' );
            // Insert the post into the database
            $post_ID = wp_insert_post($post);
            $is_valid = true;
            $term = get_term_by('slug', 'trail-stories', 'trail-story-category');
            //var_dump($term);
            wp_set_post_terms($post_ID, $term->term_id, 'trail-story-category');
            wp_set_post_terms($post_ID, $_POST['quick_post_cat'], 'trail-segments');
            //include_once( 'class-trail-story-db.php' );
            //$gtm_db = new TrailStoryDB();
            //$my_class = new My_Plugin_Class;
            //add_action( 'save_post', array( $my_class, 'save_posts_hook' ) );
            //public function create_gtm_postmeta( $post_id, $name, $email_phone, $is_newsletter,
            //$is_email_list, $is_media_release) {
            ///die();
            if (isset($_POST['story_post_thumbnail'], $_POST['post_id']) && wp_verify_nonce($_POST['story_post_thumbnail'], 'upload_post_thumbnail')) {
                // The nonce was valid and the user has the capabilities, it is safe to continue.
                // These files need to be included as dependencies when on the front end.
                require_once ABSPATH . 'wp-admin/includes/image.php';
                require_once ABSPATH . 'wp-admin/includes/file.php';
                require_once ABSPATH . 'wp-admin/includes/media.php';
                // Let WordPress handle the upload.
                // Remember, 'my_image_upload' is the name of our file input in our form above.
                $attachment_id = media_handle_upload('story_post_thumbnail', $post_ID);
                if (is_wp_error($attachment_id)) {
                    // There was an error uploading the image.
                } else {
                    // The image was uploaded successfully!
                }
            }
            //$term = get_category_by_slug('trail-stories');
            //$id = $term->term_id;
            //if ($post_ID > 0) { wp_redirect(home_url()); }
            //wp_set_post_categories( $post_ID, $id );
            set_post_thumbnail($post_ID, $attachment_id);
        }
        if ($post_ID != 0 && $term->term_id != 0) {
            global $wpdb;
            global $table;
            // $tbl_name = 'gtm_postmeta';
            $table = $wpdb->prefix . 'gtm_postmeta';
            $wpdb->insert($table, array('post_id' => $post_ID, 'primary_time' => current_time('mysql'), 'name' => $_POST['quick_post_name'], 'email_phone' => $_POST['quick_post_email_phone'], 'is_newsletter' => $_POST['opt_news'], 'is_email_list' => $_POST['opt_email'], 'is_media_release' => $_POST['opt_media'], 'is_active' => 'on'));
            if ($wpdb->insert_id > 0) {
                $is_created = true;
            } else {
                $is_error = true;
            }
        }
        // Check that the nonce is valid, and the user can edit this post.
        //if (isset($_POST['submit'])) { wp_redirect( home_url().'/story-submitted' ); exit; }
        //var_dump($post62);
        //--- IF FORM - Ou algo que permita maior customização
        $filename[0] = TEMPLATEPATH . '/geo_mashup_ui_frontend_form.php';
        $filename[1] = GEO_MASHUP_DIR_PATH . '/geo_mashup_ui_frontend_form.php';
        if (file_exists($filename[0])) {
            include_once $filename[0];
        } elseif (file_exists($filename[1])) {
            include_once $filename[1];
        } else {
            ?>
	<?php 
            if ($is_valid == true && $is_created == true && ($is_valid != null && $is_created != null)) {
                $message .= '<p id="message"><span class="icon success">' . '&nbsp;</span><strong class="submit">' . 'Your story has been submitted for approval!&nbsp;&nbsp;&nbsp;' . '<a href="/share-trail-story/">Reload&nbsp;&#x21bb;</a></strong></p>';
                echo $message;
            } elseif ($is_valid == true && $is_created == null) {
                $message .= '<p id="message"><span class="icon non-success">' . '&nbsp;</span><strong class="submit">' . '<b>Invalid submission:</b> All form fields are required.&nbsp;&nbsp;&nbsp;' . '<a href="/share-trail-story/">Reload&nbsp;&#x21bb;</a></strong></p>';
                echo $message;
            } else {
                $message .= "";
            }
            ?>
<form id="trail-story-post" method="post" name="trail_story_post" enctype="multipart/form-data">
	<!--<input id="geo_mashup_kml_url" name="geo_mashup_kml_url" type="hidden" value="<?php 
            echo $kml_url;
            ?>
" />-->
	<br/>
	<fieldset name="name">
	    <!--<label for="quick_post_title" class="quick_post_label" style="">Title:</label>-->
	    <input type="text" name="quick_post_name" id="quick_post_name" style="" value="" placeholder="Your Name*"/>
    </fieldset>
    <fieldset name="email">
	    <!--<label for="quick_post_title" class="quick_post_label" style="">Title:</label>-->
	    <input type="text" name="quick_post_email_phone" id="quick_post_email_phone" style="" value="" placeholder="Email Address or Phone Number*"/>
    </fieldset>
	<fieldset name="name">
	    <!--<label for="quick_post_title" class="quick_post_label" style="">Title:</label>-->
	    <input type="text" name="quick_post_title" id="quick_post_title" style="" value="" placeholder="Story Title*"/>
    </fieldset>
    
    <!--<input type='button' id="quick_post_load" style="" value="Visual Editor" title="Visual Editor" /> -->
    <fieldset style="max-width:500px; width:100%" name="category">
	    <?php 
            wp_dropdown_categories('tab_index=10&taxonomy=trail-segments&orderby=title&hide_empty=0&echo=1&id=&quick_post_cat&name=quick_post_cat');
            ?>
    
    </fieldset>
    <br>
    <fieldset name="content">
	    <!--<label for="quick_post_content" class="quick_post_label" style="">Content:</label>-->
	    <textarea name="quick_post_content" rows="4" id="quick_post_content" style="" placeholder="Describe your trail story*"></textarea>
    </fieldset>
 	<br/><br/>
	<input type="file" name="story_post_thumbnail" id="story_post_thumbnail" multiple="false" value="Upload Photos" />
	<input type="hidden" name="post_id" id="post_id" value="" />
	<?php 
            wp_nonce_field('upload_post_thumbnail', 'story_post_thumbnail');
            ?>

<?php 
            ?>
    <br/><br/>
    <?php 
            //if (function_exists('wp_multi_file_uploader')) { wp_multi_file_uploader(); }
            ?>
    <?php 
            //echo //do_shortcode('[wordpress_file_upload]');
            ?>
    <div style="clear:both;height:0;"></div>
    <br/>
    <?php 
            geo_mashup_edit_form('post', -1, get_class($this));
            ?>
    <br/><hr>

    <input type="checkbox" name="opt_news" id="opt_news" />&nbsp;<label style="display:inline;" for="opt_news">Yes, opt-in and receive our newsletter.</label><br>

    <input type="checkbox" name="opt_email" id="opt_email" />&nbsp;<label style="display:inline;" for="opt_email">Yes, send email announcements on Ice Age Trail Alliance news, volunteers events and more.</label><br>
    
    <input style="margin:0;" name="opt_media" id="opt_media" type="checkbox" />&nbsp;<label style="display:inline;" for="opt_media">By submitting this form, I agree to allow my photo, video or film likeness, or reproductions thereof made through any media, including electronic media, to be copyrighted and used for any legitimate purpose by the IATA or its assigns. To the fullest extent allowed by law, I hereby waive any rights of publicity or privacy that I may have in my name or likeness.</label>
    <br/>
    <fieldset name="submit">
    	<input type="submit" id="geo_mashup_add_location" style="margin-right:5%; border-radius:30px;" name="geo_mashup_add_location" value="Submit" title="Post" />
    </fieldset>

</form> 
		<?php 
        }
        //--- IF FORM
    }
 /**
  * Print the post editor form.
  * 
  * @since 1.3
  * @uses edit-form.php
  */
 public function print_form()
 {
     global $post_ID;
     include_once GEO_MASHUP_DIR_PATH . '/edit-form.php';
     geo_mashup_edit_form('post', $post_ID, get_class($this));
 }
    /**
     * Print the post editor form.
     * 
     * @since 1.3
     * @access public
     * @uses edit-form.php
     */
    function print_form()
    {
        global $post_ID;
        global $user_ID;
        include_once GEO_MASHUP_DIR_PATH . '/edit-form.php';
        /*$args = array('echo' => 0);
        		wp_list_categories( $args );
        		if ( $cats = wp_list_categories( $args ) ) {
        			print $cats[0];
        		}*/
        $trail_story_post_category = !is_array($_POST['quick_post_cat']) ? array($_POST['quick_post_cat']) : $_POST['quick_post_cat'];
        $trail_story_user_id = !is_null($user_ID) ? $user_ID : '';
        if ($_POST['geo_mashup_add_location']) {
            $post = array('post_author' => $user_ID, 'post_content' => $_POST['quick_post_content'], 'post_date' => date_i18n('Y-m-d H:i:s'), 'post_status' => 'pending', 'post_title' => $_POST['quick_post_title'], 'post_type' => 'trail-story');
            // Insert the post into the database
            $post_id = wp_insert_post($post);
        }
        //var_dump($post62);
        //--- IF FORM - Ou algo que permita maior customização
        $filename[0] = TEMPLATEPATH . '/geo_mashup_ui_frontend_form.php';
        $filename[1] = GEO_MASHUP_DIR_PATH . '/geo_mashup_ui_frontend_form.php';
        if (file_exists($filename[0])) {
            include_once $filename[0];
        } elseif (file_exists($filename[1])) {
            include_once $filename[1];
        } else {
            ?>
<form method="post">
	<fieldset name="name">
	    <label for="quick_post_title" class="quick_post_label" style="">Title:</label> 
	    <input type="text" name="quick_post_title" id="quick_post_title" style="" value="" placeholder="<Title>" />
    </fieldset>

    <fieldset name="content">
	    <label for="quick_post_content" class="quick_post_label" style="">Content:</label> 
	    <textarea name="quick_post_content" rows="3" id="quick_post_content" style="" placeholder="<Content>"></textarea>
    </fieldset>

    <!--<input type='button' id="quick_post_load" style="" value="Visual Editor" title="Visual Editor" /> -->
    
    <br />
    <!--<fieldset name="category">
	    <label for="quick_post_cat" class="quick_post_label" style="">Category:</label>
	    <?php 
            // wp_dropdown_categories( 'tab_index=10&taxonomy=trail-story-category&hide_empty=0&echo=1&id=&quick_post_cat&name=quick_post_cat' );
            ?>
    </fieldset> -->

    <?php 
            geo_mashup_edit_form('post', $post_ID, get_class($this));
            ?>
    
    <fieldset name="submit">
    	<input type="submit" id="geo_mashup_add_location" name="geo_mashup_add_location" value="Post" title="Post" />
    </fieldset>

</form> 
		<?php 
        }
        //--- IF FORM
    }