function frontier_preview_post($tmp_post_id = 0)
{
    $concat = get_option("permalink_structure") ? "?" : "&";
    //fp_log("Post id (preview): ".$tmp_post_id);
    frontier_post_output_msg();
    $preview_post = get_post($tmp_post_id);
    /*
    //post variable: $preview_post
    $tmp_content = apply_filters( 'the_content', $preview_post->post_content );
    $tmp_content = str_replace( ']]>', ']]>', $tmp_content );
    */
    $tmp_content = fp_view_post($preview_post);
    include_once frontier_load_form("frontier_post_form_preview.php");
}
function frontier_prepare_delete_post($frontier_post_shortcode_parms = array())
{
    extract($frontier_post_shortcode_parms);
    $frontier_permalink = get_permalink();
    $concat = get_option("permalink_structure") ? "?" : "&";
    //$post_task 		= isset($_GET['task']) ? $_GET['task'] : "notaskset";
    //$post_action 	= isset($_REQUEST['action']) ? $_REQUEST['action'] : "Unknown";
    if (isset($_POST['task'])) {
        $post_task = $_POST['task'];
    } else {
        if (isset($_GET['task'])) {
            $post_task = $_GET['task'];
        } else {
            $post_task = "notaskset";
        }
    }
    if (isset($_POST['user_post_submit']) && $_POST['user_post_submit'] == "delete") {
        $post_task = "delete";
    }
    $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown";
    if ($post_task == "delete") {
        if ($_REQUEST['postid']) {
            $thispost = get_post($_REQUEST['postid']);
            $post_author = $thispost->post_author;
            //double check current user is equal to author (in case directly with param)
            if (frontier_can_delete($thispost) == true) {
                echo '<div id="frontier-post-alert">' . __("Delete", "frontier-post") . ':&nbsp;' . fp_get_posttype_label_singular($thispost->post_type);
                $tmp_delete_txt = fp_get_option('fps_custom_delete_txt', '');
                if (strlen($tmp_delete_txt) > 0) {
                    echo '<br><br><p class="frontier-post-confirm-delete-text">' . $tmp_delete_txt . '</p>';
                }
                echo '</div>';
                echo '<br><br>';
                ?>
					<div id="frontier-post-delete-post" class="frontier_post_delete_form"> 
					<table>
					
					<form action="<?php 
                echo $frontier_permalink;
                ?>
" method="post" name="frontier_delete_post" id="frontier_delete_post" enctype="multipart/form-data" >
						<input type="hidden" name="action" value="wpfrtp_delete_post"> 
						<input type="hidden" name="task" value="delete">
						<input type="hidden" name="postid" id="postid" value="<?php 
                if (isset($thispost->ID)) {
                    echo $thispost->ID;
                }
                ?>
">
						<?php 
                wp_nonce_field('frontier_delete_post', 'frontier_delete_post_' . $thispost->ID);
                ?>
		
						<tr>
						</tr><tr>
						<td><center>
						<button class="button frontier-post-form-delete" type="submit" name="submit_delete" 		id="submit_delete" 	value="deletego"><?php 
                _e("Delete", "frontier-post");
                ?>
</button>
						<input type="reset" value=<?php 
                _e("Cancel", "frontier-post");
                ?>
  name="cancel" id="cancel" onclick="location.href='<?php 
                the_permalink();
                ?>
'">
						</center>
						</td></tr>
					</form>	
					</table>	
					
					<hr>
					<?php 
                echo "<table>";
                echo "<tr>";
                echo "<td><h1>" . $thispost->post_title . "</h1></td>";
                echo "</tr><tr><td>";
                /*
                $content = $thispost->post_content;
                //$content = apply_filters( 'the_content', $content);
                $content = str_replace( ']]>', ']]&gt;', $content );
                */
                $content = fp_view_post($thispost);
                echo $content;
                echo "</td>";
                // echo $thispost->post_content;
                echo "</tr></table>";
                ?>
					</div>
					
				<?php 
            }
        }
    }
}
function frontier_prepare_approve_post($frontier_post_shortcode_parms = array())
{
    extract($frontier_post_shortcode_parms);
    $frontier_permalink = get_permalink();
    $concat = get_option("permalink_structure") ? "?" : "&";
    if (isset($_POST['task'])) {
        $post_task = $_POST['task'];
    } else {
        if (isset($_GET['task'])) {
            $post_task = $_GET['task'];
        } else {
            $post_task = "notaskset";
        }
    }
    $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown";
    if ($post_task == "approve") {
        if ($_REQUEST['postid']) {
            $thispost = get_post($_REQUEST['postid']);
            $post_author = $thispost->post_author;
            if ($thispost->post_status === "pending" && current_user_can("edit_others_posts")) {
                echo '<div id="frontier-post-alert">' . __("Approve", "frontier-post") . ':&nbsp;' . fp_get_posttype_label_singular($thispost->post_type) . '</div>';
                echo '<br><br>';
                ?>
					<div class="frontier_post_approve_form"> 
					<table>
					
					<form action="<?php 
                echo $frontier_permalink;
                ?>
" method="post" name="frontier_approve_post" id="frontier_approve_post" enctype="multipart/form-data" >
						<input type="hidden" name="action" value="wpfrtp_approve_post"> 
						<input type="hidden" name="task" value="approve">
						<input type="hidden" name="postid" id="postid" value="<?php 
                if (isset($thispost->ID)) {
                    echo $thispost->ID;
                }
                ?>
">
						<?php 
                wp_nonce_field('frontier_approve_post', 'frontier_approve_post_' . $thispost->ID);
                ?>
		
						<tr>
						</tr><tr>
						<td><center>
						<button class="button" type="submit" name="submit_approve" 		id="submit_approve" 	value="approvego"><?php 
                _e("Approve", "frontier-post");
                ?>
</button>
						<input type="reset" value=<?php 
                _e("Cancel", "frontier-post");
                ?>
  name="cancel" id="cancel" onclick="location.href='<?php 
                the_permalink();
                ?>
'">
						</center>
						</td></tr>
					</form>	
					</table>	
					
					<hr>
					<?php 
                echo "<table>";
                echo "<tr>";
                echo "<td><h1>" . $thispost->post_title . "</h1></td>";
                echo "</tr><tr><td>";
                /*
                $tmp_content = apply_filters( 'the_content', $thispost->post_content );
                $tmp_content = str_replace( ']]>', ']]&gt;', $tmp_content );
                */
                $tmp_content = fp_view_post($thispost);
                echo $tmp_content;
                /*
                $content = $thispost->post_content;
                //$content = apply_filters( 'the_content', $content);
                $content = str_replace( ']]>', ']]&gt;', $content );
                echo $content;
                */
                echo "</td>";
                // echo $thispost->post_content;
                echo "</tr></table>";
                ?>
					</div>
					
				<?php 
            }
        }
    }
}