本文整理汇总了PHP中_wp_translate_postdata函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_translate_postdata函数的具体用法?PHP _wp_translate_postdata怎么用?PHP _wp_translate_postdata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_wp_translate_postdata函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save()
{
$_POST['post_type'] = SendPress_Data::email_post_type();
// Update post 37 (37!)
$my_post = _wp_translate_postdata(true);
$system_emails = SendPress_Option::base_get('system-emails');
$my_post['post_status'] = 'sp-systememail';
$my_post['post_content'] = SendPress_Data::get_sysemail_content($_POST['email_type']);
// Update the post into the database
wp_update_post($my_post);
update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']);
update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']);
update_post_meta($my_post['ID'], '_sendpress_status', 'private');
update_post_meta($my_post['ID'], '_sendpress_system', 'new');
update_post_meta($my_post['ID'], '_system_email_type', $_POST['email_type']);
update_post_meta($my_post['ID'], '_system_default', $_POST['default']);
if ($_POST['default']) {
//set default system e-mail for this type
SendPress_Data::set_system_email_default($my_post['ID'], $_POST['email_type']);
}
SendPress_Email::set_default_style($my_post['ID']);
//clear the cached file.
delete_transient('sendpress_email_html_' . $my_post['ID']);
if (!in_array($_POST['email_type'], $system_emails)) {
$system_emails[] = $_POST['email_type'];
}
SendPress_Option::base_set('system-emails', $system_emails);
SendPress_Admin::redirect('Settings_Emailedit', array('emailID' => $my_post['ID']));
//$this->save_redirect( $_POST );
}
开发者ID:pmatheus,项目名称:participacao-sitebase,代码行数:30,代码来源:class-sendpress-view-settings-systememailcreate.php
示例2: save
function save()
{
//$this->security_check();
$_POST['post_type'] = SendPress_Data::email_post_type();
// Update post 37 (37!)
$my_post = _wp_translate_postdata(true);
/*
$my_post['ID'] = $_POST['post_ID'];
$my_post['post_content'] = $_POST['content'];
$my_post['post_title'] = $_POST['post_title'];
*/
$my_post['post_status'] = 'publish';
// Update the post into the database
wp_update_post($my_post);
update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']);
update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']);
update_post_meta($my_post['ID'], '_sendpress_status', 'private');
update_post_meta($my_post['ID'], '_sendpress_system', $_POST['template_system']);
SendPress_Email::set_default_style($my_post['ID']);
//clear the cached file.
delete_transient('sendpress_email_html_' . $my_post['ID']);
if ($_POST['template_system'] == 'new') {
SendPress_Admin::redirect('Emails_Edit', array('emailID' => $my_post['ID']));
}
SendPress_Admin::redirect('Emails_Style', array('emailID' => $my_post['ID']));
//$this->save_redirect( $_POST );
}
示例3: test_order_by_priority
function test_order_by_priority()
{
$this->utils->setup_post_screen();
$post_id = $this->factory->post->create();
$post_data = $this->utils->get_post_data($post_id);
$additional1 = $this->utils->additional1;
$additional2 = $this->utils->additional2;
$post_data['ac_additional_content'][] = $additional1;
$post_data['ac_additional_content'][] = $additional2;
$_POST = _wp_translate_postdata(false, $post_data);
// saves the additional content metabox data for the post
save_metabox($post_id);
$additional = get_post_meta($post_id, '_ac_additional_content', true);
$additional1['prepend'] = '';
$additional2['append'] = '';
// additional2 has a lower priority and should come first
$expected = array($additional2, $additional1);
$this->assertNotEmpty($additional);
$this->assertEquals($expected, $additional);
}
示例4: save
function save()
{
$_POST['post_type'] = SendPress_Data::email_post_type();
// Update post 37 (37!)
$my_post = _wp_translate_postdata(true);
/*
$my_post['ID'] = $_POST['post_ID'];
$my_post['post_content'] = $_POST['content'];
$my_post['post_title'] = $_POST['post_title'];
*/
$my_post['post_status'] = 'sp-autoresponder';
// Update the post into the database
wp_update_post($my_post);
update_post_meta($my_post['ID'], '_sendpress_subject', sanitize_text_field($_POST['post_subject']));
update_post_meta($my_post['ID'], '_sendpress_template', SPNL()->validate->int($_POST['template']));
update_post_meta($my_post['ID'], '_sendpress_status', 'private');
update_post_meta($my_post['ID'], '_sendpress_system', 'new');
SendPress_Email::set_default_style($my_post['ID']);
//clear the cached file.
delete_transient('sendpress_email_html_' . $my_post['ID']);
SendPress_Admin::redirect('Emails_Edit', array('emailID' => $my_post['ID']));
//$this->save_redirect( $_POST );
}
示例5: 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);
}
示例6: 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;
}
$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_fields($_POST, true);
$new_autosave['ID'] = $old_autosave->ID;
$new_autosave['post_author'] = $post_author;
// If the new autosave is the same content as the post, delete the old autosave.
$post = get_post($post_id);
$autosave_is_different = false;
foreach (array_keys(_wp_post_revision_fields()) 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;
}
return wp_update_post($new_autosave);
}
// _wp_put_post_revision() expects unescaped.
$post_data = wp_unslash($_POST);
// Otherwise create the new autosave as a special post revision
return _wp_put_post_revision($post_data, true);
}
示例7: 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);
}
示例8: 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);
}
示例9: test__wp_translate_postdata_cap_checks_editor
function test__wp_translate_postdata_cap_checks_editor()
{
wp_set_current_user(self::$editor_id);
// Create New Draft Post
$_post_data = array();
$_post_data['post_author'] = self::$editor_id;
$_post_data['post_type'] = 'post';
$_post_data['saveasdraft'] = true;
$_results = _wp_translate_postdata(false, $_post_data);
$this->assertNotInstanceOf('WP_Error', $_results);
$this->assertEquals($_post_data['post_author'], $_results['post_author']);
$this->assertEquals('draft', $_results['post_status']);
// Publish Post
$_post_data = array();
$_post_data['post_author'] = self::$editor_id;
$_post_data['post_type'] = 'post';
$_post_data['publish'] = true;
$_results = _wp_translate_postdata(false, $_post_data);
$this->assertNotInstanceOf('WP_Error', $_results);
$this->assertEquals($_post_data['post_author'], $_results['post_author']);
$this->assertEquals('publish', $_results['post_status']);
// Create New Draft Post for another user
$_post_data = array();
$_post_data['post_author'] = self::$contributor_id;
$_post_data['post_type'] = 'post';
$_post_data['saveasdraft'] = true;
$_results = _wp_translate_postdata(false, $_post_data);
$this->assertNotInstanceOf('WP_Error', $_results);
$this->assertEquals($_post_data['post_author'], $_results['post_author']);
$this->assertEquals('draft', $_results['post_status']);
// Edit Draft Post for another user
$_post_data = array();
$_post_data['post_ID'] = self::factory()->post->create(array('post_author' => self::$contributor_id));
$_post_data['post_author'] = self::$contributor_id;
$_post_data['post_type'] = 'post';
$_post_data['post_status'] = 'draft';
$_post_data['saveasdraft'] = true;
$_results = _wp_translate_postdata(true, $_post_data);
$this->assertNotInstanceOf('WP_Error', $_results);
$this->assertEquals($_post_data['post_author'], $_results['post_author']);
$this->assertEquals('draft', $_results['post_status']);
}
示例10: SPNL
break;
case 'edit-list':
$listid = SPNL()->validate->int($_POST['listID']);
$name = sanitize_text_field($_POST['name']);
$public = 0;
if (isset($_POST['public'])) {
$public = $_POST['public'];
}
SendPress_Data::update_list($listid, array('name' => $name, 'public' => $public));
$page = apply_filters('sendpress_edit_list_redirect', SPNL()->validate->page($_GET['page']));
wp_redirect(esc_url_raw(admin_url('admin.php?page=' . $page)));
break;
case 'save-email':
$_POST['post_type'] = $this->_email_post_type;
// Update post 37
$my_post = _wp_translate_postdata(true);
/*
$my_post['ID'] = $_POST['post_ID'];
$my_post['post_content'] = $_POST['content'];
$my_post['post_title'] = $_POST['post_title'];
*/
$my_post['post_status'] = 'publish';
// Update the post into the database
wp_update_post($my_post);
update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']);
update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']);
update_post_meta($my_post['ID'], '_sendpress_status', 'private');
SendPress_Email::set_default_style($my_post['ID']);
//clear the cached file.
delete_transient('sendpress_email_html_' . $my_post['ID']);
$this->save_redirect($_POST);
示例11: create_duplicate_post
/**
* _create_duplicate_post method
*
* Create copy of event by calling {@uses wp_insert_post} function.
* Using 'post_parent' to add hierarchy.
*
* @param array $data Event instance data to copy
*
* @return int|bool New post ID or false on failure
**/
public function create_duplicate_post()
{
if (!isset($_POST['post_ID'])) {
return false;
}
$clean_fields = array('ai1ec_repeat' => NULL, 'ai1ec_rrule' => '', 'ai1ec_exrule' => '', 'ai1ec_exdate' => '', 'post_ID' => NULL, 'post_name' => NULL, 'ai1ec_instance_id' => NULL);
$old_post_id = $_POST['post_ID'];
$instance_id = $_POST['ai1ec_instance_id'];
foreach ($clean_fields as $field => $to_value) {
if (NULL === $to_value) {
unset($_POST[$field]);
} else {
$_POST[$field] = $to_value;
}
}
$_POST = _wp_translate_postdata(false, $_POST);
$_POST['post_parent'] = $old_post_id;
$post_id = wp_insert_post($_POST);
$this->_registry->get('model.event.parent')->event_parent($post_id, $old_post_id, $instance_id);
return $post_id;
}
示例12: 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;
}
$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_fields($_POST, true);
$new_autosave['ID'] = $old_autosave->ID;
$new_autosave['post_author'] = $post_author;
// Auto-save revisioned meta fields.
foreach (_wp_post_revision_meta_keys() as $meta_key) {
if (isset($_POST[$meta_key]) && get_post_meta($new_autosave['ID'], $meta_key, true) != $_POST[$meta_key]) {
// Use the underlying delete_metadata and add_metadata vs delete_post_meta
// and add_post_meta to make sure we're working with the actual revision meta.
delete_metadata('post', $new_autosave['ID'], $meta_key);
if (!empty($_POST[$meta_key])) {
add_metadata('post', $new_autosave['ID'], $meta_key, $_POST[$meta_key]);
}
}
}
// Save the post format if different
if (isset($_POST['post_format']) && get_post_meta($new_autosave['ID'], '_revision_post_format', true) != $_POST['post_format']) {
delete_metadata('post', $new_autosave['ID'], '_revision_post_format');
if (!empty($_POST['post_format'])) {
add_metadata('post', $new_autosave['ID'], '_revision_post_format', $_POST['post_format']);
}
}
return wp_update_post($new_autosave);
}
// _wp_put_post_revision() expects unescaped.
$_POST = wp_unslash($_POST);
// Otherwise create the new autosave as a special post revision
return _wp_put_post_revision($_POST, true);
}
示例13: save
function save()
{
$saveid = SPNL()->validate->int($_POST['post_ID']);
$bodybg = SPNL()->validate->hex($_POST['body_bg']);
$bodytext = SPNL()->validate->hex($_POST['body_text']);
$bodylink = SPNL()->validate->hex($_POST['body_link']);
$contentbg = SPNL()->validate->hex($_POST['content_bg']);
$contenttext = SPNL()->validate->hex($_POST['content_text']);
$contentlink = SPNL()->validate->hex($_POST['sp_content_link_color']);
$contentborder = SPNL()->validate->hex($_POST['content_border']);
$upload_image = $_POST['upload_image'];
$headerbg = SPNL()->validate->hex($_POST['header_bg']);
$headertextcolor = SPNL()->validate->hex($_POST['header_text_color']);
$headertext = sanitize_text_field($_POST['header_text']);
$headerlink = esc_url_raw($_POST['header_link']);
$imageheaderurl = esc_url_raw($_POST['image_header_url']);
$subheadertext = sanitize_text_field($_POST['sub_header_text']);
$activeHeader = $_POST['active_header'];
$_POST['post_type'] = 'sp_newsletters';
// Update post 37
$my_post = _wp_translate_postdata(true);
/*
$my_post['ID'] = $_POST['post_ID'];
$my_post['post_content'] = $_POST['content'];
$my_post['post_title'] = $_POST['post_title'];
*/
/*
$str = $my_post['post_content'];
$DOM = new DOMDocument;
$DOM->loadHTML($str);
//get all H1
$aTags = $DOM->getElementsByTagName('a');
foreach ($aTags as $aElement) {
$style = $aElement->getAttribute('style');
if($style == ""){
$aElement->setAttribute('style', 'color: '. $contentlink);
}
}
$body_html = $DOM->saveHtml();
$my_post['post_content'] = $body_html;
*/
$my_post['post_status'] = 'publish';
// Update the post into the database
wp_update_post($my_post);
update_post_meta($my_post['ID'], '_sendpress_subject', sanitize_text_field($_POST['post_subject']));
update_post_meta($my_post['ID'], '_sendpress_template', SPNL()->validate->int($_POST['template']));
update_post_meta($my_post['ID'], '_sendpress_status', 'private');
SendPress_Email::set_default_style($my_post['ID']);
//clear the cached file.
delete_transient('sendpress_email_html_' . $my_post['ID']);
update_post_meta($saveid, 'body_bg', $bodybg);
update_post_meta($saveid, 'body_text', $bodytext);
update_post_meta($saveid, 'body_link', $bodylink);
update_post_meta($saveid, 'content_bg', $contentbg);
update_post_meta($saveid, 'content_text', $contenttext);
update_post_meta($saveid, 'sp_content_link_color', $contentlink);
update_post_meta($saveid, 'content_border', $contentborder);
update_post_meta($saveid, 'upload_image', $upload_image);
update_post_meta($saveid, 'header_bg', $headerbg);
update_post_meta($saveid, 'header_text_color', $headertextcolor);
update_post_meta($saveid, 'header_text', $headertext);
update_post_meta($saveid, 'header_link', $headerlink);
update_post_meta($saveid, 'image_header_url', $imageheaderurl);
update_post_meta($saveid, 'sub_header_text', $subheadertext);
update_post_meta($saveid, 'active_header', $activeHeader);
if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') {
SendPress_Admin::redirect('Emails_Send', array('emailID' => SPNL()->validate->int($_GET['emailID'])));
} else {
if (isset($_POST['submit']) && $_POST['submit'] == 'send-test') {
$email = new stdClass();
$email->emailID = $my_post['ID'];
$email->subscriberID = 0;
$email->listID = 0;
$email->to_email = $_POST['test-email'];
$d = SendPress_Manager::send_test_email($email);
//print_r($d);
SendPress_Admin::redirect('Emails_Style', array('emailID' => SPNL()->validate->int($_GET['emailID'])));
} else {
SendPress_Admin::redirect('Emails_Style', array('emailID' => SPNL()->validate->int($_GET['emailID'])));
}
}
}
示例14: _create_duplicate_post
/**
* _create_duplicate_post method
*
* Create copy of event by calling {@uses wp_insert_post} function.
* Using 'post_parent' to add hierarchy.
*
* @param array $data Event instance data to copy
*
* @return int|bool New post ID or false on failure
**/
protected function _create_duplicate_post()
{
global $ai1ec_events_helper;
if (!isset($_POST['post_ID'])) {
return false;
}
$clean_fields = array('ai1ec_repeat' => NULL, 'ai1ec_rrule' => '', 'ai1ec_exrule' => '', 'ai1ec_exdate' => '', 'post_ID' => NULL, 'post_name' => NULL, 'ai1ec_instance_id' => NULL);
$old_post_id = $_POST['post_ID'];
$instance_id = $_POST['ai1ec_instance_id'];
foreach ($clean_fields as $field => $to_value) {
if (NULL === $to_value) {
unset($_POST[$field]);
} else {
$_POST[$field] = $to_value;
}
}
$_POST = _wp_translate_postdata(false, $_POST);
$_POST['post_parent'] = $old_post_id;
$post_id = wp_insert_post($_POST);
$ai1ec_events_helper->event_parent($post_id, $old_post_id, $instance_id);
return $post_id;
}