function frontier_user_post_list($frontier_post_shortcode_parms = array())
{
    extract($frontier_post_shortcode_parms);
    global $post;
    global $current_user;
    get_currentuserinfo();
    $tmp_p_id = get_the_id();
    $pagenum = isset($_GET['pagenum']) ? intval($_GET['pagenum']) : 1;
    $ppp = (int) fp_get_option('fps_ppp', 5);
    $args = array('post_type' => $frontier_list_post_types, 'post_status' => 'draft, pending, publish, private', 'order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => $ppp, 'paged' => $pagenum);
    // add category from shortcode to limit posts
    if ($frontier_list_cat_id > 0) {
        $args["cat"] = implode(",", $frontier_list_cat_id);
    }
    //List all published posts
    if ($frontier_list_all_posts == "true") {
        // limit list to status=publish to the list, if users do not have private posts (editors & admins)
        if (!current_user_can('edit_private_posts')) {
            $args["post_status"] = "publish";
        }
    } else {
        $args["author"] = $current_user->ID;
    }
    // List pending posts
    if ($frontier_list_pending_posts == "true") {
        if (!current_user_can('edit_others_posts')) {
            echo '<br><div id="frontier-post-alert">' . __("You do not have access to other users pending posts", "frontier-post") . '</div><br>';
            return;
        }
        $args["post_status"] = "pending";
        if (array_key_exists("author", $args)) {
            unset($args['author']);
        }
    }
    $user_posts = new WP_Query($args);
    $fp_show_icons = fp_get_option_bool('fps_use_icons');
    $fp_list_form = fp_get_option("fps_default_list", "list");
    switch ($fp_list_form) {
        case 'simple':
            include_once frontier_load_form("frontier_post_form_list.php");
            break;
        case 'theme':
            include_once frontier_load_form("frontier_post_form_list_theme.php");
            break;
        default:
            include_once frontier_load_form("frontier_post_form_list_detail.php");
            break;
    }
    /*
    if (fp_get_option("fps_default_list", "list") == "simple")
    	include_once(frontier_load_form("frontier_post_form_list.php"));
    else
    	include_once(frontier_load_form("frontier_post_form_list_detail.php"));
    */
}
function frontier_quickpost($fpost_sc_parms = array())
{
    if (fp_get_option_bool('fps_use_quickpost') && frontier_can_add($fpost_sc_parms['frontier_add_post_type'])) {
        // Show/Hide Quickpost
        ?>
		<script type="text/javascript">
		jQuery(document).ready(function($) 
			{
			$("#fp-quickpost-show").click(function ()
				{
				/*alert('show');*/
				$("#frontier-post-quickpost").show();
				$("#fp-quickpost-show").hide();
				$("#fp-quickpost-hide").show();
				$(".frontier-quickpost-hide").hide();
				$(".frontier-quickpost-show").show();
				$("#fp_show_quickpost").val("true");
				}
			);
			$("#fp-quickpost-hide").click(function ()
				{
				/*alert('hide');*/
				$("#frontier-post-quickpost").hide();
				$("#fp-quickpost-show").show();
				$("#fp-quickpost-hide").hide();
				$(".frontier-quickpost-hide").show();
				$(".frontier-quickpost-show").hide();
				$("#fp_show_quickpost").val("false");
				}
			);
			}
		
		);
		</script>
	
	
	
		<?php 
        if (strlen(trim($fpost_sc_parms['frontier_add_link_text'])) > 0) {
            $tmp_add_text = $fpost_sc_parms['frontier_add_link_text'];
        } else {
            $tmp_add_text = __("Create New", "frontier-post") . " " . fp_get_posttype_label_singular($fpost_sc_parms['frontier_add_post_type']);
        }
        echo '<button class="button frontier-post-quickpost-button frontier-quickpost-hide" type="button" name="fp-quickpost-show" id="fp-quickpost-show" value="show">' . $tmp_add_text . '</button>';
        echo '<button class="button frontier-post-quickpost-button frontier-quickpost-show" type="button" name="fp-quickpost-hide" id="fp-quickpost-hide" value="hide">' . __("Hide", "frontier-post") . " " . $tmp_add_text . '</button>';
        echo '<fieldset id="frontier-post-quickpost" class="frontier-quickpost-show">';
        frontier_post_add_edit($fpost_sc_parms, true);
        echo '</fieldset>';
    }
    // fps_use_quickpost
}
    ?>
			<button class="button" type="submit" name="user_post_submit" 	id="user_post_preview" 	value="preview"><?php 
    _e("Save & Preview", "frontier-post");
    ?>
</button>
		<?php 
}
if (fp_get_option_bool("fps_submit_delete") && current_user_can("frontier_post_can_delete") && !$tmp_task_new) {
    ?>
			<button class="button frontier-post-form-delete" type="submit" name="user_post_submit" 	id="user_post_delete" 	value="delete"><?php 
    _e("Delete", "frontier-post");
    ?>
</button>
		<?php 
}
if (fp_get_option_bool("fps_submit_cancel")) {
    ?>
		<input type="reset" value="<?php 
    _e("Cancel", "frontier-post");
    ?>
"  name="cancel" id="frontier-post-cancel" onclick="location.href='<?php 
    the_permalink();
    ?>
'">
		<?php 
}
/*
if ( fp_get_option_bool("fps_submit_delete") && $thispost->post_status !== "publish" && current_user_can("frontier_post_can_delete") && !$tmp_task_new )
	{
	echo "&nbsp;".frontier_post_delete_link($thispost, false, $frontier_permalink, 'frontier-post-form-delete' );
	}
function frontier_post_admin_page_capabilities()
{
    //must check that the user has the required capability
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    include FRONTIER_POST_DIR . "/include/frontier_post_defaults.php";
    //include("../include/frontier_post_defaults.php");
    echo '<strong>Frontier Post version: ' . FRONTIER_POST_VERSION . '</strong>';
    // ****************************************************************************
    // Save settings
    //*******************************************************************************
    // See if the user has posted us some information
    // If they did, this hidden field will be set to 'Y'
    if (isset($_POST["frontier_isupdated_capabilities_hidden"]) && $_POST["frontier_isupdated_capabilities_hidden"] == 'Y') {
        // ****************************************************************************
        // Update option for capabilities per role
        //*******************************************************************************
        // Do not update capabilities if capabilities are managed externally
        if (!fp_get_option_bool("fps_external_cap")) {
            // Reinstate roles
            $wp_roles = new WP_Roles();
            $roles = $wp_roles->get_names();
            $tmp_cap_list = array_merge($fp_capability_list, $fp_role_option_list);
            $saved_capabilities = frontier_post_get_capabilities();
            foreach ($roles as $key => $item) {
                $xrole = get_role($key);
                $xrole_caps = $xrole->capabilities;
                foreach ($tmp_cap_list as $tmp_cap => $tmp_cap_name) {
                    $tmp_name = $key . '_' . $tmp_cap;
                    $def_value = "false";
                    if ($tmp_cap == 'fps_role_editor_type') {
                        $def_value = "minimal-visual";
                    }
                    if ($tmp_cap == 'fps_role_category_layout') {
                        $def_value = "multi";
                    }
                    if ($tmp_cap == 'fps_role_default_category') {
                        $def_value = get_option("default_category");
                    }
                    if ($tmp_cap == 'fps_role_allowed_categories') {
                        $def_value = '';
                    }
                    if (isset($_POST[$tmp_name])) {
                        $tmp_value = $_POST[$tmp_name] ? $_POST[$tmp_name] : $def_value;
                    } else {
                        $tmp_value = $def_value;
                    }
                    $saved_capabilities[$key][$tmp_cap] = $tmp_value;
                }
                //caps
            }
            // roles
            update_option(FRONTIER_POST_CAPABILITY_OPTION_NAME, $saved_capabilities);
            // Put an settings updated message on the screen
            echo '<div class="updated"><p><strong>' . __("Settings saved.", 'frontier-post') . '</strong></p></div>';
            // Set Wordpress capabilities
            frontier_post_set_cap();
            // Put an settings updated message on the screen
            echo '<div class="updated"><p><strong>' . __("Capabilities set.", 'frontier-post') . '</strong></p></div>';
        }
        // End external managed capabilities
    }
    // end update options
    echo '<div class="wrap">';
    echo '<div class="frontier-admin-menu">';
    echo '<h2>' . __("Frontier Post - Capabilities & Role based settings", "frontier-post") . '</h2>';
    echo '<hr>' . __("Documentation", "frontier_post") . ': <a href="http://wpfrontier.com/frontier-post-profiles-capabilities/" target="_blank">Profiles & Capabilities</a>';
    echo ' - <a href="http://wpfrontier.com/frontier-post-role-based-settings/" target="_blank">Role based settings</a><hr>';
    echo '<form name="frontier_post_settings" method="post" action="">';
    echo '<input type="hidden" name="frontier_isupdated_capabilities_hidden" value="Y">';
    //*****************************************************************************
    // Start capability listing
    //*****************************************************************************
    if (fp_get_option_bool("fps_external_cap")) {
        echo '<i><strong>' . __('Capabilities managed externally', 'frontier-post') . '</strong></i>';
    } else {
        echo '<table border="1" cellspacing="0" cellpadding="0">';
        echo "<tr>";
        echo '<th colspan="16"></center>' . __("Capabilities by user role", "frontier-post") . '</center></th>';
        echo "</tr><tr>";
        echo '<th width="6%">' . __("Role", "frontier-post") . '</th>';
        foreach ($fp_capability_list as $tmp_cap => $tmp_cap_name) {
            echo '<th width="6%">' . $tmp_cap_name . '</th>';
        }
        echo "</tr><tr>";
        global $wp_roles;
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $roles = $wp_roles->get_names();
        $saved_capabilities = frontier_post_get_capabilities();
        // loop through each role
        foreach ($roles as $key => $item) {
            echo '<tr><td>' . $item . '</td>';
            //If Role does not exists, create it in the frontier post array
            if (!array_key_exists($key, $saved_capabilities)) {
                $saved_capabilities[$key] = array();
            }
            $tmp_role_settings = $saved_capabilities[$key];
            if (!is_array($tmp_role_settings)) {
                $tmp_role_settings = array();
            }
            foreach ($fp_capability_list as $tmp_cap => $tmp_cap_name) {
                $tmp_name = $key . '_' . $tmp_cap;
                if (array_key_exists($tmp_cap, $tmp_role_settings)) {
                    $tmp_value = $saved_capabilities[$key][$tmp_cap] ? $saved_capabilities[$key][$tmp_cap] : "false";
                } else {
                    $tmp_value = "false";
                }
                if ($tmp_value == "true") {
                    $tmp_checked = " checked";
                } else {
                    $tmp_checked = " ";
                }
                echo '<td><center>';
                //echo $key."<br>".$tmp_cap."<br>";
                //Hide can_media for subscribers and contributors
                if ($tmp_cap == "frontier_post_can_media" && ($key == "subscriber" || $key == "contributor")) {
                    echo 'N/A';
                } else {
                    echo '<input value="true" type="checkbox" name="' . $tmp_name . '" id="' . $tmp_name . '" ' . $tmp_checked . ' />';
                }
                echo '</center></td>';
            }
            // end cap
            echo '</tr>';
        }
        // end roles
        echo '</table>';
        echo '* ' . __("Wordpress standard does not allow Contributors  and Subscribers to upload media", "frontier-post");
    }
    // endfps_external_cap
    //*****************************************************************************
    // Start Role Based settings
    //*****************************************************************************
    echo '<hr>';
    echo '<table border="1" cellspacing="0" cellpadding="0">';
    echo "<tr>";
    echo '<th colspan="5"></center>' . __("Role based settings", "frontier-post") . '</center></th>';
    echo "</tr><tr>";
    echo '<th width="6%">' . __("Role", "frontier-post") . '</th>';
    foreach ($fp_role_option_list as $tmp_role_option => $tmp_role_option_name) {
        echo '<th width="6%">' . $tmp_role_option_name . '</th>';
    }
    echo "</tr><tr>";
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    $saved_capabilities = frontier_post_get_capabilities();
    $tmp_role_option_list = array_keys($fp_role_option_list);
    // loop through each role
    foreach ($roles as $key => $item) {
        echo '<tr><td>' . $item . '</td>';
        if (!array_key_exists($key, $saved_capabilities)) {
            $saved_capabilities[$key] = array();
        }
        $tmp_role_options = $saved_capabilities[$key];
        if (!is_array($tmp_role_options)) {
            $tmp_role_options = array();
        }
        foreach ($fp_role_option_list as $tmp_role_option => $tmp_role_option_name) {
            $tmp_name = $key . '_' . $tmp_role_option;
            if (array_key_exists($tmp_role_option, $tmp_role_options)) {
                $tmp_value = $saved_capabilities[$key][$tmp_role_option] ? $saved_capabilities[$key][$tmp_role_option] : "false";
            } else {
                $tmp_value = "";
            }
            echo '<td>';
            switch ($tmp_role_option) {
                case 'fps_role_editor_type':
                    $optionlist = array_flip($editor_types);
                    ?>
	
							<select  id="<?php 
                    echo $tmp_name;
                    ?>
" name="<?php 
                    echo $tmp_name;
                    ?>
" >
							<?php 
                    foreach ($optionlist as $id => $desc) {
                        ?>
   
								<option value='<?php 
                        echo $id;
                        ?>
' <?php 
                        echo $id == $tmp_value ? "selected='selected'" : ' ';
                        ?>
>
									<?php 
                        echo $desc;
                        ?>
								</option>
							<?php 
                    }
                    ?>
							</select>
							<?php 
                    break;
                case 'fps_role_category_layout':
                    $optionlist = array_flip($category_types);
                    ?>
	
							<select  id="<?php 
                    echo $tmp_name;
                    ?>
" name="<?php 
                    echo $tmp_name;
                    ?>
" >
							<?php 
                    foreach ($optionlist as $id => $desc) {
                        ?>
   
								<option value='<?php 
                        echo $id;
                        ?>
' <?php 
                        echo $id == $tmp_value ? "selected='selected'" : ' ';
                        ?>
>
									<?php 
                        echo $desc;
                        ?>
								</option>
							<?php 
                    }
                    ?>
							</select>
							<?php 
                    break;
                case 'fps_role_default_category':
                    wp_dropdown_categories(array('id' => $tmp_name, 'hide_empty' => 0, 'name' => $tmp_name, 'orderby' => 'name', 'selected' => $tmp_value, 'hierarchical' => true));
                    break;
                case 'fps_role_allowed_categories':
                    if ($tmp_value == "false") {
                        $tmp_value = "";
                    }
                    echo '<input type="text" name="' . $tmp_name . '" value="' . $tmp_value . '">';
                    break;
            }
            echo '</td>';
        }
        // end option
        echo '</tr>';
    }
    // end roles
    echo '</table>';
    echo '<p class="submit"><input type="submit" name="Submit" class="button-primary" value="' . __('Save Changes') . '"></p>';
    echo '</form>';
    echo '<hr>';
    echo '</div>';
    //frontier-admin-menu
    echo '</div>';
    //wrap
}
function frontier_post_admin_page_advanced()
{
    //must check that the user has the required capability
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    include FRONTIER_POST_DIR . "/include/frontier_post_defaults.php";
    //echo print_r(fp_get_option("fps_custom_post_type_list"), true);
    //echo "<br>";
    //****************************************************************************
    // Save settings
    //*******************************************************************************
    // See if the user has posted us some information
    // If they did, this hidden field will be set to 'Y'
    if (isset($_POST["frontier_isupdated_advanced_hidden"]) && $_POST["frontier_isupdated_advanced_hidden"] == 'Y') {
        if (!check_admin_referer('frontier_post_admin_advanced', 'frontier_post_admin')) {
            wp_die(__("Security violation (Nonce check) - Please contact your Wordpress administrator", "frontier-post"));
        }
        $fps_save_general_options = frontier_post_get_settings();
        foreach ($fps_advanced_option_list as $tmp_option_name) {
            if (!key_exists($tmp_option_name, $fps_save_general_options)) {
                $fps_save_general_options[$tmp_option_name] = $fps_general_defaults[$tmp_option_name];
            }
            $fps_save_general_options[$tmp_option_name] = isset($_POST[$tmp_option_name]) ? $_POST[$tmp_option_name] : "";
            /*
            if (is_array($fps_save_general_options[$tmp_option_name]))
            	{
            	echo "Saving. ".$tmp_option_name." - Value: ";
            	echo print_r($fps_save_general_options[$tmp_option_name], true);
            	echo"<br>";
            	}
            else
            	echo "Saving. ".$tmp_option_name." - Value: ".$fps_save_general_options[$tmp_option_name]."<br>";
            */
        }
        if (intval($fps_save_general_options["fps_tag_count"]) == 0) {
            $fps_save_general_options["fps_tag_count"] = 3;
        }
        update_option(FRONTIER_POST_SETTINGS_OPTION_NAME, $fps_save_general_options);
        // Put an settings updated message on the screen
        echo '<div class="updated"><p><strong>' . __("Settings saved.", 'frontier-post') . '</strong></p></div>';
    }
    // end save settngs
    //**********************************************************************
    //* Form start
    //**********************************************************************
    // Load settings from options
    $fps_general_options = frontier_post_get_settings();
    echo '<div class="wrap">';
    echo '<div class="frontier-admin-menu">';
    echo '<h2>' . __("Frontier Post Advanced Settings", "frontier-post") . '</h2>';
    echo '<hr>' . __("Documentation", "frontier_post") . ': <a href="http://wpfrontier.com/frontier-post-advanced-settings/" target="_blank">Advanced settings</a><hr>';
    echo '<form name="frontier_post_settings" method="post" action="">';
    echo '<input type="hidden" name="frontier_isupdated_advanced_hidden" value="Y">';
    wp_nonce_field('frontier_post_admin_advanced', 'frontier_post_admin');
    echo '<table border="1" cellspacing="0" cellpadding="2">';
    echo "<tr>";
    echo "<td>" . __("Add Frontier Author user role", "frontier-post") . "</td>";
    fps_html_field("fps_author_role", 'checkbox', $fps_general_options, true, 1);
    echo "<td>" . __("Adds a new role: Frontend Author to Wordpress", "frontier-post") . "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Show ID in category list", "frontier-post") . "</td>";
    fps_html_field("fps_catid_list", 'checkbox', $fps_general_options, true, 1);
    echo "<td>" . __("If checked ID column will be added to the standard category list in admin panel", "frontier-post") . "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Number of tags", "frontier-post") . "</td>";
    echo "<td></td>";
    if (intval($fps_general_options["fps_tag_count"]) == 0) {
        $fps_general_options["fps_tag_count"] = 3;
    }
    fps_html_field("fps_tag_count", 'text', $fps_general_options, true, 1);
    echo " " . __("number of tags to edit on the input form", "frontier-post");
    echo "</tr><tr>";
    echo "<td>" . __("Tag transformation", "frontier-post") . "</td>";
    echo "<td></td>";
    fps_html_field("fps_tags_transform", 'select', $fps_general_options, true, 1, $fp_tag_transform_list);
    echo "</tr><tr>";
    echo "<td>" . __("Hide post status", "frontier-post") . "</td>";
    fps_html_field("fps_hide_status", 'checkbox', $fps_general_options, true, 1);
    echo "<td>" . __("Hide the post status on the entry form", "frontier-post") . "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Input form", "frontier-post") . "</td>";
    echo "<td></td>";
    fps_html_field("fps_default_form", 'select', $fps_general_options, true, 1, $frontier_post_forms);
    echo "</tr><tr>";
    echo "<td>" . __("Height of editor", "frontier-post") . "</td>";
    echo "<td></td>";
    fps_html_field("fps_editor_lines", 'text', $fps_general_options, true, 1);
    echo "</tr><tr>";
    echo "<td>" . __("Custom login text", "frontier-post") . "</td>";
    fps_html_field("fps_use_custom_login_txt", 'checkbox', $fps_general_options, true);
    echo "<td align='left'>";
    echo '<textarea rows="4" cols="100" name="fps_custom_login_txt">' . stripslashes($fps_general_options['fps_custom_login_txt']) . '</textarea>';
    echo '<br>' . __("This text (and link) is displayed when a user is required to login", "frontier-post");
    echo ' - Default text: ' . __("Please log in !", "frontier-post") . '&nbsp;<a href="' . wp_login_url() . '">' . __("Login Page", "frontier-post") . '</a>';
    echo "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Hide title on these pages", "frontier-post") . "</td>";
    echo "<td></td>";
    echo "<td>";
    echo fps_text_field("fps_hide_title_ids", $fps_general_options['fps_hide_title_ids'], 100);
    echo '<br>' . __("comma separated list of IDs", "frontier-post");
    echo "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Allow Custom Taxonomies", "frontier-post") . "</td>";
    echo "<td></td>";
    echo "<td><strong>" . __("Taxonomies", "frontier-post") . ":</strong><br>";
    echo fps_checkbox_select_field("fps_custom_tax_list[]", $fps_general_options["fps_custom_tax_list"], fp_get_tax_list()) . "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Default Taxonomy layout", "frontier-post") . "</td>";
    echo "<td></td>";
    fps_html_field("fps_default_tax_select", 'select', $fps_general_options, true, 1, array_flip($category_types));
    echo "</tr><tr>";
    echo "<td>" . __("Allow shortcode in Post Types", "frontier-post") . "</td>";
    echo "<td></td>";
    echo "<td><strong>" . __("Post Types", "frontier-post") . ":</strong><br>";
    echo fps_checkbox_select_field("fps_sc_allowed_in[]", $fps_general_options["fps_sc_allowed_in"], fp_get_post_type_list());
    echo "<strong>" . __("It only recommended to allow shortcode in pages, allowing in posts can enable authors to display information they might not have access to !!", "frontier-post") . "</strong></td>";
    echo "</tr><tr>";
    echo "<td>" . __("Custom delete text", "frontier-post") . "</td>";
    echo "<td>&nbsp;</td>";
    echo "<td align='left'>";
    echo '<textarea rows="3" cols="100" name="fps_custom_delete_txt">' . stripslashes($fps_general_options['fps_custom_delete_txt']) . '</textarea>';
    echo '<br>' . __("This text is displayed when a user is confirming delete of a post", "frontier-post");
    echo "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Send email to Admins on post to approve", "frontier-post") . "</td>";
    fps_html_field("fps_mail_to_approve", 'checkbox', $fps_general_options, true);
    echo "<td>";
    echo fps_text_field("fps_mail_address", $fps_general_options['fps_mail_address'], 100);
    echo '<br>' . __("Approver email (ex: name1@domain.xx, name2@domain.xx)", "frontier-post");
    echo "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Send email to author when post is approved", "frontier-post") . "</td>";
    fps_html_field("fps_mail_approved", 'checkbox', $fps_general_options, true);
    echo "</tr><tr>";
    echo "<td>" . __("Disable control of Admin Bar", "frontier-post") . "</td>";
    fps_html_field("fps_disable_abar_ctrl", 'checkbox', $fps_general_options, true, 1);
    echo "<td>" . __("If this is checked, frontier post will not enable/disable the admin bar (Check this if another plugin is enabling/disabling the admin bar to avoid conflict)", "frontier-post") . "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Keep Frontier Post settings on uninstall", "frontier-post") . "</td>";
    fps_html_field("fps_keep_options_uninstall", 'checkbox', $fps_general_options, true, 1);
    echo "<td>" . __("If this is checked, the Frontier Settings will not be deleted on uninstall", "frontier-post") . "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Template directory", "frontier-post") . "</td>";
    echo "<td></td>";
    echo "<td>";
    echo frontier_template_dir();
    // check if frontuier post templates are used
    if (locate_template(array('/plugins/frontier-post/' . "frontier_post_form_standard.php"), false, true)) {
        echo "<br /><strong><font color='red'> frontier_post_form_standard.php </font> " . __("exists in the template directory", "fontier-post") . "</strong>";
    }
    if (locate_template(array('/plugins/frontier-post/' . "frontier_post_form_old.php"), false, true)) {
        echo "<br /><strong><font color='red'> frontier_post_form_old.php </font> " . __("exists in the template directory", "fontier-post") . "</strong>";
    }
    if (locate_template(array('/plugins/frontier-post/' . "frontier_post_form_simple.php"), false, true)) {
        echo "<br /><strong><font color='red'> frontier_post_form_simple.php </font> " . __("exists in the template directory", "fontier-post") . "</strong>";
    }
    if (locate_template(array('/plugins/frontier-post/' . "frontier_post_form_list.php"), false, true)) {
        echo "<br /><strong><font color='red'> frontier_post_form_list.php </font> " . __("exists in the template directory", "fontier-post") . "</strong>";
    }
    if (locate_template(array('/plugins/frontier-post/' . "frontier_post_form_page.php"), false, true)) {
        echo "<br /><strong><font color='red'> frontier_post_form_page.php </font> " . __("exists in the template directory", "fontier-post") . "</strong>";
    }
    if (locate_template(array('/plugins/frontier-post/' . "frontier_post_form_preview.php"), false, true)) {
        echo "<br /><strong><font color='red'> frontier_post_form_preview.php </font> " . __("exists in the template directory", "fontier-post") . "</strong>";
    }
    if (locate_template(array('/plugins/frontier-post/' . "frontier-post.css"), false, true)) {
        echo "<br /><strong><font color='red'> frontier-post.css </font>" . __("exists in the template directory", "fontier-post") . "</strong>";
    }
    echo "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Set Capabilities externally", "frontier-post") . "</td>";
    fps_html_field("fps_external_cap", 'checkbox', $fps_general_options, true);
    echo '<td>' . __("If checked capabilities will be managed from external plugin ex.: User Role Editor", "frontier-post") . '</td>';
    echo "</tr><tr>";
    if (fp_get_option_bool("fps_external_cap")) {
        echo "<td>" . __("Default Editor", "frontier-post") . "</td>";
        fps_html_field("fps_default_editor", 'select', $fps_general_options, true, 1, array_flip($editor_types));
        echo "</tr><tr>";
        echo "<td>" . __("Default category select", "frontier-post") . "</td>";
        fps_html_field("fps_default_cat_select", 'select', $fps_general_options, true, 1, array_flip($category_types));
        echo "</tr><tr>";
    }
    echo "</tr><tr>";
    echo "<td>" . __("Use tinymce Word count", "frontier-post") . "</td>";
    fps_html_field("fps_tinymce_wordcount", 'checkbox', $fps_general_options, true, 1);
    echo "<td>" . __("If this is checked, the tinymce Wordcount will be used instead of standard wordcount", "frontier-post") . "</td>";
    echo "</tr><tr>";
    $tmp_edit_link_types = array("post" => __("Post", "frontier-post"), "page" => __("Page", "frontier-post"));
    echo "<td>" . __("Super Admin Edit Link", "frontier-post") . "</td>";
    echo "<td></td>";
    echo "<td><strong>" . __("Redirect to Frontier Post edit form for the below post types", "frontier-post") . ":</strong><br>";
    echo fps_checkbox_select_field("fps_sc_super_admin_types[]", $fps_general_options["fps_sc_super_admin_types"], $tmp_edit_link_types);
    echo "" . __("If above post types are checked, the standard Wordpress edit link is changed to point at Frontier Post, as opposed to the backend.", "frontier-post") . "</td>";
    // moderation
    echo "</tr><tr>";
    echo "<th colspan='3'>Post Moderation<th>";
    echo "</tr><tr>";
    echo "<td>" . __("Activate post moderation", "frontier-post") . "</td>";
    fps_html_field("fps_use_moderation", 'checkbox', $fps_general_options, true, 1);
    echo "<td>" . __("If this is checked, moderation comments can be edited on the post form", "frontier-post") . "</td>";
    echo "</tr><tr>";
    echo "<td>" . __("Cache time for taxonomy lists", "frontier-post") . "</td>";
    echo "<td></td>";
    fps_html_field("fps_cache_time_tax_lists", 'select', $fps_general_options, true, 1, $fp_cache_time_list);
    echo '</tr></table>';
    echo '<p class="submit"><input type="submit" name="Submit" class="button-primary" value="' . __('Save Changes') . '"></p>';
    echo '</form>';
    echo '<hr>';
    echo '</div>';
    //frontier-admin-menu
    echo '</div>';
    //wrap
}
*/
$concat = get_option("permalink_structure") ? "?" : "&";
//set the permalink for the page itself
$frontier_permalink = get_permalink();
//Display before text from shortcode
if (strlen($frontier_list_text_before) > 1) {
    echo '<div id="frontier_list_text_before">' . $frontier_list_text_before . '</div>';
}
//Display message
frontier_post_output_msg();
$fp_cat_list = implode(",", $frontier_cat_id);
/*
echo "post_type: ".$frontier_add_post_type."<br>";
echo "Label: ".fp_get_posttype_label_singular($frontier_add_post_type);
*/
if (frontier_can_add() && !fp_get_option_bool("fps_hide_add_on_list")) {
    if (strlen(trim($frontier_add_link_text)) > 0) {
        $tmp_add_text = $frontier_add_link_text;
    } else {
        $tmp_add_text = __("Create New", "frontier-post") . " " . fp_get_posttype_label_singular($frontier_add_post_type);
    }
    ?>
	<table class="frontier-menu" >
		<tr class="frontier-menu">
			<th class="frontier-menu" >&nbsp;</th>
			<th class="frontier-menu" ><a id="frontier-post-add-new-link" href='<?php 
    echo frontier_post_add_link($tmp_p_id);
    ?>
'><?php 
    echo $tmp_add_text;
    ?>
    }
    ?>
	
				</td>
				<?php 
}
// Hide post_status
?>
			</tr>
			</tbody></table>
		</td>	
	</tr><tr>
		<td><div id="frontier_editor_field"> 
			<?php 
