当前位置: 首页>>代码示例>>PHP>>正文


PHP edit_post函数代码示例

本文整理汇总了PHP中edit_post函数的典型用法代码示例。如果您正苦于以下问题:PHP edit_post函数的具体用法?PHP edit_post怎么用?PHP edit_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了edit_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ajax_post

 function ajax_post()
 {
     require_once ABSPATH . '/wp-admin/includes/post.php';
     if (!wp_verify_nonce($_POST['_wpnonce'], 'update-post_' . $_POST['post_ID'])) {
         wp_send_json_error(array('message' => __('You are not allowed to edit this item.')));
     }
     $_POST['post_title'] = strip_tags($_POST['post_title']);
     $post_id = edit_post();
     if (isset($_POST['save']) || isset($_POST['publish'])) {
         $status = get_post_status($post_id);
         if (isset($_POST['publish'])) {
             switch ($status) {
                 case 'pending':
                     $message = 8;
                     break;
                 case 'future':
                     $message = 9;
                     break;
                 default:
                     $message = 6;
             }
         } else {
             $message = 'draft' == $status ? 10 : 1;
         }
     } else {
         $message = 4;
     }
     $post = get_post($post_id);
     wp_send_json_success(array('message' => $this->get_message($post, $message), 'post' => $post, 'processedPostContent' => apply_filters('the_content', $post->post_content)));
 }
开发者ID:foxpcteam,项目名称:wp-front-end-editor,代码行数:30,代码来源:class-fee.php

示例2: edit_action

function edit_action($id)
{
    edit_post($id);
    $posts = get_all_posts();
    $html = render_template('View/Templates/admin.php', array('posts' => $posts));
    return $html;
}
开发者ID:JuriZurakovski,项目名称:2KTVRp2015,代码行数:7,代码来源:controller.php

