コード例 #1
0
function frontier_clone_post($fpost_sc_parms = array())
{
    //extract($fpost_sc_parms);
    //echo "CLONE POST<br>";
    $frontier_permalink = get_permalink();
    $concat = get_option("permalink_structure") ? "?" : "&";
    if (isset($_POST['task'])) {
        $post_task = $_POST['task'];
    } else {
        if (isset($_GET['task'])) {
            $post_task = $_GET['task'];
        } else {
            $post_task = "notaskset";
        }
    }
    $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown";
    if ($post_task == "clone" && $_REQUEST['postid']) {
        $old_post = get_post($_REQUEST['postid']);
        $old_post_id = $old_post->ID;
        //double check current user can add a post with this post type
        if (frontier_can_add($old_post->post_type)) {
            require_once ABSPATH . '/wp-admin/includes/post.php';
            global $current_user;
            //Get permalink from old post
            $old_permalink = get_permalink($old_post_id);
            // lets clone it
            $thispost = get_default_post_to_edit($fpost_sc_parms['frontier_add_post_type'], true);
            $new_post_id = $thispost->ID;
            $tmp_post = array('ID' => $new_post_id, 'post_type' => $old_post->post_type, 'post_title' => __("CLONED from", "frontier-post") . ': <a href="' . $old_permalink . '">' . $old_post->post_title . '</a>', 'post_content' => __("CLONED from", "frontier-post") . ': <a href="' . $old_permalink . '">' . $old_post->post_title . '</a><br>' . $old_post->post_content, 'post_status' => "draft", 'post_author' => $current_user->ID);
            //****************************************************************************************************
            // Apply filter before update of post
            // filter:			frontier_post_clone
            // $tmp_post 		Array that holds the updated fields
            // $old_post  		The post being cloed (Object)
            //****************************************************************************************************
            $tmp_post = apply_filters('frontier_post_clone', $tmp_post, $old_post);
            // save post
            wp_update_post($tmp_post);
            //Get the updated post
            $new_post = get_post($new_post_id);
            //get all current post terms ad set them to the new post draft
            $taxonomies = get_object_taxonomies($old_post->post_type);
            // returns array of taxonomy names for post type, ex array("category", "post_tag");
            foreach ($taxonomies as $taxonomy) {
                $post_terms = wp_get_object_terms($old_post_id, $taxonomy, array('fields' => 'slugs'));
                wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
            }
            // Set featured image:
            $post_thumbnail_id = get_post_thumbnail_id($old_post_id);
            if (intval($post_thumbnail_id) > 0) {
                set_post_thumbnail($new_post_id, $post_thumbnail_id);
            }
            // Add/Update message
            frontier_post_set_msg(__("Post Cloned and ready edit", "frontier-post") . ": " . $new_post->post_title);
            frontier_post_set_msg(__("Post status set to Draft", "frontier-post"));
            frontier_user_post_list($fpost_sc_parms);
        }
    }
}
コード例 #2
0
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
}
コード例 #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
}
コード例 #4
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
}
コード例 #5
0
function frontier_execute_delete_post($frontier_post_shortcode_parms = array())
{
    extract($frontier_post_shortcode_parms);
    //$post_task 		= isset($_GET['task']) ? $_GET['task'] : "notaskset";
    //$post_action 	= isset($_REQUEST['action']) ? $_REQUEST['action'] : "Unknown";
    if (isset($_POST['task'])) {
        $post_task = $_POST['task'];
    } else {
        if (isset($_GET['task'])) {
            $post_task = $_GET['task'];
        } else {
            $post_task = "notaskset";
        }
    }
    $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown";
    $submit_delete = isset($_POST['submit_delete']) ? $_POST['submit_delete'] : "Unknown";
    $postid = isset($_POST['postid']) ? $_POST['postid'] : 0;
    if ($post_action == "wpfrtp_delete_post" && $postid != 0) {
        if (!wp_verify_nonce($_POST['frontier_delete_post_' . $_POST['postid']], 'frontier_delete_post')) {
            wp_die(__("Security violation (Nonce check) - Please contact your Wordpress administrator", "frontier-post"));
        }
        $thispost = get_post($postid);
        //double check current user is equal to author (in case directly with param)
        if (($submit_delete = "deletego") && frontier_can_delete($thispost) == true) {
            //Move post to recycle bin
            $tmp_title = $thispost->post_title;
            wp_trash_post($_REQUEST['postid']);
            frontier_post_set_msg(__("Post deleted", "frontier-post") . ": " . $tmp_title);
            frontier_user_post_list($frontier_post_shortcode_parms);
        }
    }
}
コード例 #6
0
function frontier_execute_approve_post($frontier_post_shortcode_parms = array())
{
    extract($frontier_post_shortcode_parms);
    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";
    $submit_approve = isset($_POST['submit_approve']) ? $_POST['submit_approve'] : "Unknown";
    $postid = isset($_POST['postid']) ? $_POST['postid'] : 0;
    if ($post_action == "wpfrtp_approve_post" && $postid != 0) {
        if (!wp_verify_nonce($_POST['frontier_approve_post_' . $_POST['postid']], 'frontier_approve_post')) {
            wp_die(__("Security violation (Nonce check) - Please contact your Wordpress administrator", "frontier-post"));
        }
        $thispost = get_post($postid);
        if (($submit_approve = "approvego") && $thispost->post_status === "pending" && current_user_can("edit_others_posts")) {
            $tmp_title = $thispost->post_title;
            //Set status to publish
            $tmp_post = array('ID' => $postid, 'post_status' => 'publish');
            wp_update_post($tmp_post);
            frontier_post_set_msg(__("Post approved", "frontier-post") . ": " . $tmp_title);
            frontier_user_post_list($frontier_post_shortcode_parms);
        }
    }
}