wp_editor($thispost->post_content, 'user_post_desc', frontier_post_wp_editor_args($editor_type, $frontier_media_button, $frontier_editor_height, false));
if (!fp_get_option_bool('fps_tinymce_wordcount')) {
    printf(__('Word count: %s'), '<span class="word-count">0</span>');
}
?>
		</div></td>
	</tr><tr>
		<td><table><tbody>
		<tr>
		<?php 
if ($category_type != "hide") {
    ?>
			<th class="frontier_heading" width="50%"><?php 
    _e("Category", "frontier-post");
    ?>
</th>
		<?php 
示例#8
0
function frontier_posting_form_submit($frontier_post_shortcode_parms = array())
{
    extract($frontier_post_shortcode_parms);
    global $current_user;
    // which button has been pressed
    $tmp_return = isset($_POST['user_post_submit']) ? $_POST['user_post_submit'] : "savereturn";
    //Get Frontier Post capabilities
    $fp_capabilities = frontier_post_get_capabilities();
    if (isset($_POST['action']) && $_POST['action'] == "wpfrtp_save_post") {
        if (!wp_verify_nonce($_POST['frontier_add_edit_post_' . $_POST['postid']], 'frontier_add_edit_post')) {
            wp_die(__("Security violation (Nonce check) - Please contact your Wordpress administrator", "frontier-post"));
        }
        if (isset($_REQUEST['task']) && $_REQUEST['task'] == "new") {
            $tmp_task_new = true;
        } else {
            $tmp_task_new = false;
        }
        //fp_log("New post ? : ".$tmp_task_new);
        if (isset($_POST['post_status'])) {
            $post_status = $_POST['post_status'];
        } else {
            $post_status = 'draft';
        }
        //Check if Publish has been pressed
        if ($tmp_return === "publish" && current_user_can("frontier_post_can_publish")) {
            $post_status = 'publish';
        }
        $tmp_post_type = isset($_POST['posttype']) ? $_POST['posttype'] : 'post';
        $postid = $_POST['postid'];
        $tmp_title = trim($_POST['user_post_title']);
        $tmp_content = trim($_POST['user_post_desc']);
        // check empty title, and set status to draft if status is empty
        if (empty($tmp_title)) {
            if (strlen($tmp_content) > 20) {
                $tmp_title = wp_trim_words($tmp_content, 10);
            } else {
                $tmp_title = __("No Title", "frontier-post");
            }
            $post_status = 'draft';
            frontier_post_set_msg('<div id="frontier-post-alert">' . __("Warning", "frontier-post") . ': ' . __("Title was empty", "frontier-post") . ' - ' . __("Post status set to draft", "frontier-post") . '</div>');
        }
        $tmp_title = trim(strip_tags($tmp_title));
        if (empty($tmp_content)) {
            $tmp_content = __("No content", "frontier-post");
            $post_status = 'draft';
            frontier_post_set_msg('<div id="frontier-post-alert">' . __("Warning", "frontier-post") . ': ' . __("Content was empty", "frontier-post") . ' - ' . __("Post status set to draft", "frontier-post") . '</div>');
        }
        $tmp_excerpt = isset($_POST['user_post_excerpt']) ? trim($_POST['user_post_excerpt']) : null;
        $users_role = frontier_get_user_role();
        //****************************************************************************************************
        // Manage Categories
        //****************************************************************************************************
        // Do not manage categories for page
        if ($tmp_post_type != 'page') {
            $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");
            $tmp_field_name = frontier_tax_field_name('category');
            if ($category_type != "hide" && $category_type != "readonly") {
                $tmp_categorymulti = isset($_POST[$tmp_field_name]) ? $_POST[$tmp_field_name] : array();
            }
            //frontier_post_set_msg("Default Category: ".$default_category);
            //frontier_post_set_msg("Post Categories: ".( isset($_POST['post_categories']) ? $_POST['post_categories'] : "NONE"));
            // if no category returned from entry form, check for hidden field, if this is empty set default category
            if (!isset($tmp_categorymulti) || count($tmp_categorymulti) == 0) {
                $tmp_categorymulti = isset($_POST['post_categories']) ? explode(',', $_POST['post_categories']) : array();
                // Do not use default category if post type = page
                if ($tmp_post_type != 'page') {
                    $tmp_categorymulti = count($tmp_categorymulti) > 0 && isset($tmp_categorymulti[0]) && $tmp_categorymulti[0] > 0 ? $tmp_categorymulti : array($default_category);
                }
            }
            //frontier_post_set_msg("Category from POST: ".print_r($tmp_categorymulti,true));
        }
        // do not manage categories for pages
        //****************************************************************************************************
        // Update post
        //****************************************************************************************************
        $tmp_post = array('ID' => $postid, 'post_type' => $tmp_post_type, 'post_title' => $tmp_title, 'post_status' => $post_status, 'post_content' => $tmp_content, 'post_excerpt' => $tmp_excerpt);
        // Do not manage categories for page
        if ($tmp_post_type != 'page') {
            $tmp_post['post_category'] = $tmp_categorymulti;
        }
        //****************************************************************************************************
        // Apply filter before update of post
        // filter:			frontier_post_pre_update
        // $tmp_post 		Array that holds the updated fields
        // $tmp_task_new  	Equals true if the user is adding a post
        // $_POST			Input form
        //****************************************************************************************************
        $tmp_post = apply_filters('frontier_post_pre_update', $tmp_post, $tmp_task_new, $_POST);
        //Set $post_status to tmp_post value, if changed by filter
        $post_status = $tmp_post['post_status'];
        //force save with draft status first, if new post and status is set to published to align with wordpress standard
        if ($tmp_task_new == true && $post_status == "publish") {
            $tmp_post['post_status'] = "draft";
            wp_update_post($tmp_post);
            $tmp_post = array('ID' => $postid, 'post_status' => $post_status);
            wp_update_post($tmp_post);
        } else {
            wp_update_post($tmp_post);
        }
        //****************************************************************************************************
        // Tags
        //****************************************************************************************************
        // Do not manage tags for page
        if (current_user_can('frontier_post_tags_edit') && $tmp_post_type != 'page') {
            $fp_tag_count = fp_get_option_int("fps_tag_count", 3);
            $taglist = array();
            for ($i = 0; $i < $fp_tag_count; $i++) {
                if (isset($_POST['user_post_tag' . $i])) {
                    array_push($taglist, fp_tag_transform($_POST['user_post_tag' . $i]));
                }
            }
            wp_set_post_tags($postid, $taglist);
        }
        //****************************************************************************************************
        // Add/Update message
        //****************************************************************************************************
        if ($tmp_task_new == true) {
            frontier_post_set_msg(__("Post added", "frontier-post") . ": " . $tmp_title);
        } else {
            frontier_post_set_msg(__("Post updated", "frontier-post") . ": " . $tmp_title);
        }
        //****************************************************************************************************
        // Taxonomies
        //****************************************************************************************************
        // Do not manage taxonomies for page
        if ($tmp_post_type != 'page') {
            foreach ($frontier_custom_tax as $tmp_tax_name) {
                if (!empty($tmp_tax_name) && $tmp_tax_name != 'category') {
                    $tmp_field_name = frontier_tax_field_name($tmp_tax_name);
                    $tmp_value = isset($_POST[$tmp_field_name]) ? $_POST[$tmp_field_name] : array();
                    if (is_array($tmp_value)) {
                        $tmp_tax_selected = $tmp_value;
                    } else {
                        $tmp_tax_selected = array($tmp_value);
                    }
                    wp_set_post_terms($postid, $tmp_tax_selected, $tmp_tax_name);
                    //error_log("set terms: ".$tmp_tax_name." : ". print_r($tmp_tax_selected,true));
                }
            }
        }
        // end do not manage taxonomies for pages
        //****************************************************************************************************
        // End updating post
        //****************************************************************************************************
        //Get the updated post
        $my_post = get_post($postid);
        // Delete users cache for My Posts widget
        fp_delete_my_post_w_cache();
        //***************************************************************************************
        //* Save post moderation fields
        //***************************************************************************************
        if (fp_get_option_bool("fps_use_moderation") && (current_user_can("edit_others_posts") || $current_user->ID == $my_post->post_author)) {
            if (isset($_POST['frontier_post_moderation_new_text'])) {
                $fp_moderation_comments_new = $_POST['frontier_post_moderation_new_text'];
                //$fp_moderation_comments_new = trim(stripslashes(strip_tags($fp_moderation_comments_new)));
                $fp_moderation_comments_new = wp_strip_all_tags($fp_moderation_comments_new);
                $fp_moderation_comments_new = nl2br($fp_moderation_comments_new);
                $fp_moderation_comments_new = stripslashes($fp_moderation_comments_new);
                $fp_moderation_comments_new = trim($fp_moderation_comments_new);
                if (strlen($fp_moderation_comments_new) > 0) {
                    global $current_user;
                    $fp_moderation_comments_old = get_post_meta($my_post->ID, 'FRONTIER_POST_MODERATION_TEXT', true);
                    $fp_moderation_comments = current_time('mysql') . " - " . $current_user->user_login . ":<br>";
                    $fp_moderation_comments .= $fp_moderation_comments_new . "<br>";
                    $fp_moderation_comments .= '<hr>' . "<br>";
                    $fp_moderation_comments .= $fp_moderation_comments_old . "<br>";
                    update_post_meta($my_post->ID, 'FRONTIER_POST_MODERATION_TEXT', $fp_moderation_comments);
                    update_post_meta($my_post->ID, 'FRONTIER_POST_MODERATION_DATE', current_time('mysql'));
                    update_post_meta($my_post->ID, 'FRONTIER_POST_MODERATION_FLAG', 'true');
                    // Email author on moderation comments
                    if (isset($_POST['frontier_post_moderation_send_email']) && $_POST['frontier_post_moderation_send_email'] == "true") {
                        $to = get_the_author_meta('email', $my_post->post_author);
                        $subject = __("Moderator has commented your pending post", "frontier-post") . " (" . get_bloginfo("name") . ")";
                        $body = __("Moderator has commented your pending post", "frontier-post") . ": " . $my_post->post_title . " (" . get_bloginfo("name") . ")" . "\r\n\r\n";
                        $body .= "Comments: " . $_POST['frontier_post_moderation_new_text'] . "\r\n\r\n";
                        if (!wp_mail($to, $subject, $body)) {
                            frontier_post_set_msg(__("Message delivery failed - Recipient: (", "frontier-post") . $to . ")");
                        }
                    }
                }
            }
        }
        //****************************************************************************************************
        // Action fires after add/update of post, and after taxonomies are updated
        // Do action 		frontier_post_post_save
        // $my_post 		Post object for the post just updated
        // $tmp_task_new  	Equals true if the user is adding a post
        // $_POST			Input form
        //****************************************************************************************************
        do_action('frontier_post_post_save', $my_post, $tmp_task_new, $_POST);
        //If save, set task to edit
        if ($tmp_return == "save") {
            $_REQUEST['task'] = "edit";
            $_REQUEST['postid'] = $postid;
        }
        // if shortcode frontier_mode=add, return to add form instead of list
        if ($frontier_mode == "add" && $tmp_return == "savereturn") {
            $tmp_return = "add";
        }
        switch ($tmp_return) {
            case 'preview':
                frontier_preview_post($postid);
                break;
            case 'add':
                frontier_post_add_edit($frontier_post_shortcode_parms);
                break;
            case 'savereturn':
                frontier_user_post_list($frontier_post_shortcode_parms);
                break;
            case 'save':
                frontier_post_add_edit($frontier_post_shortcode_parms);
                break;
            case 'delete':
                frontier_prepare_delete_post($frontier_post_shortcode_parms);
                break;
            default:
                frontier_user_post_list($frontier_post_shortcode_parms);
                break;
        }
    } else {
        frontier_post_set_msg(__("Error - Unable to save post", "frontier-post"));
        frontier_user_post_list($frontier_post_shortcode_parms);
    }
    // end isset post
}
function frontier_post_set_defaults()
{
    if (!defined('FRONTIER_POST_SETTINGS_OPTION_NAME')) {
        define('FRONTIER_POST_SETTINGS_OPTION_NAME', "frontier_post_general_options");
    }
    if (!defined('FRONTIER_POST_CAPABILITY_OPTION_NAME')) {
        define('FRONTIER_POST_CAPABILITY_OPTION_NAME', "frontier_post_capabilities");
    }
    include FRONTIER_POST_DIR . '/include/frontier_post_defaults.php';
    $fp_last_upgrade = fp_get_option('fps_options_migrated_version', get_option("frontier_post_version", '0.0.0'));
    // Upgrade old versions, but dont run upgrade if fresh install
    if ($fp_last_upgrade != '0.0.0' && version_compare($fp_last_upgrade, '3.3.0') < 0) {
        include FRONTIER_POST_DIR . '/admin/frontier-post-convert-options.php';
        fps_cnv_general_options(true);
        $fp_upgrade_msg = 'Frontier Post - Settings upgraded from version: ' . $fp_last_upgrade . ' to version: ' . FRONTIER_POST_VERSION;
    } else {
        //******************************************************************************
        // add settings if not already there
        //******************************************************************************
        if (!fp_get_option_bool('fps_keep_options_uninstall', false)) {
            // Set default capabilities
            $saved_capabilities = frontier_post_get_capabilities();
            // administrators capabilities
            $tmp_administrator_cap = array('frontier_post_can_add' => 'true', 'frontier_post_can_edit' => 'true', 'frontier_post_can_delete' => 'true', 'frontier_post_can_publish' => 'true', 'frontier_post_can_draft' => 'true', 'frontier_post_can_pending' => 'true', 'frontier_post_can_private' => 'true', 'frontier_post_redir_edit' => 'true', 'frontier_post_show_admin_bar' => 'true', 'frontier_post_exerpt_edit' => 'true', 'frontier_post_tags_edit' => 'true', 'frontier_post_can_media' => 'true', 'frontier_post_can_page' => 'true', 'fps_role_editor_type' => 'full', 'fps_role_category_layout' => 'multi', 'fps_role_default_category' => get_option("default_category"), 'fps_role_allowed_categories' => '');
            // editor
            $tmp_editor_cap = $tmp_administrator_cap;
            // Author
            $tmp_author_cap = $tmp_editor_cap;
            $tmp_author_cap['frontier_post_can_private'] = 'false';
            $tmp_author_cap['frontier_post_show_admin_bar'] = 'false';
            $tmp_author_cap['frontier_post_can_page'] = 'false';
            // Contributor
            $tmp_contributor_cap = $tmp_author_cap;
            $tmp_contributor_cap['frontier_post_can_delete'] = 'false';
            $tmp_contributor_cap['frontier_post_can_publish'] = 'false';
            $tmp_contributor_cap['frontier_post_redir_edit'] = 'false';
            $tmp_contributor_cap['frontier_post_tags_edit'] = 'false';
            $tmp_contributor_cap['frontier_post_can_media'] = 'false';
            $tmp_contributor_cap['fps_role_editor_type'] = 'minimal-visual';
            // Subscriber
            $tmp_subscriber_cap = $tmp_contributor_cap;
            $tmp_subscriber_cap['frontier_post_can_add'] = 'false';
            $tmp_subscriber_cap['frontier_post_can_edit'] = 'false';
            $tmp_subscriber_cap['frontier_post_can_pending'] = 'false';
            $tmp_subscriber_cap['frontier_post_can_draft'] = 'false';
            $wp_roles = new WP_Roles();
            $roles = $wp_roles->get_names();
            $saved_capabilities = frontier_post_get_capabilities();
            foreach ($roles as $key => $item) {
                switch ($key) {
                    case 'administrator':
                        $tmp_cap_list = $tmp_administrator_cap;
                        break;
                    case 'editor':
                        $tmp_cap_list = $tmp_editor_cap;
                        break;
                    case 'author':
                        $tmp_cap_list = $tmp_author_cap;
                        break;
                    case 'frontier-author':
                        $tmp_cap_list = $tmp_author_cap;
                        break;
                    case 'contributor':
                        $tmp_cap_list = $tmp_contributor_cap;
                        break;
                    case 'subscriber':
                        $tmp_cap_list = $tmp_subscriber_cap;
                        break;
                    default:
                        $tmp_cap_list = $tmp_contributor_cap;
                        break;
                }
                $saved_capabilities[$key] = $tmp_cap_list;
            }
            // roles
            // Save options
            update_option(FRONTIER_POST_CAPABILITY_OPTION_NAME, $saved_capabilities);
        }
        // end update settings if not saved from during previous uninstall
    }
    //end Upgrade or not
    // update default settings
    fp_post_set_defaults();
    // Set Wordpress capabilities
    frontier_post_set_cap();
    global $wpdb;
    // Check if page containing [frontier-post] exists already, else create it
    $tmp_id = $wpdb->get_var("SELECT id \r\n\t\t  FROM {$wpdb->posts} \r\n\t\t  WHERE post_type='page' AND \r\n\t\t  post_status='publish' AND \r\n\t\t post_content LIKE '%[frontier-post]%'\r\n\t\t");
    if ((int) $tmp_id <= 0) {
        // Add new page
        $my_page = array('post_title' => __('My Posts', 'frontier-post'), 'post_content' => '[frontier-post]', 'post_status' => 'publish', 'comment_status' => 'closed', 'post_type' => 'page', 'ping_status' => 'closed');
        // Insert the page into the database
        $tmp_id = wp_insert_post($my_page);
        // save page id
        $fps_save_general_options = frontier_post_get_settings();
        $fps_save_general_options['fps_page_id'] = $tmp_id;
        update_option(FRONTIER_POST_SETTINGS_OPTION_NAME, $fps_save_general_options);
    } else {
        if (fp_get_option_int('fps_page_id', 0) === 0) {
            // save page id
            $fps_save_general_options = frontier_post_get_settings();
            $fps_save_general_options['fps_page_id'] = $tmp_id;
            update_option(FRONTIER_POST_SETTINGS_OPTION_NAME, $fps_save_general_options);
        }
    }
    //save to options that capabilities has been migrated
    $fps_general_options = frontier_post_get_settings();
    $fps_general_options['fps_options_migrated'] = "true";
    $fps_general_options['fps_options_migrated_version'] = FRONTIER_POST_VERSION;
    update_option(FRONTIER_POST_SETTINGS_OPTION_NAME, $fps_general_options);
    // Put an updated message on the screen - NO NO, Cant do that in activation script.
    //echo '<div class="updated"><p><strong>'.__("Frontier Post - Default settings and capabilities set - Please review settings and capabilities", 'frontier-post' ).'</strong></p></div>';
}
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 = "";
    }
}
function frontier_can_delete($tmp_post)
{
    $fps_access_check_msg = "";
    $cur_user = wp_get_current_user();
    $tmp_can_do = true;
    // Check if the user is allowed to delete posts
    if (!current_user_can('frontier_post_can_delete')) {
        $tmp_can_do = false;
        $fps_access_check_msg .= __("You are not allowed to delete posts", "frontier-post") . "<br>";
    }
    // Users can not delete other users posts unless they have capability "delete_others_posts" (Administrators & Editors)
    if ($cur_user->ID != $tmp_post->post_author && !current_user_can('delete_others_posts')) {
        $tmp_can_do = false;
        $fps_access_check_msg .= __("You are not allowed to delete post from another user", "frontier-post") . "<br>";
    }
    // Check that the age of the post is below the Frontier Post setting
    if (frontier_post_age($tmp_post->post_date) > fp_get_option_int('fps_delete_max_age')) {
        $tmp_can_do = false;
        $fps_access_check_msg .= __("You are not allowed to delete post older than: ", "frontier-post") . get_option('frontier_post_delete_max_age') . " " . __("days", "frontier-post") . "<br>";
    }
    // Check that user is allowed to delete posts that already has comments
    if ((int) $tmp_post->comment_count > 0 && !fp_get_option_bool("fps_del_w_comments")) {
        $tmp_can_do = false;
        $fps_access_check_msg .= __("You are not allowed to deelete post that already has comments", "frontier-post") . "<br>";
    }
    // Check that user is allowed to delete published posts
    if (!fp_get_option("fps_change_status") && $tmp_post->post_status == "publish") {
        $tmp_can_do = false;
        $fps_access_check_msg .= __("You are not allowed to delete published posts", "frontier-post") . "<br>";
    }
    // check if it is an allowed posttype
    if (!fp_check_post_type($tmp_post->post_type)) {
        $tmp_can_do = false;
        $fps_access_check_msg .= __("You are not allowed to delete", "frontier-post") . ": " . fp_get_posttype_label($tmp_post->post_type) . "<br>";
    }
    // Always allow the boss
    if (current_user_can('administrator')) {
        $tmp_can_do = true;
        $fps_access_check_msg = "";
    }
    // Last check, PRIVATE posts can only be deleted by the author, or users with capability delete_private_posts (admins and editors)
    if ($tmp_post->post_status == "private" && ($cur_user->ID != $tmp_post->post_author || !current_user_can('frontier_post_can_private') || !current_user_can('frontier_post_can_delete'))) {
        $tmp_can_do = false;
        $fps_access_check_msg .= __("You are not allowed to delete PRIVATE post from another user", "frontier-post") . "<br>";
    }
    return $tmp_can_do;
}
示例#12
0
function fp_login_text()
{
    if (fp_get_option_bool('fps_use_custom_login_txt', false)) {
        $out = fp_get_option('fps_custom_login_txt', __("Please log in !", "frontier-post"));
    } else {
        include FRONTIER_POST_DIR . "/include/frontier_post_defaults.php";
        $out = '';
        $out .= "<br>---- ";
        if (fp_get_option_bool("fps_show_login", false)) {
            $out .= $frontier_default_login_txt;
        } else {
            $out .= __("Please log in !", "frontier-post");
        }
        $out .= " ------<br><br>";
    }
    return '<div id="frontier-post-login-msg">' . stripslashes($out) . '</div>';
}
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
}
$tmp_status_list['future'] = __("Future", "frontier-post");
$tmp_info_separator = " | ";
//Display before text from shortcode
if (strlen($fpost_sc_parms['frontier_list_text_before']) > 1) {
    echo '<div id="frontier_list_text_before">' . $frontier_list_text_before . '</div>';
}
// Dummy translation of ago for human readable time
$crap = __("ago", "frontier-post");
if (strlen(trim($fpost_sc_parms['frontier_add_link_text'])) > 0) {
    $tmp_add_text = $fpost_sc_parms['frontier_add_link_text'];
} else {
    $tmp_add_text = __("Create New", "frontier-post") . " " . fp_get_posttype_label_singular($fpost_sc_parms['frontier_add_post_type']);
}
//Display message
frontier_post_output_msg();
if (frontier_can_add($fpost_sc_parms['frontier_add_post_type']) && !fp_get_option_bool("fps_hide_add_on_list")) {
    ?>
	<fieldset class="frontier-new-menu">
		<a id="frontier-post-add-new-link" href='<?php 
    echo frontier_post_add_link($tmp_p_id);
    ?>
'><?php 
    echo $tmp_add_text;
    ?>
</a>
	</fieldset>
	<?php 
} else {
    if (current_user_can("manage_options") && strlen(trim($fps_access_check_msg)) > 0) {
        echo '<div id="frontier-post-posttype-warning">';
        echo $fps_access_check_msg;
$concat = get_option("permalink_structure") ? "?" : "&";
//set the permalink for the page itself
$frontier_permalink = get_permalink();
$tmp_status_list = get_post_statuses();
// Add future to list
$tmp_status_list['future'] = __("Future", "frontier-post");
$tmp_info_separator = " | ";
//Display before text from shortcode
if (strlen($frontier_list_text_before) > 1) {
    echo '<div id="frontier_list_text_before">' . $frontier_list_text_before . '</div>';
}
// Dummy translation of ago for human readable time
$crap = __("ago", "frontier-post");
//Display message
frontier_post_output_msg();
if (frontier_can_add($frontier_add_post_type) && !fp_get_option_bool("fps_hide_add_on_list")) {
    if (strlen(trim($frontier_add_link_text)) > 0) {
        $tmp_add_text = $frontier_add_link_text;
    } else {
        $tmp_add_text = __("Create New", "frontier-post") . " " . fp_get_posttype_label_singular($frontier_add_post_type);
    }
    ?>
	<fieldset class="frontier-new-menu">
		<a id="frontier-post-add-new-link" href='<?php 
    echo frontier_post_add_link($tmp_p_id);
    ?>
'><?php 
    echo $tmp_add_text;
    ?>
</a>
	</fieldset>
?>
" type="text" value="<?php 
if (!empty($thispost->post_title)) {
    echo $thispost->post_title;
}
?>
" name="user_post_title" id="fp_title" >			
	</fieldset>
	<fieldset id="frontier_post_fieldset_status" class="frontier_post_fieldset">
		<legend><?php 
_e("Status", "frontier-post");
?>
</legend>
	
		<?php 
if (fp_get_option_bool("fps_hide_status")) {
    echo '<input type="hidden" id="post_status" name="post_status" value="' . $thispost->post_status . '"  >';
} else {
    //echo ' '.__("Status", "frontier-post").': ';
    ?>
 
				<select  class="frontier_post_dropdown" id="post_status" name="post_status" >
					<?php 
    foreach ($status_list as $key => $value) {
        ?>
   
						<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == $tmp_post_status ? "selected='selected'" : ' ';