示例3: test_edit_post

 /**
  * Tests the controller function that expects slashed data
  *
  */
 function test_edit_post()
 {
     $id = $this->factory->post->create();
     $_POST = array();
     $_POST['post_ID'] = $id;
     $_POST['post_title'] = $this->slash_1;
     $_POST['content'] = $this->slash_5;
     $_POST['excerpt'] = $this->slash_7;
     $_POST = add_magic_quotes($_POST);
     // the edit_post() function will strip slashes
     $post_id = edit_post();
     $post = get_post($post_id);
     $this->assertEquals($this->slash_1, $post->post_title);
     $this->assertEquals($this->slash_5, $post->post_content);
     $this->assertEquals($this->slash_7, $post->post_excerpt);
     $_POST = array();
     $_POST['post_ID'] = $id;
     $_POST['post_title'] = $this->slash_2;
     $_POST['content'] = $this->slash_4;
     $_POST['excerpt'] = $this->slash_6;
     $_POST = add_magic_quotes($_POST);
     $post_id = edit_post();
     $post = get_post($post_id);
     $this->assertEquals($this->slash_2, $post->post_title);
     $this->assertEquals($this->slash_4, $post->post_content);
     $this->assertEquals($this->slash_6, $post->post_excerpt);
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:31,代码来源:slashes.php

示例4: test_edit_post

 /**
  * Tests the controller function that expects slashed data
  *
  */
 function test_edit_post()
 {
     $id = self::factory()->post->create();
     if (function_exists('wp_add_post_meta')) {
         $meta_1 = wp_add_post_meta($id, 'slash_test_1', 'foo');
         $meta_2 = wp_add_post_meta($id, 'slash_test_2', 'foo');
         $meta_3 = wp_add_post_meta($id, 'slash_test_3', 'foo');
     } else {
         // expects slashed data
         $meta_1 = add_post_meta($id, 'slash_test_1', addslashes('foo'));
         $meta_2 = add_post_meta($id, 'slash_test_2', addslashes('foo'));
         $meta_3 = add_post_meta($id, 'slash_test_3', addslashes('foo'));
     }
     $_POST = array();
     $_POST['post_ID'] = $id;
     $_POST['metakeyselect'] = '#NONE#';
     $_POST['metakeyinput'] = 'slash_test_0';
     $_POST['metavalue'] = $this->slash_6;
     $_POST['meta'] = array($meta_1 => array('key' => 'slash_test_1', 'value' => $this->slash_1), $meta_2 => array('key' => 'slash_test_2', 'value' => $this->slash_3), $meta_3 => array('key' => 'slash_test_3', 'value' => $this->slash_4));
     $_POST = add_magic_quotes($_POST);
     // the edit_post() function will strip slashes
     edit_post();
     $post = get_post($id);
     $this->assertEquals($this->slash_6, get_post_meta($id, 'slash_test_0', true));
     $this->assertEquals($this->slash_1, get_post_meta($id, 'slash_test_1', true));
     $this->assertEquals($this->slash_3, get_post_meta($id, 'slash_test_2', true));
     $this->assertEquals($this->slash_4, get_post_meta($id, 'slash_test_3', true));
     $_POST = array();
     $_POST['post_ID'] = $id;
     $_POST['metakeyselect'] = '#NONE#';
     $_POST['metakeyinput'] = 'slash_test_0';
     $_POST['metavalue'] = $this->slash_7;
     $_POST['meta'] = array($meta_1 => array('key' => 'slash_test_1', 'value' => $this->slash_2), $meta_2 => array('key' => 'slash_test_2', 'value' => $this->slash_4), $meta_3 => array('key' => 'slash_test_3', 'value' => $this->slash_5));
     $_POST = add_magic_quotes($_POST);
     // the edit_post() function will strip slashes
     edit_post();
     $post = get_post($id);
     $this->assertEquals($this->slash_2, get_post_meta($id, 'slash_test_1', true));
     $this->assertEquals($this->slash_4, get_post_meta($id, 'slash_test_2', true));
     $this->assertEquals($this->slash_5, get_post_meta($id, 'slash_test_3', true));
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:45,代码来源:slashes.php

示例5: callback

 function callback($path = '', $blog_id = 0, $post_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     $args = $this->query_args();
     $input = $this->input(false);
     if (!is_array($input) || !$input) {
         return new WP_Error('invalid_input', 'Invalid request input', 400);
     }
     $post = get_post($post_id);
     if (!$post || is_wp_error($post)) {
         return new WP_Error('unknown_post', 'Unknown post', 404);
     }
     if (!current_user_can('edit_post', $post->ID)) {
         return new WP_Error('unauthorized', 'User cannot edit post', 403);
     }
     $post_data = array('post_ID' => $post_id, 'post_title' => $input['title'], 'post_content' => $input['content'], 'post_excerpt' => $input['excerpt']);
     $preview_url = add_query_arg('preview', 'true', get_permalink($post->ID));
     if (!wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) {
         // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
         $auto_ID = edit_post(wp_slash($post_data));
     } else {
         // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user.
         $auto_ID = wp_create_post_autosave(wp_slash($post_data));
         $nonce = wp_create_nonce('post_preview_' . $post->ID);
         $preview_url = add_query_arg(array('preview_id' => $auto_ID, 'preview_nonce' => $nonce), $preview_url);
     }
     $updated_post = get_post($auto_ID);
     if ($updated_post && $updated_post->ID && $updated_post->post_modified) {
         return array('ID' => $auto_ID, 'post_ID' => $post->ID, 'modified' => $this->format_date($updated_post->post_modified), 'preview_URL' => $preview_url);
     } else {
         return new WP_Error('autosave_error', __('Autosave encountered an unexpected error', 'jetpack'), 500);
     }
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:36,代码来源:class.wpcom-json-api-autosave-post-v1-1-endpoint.php

示例6: edit_post

         $data['parent_id'] = $data['post_parent'];
     }
     // status
     if (isset($data['keep_private']) && 'private' == $data['keep_private']) {
         $data['post_status'] = 'private';
     } else {
         $data['post_status'] = $data['_status'];
     }
     if (empty($data['comment_status'])) {
         $data['comment_status'] = 'closed';
     }
     if (empty($data['ping_status'])) {
         $data['ping_status'] = 'closed';
     }
     // update the post
     edit_post();
     $post = array();
     if ('page' == $_POST['post_type']) {
         $post[] = get_post($_POST['post_ID']);
         page_rows($post);
     } elseif ('post' == $_POST['post_type']) {
         $mode = $_POST['post_view'];
         $post[] = get_post($_POST['post_ID']);
         post_rows($post);
     }
     exit;
     break;
 case 'inline-save-tax':
     check_ajax_referer('taxinlineeditnonce', '_inline_edit');
     if (!current_user_can('manage_categories')) {
         die(__('Cheatin’ uh?'));
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php

示例7: wp_ajax_wp_fullscreen_save_post

function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = $post_type = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    if ($post) {
        $post_type = $post->post_type;
    } elseif (isset($_POST['post_type']) && post_type_exists($_POST['post_type'])) {
        $post_type = $_POST['post_type'];
    }
    check_ajax_referer('update-' . $post_type . '_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        if ($post_id->get_error_message()) {
            $message = $post_id->get_error_message();
        } else {
            $message = __('Save failed');
        }
        echo json_encode(array('message' => $message, 'last_edited' => ''));
        wp_die();
    } else {
        $message = __('Saved.');
    }
    if ($post) {
        $last_date = mysql2date(get_option('date_format'), $post->post_modified);
        $last_time = mysql2date(get_option('time_format'), $post->post_modified);
    } else {
        $last_date = date_i18n(get_option('date_format'));
        $last_time = date_i18n(get_option('time_format'));
    }
    if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
        $last_user = get_userdata($last_id);
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    echo json_encode(array('message' => $message, 'last_edited' => $last_edited));
    wp_die();
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:41,代码来源:ajax-actions.php

示例8: update_content

 /**
  * Default handling for updating content types.  This should be overridden if special handling is needed
  *
  * @param int $post_ID
  * @param array $post_data
  */
 public function update_content($post_ID, $post_data)
 {
     $page_ID = edit_post($post_data);
     if (isset($_POST['wp-preview']) && $_POST['wp-preview'] == 'dopreview') {
         wp_redirect(get_permalink($post_ID));
         exit;
     }
     $this->redirect_content($page_ID);
 }
开发者ID:voceconnect,项目名称:cms-press,代码行数:15,代码来源:cp-custom-content-handler-base.php

示例9: wp_autosave

/**
 * Save a post submitted with XHR
 *
 * Intended for use with heartbeat and autosave.js
 *
 * @since 3.9.0
 *
 * @param array $post_data Associative array of the submitted post data.
 * @return mixed The value 0 or WP_Error on failure. The saved post ID on success.
 *               The ID can be the draft post_id or the autosave revision post_id.
 */
function wp_autosave($post_data)
{
    // Back-compat
    if (!defined('DOING_AUTOSAVE')) {
        define('DOING_AUTOSAVE', true);
    }
    $post_id = (int) $post_data['post_id'];
    $post_data['ID'] = $post_data['post_ID'] = $post_id;
    if (false === wp_verify_nonce($post_data['_wpnonce'], 'update-post_' . $post_id)) {
        return new WP_Error('invalid_nonce', __('Error while saving.'));
    }
    $post = get_post($post_id);
    if (!current_user_can('edit_post', $post->ID)) {
        return new WP_Error('edit_posts', __('Sorry, you are not allowed to edit this item.'));
    }
    if ('auto-draft' == $post->post_status) {
        $post_data['post_status'] = 'draft';
    }
    if ($post_data['post_type'] != 'page' && !empty($post_data['catslist'])) {
        $post_data['post_category'] = explode(',', $post_data['catslist']);
    }
    if (!wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) {
        // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
        return edit_post(wp_slash($post_data));
    } else {
        // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user.
        return wp_create_post_autosave(wp_slash($post_data));
    }
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:40,代码来源:post.php

示例10: enqueue_comment_hotkeys_js

         enqueue_comment_hotkeys_js();
     }
     include ABSPATH . 'wp-admin/edit-form-advanced.php';
     break;
 case 'editattachment':
     check_admin_referer('update-post_' . $post_id);
     // Don't let these be changed
     unset($_POST['guid']);
     $_POST['post_type'] = 'attachment';
     // Update the thumbnail filename
     $newmeta = wp_get_attachment_metadata($post_id, true);
     $newmeta['thumb'] = $_POST['thumb'];
     wp_update_attachment_metadata($post_id, $newmeta);
 case 'editpost':
     check_admin_referer('update-post_' . $post_id);
     $post_id = edit_post();
     // Session cookie flag that the post was saved
     if (isset($_COOKIE['wp-saving-post']) && $_COOKIE['wp-saving-post'] === $post_id . '-check') {
         setcookie('wp-saving-post', $post_id . '-saved', time() + DAY_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, is_ssl());
     }
     redirect_post($post_id);
     // Send user on their way while we keep working
     exit;
 case 'trash':
     check_admin_referer('trash-post_' . $post_id);
     if (!$post) {
         wp_die(__('The item you are trying to move to the Trash no longer exists.'));
     }
     if (!$post_type_object) {
         wp_die(__('Unknown post type.'));
     }
开发者ID:pbearne,项目名称:contrib2core,代码行数:31,代码来源:post.php

示例11: post_preview

/**
 * Save draft or manually autosave for showing preview.
 *
 * @package WordPress
 * @since 2.7
 *
 * @uses wp_write_post()
 * @uses edit_post()
 * @uses get_post()
 * @uses current_user_can()
 * @uses wp_create_post_autosave()
 *
 * @return str URL to redirect to show the preview
 */
function post_preview()
{
    $post_ID = (int) $_POST['post_ID'];
    if ($post_ID < 1) {
        wp_die(__('Preview not available. Please save as a draft first.'));
    }
    if (isset($_POST['catslist'])) {
        $_POST['post_category'] = explode(",", $_POST['catslist']);
    }
    if (isset($_POST['tags_input'])) {
        $_POST['tags_input'] = explode(",", $_POST['tags_input']);
    }
    if ($_POST['post_type'] == 'page' || empty($_POST['post_category'])) {
        unset($_POST['post_category']);
    }
    $_POST['ID'] = $post_ID;
    $post = get_post($post_ID);
    if ('page' == $post->post_type) {
        if (!current_user_can('edit_page', $post_ID)) {
            wp_die(__('You are not allowed to edit this page.'));
        }
    } else {
        if (!current_user_can('edit_post', $post_ID)) {
            wp_die(__('You are not allowed to edit this post.'));
        }
    }
    if ('draft' == $post->post_status) {
        $id = edit_post();
    } else {
        // Non drafts are not overwritten.  The autosave is stored in a special post revision.
        $id = wp_create_post_autosave($post->ID);
        if (!is_wp_error($id)) {
            $id = $post->ID;
        }
    }
    if (is_wp_error($id)) {
        wp_die($id->get_error_message());
    }
    if ($_POST['post_status'] == 'draft') {
        $url = add_query_arg('preview', 'true', get_permalink($id));
    } else {
        $nonce = wp_create_nonce('post_preview_' . $id);
        $url = add_query_arg(array('preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce), get_permalink($id));
    }
    return $url;
}
开发者ID:schr,项目名称:wordpress,代码行数:60,代码来源:post.php

示例12: from

 $url = from($_REQUEST, 'url');
 $content = from($_REQUEST, 'content');
 $oldfile = from($_REQUEST, 'oldfile');
 $destination = from($_GET, 'destination');
 $description = from($_REQUEST, 'description');
 $date = from($_REQUEST, 'date');
 $time = from($_REQUEST, 'time');
 $dateTime = null;
 if ($date !== null && $time !== null) {
     $dateTime = $date . ' ' . $time;
 }
 if ($proper && !empty($title) && !empty($tag) && !empty($content)) {
     if (empty($url)) {
         $url = $title;
     }
     edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $fi, $vid);
 } else {
     $message['error'] = '';
     if (empty($title)) {
         $message['error'] .= '<li>Title field is required.</li>';
     }
     if (empty($tag)) {
         $message['error'] .= '<li>Tag field is required.</li>';
     }
     if (empty($content)) {
         $message['error'] .= '<li>Content field is required.</li>';
     }
     if (!$proper) {
         $message['error'] .= '<li>CSRF Token not correct.</li>';
     }
     config('views.root', 'system/admin/views');
开发者ID:EricGhildyal,项目名称:ergh.co-Backend,代码行数:31,代码来源:htmly.php

示例13: trim

    $contents = trim($_POST['contents']);
    if (empty($title)) {
        $errors[] = "You need to supply a title.";
    } else {
        if (strlen($title) > 255) {
            $errors[] = "The title cannot be longer than 255 characters.";
        }
    }
    if (empty($contents)) {
        $errors[] = "You need to supply some text.";
    }
    if (!category_exits('id', $_POST['category'])) {
        $errors[] = "The category does not exit.";
    }
    if (empty($errors)) {
        edit_post($_GET['id'], $title, $contents, $_POST['category']);
        Header("Location: index.php?id={$post[0]['post_id']}");
        die;
    }
}
?>

<html>
	<head>
		<style>
		   label{display : block; }
		</style>
		
	    <title>Edit a post</title>
	</head>
	
开发者ID:Chanpa-Majumder,项目名称:Blogsite,代码行数:30,代码来源:edit_post.php

示例14: isset

$uid = $_SESSION['uid'];
$old_cid = isset($_POST['old_cid']) ? $_POST['old_cid'] : $post['Course_ID'];
$old_week = isset($_POST['old_week']) ? $_POST['old_week'] : $post['Post_Week'];
$old_title = isset($_POST['old_title']) ? $_POST['old_title'] : $post['Post_Title'];
$old_url = isset($_POST['old_url']) ? $_POST['old_url'] : $post['Post_URL'];
$old_body = isset($_POST['old_body']) ? $_POST['old_body'] : $post['Post_Question'];
$old_answer = isset($_POST['old_answer']) ? $_POST['old_answer'] : $post['Post_Answer'];
$cid = isset($_POST['cid']) ? $_POST['cid'] : '';
$week = isset($_POST['week']) ? $_POST['week'] : '';
$title = isset($_POST['title']) ? $_POST['title'] : '';
$url = isset($_POST['url']) ? $_POST['url'] : '';
$body = isset($_POST['body']) ? $_POST['body'] : '';
$answer = isset($_POST['answer']) ? $_POST['answer'] : '';
if (isset($_POST['submit'])) {
    if ($uid == $post['User_ID'] || $_SESSION['rid'] == 1 || $_SESSION['rid'] == 3) {
        edit_post($_POST['pid'], $cid, $week, $title, $url, $body, $answer);
        sleep(1);
        header('location: ' . currentURL() . '?p=question/' . $url);
        print 'Post edited. Click <a href="?p=post">here</a> to view posts';
    } else {
        print 'Not authorized';
    }
}
?>
<link rel="stylesheet" type="text/css" href="markitup/skins/markitup/style.css" />
<link rel="stylesheet" type="text/css" href="markitup/sets/html/style.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="markitup/jquery.markitup.js"></script>
<script type="text/javascript" src="markitup/sets/html/set.js"></script>
<script language="javascript">
$(document).ready(function()	{
开发者ID:khanhnnvn,项目名称:OKMS,代码行数:31,代码来源:edit.php

示例15: update_content

 /**
  * Default handling for updating content types.  This should be overridden if special handling is needed
  *
  * @param int $post_ID
  * @param array $post_data
  */
 public function update_content($post_ID, $post_data)
 {
     $page_ID = edit_post($post_data);
     $this->redirect_content($page_ID);
 }
开发者ID:andru,项目名称:cms-press,代码行数:11,代码来源:cp-custom-content-handler-base.php


注:本文中的edit_post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。