本文整理汇总了PHP中wp_get_post_autosave函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_post_autosave函数的具体用法?PHP wp_get_post_autosave怎么用?PHP wp_get_post_autosave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_post_autosave函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: fw_get_db_post_option
/**
* Get post option value from the database
*
* @param null|int $post_id
* @param string|null $option_id Specific option id (accepts multikey). null - all options
* @param null|mixed $default_value If no option found in the database, this value will be returned
* @param null|bool $get_original_value Original value is that with no translations and other changes
*
* @return mixed|null
*/
function fw_get_db_post_option($post_id = null, $option_id = null, $default_value = null, $get_original_value = null)
{
if (!$post_id) {
/** @var WP_Post $post */
global $post;
if (!$post) {
return $default_value;
} else {
$post_id = $post->ID;
}
/**
* Check if is Preview and use the preview post_id instead of real/current post id
*
* Note: WordPress changes the global $post content on preview:
* 1. https://github.com/WordPress/WordPress/blob/2096b451c704715db3c4faf699a1184260deade9/wp-includes/query.php#L3573-L3583
* 2. https://github.com/WordPress/WordPress/blob/4a31dd6fe8b774d56f901a29e72dcf9523e9ce85/wp-includes/revision.php#L485-L528
*/
if (is_preview()) {
$preview = wp_get_post_autosave($post->ID);
if (is_object($preview)) {
$post_id = $preview->ID;
}
}
}
$option_id = 'fw_options' . ($option_id !== null ? '/' . $option_id : '');
return FW_WP_Meta::get('post', $post_id, $option_id, $default_value, $get_original_value);
}
开发者ID:vonsuu,项目名称:Unyson,代码行数:37,代码来源:database.php
示例2: acf_filter_post_id
function acf_filter_post_id($post_id)
{
// set post_id to global
if (!$post_id) {
global $post;
if ($post) {
$post_id = $post->ID;
}
}
// allow for option == options
if ($post_id == "option") {
$post_id = "options";
}
/*
* Override for preview
*
* If the $_GET['preview_id'] is set, then the user wants to see the preview data.
* There is also the case of previewing a page with post_id = 1, but using get_field
* to load data from another post_id.
* In this case, we need to make sure that the autosave revision is actually related
* to the $post_id variable. If they match, then the autosave data will be used, otherwise,
* the user wants to load data from a completely different post_id
*/
if (isset($_GET['preview_id'])) {
$autosave = wp_get_post_autosave($_GET['preview_id']);
if ($autosave->post_parent == $post_id) {
$post_id = $autosave->ID;
}
}
// return
return $post_id;
}
开发者ID:adrian-sowinski,项目名称:fotos,代码行数:32,代码来源:api.php
示例3: post_revisions
function post_revisions()
{
global $post, $current_user, $role;
if ($this->WikiHelper->is_wiki('front_end_check')) {
$wpw_options = get_option('wpw_options');
$revisions = get_posts('post_status=any&post_type=revision&post_parent=' . $post->ID . '&numberposts=' . $wpw_options['number_of_revisions']);
//Most recent revision
$date = date(__('m/d/y g:i a'), mktime($post->post_modified));
$author = $this->WikiHelper->get_author($post);
$latest_revision = sprintf(__('Latest revision (@ %1s by %2s)'), $post->post_modified, $author);
$output = '<a href="' . get_permalink($post->ID) . '">' . $latest_revision . '</a><br />';
//If we have revisions...
if ($revisions) {
//Loop through them!
$count = 0;
foreach ($revisions as $revision) {
if (@wp_get_post_autosave($post->ID)->ID != $revision->ID) {
$author = $this->WikiHelper->get_author($revision);
$date = date(__('m/d/y g:i a'), mktime($revision->post_modified));
$revision_title = sprintf(__('Revision @ %1s by %2s'), $date, $author);
$output .= '<a href="' . get_permalink($post->ID) . '?revision=' . $revision->ID . '">' . $revision_title . '</a><br />';
$count++;
}
}
}
return $output;
}
}
开发者ID:radgeek,项目名称:WikiWikiWordPress,代码行数:28,代码来源:wiki_pages.php
示例4: request_handler
/**
* Request handler for XML.
*/
public function request_handler()
{
if (get_query_var('xml')) {
// Sanitize our article ID
$id = get_the_ID();
// If we don't have an Article, get out
if (empty($id)) {
wp_die(__('No article found.', $this->i18n));
}
// If we're not debugging, turn off errors
if (!$this->debug) {
$display_errors = ini_get('display_errors');
ini_set('display_errors', 0);
}
// Default Article
$article = null;
// If we're published, grab the published article
if (!is_preview()) {
$article = get_post($id);
} else {
if (is_preview() && current_user_can('edit_post', $id)) {
$article = get_post($id);
/* Drafts and sometimes pending statuses append a preview_id on the
end of the preview URL. While we're building the XML download link
we do a check for that, and set this query arg if the preview_id is
present. */
if (isset($_GET['autosave'])) {
$article = wp_get_post_autosave($id);
}
}
}
// Ensure we have an article
if (empty($article)) {
wp_die(__('Required article first.', $this->i18n));
}
// Get our XML ready and stored
$this->generate_xml($article);
// Send our headers
if (!$_GET['screen']) {
$this->set_headers($article);
}
// Send the file
echo $this->xml;
exit;
}
}
开发者ID:nameofname,项目名称:momo-wordpress-theme,代码行数:49,代码来源:anno-xml-download.php
示例5: wp_get_post_autosave
public function &get($postID = false, $type = "post")
{
if (!$postID) {
global $post;
if ($post) {
$postID = $post->ID;
$type = $post->post_type;
} else {
return $this->empty;
}
}
if (isset($this->cache[$postID])) {
return $this->cache[$postID];
}
$db = false;
if ($postID) {
$metaID = $postID;
if (!empty($this->preview) && $postID == $this->preview) {
// preview mode so we use meta stored in the autosave
$preview = wp_get_post_autosave($postID);
if (!empty($preview->ID)) {
$metaID = $preview->ID;
}
}
$db = maybe_unserialize(get_post_meta($metaID, PE_THEME_META, true));
}
if (!isset($this->defaults[$type])) {
$this->getDefaultValues($type);
}
if ($db) {
$cache = new stdClass();
$empty = array();
foreach ($this->keys[$type] as $key) {
if (!isset($db->{$key})) {
$db->{$key} = array();
}
$cache->{$key} = (object) array_merge((array) $this->defaults[$type]->{$key}, (array) $db->{$key});
}
} else {
$cache =& $this->defaults[$type];
}
if ($postID) {
$this->cache[$postID] =& $cache;
}
return $cache;
}
开发者ID:lukesmmr,项目名称:lowconstrutores,代码行数:46,代码来源:PeThemeMeta.php
示例6: maybe_set_preview
/**
* @param array $posts
* @return array
*/
public static function maybe_set_preview($posts)
{
if (is_array($posts) && isset($_GET['preview']) && $_GET['preview'] && isset($_GET['preview_id']) && $_GET['preview_id'] && current_user_can('edit_post', $_GET['preview_id'])) {
// No need to check the nonce, that already happened in _show_post_preview on init
$preview_id = $_GET['preview_id'];
foreach ($posts as &$post) {
if (is_object($post) && $post->ID == $preview_id) {
// Based on _set_preview( $post ), but adds import_custom
$preview = wp_get_post_autosave($preview_id);
if (is_object($preview)) {
$preview = sanitize_post($preview);
$post->post_content = $preview->post_content;
$post->post_title = $preview->post_title;
$post->post_excerpt = $preview->post_excerpt;
$post->import_custom($preview_id);
add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3);
}
}
}
}
return $posts;
}
开发者ID:jarednova,项目名称:timber,代码行数:26,代码来源:PostCollection.php
示例7: update_item
/**
* Update an autosave for a post.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function update_item($request)
{
$parent = get_post($request['id']);
$autosave = wp_get_post_autosave($parent->ID, get_current_user_id());
$post_data = (array) $this->prepare_item_for_database($request);
if (!$autosave) {
$autosave_id = _wp_put_post_revision($post_data, true);
} else {
$post_data['ID'] = $autosave->ID;
/**
* Fires before an autosave is stored.
*
* @since 4.1.0
*
* @param array $new_autosave Post array - the autosave that is about to be saved.
*/
do_action('wp_creating_autosave', $post_data);
wp_update_post($post_data);
$autosave_id = $autosave->ID;
}
return $this->prepare_item_for_response(get_post($autosave_id), $request);
}
开发者ID:louis-ev,项目名称:wp-front-end-editor,代码行数:28,代码来源:class-wp-rest-post-autosave-controller.php
示例8: 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;
}
$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);
}
$autosave = wp_get_post_autosave($post->ID);
if ($autosave) {
$preview_url = add_query_arg('preview', 'true', get_permalink($post->ID));
$nonce = wp_create_nonce('post_preview_' . $post->ID);
$preview_url = add_query_arg(array('preview_id' => $auto_ID, 'preview_nonce' => $nonce), $preview_url);
return array('ID' => $autosave->ID, 'author_ID' => $autosave->post_author, 'post_ID' => $autosave->post_parent, 'title' => $autosave->post_title, 'content' => $autosave->post_content, 'excerpt' => $autosave->post_excerpt, 'preview_URL' => $preview_url, 'modified' => $this->format_date($autosave->post_modified));
} else {
return new WP_Error('not_found', 'No autosaves exist for this post', 404);
}
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:23,代码来源:class.wpcom-json-api-get-autosave-v1-1-endpoint.php
示例9: wp_create_post_autosave
/**
* Creates autosave data for the specified post from $_POST data.
*
* @package WordPress
* @subpackage Post_Revisions
* @since 2.6.0
*
* @uses _wp_translate_postdata()
* @uses _wp_post_revision_fields()
*
* @return unknown
*/
function wp_create_post_autosave($post_id)
{
$translated = _wp_translate_postdata(true);
if (is_wp_error($translated)) {
return $translated;
}
// Only store one autosave. If there is already an autosave, overwrite it.
if ($old_autosave = wp_get_post_autosave($post_id)) {
$new_autosave = _wp_post_revision_fields($_POST, true);
$new_autosave['ID'] = $old_autosave->ID;
$new_autosave['post_author'] = get_current_user_id();
return wp_update_post($new_autosave);
}
// _wp_put_post_revision() expects unescaped.
$_POST = stripslashes_deep($_POST);
// Otherwise create the new autosave as a special post revision
return _wp_put_post_revision($_POST, true);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:30,代码来源:post.php
示例10: fw_get_db_post_option
/**
* Get post option value from the database
*
* @param null|int $post_id
* @param string|null $option_id Specific option id (accepts multikey). null - all options
* @param null|mixed $default_value If no option found in the database, this value will be returned
* @param null|bool $get_original_value Original value is that with no translations and other changes
*
* @return mixed|null
*/
function fw_get_db_post_option($post_id = null, $option_id = null, $default_value = null, $get_original_value = null)
{
if (!$post_id) {
/** @var WP_Post $post */
global $post;
if (!$post) {
return $default_value;
} else {
$post_id = $post->ID;
}
/**
* Check if is Preview and use the preview post_id instead of real/current post id
*
* Note: WordPress changes the global $post content on preview:
* 1. https://github.com/WordPress/WordPress/blob/2096b451c704715db3c4faf699a1184260deade9/wp-includes/query.php#L3573-L3583
* 2. https://github.com/WordPress/WordPress/blob/4a31dd6fe8b774d56f901a29e72dcf9523e9ce85/wp-includes/revision.php#L485-L528
*/
if (is_preview() && is_object($preview = wp_get_post_autosave($post->ID))) {
$post_id = $preview->ID;
}
}
$post_type = get_post_type(($post_revision_id = wp_is_post_revision($post_id)) ? $post_revision_id : $post_id);
/**
* Before fw_db_option_storage_load() feature
* there was possible to call fw_get_db_post_option() and it worked fine
* but after v2.5.0 it's not possible anymore (it creates an infinite recursion)
* but the Slider extension does that and maybe other extensions,
* so the solution is to check if it is recursion, to not load the options array (disable the storage feature)
*/
static $recursion = array();
if (!isset($recursion[$post_type])) {
$recursion[$post_type] = false;
}
if ($recursion[$post_type]) {
/**
* Allow known post types that sure don't have options with 'fw-storage' parameter
*/
if (!in_array($post_type, array('fw-slider'))) {
trigger_error('Infinite recursion detected in post type "' . $post_type . '" options caused by ' . __FUNCTION__ . '()', E_USER_WARNING);
}
$options = array();
} else {
$recursion[$post_type] = true;
$options = fw_extract_only_options(fw()->theme->get_post_options($post_type));
$recursion[$post_type] = false;
}
if ($option_id) {
$option_id = explode('/', $option_id);
// 'option_id/sub/keys'
$_option_id = array_shift($option_id);
// 'option_id'
$sub_keys = implode('/', $option_id);
// 'sub/keys'
$option_id = $_option_id;
unset($_option_id);
$value = FW_WP_Meta::get('post', $post_id, 'fw_options/' . $option_id, null, $get_original_value);
if (isset($options[$option_id])) {
$value = fw()->backend->option_type($options[$option_id]['type'])->storage_load($option_id, $options[$option_id], $value, array('post-id' => $post_id));
}
if ($sub_keys) {
return fw_akg($sub_keys, $value, $default_value);
} else {
return is_null($value) ? $default_value : $value;
}
} else {
$value = FW_WP_Meta::get('post', $post_id, 'fw_options', $default_value, $get_original_value);
if (!is_array($value)) {
$value = array();
}
foreach ($options as $_option_id => $_option) {
$value[$_option_id] = fw()->backend->option_type($_option['type'])->storage_load($_option_id, $_option, isset($value[$_option_id]) ? $value[$_option_id] : null, array('post-id' => $post_id));
}
return $value;
}
}
开发者ID:isatrio,项目名称:Unyson,代码行数:85,代码来源:database.php
示例11: wp_create_post_autosave
/**
* Creates autosave data for the specified post from $_POST data.
*
* @package WordPress
* @subpackage Post_Revisions
* @since 2.6.0
*
* @uses _wp_translate_postdata()
* @uses _wp_post_revision_fields()
*/
function wp_create_post_autosave($post_id)
{
$translated = _wp_translate_postdata(true);
if (is_wp_error($translated)) {
return $translated;
}
// Only store one autosave. If there is already an autosave, overwrite it.
if ($old_autosave = wp_get_post_autosave($post_id)) {
$new_autosave = _wp_post_revision_fields($_POST, true);
$new_autosave['ID'] = $old_autosave->ID;
return wp_update_post($new_autosave);
}
// Otherwise create the new autosave as a special post revision
return _wp_put_post_revision($_POST, true);
}
开发者ID:schr,项目名称:wordpress,代码行数:25,代码来源:post.php
示例12: get_post_by
//.........这里部分代码省略.........
case 'publicize_URLs':
$publicize_URLs = array();
$publicize = get_post_meta($post->ID, 'publicize_results', true);
if ($publicize) {
foreach ($publicize as $service => $data) {
switch ($service) {
case 'twitter':
foreach ($data as $datum) {
$publicize_URLs[] = esc_url_raw("https://twitter.com/{$datum['user_id']}/status/{$datum['post_id']}");
}
break;
case 'fb':
foreach ($data as $datum) {
$publicize_URLs[] = esc_url_raw("https://www.facebook.com/permalink.php?story_fbid={$datum['post_id']}&id={$datum['user_id']}");
}
break;
}
}
}
$response[$key] = (array) $publicize_URLs;
break;
case 'tags':
$response[$key] = array();
$terms = wp_get_post_tags($post->ID);
foreach ($terms as $term) {
if (!empty($term->name)) {
$response[$key][$term->name] = $this->format_taxonomy($term, 'post_tag', 'display');
}
}
$response[$key] = (object) $response[$key];
break;
case 'categories':
$response[$key] = array();
$terms = wp_get_object_terms($post->ID, 'category', array('fields' => 'all'));
foreach ($terms as $term) {
if (!empty($term->name)) {
$response[$key][$term->name] = $this->format_taxonomy($term, 'category', 'display');
}
}
$response[$key] = (object) $response[$key];
break;
case 'attachments':
$response[$key] = array();
$_attachments = new WP_Query(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'posts_per_page' => '20'));
foreach ($_attachments->posts as $attachment) {
$response[$key][$attachment->ID] = $this->get_media_item_v1_1($attachment->ID);
}
$response['attachment_count'] = $_attachments->found_posts;
$response[$key] = (object) $response[$key];
break;
case 'metadata':
// (array|false)
$metadata = array();
foreach ((array) has_meta($post_id) as $meta) {
// Don't expose protected fields.
$show = false;
if ($this->is_metadata_public($meta['meta_key'])) {
$show = true;
}
if (current_user_can('edit_post_meta', $post_id, $meta['meta_key'])) {
$show = true;
}
if (!$show) {
continue;
}
$metadata[] = array('id' => $meta['meta_id'], 'key' => $meta['meta_key'], 'value' => maybe_unserialize($meta['meta_value']));
}
if (!empty($metadata)) {
$response[$key] = $metadata;
} else {
$response[$key] = false;
}
break;
case 'meta':
$response[$key] = (object) array('links' => (object) array('self' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID), 'help' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'help'), 'site' => (string) $this->get_site_link($this->api->get_blog_id_for_output()), 'replies' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'replies/'), 'likes' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'likes/')));
// add autosave link if a more recent autosave exists
if ('edit' === $context) {
$autosave = wp_get_post_autosave($post_id);
if ($autosave && $autosave->post_modified > $post->post_modified) {
$response[$key]->links->autosave = (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID) . '/autosave';
}
}
break;
case 'capabilities':
$response[$key] = $capabilities;
break;
case 'other_URLs':
$other_urls = array();
if ('publish' !== $post->post_status) {
$other_urls = $this->get_post_permalink_suggestions($post->ID, $post->post_title);
}
$response[$key] = (object) $other_urls;
break;
}
}
// WPCOM_JSON_API_Post_Endpoint::find_featured_worthy_media( $post );
// $response['featured_media'] = self::find_featured_media( $response );
unset($GLOBALS['post']);
return $response;
}
开发者ID:jfbelisle,项目名称:magexpress,代码行数:101,代码来源:class.wpcom-json-api-post-v1-1-endpoint.php
示例13: wp_create_post_autosave
/**
* Creates autosave data for the specified post from $_POST data.
*
* @package WordPress
* @subpackage Post_Revisions
* @since 2.6.0
*
* @param mixed $post_data Associative array containing the post data or int post ID.
* @return mixed The autosave revision ID. WP_Error or 0 on error.
*/
function wp_create_post_autosave($post_data)
{
if (is_numeric($post_data)) {
$post_id = $post_data;
$post_data = $_POST;
} else {
$post_id = (int) $post_data['post_ID'];
}
$post_data = _wp_translate_postdata(true, $post_data);
if (is_wp_error($post_data)) {
return $post_data;
}
$post_author = get_current_user_id();
// Store one autosave per author. If there is already an autosave, overwrite it.
if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) {
$new_autosave = _wp_post_revision_data($post_data, true);
$new_autosave['ID'] = $old_autosave->ID;
$new_autosave['post_author'] = $post_author;
// If the new autosave has the same content as the post, delete the autosave.
$post = get_post($post_id);
$autosave_is_different = false;
foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields($post))) as $field) {
if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->{$field})) {
$autosave_is_different = true;
break;
}
}
if (!$autosave_is_different) {
wp_delete_post_revision($old_autosave->ID);
return 0;
}
/**
* Fires before an autosave is stored.
*
* @since 4.1.0
*
* @param array $new_autosave Post array - the autosave that is about to be saved.
*/
do_action('wp_creating_autosave', $new_autosave);
return wp_update_post($new_autosave);
}
// _wp_put_post_revision() expects unescaped.
$post_data = wp_unslash($post_data);
// Otherwise create the new autosave as a special post revision
return _wp_put_post_revision($post_data, true);
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:56,代码来源:post.php
示例14: wp_list_post_revisions
/**
* Display list of a post's revisions.
*
* Can output either a UL with edit links or a TABLE with diff interface, and
* restore action links.
*
* Second argument controls parameters:
* (bool) parent : include the parent (the "Current Revision") in the list.
* (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table'
* outputs TABLE with UI.
* (int) right : what revision is currently being viewed - used in
* form-table format.
* (int) left : what revision is currently being diffed against right -
* used in form-table format.
*
* @package WordPress
* @subpackage Post_Revisions
* @since 2.6.0
*
* @uses wp_get_post_revisions()
* @uses wp_post_revision_title()
* @uses get_edit_post_link()
* @uses get_the_author_meta()
*
* @todo split into two functions (list, form-table) ?
*
* @param int|object $post_id Post ID or post object.
* @param string|array $args See description {@link wp_parse_args()}.
* @return null
*/
function wp_list_post_revisions($post_id = 0, $args = null)
{
if (!($post = get_post($post_id))) {
return;
}
$defaults = array('parent' => false, 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all');
extract(wp_parse_args($args, $defaults), EXTR_SKIP);
switch ($type) {
case 'autosave':
if (!($autosave = wp_get_post_autosave($post->ID))) {
return;
}
$revisions = array($autosave);
break;
case 'revision':
// just revisions - remove autosave later
// just revisions - remove autosave later
case 'all':
default:
if (!($revisions = wp_get_post_revisions($post->ID))) {
return;
}
break;
}
/* translators: post revision: 1: when, 2: author name */
$titlef = _x('%1$s by %2$s', 'post revision');
if ($parent) {
array_unshift($revisions, $post);
}
$rows = $right_checked = '';
$class = false;
$can_edit_post = current_user_can('edit_post', $post->ID);
foreach ($revisions as $revision) {
if (!current_user_can('read_post', $revision->ID)) {
continue;
}
if ('revision' === $type && wp_is_post_autosave($revision)) {
continue;
}
$date = wp_post_revision_title($revision);
$name = get_the_author_meta('display_name', $revision->post_author);
if ('form-table' == $format) {
if ($left) {
$left_checked = $left == $revision->ID ? ' checked="checked"' : '';
} else {
$left_checked = $right_checked ? ' checked="checked"' : '';
}
// [sic] (the next one)
$right_checked = $right == $revision->ID ? ' checked="checked"' : '';
$class = $class ? '' : " class='alternate'";
if ($post->ID != $revision->ID && $can_edit_post) {
$actions = '<a href="' . wp_nonce_url(add_query_arg(array('revision' => $revision->ID, 'action' => 'restore')), "restore-post_{$post->ID}|{$revision->ID}") . '">' . __('Restore') . '</a>';
} else {
$actions = '';
}
$rows .= "<tr{$class}>\n";
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='{$revision->ID}'{$left_checked} /></th>\n";
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='{$revision->ID}'{$right_checked} /></th>\n";
$rows .= "\t<td>{$date}</td>\n";
$rows .= "\t<td>{$name}</td>\n";
$rows .= "\t<td class='action-links'>{$actions}</td>\n";
$rows .= "</tr>\n";
} else {
$title = sprintf($titlef, $date, $name);
$rows .= "\t<li>{$title}</li>\n";
}
}
if ('form-table' == $format) {
?>
//.........这里部分代码省略.........
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:101,代码来源:post-template.php
示例15: _set_preview
/**
* Sets up the post object for preview based on the post autosave.
*
* @since 2.7.0
* @access private
*
* @param WP_Post $post
* @return WP_Post|false
*/
function _set_preview($post)
{
if (!is_object($post)) {
return $post;
}
$preview = wp_get_post_autosave($post->ID);
if (!is_object($preview)) {
return $post;
}
$preview = sanitize_post($preview);
$post->post_content = $preview->post_content;
$post->post_title = $preview->post_title;
$post->post_excerpt = $preview->post_excerpt;
add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3);
return $post;
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:25,代码来源:revision.php
示例16: get_autosave_notice
function get_autosave_notice()
{
global $post;
if ('auto-draft' == $post->post_status) {
$autosave = false;
} else {
$autosave = wp_get_post_autosave($post->ID);
}
// Detect if there exists an autosave newer than the post and if that autosave is different than the post
if ($autosave && mysql2date('U', $autosave->post_modified_gmt, false) > mysql2date('U', $post->post_modified_gmt, false)) {
foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
if (normalize_whitespace($autosave->{$autosave_field}) !== normalize_whitespace($post->{$autosave_field})) {
return sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>'), get_edit_post_link($autosave->ID));
}
}
// If this autosave isn't different from the current post, begone.
wp_delete_post_revision($autosave->ID);
}
return false;
}
开发者ID:foxpcteam,项目名称:wp-front-end-editor,代码行数:20,代码来源:class-fee.php
示例17: get_meta
public function get_meta()
{
$meta = (object) array('links' => (object) array('self' => (string) $this->get_post_link(), 'help' => (string) $this->get_post_link('help'), 'site' => (string) $this->get_site_link(), 'replies' => (string) $this->get_post_link('replies/'), 'likes' => (string) $this->get_post_link('likes/')));
// add autosave link if a more recent autosave exists
if ('edit' === $this->context) {
$autosave = wp_get_post_autosave($this->post->ID);
if ($autosave && $autosave->post_modified > $this->post->post_modified) {
$meta->links->autosave = (string) $this->get_post_link() . '/autosave';
}
}
return $meta;
}
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:12,代码来源:class.json-api-post-base.php
示例18: _get_post_revisions_meta
private function _get_post_revisions_meta($post_id, $key, $type = 'revision')
{
if (!($post = get_post($post_id))) {
return array();
}
$revisions = array();
switch ($type) {
case 'autosave':
if (function_exists('wp_get_post_autosave')) {
if ($autosave = wp_get_post_autosave($post->ID)) {
$revisions = array($autosave);
}
}
break;
case 'revision':
// just revisions - remove autosave later
// just revisions - remove autosave later
case 'all':
default:
if (function_exists('wp_get_post_revisions')) {
if (!($revisions = wp_get_post_revisions($post->ID))) {
$revisions = array();
}
}
break;
}
$meta_vals = array();
foreach ($revisions as $revision) {
$meta_vals[] = $this->_get_post_meta($revision->ID, $key);
}
return $meta_vals;
}
开发者ID:Naguchi,项目名称:hokohoi,代码行数:32,代码来源:simple-tweet.php
示例19: calcParams
/**
* calc section params by keyword
* @param string $keyword
* @return array
*/
protected function calcParams($keyword)
{
$params = array('title' => 0, 'h1' => 0, 'h2' => 0, 'h3' => 0, 'bold' => 0, 'italic' => 0, 'underline' => 0, 'alt' => 0);
$title = wtb_seo_helper::strtolower($this->post['title']);
$content = $this->post['content'];
$html = str_get_html($content);
// h1
if (strpos($title, $keyword) !== false) {
$params['h1'] = 1;
}
if ($html) {
foreach ($html->find('h1') as $h1) {
if (strpos($h1->plaintext, $keyword) !== false) {
$params['h1'] = 1;
break;
}
}
// h2
foreach ($html->find('h2') as $h2) {
if (strpos($h2->plaintext, $keyword) !== false) {
$params['h2'] = 1;
break;
}
}
// h3
foreach ($html->find('h3') as $h3) {
if (strpos($h3->plaintext, $keyword) !== false) {
$params['h3'] = 1;
break;
}
}
// bold
foreach ($html->find('strong') as $strong) {
if (strpos($strong->plaintext, $keyword) !== false) {
$params['bold'] = 1;
break;
}
}
foreach ($html->find('b') as $strong) {
if (strpos($strong->plaintext, $keyword) !== false) {
$params['bold'] = 1;
break;
}
}
// italic
foreach ($html->find('i') as $strong) {
if (strpos($strong->plaintext, $keyword) !== false) {
$params['italic'] = 1;
break;
}
}
foreach ($html->find('em') as $strong) {
if (strpos($strong->plaintext, $keyword) !== false) {
$params['italic'] = 1;
break;
}
}
// underline
foreach ($html->find('u') as $strong) {
if (strpos($strong->plaintext, $keyword) !== false) {
$params['underline'] = 1;
break;
}
}
foreach ($html->find('span') as $strong) {
if (strpos($strong->__toString(), 'text-decoration: underline') !== false and strpos($strong->plaintext, $keyword) !== false) {
$params['underline'] = 1;
break;
}
}
// img alt
foreach ($html->find('img') as $img) {
// because bug on vendor lib
$imgAsString = $img->__toString();
if (strpos($imgAsString, $keyword) !== false and strpos($imgAsString, $keyword, (int) strpos($imgAsString, ' alt=')) > (int) strpos($imgAsString, ' alt=')) {
$params['alt'] = 1;
break;
}
}
}
// title
$post = wp_get_post_autosave($this->post['id']);
if (!$post) {
$post = get_post($this->post['id']);
}
// try to simulate wp_title()
if (isset($post->post_title)) {
$metaTitle = apply_filters('single_post_title', $this->post['title'], $post);
} else {
$metaTitle = apply_filters('single_post_title', $this->post['title']);
}
$t_sep = '%WP_TITILE_SEP%';
$prefix = '';
if (!empty($metaTitle)) {
$prefix = " | ";
//.........这里部分代码省略.........
开发者ID:repupress,项目名称:onpage-post-seo-wordpress-plugin,代码行数:101,代码来源:calculator.php
示例20: wp_die
* @package WordPress
* @subpackage ALO EasyMail plugin
*/
include '../../../../wp-load.php';
global $wpdb;
global $user_ID;
if (!current_user_can("edit_newsletters")) {
wp_die(__('Cheatin’ uh?'));
}
check_admin_referer("alo-easymail");
$newsletter_id = isset($_GET['newsletter']) && is_numeric($_GET['newsletter']) ? (int) $_GET['newsletter'] : false;
if (!alo_em_user_can_edit_newsletter($newsletter_id)) {
wp_die(__('Cheatin’ uh?'));
}
// first, search latest autosave
$newsletter = wp_get_
|
请发表评论