本文整理汇总了PHP中wp_autosave函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_autosave函数的具体用法?PHP wp_autosave怎么用?PHP wp_autosave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_autosave函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: heartbeat_autosave
/**
* Autosave with heartbeat
*
* @since 3.9.0
*
* @param array $response The Heartbeat response.
* @param array $data The $_POST data sent.
* @return array The Heartbeat response.
*/
function heartbeat_autosave($response, $data)
{
if (!empty($data['wp_autosave'])) {
$saved = wp_autosave($data['wp_autosave']);
if (is_wp_error($saved)) {
$response['wp_autosave'] = array('success' => false, 'message' => $saved->get_error_message());
} elseif (empty($saved)) {
$response['wp_autosave'] = array('success' => false, 'message' => __('Error while saving.'));
} else {
/* translators: draft saved date format, see http://php.net/date */
$draft_saved_date_format = __('g:i:s a');
/* translators: %s: date and time */
$response['wp_autosave'] = array('success' => true, 'message' => sprintf(__('Draft saved at %s.'), date_i18n($draft_saved_date_format)));
}
}
return $response;
}
开发者ID:akalipetis,项目名称:WordPress,代码行数:26,代码来源:misc.php
示例2: filter__heartbeat_received
/**
* Filter @see heartbeat_received
* @since 1.0.1
*
* @param array $response
* @param array $data
* @param string $screen_id
*
* @return array
*/
public static function filter__heartbeat_received($response, $data, $screen_id)
{
if (false !== strpos($_SERVER['HTTP_REFERER'], 'wpglobus=off')) {
/**
* Check $_SERVER['HTTP_REFERER'] for wpglobus toggle is off because wpglobus-admin.js doesn't loaded in this mode
*/
return $response;
}
if (!empty($data['wp_autosave'])) {
if (empty($data['wp_autosave']['post_id']) || (int) $data['wp_autosave']['post_id'] == 0) {
/**
* wp_autosave may come from edit.php page
*/
return $response;
}
if (empty($data['wpglobus_heartbeat'])) {
/**
* Check for wpglobus key
*/
return $response;
}
$title_wrap = false;
$content_wrap = false;
$post_title_ext = '';
$content_ext = '';
foreach (WPGlobus::Config()->enabled_languages as $language) {
if ($language == WPGlobus::Config()->default_language) {
$post_title_ext .= WPGlobus::add_locale_marks($data['wp_autosave']['post_title'], $language);
$content_ext .= WPGlobus::add_locale_marks($data['wp_autosave']['content'], $language);
} else {
if (!empty($data['wp_autosave']['post_title_' . $language])) {
$title_wrap = true;
$post_title_ext .= WPGlobus::add_locale_marks($data['wp_autosave']['post_title_' . $language], $language);
}
if (!empty($data['wp_autosave']['content_' . $language])) {
$content_wrap = true;
$content_ext .= WPGlobus::add_locale_marks($data['wp_autosave']['content_' . $language], $language);
}
}
}
if ($title_wrap) {
$data['wp_autosave']['post_title'] = $post_title_ext;
}
if ($content_wrap) {
$data['wp_autosave']['content'] = $content_ext;
}
/**
* Filter before autosave
* @since 1.0.2
*
* @param array $data ['wp_autosave'] Array of post data.
*/
$data['wp_autosave'] = apply_filters('wpglobus_autosave_post_data', $data['wp_autosave']);
$saved = wp_autosave($data['wp_autosave']);
if (is_wp_error($saved)) {
$response['wp_autosave'] = array('success' => false, 'message' => $saved->get_error_message());
} elseif (empty($saved)) {
$response['wp_autosave'] = array('success' => false, 'message' => __('Error while saving.'));
} else {
/* translators: draft saved date format, see http://php.net/date */
$draft_saved_date_format = __('g:i:s a');
/* translators: %s: date and time */
$response['wp_autosave'] = array('success' => true, 'message' => sprintf(__('Draft saved at %s.'), date_i18n($draft_saved_date_format)));
}
}
return $response;
}
开发者ID:wpglobus,项目名称:wpglobus,代码行数:77,代码来源:class-wpglobus-filters.php
注:本文中的wp_autosave函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论