function frontier_user_posts($atts)
{
    global $wp_roles;
    global $current_user;
    global $post;
    $sc_allowed_post_types = fp_get_option_array('fps_sc_allowed_in', array("page"));
    //new in version 3.6.6, admin can choose wich post types are aloowed
    if (has_shortcode($post->post_content, 'frontier-post') && in_array($post->post_type, $sc_allowed_post_types)) {
        if (is_user_logged_in()) {
            //if ( !is_page(get_the_id()) )
            if (!in_array($post->post_type, $sc_allowed_post_types)) {
                die('<center><h1>ERROR: ' . __("frontier-post Shortcode only allowed in pages", "frontier-post") . " (" . $post->post_type . ")</h1></center>");
                return;
            }
            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";
            $fpost_sc_parms = shortcode_atts(array('frontier_mode' => 'none', 'frontier_parent_cat_id' => 0, 'frontier_cat_id' => 0, 'frontier_list_cat_id' => 0, 'frontier_list_all_posts' => 'false', 'frontier_list_pending_posts' => 'false', 'frontier_list_draft_posts' => 'false', 'frontier_list_text_before' => '', 'frontier_edit_text_before' => '', 'frontier_myid' => $post->ID, 'frontier_page_id' => $post->ID, 'frontier_return_text' => __("Save & Return", "frontier-post"), 'frontier_add_link_text' => '', 'frontier_add_post_type' => 'post', 'frontier_list_post_types' => 'post', 'frontier_custom_tax' => '', 'frontier_custom_tax_layout' => '', 'frontier_edit_form' => fp_get_option("fps_default_form", "standard"), 'frontier_editor_height' => fp_get_option_int("fps_editor_lines", 300), 'frontier_quick_editor_height' => fp_get_option_int("fps_quick_editor_lines", 200), 'frontier_list_form' => fp_get_option("fps_default_list", "list"), 'fps_cache_time_tax_lists' => fp_get_option_int("fps_cache_time_tax_lists", 30 * 60), 'frontier_pagination' => 'true', 'frontier_ppp' => (int) fp_get_option('fps_ppp', 5), 'frontier_user_status' => ''), $atts);
            // support for url link based creation of custom post types
            if (isset($_GET['task']) && $_GET['task'] == "new" && isset($_GET['frontier_add_post_type'])) {
                $tmp_post_type = $_GET['frontier_add_post_type'];
                $tmp_post_type_list = fp_get_option_array('fps_custom_post_type_list', array());
                if (in_array($tmp_post_type, $tmp_post_type_list)) {
                    $fpost_sc_parms['frontier_add_post_type'] = $tmp_post_type;
                }
            }
            // Remove quotes from post type
            $fpost_sc_parms['frontier_add_post_type'] = str_replace("'", "", $fpost_sc_parms['frontier_add_post_type']);
            $fpost_sc_parms['frontier_add_post_type'] = str_replace('"', '', $fpost_sc_parms['frontier_add_post_type']);
            //If Category parsed from widget assign it instead of category from shortcode
            if (isset($_GET['frontier_new_cat_widget']) && $_GET['frontier_new_cat_widget'] == "true") {
                $_REQUEST['frontier_new_cat_widget'] = "true";
                $fpost_sc_parms['frontier_cat_id'] = isset($_GET['frontier_cat_id']) ? $_GET['frontier_cat_id'] : 0;
            }
            //Change Categories to array
            $fpost_sc_parms['frontier_cat_id'] = fp_list2array($fpost_sc_parms['frontier_cat_id']);
            $fpost_sc_parms['frontier_list_cat_id'] = fp_list2array($fpost_sc_parms['frontier_list_cat_id']);
            $fpost_sc_parms['frontier_list_post_types'] = fp_list2array($fpost_sc_parms['frontier_list_post_types']);
            $fpost_sc_parms['frontier_custom_tax'] = fp_list2array($fpost_sc_parms['frontier_custom_tax']);
            $fpost_sc_parms['frontier_custom_tax_layout'] = fp_list2array($fpost_sc_parms['frontier_custom_tax_layout']);
            $fpost_sc_parms['frontier_user_status'] = fp_list2array($fpost_sc_parms['frontier_user_status']);
            extract($fpost_sc_parms);
            // if mode is add, go directly to show form - enables use directly on several pages
            if ($frontier_mode == "add" && $post_task != 'delete') {
                $post_task = "new";
            }
            ob_start();
            switch ($post_task) {
                case 'new':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($fpost_sc_parms);
                    } else {
                        frontier_post_add_edit($fpost_sc_parms);
                    }
                    break;
                case 'edit':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($fpost_sc_parms);
                    } else {
                        frontier_post_add_edit($fpost_sc_parms);
                    }
                    break;
                case 'delete':
                    if ($post_action == "wpfrtp_delete_post") {
                        frontier_execute_delete_post($fpost_sc_parms);
                    } else {
                        frontier_prepare_delete_post($fpost_sc_parms);
                    }
                    break;
                case 'approve':
                    if ($post_action == "wpfrtp_approve_post") {
                        frontier_execute_approve_post($fpost_sc_parms);
                    } else {
                        frontier_prepare_approve_post($fpost_sc_parms);
                    }
                    break;
                case 'clone':
                    frontier_clone_post($fpost_sc_parms);
                    break;
                default:
                    frontier_user_post_list($fpost_sc_parms);
                    break;
            }
            //return content to shortcode for output
            $fp_content = ob_get_contents();
            ob_end_clean();
            return $fp_content;
        } else {
            echo fp_login_text();
        }
        // user_logged_in
    } else {
        //Shortcode called from enything else than page, not allowed
        if (!in_array($post->post_type, $sc_allowed_post_types) && is_singular()) {
            // Only show warning if single post
            $sing = is_singular() ? "S" : "M";
            echo '<br><div id="frontier-post-alert">frontier-post shortcode ' . __("only allowed in", "frontier-post") . ': ' . implode(", ", $sc_allowed_post_types) . ' - This post type: (' . $post->post_type . ') - (' . $post->ID . '/' . $sing . ')</div><br>';
            return;
        }
    }
    // has_shortcode
}
Ejemplo n.º 2
0
function frontier_post_add_edit($frontier_post_shortcode_parms = array())
{
    require_once ABSPATH . '/wp-admin/includes/post.php';
    global $current_user;
    global $wpdb;
    //add_thickbox();
    $frontier_permalink = get_permalink();
    $concat = get_option("permalink_structure") ? "?" : "&";
    //set start of output debug query
    $qlog = $wpdb->queries;
    $qlog_start = count($qlog);
    $fps_access_check_msg = "";
    $user_can_edit_this_post = false;
    //Reset access message
    $fps_access_check_msg = "";
    //Get Frontier Post capabilities
    $fp_capabilities = frontier_post_get_capabilities();
    //$fp_settings		= frontier_post_get_settings()
    // Get vars from shortcode
    extract($frontier_post_shortcode_parms);
    if (!is_user_logged_in()) {
        echo fp_login_text();
    } else {
        // Check if new, and if Edit that current users is allowed to edit
        if (isset($_REQUEST['task']) && $_REQUEST['task'] == "edit") {
            $thispost = get_post($_REQUEST['postid']);
            $user_post_excerpt = get_post_meta($thispost->ID, "user_post_excerpt");
            $tmp_task_new = false;
            if (frontier_can_edit($thispost) == true) {
                $user_can_edit_this_post = true;
            }
        } else {
            $tmp_post_type = post_type_exists($frontier_add_post_type) ? $frontier_add_post_type : 'post';
            if (frontier_can_add($tmp_post_type) == true) {
                if (empty($thispost->ID)) {
                    $thispost = get_default_post_to_edit("{$tmp_post_type}", true);
                    $thispost->post_author = $current_user->ID;
                    $thispost->post_type = $tmp_post_type;
                    //echo "New post for edit: ".$thispost->ID."<br>";
                }
                $_REQUEST['task'] = "new";
                $tmp_task_new = true;
                $user_can_edit_this_post = true;
            }
        }
    }
    // Do not proceed with all the processing if user is not able to add/edit
    if ($user_can_edit_this_post == true) {
        $post_id = $thispost->ID;
        //get users role:
        $users_role = frontier_get_user_role();
        // get list of taxonomies
        $tax_form_lists = frontier_get_tax_lists($frontier_page_id, intval($frontier_parent_cat_id), intval($fps_cache_time_tax_lists));
        //******************************************************************************************
        // Set defaults, so post can be saved without errors
        //******************************************************************************************
        if (!isset($thispost->post_type)) {
            $thispost->post_type = 'post';
        }
        if (!isset($thispost->post_content)) {
            $thispost->post_content = '';
        }
        // Call media fix (to support older versions)
        frontier_media_fix($post_id);
        //******************************************************************************************
        // Manage post status
        //******************************************************************************************
        //build post status list based on current status and users capability
        $tmp_status_list = get_post_statuses();
        $tmp_status_list = array_reverse($tmp_status_list);
        // Remove private status from array if not allowed
        if (!current_user_can('frontier_post_can_private')) {
            unset($tmp_status_list['private']);
        }
        // Remove draft status from array if user is not allowed to use drafts
        if (!current_user_can('frontier_post_can_draft')) {
            unset($tmp_status_list['draft']);
        }
        // Remove pending status from array if user is not allowed to use pending status or if it is a page we are editing
        if (!current_user_can('frontier_post_can_pending') || $thispost->post_type == 'page') {
            unset($tmp_status_list['pending']);
        }
        // Remove publish status from array if not allowed
        if (!current_user_can('frontier_post_can_publish')) {
            unset($tmp_status_list['publish']);
        }
        // Set default status if new post - Check if the default status is in the allowed statuses, and if so set the default status
        $tmp_default_status = fp_get_option("fps_default_status", "publish");
        if ($tmp_task_new == true && array_key_exists($tmp_default_status, $tmp_status_list)) {
            $thispost->post_status = $tmp_default_status;
        }
        $status_list = array();
        $tmp_post_status = $thispost->post_status ? $thispost->post_status : $tmp_default_status;
        // if The deafult status is not in the list, set default status to the first in the list
        if (!in_array($tmp_post_status, array_keys($tmp_status_list))) {
            $tmp_post_status = current(array_keys($tmp_status_list));
        }
        $status_list = $tmp_status_list;
        //**************************************************************************************************
        // -- Setup wp_editor layout
        // full: full Tiny MCE
        // minimal-visual: Teeny layout
        // minimal-html: simple layout with html options
        // text: text only
        //**************************************************************************************************
        // If capabilities is managed from other plugin, use default setting for all profiles
        if (get_option("frontier_post_external_cap", "false") == "true") {
            $editor_type = fp_get_option("fps_default_editor", "full");
        } else {
            $editor_type = $fp_capabilities[$users_role]['fps_role_editor_type'] ? $fp_capabilities[$users_role]['fps_role_editor_type'] : "full";
        }
        $editor_layout = array('dfw' => false, 'tabfocus_elements' => 'sample-permalink,post-preview', 'editor_height' => 300);
        $frontier_media_button = current_user_can('frontier_post_can_media') ? current_user_can('frontier_post_can_media') : false;
        // Call to wp_editor in done in entry form
        //************************************************************************
        // Setup category
        //************************************************************************
        // Do not manage categories for page
        if ($thispost->post_type != 'page') {
            // If capabilities is managed from other plugin, use default setting for all profiles
            if (fp_get_option("fps_external_cap", "false") == "true") {
                $category_type = fp_get_option("fps_default_cat_select", "multi");
            } else {
                $category_type = $fp_capabilities[$users_role]['fps_role_category_layout'] ? $fp_capabilities[$users_role]['fps_role_category_layout'] : "multi";
            }
            $default_category = $fp_capabilities[$users_role]['fps_role_default_category'] ? $fp_capabilities[$users_role]['fps_role_default_category'] : get_option("default_category");
            // set default category, if new and category parsed from shortcode,
            if ($tmp_task_new) {
                $cats_selected = $frontier_cat_id;
                if (count($frontier_cat_id) > 0 && $frontier_cat_id[0] > 0) {
                    $default_category = $frontier_cat_id[0];
                }
            } else {
                $cats_selected = $thispost->post_category;
            }
            // if no category selected (from post), insert default category.
            // removed in version 3.5.7, as default category is set on save
            /*
            if (empty($cats_selected[0]))
            	$cats_selected[0] = $default_category;
            */
            // Build list of categories (3 levels)
            // removed in version 3.5.7
            /*
            if ( ($category_type == "multi") || ($category_type == "checkbox") )
            	{
            	$catlist 		= array();
            	$catlist 		= frontier_tax_list("category", fp_get_option("fps_excl_cats", ''), $frontier_parent_cat_id );
            	}
            */
        } else {
            $cats_selected = array();
        }
        // end exclude categories for pages
        // Set variable for hidden field, if category field is removed from the form
        $cats_selected_txt = implode(',', $cats_selected);
        //echo "Cats selected: ".$cats_selected_txt."<hr>";
        //***************************************************************************************
        //* Set tags
        //***************************************************************************************
        $fp_tag_count = fp_get_option_int("fps_tag_count", 3);
        if (current_user_can('frontier_post_tags_edit') && $thispost->post_type != 'page') {
            $taglist = array();
            if (isset($thispost->ID)) {
                $tmptags = get_the_tags($thispost->ID);
                if ($tmptags) {
                    foreach ($tmptags as $tag) {
                        array_push($taglist, $tag->name);
                    }
                }
            }
        }
        $hide_post_status = fp_get_option("fps_hide_status", "false") == "true" ? true : false;
        $frontier_use_feat_img = fp_get_option("fps_show_feat_img", "false");
        //***************************************************************************************
        //* Get post moderation fields
        //***************************************************************************************
        if (fp_get_option_bool("fps_use_moderation") && (current_user_can("edit_others_posts") || $current_user->ID == $thispost->post_author)) {
            $fp_moderation_comments = get_post_meta($post_id, 'FRONTIER_POST_MODERATION_TEXT', true);
        }
    }
    // end if OK to Edit
    if ($user_can_edit_this_post) {
        $fp_form = $frontier_edit_form;
        if ($thispost->post_type == 'page') {
            $fp_form = "page";
        }
        //echo "Form: ".$fp_form."<br>";
        switch ($fp_form) {
            case "standard":
                include frontier_load_form("frontier_post_form_standard.php");
                break;
            case "old":
                include frontier_load_form("frontier_post_form_old.php");
                break;
            case "simple":
                include frontier_load_form("frontier_post_form_simple.php");
                break;
            case "page":
                include frontier_load_form("frontier_post_form_page.php");
                break;
            default:
                include frontier_load_form("frontier_post_form_standard.php");
                break;
        }
        //output debug query
        if (1 === 2) {
            error_log('---------------- SQL LOG START (' . $qlog_start . ')---------------');
            global $wpdb;
            $q_log = $wpdb->queries;
            error_log("Queries");
            error_log(print_r($q_log, true));
            $l = 0;
            echo "<hr>Queries<hr>";
            foreach ($q_log as $tmp_sql) {
                if ($l >= $qlog_start) {
                    //error_log('('.zeroise($l,3).') '.$tmp_sql[1].' '.$tmp_sql[0]);
                    echo '(' . zeroise($l, 3) . ') ' . $tmp_sql[1] . ' ' . $tmp_sql[0] . "<hr>";
                }
                $l++;
            }
            error_log('---------------- SQL LOG END---------------');
        }
    } else {
        // Echo reason why user cant add/edit post.
        global $fps_access_check_msg;
        if (empty($fps_access_check_msg) || $fps_access_check_msg < " ") {
            echo __("You are not allowed to edit this post, sorry ", "frontier-post");
        } else {
            echo "<br>" . $fps_access_check_msg;
        }
        //Reset message once displayed
        $fps_access_check_msg = "";
    }
}
Ejemplo n.º 3
0
function frontier_user_posts($atts)
{
    global $wp_roles;
    global $current_user;
    global $post;
    if (has_shortcode($post->post_content, 'frontier-post') && $post->post_type == 'page') {
        if (is_user_logged_in()) {
            //if ( !is_page(get_the_id()) )
            if ($post->post_type != 'page') {
                die('<center><h1>ERROR: ' . __("frontier-post Shortcode only allowed in pages", "frontier-post") . '</h1></center>');
                return;
            }
            //error_log("Custom tax from settings ----->");
            //error_log(print_r(fp_get_option_array("fps_custom_tax_list"), true));
            /*
            error_log("Get var---->");
            error_log(print_r($_GET, true));
            */
            if (isset($_POST['task'])) {
                $post_task = $_POST['task'];
            } else {
                if (isset($_GET['task'])) {
                    $post_task = $_GET['task'];
                } else {
                    $post_task = "notaskset";
                }
            }
            //$post_task 		= isset($_GET['task']) ? $_GET['task'] : "notaskset";
            $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown";
            /*
            error_log("Post task---->".$post_task);
            
            error_log("Post action---->".$post_action);
            error_log(print_r($_POST, true));
            */
            $frontier_post_shortcode_parms = shortcode_atts(array('frontier_mode' => 'none', 'frontier_parent_cat_id' => 0, 'frontier_cat_id' => 0, 'frontier_list_cat_id' => 0, 'frontier_list_all_posts' => 'false', 'frontier_list_pending_posts' => 'false', 'frontier_list_text_before' => '', 'frontier_edit_text_before' => '', 'frontier_myid' => $post->ID, 'frontier_page_id' => $post->ID, 'frontier_return_text' => __("Save & Return", "frontier-post"), 'frontier_add_link_text' => '', 'frontier_add_post_type' => 'post', 'frontier_list_post_types' => 'post', 'frontier_custom_tax' => '', 'frontier_custom_tax_layout' => '', 'frontier_edit_form' => fp_get_option("fps_default_form", "standard"), 'frontier_editor_height' => fp_get_option_int("fps_editor_lines", 300), 'frontier_list_form' => fp_get_option("fps_default_list", "list"), 'fps_cache_time_tax_lists' => fp_get_option_int("fps_cache_time_tax_lists", 30 * 60)), $atts);
            //error_log(print_r($frontier_post_shortcode_parms,true));
            //If Category parsed from widget assign it instead of category from shortcode
            if (isset($_GET['frontier_new_cat_widget']) && $_GET['frontier_new_cat_widget'] == "true") {
                $_REQUEST['frontier_new_cat_widget'] = "true";
                $frontier_post_shortcode_parms['frontier_cat_id'] = isset($_GET['frontier_cat_id']) ? $_GET['frontier_cat_id'] : 0;
            }
            //Change Categories to array
            $frontier_post_shortcode_parms['frontier_cat_id'] = fp_list2array($frontier_post_shortcode_parms['frontier_cat_id']);
            $frontier_post_shortcode_parms['frontier_list_cat_id'] = fp_list2array($frontier_post_shortcode_parms['frontier_list_cat_id']);
            $frontier_post_shortcode_parms['frontier_list_post_types'] = fp_list2array($frontier_post_shortcode_parms['frontier_list_post_types']);
            $frontier_post_shortcode_parms['frontier_custom_tax'] = fp_list2array($frontier_post_shortcode_parms['frontier_custom_tax']);
            $frontier_post_shortcode_parms['frontier_custom_tax_layout'] = fp_list2array($frontier_post_shortcode_parms['frontier_custom_tax_layout']);
            extract($frontier_post_shortcode_parms);
            // if mode is add, go directly to show form - enables use directly on several pages
            if ($frontier_mode == "add") {
                $post_task = "new";
            }
            ob_start();
            switch ($post_task) {
                case 'new':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($frontier_post_shortcode_parms);
                    } else {
                        frontier_post_add_edit($frontier_post_shortcode_parms);
                    }
                    break;
                case 'edit':
                    if ($post_action == "wpfrtp_save_post") {
                        frontier_posting_form_submit($frontier_post_shortcode_parms);
                    } else {
                        frontier_post_add_edit($frontier_post_shortcode_parms);
                    }
                    break;
                case 'delete':
                    if ($post_action == "wpfrtp_delete_post") {
                        frontier_execute_delete_post($frontier_post_shortcode_parms);
                    } else {
                        frontier_prepare_delete_post($frontier_post_shortcode_parms);
                    }
                    break;
                default:
                    frontier_user_post_list($frontier_post_shortcode_parms);
                    break;
            }
            //return content to shortcode for output
            $fp_content = ob_get_contents();
            ob_end_clean();
            return $fp_content;
        } else {
            echo fp_login_text();
        }
        // user_logged_in
    } else {
        //Shortcode called from post, not allowed
        if (is_singular()) {
            // Only show warning if single post
            echo '<br><div id="frontier-post-alert">frontier-post shortcode ' . __("not allowed in posts, only pages !", "frontier-post") . '</div><br>';
            return;
        }
    }
    // has_shortcode
}
function frontier_post_add_edit($fpost_sc_parms = array(), $fp_use_quickpost = false)
{
    require_once ABSPATH . '/wp-admin/includes/post.php';
    global $current_user;
    //global $wpdb;
    global $fps_access_check_msg;
    //Reset access message
    $fps_access_check_msg = "";
    $frontier_permalink = get_permalink();
    $concat = get_option("permalink_structure") ? "?" : "&";
    $user_can_edit_this_post = false;
    //Get Frontier Post capabilities
    $fp_capabilities = frontier_post_get_capabilities();
    //$fp_settings		= frontier_post_get_settings()
    // Get vars from shortcode
    //extract($frontier_post_shortcode_parms);
    if (!is_user_logged_in()) {
        // stop and display message
        echo fp_login_text();
    } else {
        // Check if new, and if Edit that current users is allowed to edit
        if (isset($_REQUEST['task']) && $_REQUEST['task'] == "edit") {
            $thispost = get_post($_REQUEST['postid']);
            $user_post_excerpt = get_post_meta($thispost->ID, "user_post_excerpt");
            $tmp_task_new = false;
            if (frontier_can_edit($thispost)) {
                $user_can_edit_this_post = true;
            }
        } else {
            if (frontier_can_add($fpost_sc_parms['frontier_add_post_type'])) {
                if (empty($thispost->ID)) {
                    $thispost = get_default_post_to_edit($fpost_sc_parms['frontier_add_post_type'], true);
                    $thispost->post_author = $current_user->ID;
                    $thispost->post_type = $fpost_sc_parms['frontier_add_post_type'];
                    //echo "New post for edit: <pre>".print_r($thispost, true)."</pre><br>";
                }
                $_REQUEST['task'] = "new";
                $tmp_task_new = true;
                $user_can_edit_this_post = true;
            } else {
                echo '<br><div id="frontier-post-alert">';
                echo $fps_access_check_msg;
                echo '</div><br>';
                return;
            }
        }
    }
    //**************************************************************************************************
    // Do not proceed with all the processing if user is not able to add/edit
    //**************************************************************************************************
    if (!$user_can_edit_this_post) {
        // Echo reason why user cant add/edit post.
        global $fps_access_check_msg;
        if (empty($fps_access_check_msg) || $fps_access_check_msg < " ") {
            echo __("You are not allowed to edit this post, sorry ", "frontier-post");
        } else {
            echo "<br>" . $fps_access_check_msg;
        }
        //Reset message once displayed
        $fps_access_check_msg = "";
        return;
    } else {
        $post_id = $thispost->ID;
        $users_role = frontier_get_user_role();
        $tax_form_lists = frontier_get_tax_lists($fpost_sc_parms['frontier_page_id'], intval($fpost_sc_parms['frontier_parent_cat_id']), intval($fpost_sc_parms['fps_cache_time_tax_lists']));
        //******************************************************************************************
        // Set defaults, so post can be saved without errors
        //******************************************************************************************
        if (!isset($thispost->post_type)) {
            $thispost->post_type = 'post';
        }
        if (!isset($thispost->post_content)) {
            $thispost->post_content = '';
        }
        // Call media fix (to support older versions)
        frontier_media_fix($post_id);
        //******************************************************************************************
        // Manage post status
        //******************************************************************************************
        //build post status list based on current status and users capability
        $tmp_status_list = get_post_statuses();
        $tmp_status_list = array_reverse($tmp_status_list);
        // Remove private status from array if not allowed
        if (!current_user_can('frontier_post_can_private')) {
            unset($tmp_status_list['private']);
        }
        // Remove draft status from array if user is not allowed to use drafts
        if (!current_user_can('frontier_post_can_draft')) {
            unset($tmp_status_list['draft']);
        }
        // Remove pending status from array if user is not allowed to use pending status or if it is a page we are editing
        if (!current_user_can('frontier_post_can_pending') || $thispost->post_type == 'page') {
            unset($tmp_status_list['pending']);
        }
        // Remove publish status from array if not allowed
        if (!current_user_can('frontier_post_can_publish')) {
            unset($tmp_status_list['publish']);
        }
        // Add Future to status list, if post status is future
        if ($thispost->post_status == "future") {
            $tmp_status_list['future'] = __("Future", "frontier-post");
        }
        // Set default status if new post - Check if the default status is in the allowed statuses, and if so set the default status
        $tmp_default_status = fp_get_option("fps_default_status", "publish");
        if ($tmp_task_new == true && array_key_exists($tmp_default_status, $tmp_status_list)) {
            $thispost->post_status = $tmp_default_status;
        }
        $status_list = array();
        $tmp_post_status = $thispost->post_status ? $thispost->post_status : $tmp_default_status;
        // if The deafult status is not in the list, set default status to the first in the list
        if (!in_array($tmp_post_status, array_keys($tmp_status_list))) {
            $tmp_post_status = current(array_keys($tmp_status_list));
        }
        $status_list = $tmp_status_list;
        //************************************************************************
        // Setup category
        //************************************************************************
        // Do not manage categories for page
        if ($thispost->post_type != 'page') {
            // If capabilities is managed from other plugin, use default setting for all profiles
            if (fp_get_option("fps_external_cap", "false") == "true") {
                $category_type = fp_get_option("fps_default_cat_select", "multi");
            } else {
                $category_type = $fp_capabilities[$users_role]['fps_role_category_layout'] ? $fp_capabilities[$users_role]['fps_role_category_layout'] : "multi";
            }
            $default_category = $fp_capabilities[$users_role]['fps_role_default_category'] ? $fp_capabilities[$users_role]['fps_role_default_category'] : get_option("default_category");
            // set default category, if new and category parsed from shortcode,
            if ($tmp_task_new) {
                $cats_selected = $fpost_sc_parms['frontier_cat_id'];
                if (count($cats_selected) > 0 && ${$cats_selected}[0] > 0) {
                    $default_category = $frontier_cat_id[0];
                }
            } else {
                $cats_selected = $thispost->post_category;
            }
        } else {
            $cats_selected = array();
        }
        // end exclude categories for pages
        // Set variable for hidden field, if category field is removed from the form
        $cats_selected_txt = implode(',', $cats_selected);
        //***************************************************************************************
        //* Set tags
        //***************************************************************************************
        $fp_tag_count = fp_get_option_int("fps_tag_count", 3);
        if (current_user_can('frontier_post_tags_edit') && $thispost->post_type != 'page') {
            $taglist = array();
            if (isset($thispost->ID)) {
                $tmptags = get_the_tags($thispost->ID);
                if ($tmptags) {
                    foreach ($tmptags as $tag) {
                        array_push($taglist, $tag->name);
                    }
                }
            }
        }
        //***************************************************************************************
        //* Get post moderation fields
        //***************************************************************************************
        if (fp_get_option_bool("fps_use_moderation") && (current_user_can("edit_others_posts") || $current_user->ID == $thispost->post_author)) {
            $fp_moderation_comments = get_post_meta($post_id, 'FRONTIER_POST_MODERATION_TEXT', true);
        }
        //***************************************************************************************
        // Enqueue media javascript
        //***************************************************************************************
        wp_enqueue_media(array('post' => $thispost->ID));
        //***************************************************************************************
        // Setup entry form
        //***************************************************************************************
        $fp_form = $fpost_sc_parms['frontier_edit_form'];
        // override if this is a quickpost
        if (fp_bool($fp_use_quickpost)) {
            $fp_form = "quickpost";
        }
        if ($thispost->post_type == 'page') {
            $fp_form = "page";
        }
        switch ($fp_form) {
            case "standard":
                include frontier_load_form("frontier_post_form_standard.php");
                break;
            case "old":
                include frontier_load_form("frontier_post_form_old.php");
                break;
            case "simple":
                include frontier_load_form("frontier_post_form_simple.php");
                break;
            case "page":
                include frontier_load_form("frontier_post_form_page.php");
                break;
            case "quickpost":
                include frontier_load_form("frontier_post_form_quickpost.php");
                break;
            default:
                include frontier_load_form("frontier_post_form_standard.php");
                break;
        }
    }
    // end  $user_can_edit_this_post
}