本文整理汇总了PHP中wp_untrash_post函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_untrash_post函数的具体用法?PHP wp_untrash_post怎么用?PHP wp_untrash_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_untrash_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_bbp_forum_trashed_untrashed_topic_counts
/**
* Generic function to test the forum counts on a trashed/untrashed topic
*/
public function test_bbp_forum_trashed_untrashed_topic_counts()
{
$f = $this->factory->forum->create();
$t = $this->factory->topic->create_many(3, array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
$r1 = $this->factory->reply->create_many(2, array('post_parent' => $t[1], 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t[1])));
$r2 = $this->factory->reply->create_many(2, array('post_parent' => $t[2], 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t[2])));
$count = bbp_update_forum_topic_count($f);
$this->assertSame(3, $count);
$count = bbp_update_forum_topic_count_hidden($f);
$this->assertSame(0, $count);
$count = bbp_update_forum_reply_count($f);
$this->assertSame(4, $count);
// ToDo: Update this to use bbp_trash_topic().
wp_trash_post($t[2]);
$count = bbp_get_forum_topic_count($f, true, true);
$this->assertSame(2, $count);
$count = bbp_get_forum_topic_count_hidden($f, true, true);
$this->assertSame(1, $count);
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame(2, $count);
// ToDo: Update this to use bbp_untrash_topic().
wp_untrash_post($t[2]);
$count = bbp_get_forum_topic_count($f, true, true);
$this->assertSame(3, $count);
$count = bbp_get_forum_topic_count_hidden($f, true, true);
$this->assertSame(0, $count);
$count = bbp_get_forum_reply_count($f, true, true);
$this->assertSame(4, $count);
}
示例2: untrash_all
/**
* Restores all the children events of an event post from the trash to their previous state.
* @param $post_id
*/
public function untrash_all($post_id)
{
$children = $this->get_ids($post_id, array('post_status' => 'trash'));
foreach ($children as $child_id) {
wp_untrash_post($child_id);
}
}
示例3: untrash_translation
public function untrash_translation($trans_id)
{
if (WPML_WordPress_Actions::is_bulk_untrash($trans_id)) {
// Do nothing as the translation is part of the bulk untrash.
} else {
wp_untrash_post($trans_id);
}
}
示例4: restore_all_ticket_types
function restore_all_ticket_types()
{
$args = array('post_type' => 'tc_tickets', 'post_status' => 'trash');
$ticket_types = get_posts($args);
foreach ($ticket_types as $ticket_type) {
wp_untrash_post($ticket_type->ID);
}
}
示例5: wp_trash_post
/**
* @ticket 11863
*/
function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name()
{
$about_page_id = self::factory()->post->create(array('post_type' => 'page', 'post_title' => 'About', 'post_status' => 'publish'));
wp_trash_post($about_page_id);
$another_about_page_id = self::factory()->post->create(array('post_type' => 'page', 'post_title' => 'About', 'post_status' => 'publish'));
wp_untrash_post($about_page_id);
$this->assertEquals('about', get_post($another_about_page_id)->post_name);
$this->assertEquals('about-2', get_post($about_page_id)->post_name);
}
示例6: restore_event
function restore_event($event_id)
{
wp_untrash_post($event_id);
//delete event ticket types
$args = array('post_type' => 'tc_tickets', 'meta_key' => 'event_name', 'meta_value' => $event_id);
$ticket_types = get_posts($args);
foreach ($ticket_types as $ticket_type) {
wp_untrash_post($ticket_type->ID);
}
}
示例7: untrash_order
function untrash_order($id = false)
{
$id = $id ? $id : $this->id;
wp_untrash_post($id);
//Delete associated ticket instances
$args = array('post_type' => 'tc_tickets_instances', 'post_status' => 'trash', 'post_parent' => $id);
$ticket_instances = get_posts($args);
foreach ($ticket_instances as $ticket_instance) {
wp_untrash_post($ticket_instance->ID);
}
}
示例8: erm_untrash_menu_items
/**
* Restore menu items when restore post type erm_menu
*
* @since 1.0
* @param $post_id
*/
function erm_untrash_menu_items($post_id)
{
if (get_post_type($post_id) != 'erm_menu') {
return;
}
$menu_items = get_post_meta($post_id, '_erm_menu_items', true);
if (empty($menu_items)) {
return array();
}
$menu_items = preg_split('/,/', $menu_items);
foreach ($menu_items as $id) {
wp_untrash_post($id);
}
}
示例9: untrashed_post
/**
* Callback on post untrashing
*
* @param int $post_id ID of post being untrashed
*
* @return void Method does not return
*/
public function untrashed_post($post_id)
{
try {
$ai1ec_event = new Ai1ec_Event($post_id);
if (isset($ai1ec_event->post) && !empty($ai1ec_event->recurrence_rules)) {
// untrash child event
global $ai1ec_events_helper;
$children = $ai1ec_events_helper->get_child_event_objects($ai1ec_event->post_id, true);
foreach ($children as $child) {
wp_untrash_post($child->post_id);
}
}
} catch (Ai1ec_Event_Not_Found $exception) {
// ignore - not an event
}
}
示例10: untrash_post
/**
* Untrash all connected events of a production.
*
* Whenever a production is untrashed, make sure that all connected events are untrashed as well.
*
* @since 0.7
*
*/
function untrash_post($post_id)
{
$post = get_post($post_id);
if (!empty($post) && $post->post_type == WPT_Production::post_type_name) {
$args = array('post_type' => WPT_Event::post_type_name, 'post_status' => 'trash', 'meta_query' => array(array('key' => WPT_Production::post_type_name, 'value' => $post_id)));
$events = get_posts($args);
foreach ($events as $event) {
wp_untrash_post($event->ID);
}
}
}
示例11: acf_untrash_field
function acf_untrash_field($selector = 0)
{
// disable filters to ensure ACF loads raw data from DB
acf_disable_filters();
// load the origional field gorup
$field = acf_get_field($selector);
// bail early if field did not load correctly
if (empty($field)) {
return false;
}
// delete field
wp_untrash_post($field['ID']);
// action for 3rd party customisation
do_action('acf/untrash_field', $field);
// return
return true;
}
示例12: motopressCECreateTemporaryPost
/**
* Create temporary post with motopress adapted content
*/
function motopressCECreateTemporaryPost($post_id, $content)
{
$post = get_post($post_id);
$post->ID = '';
$post->post_title = 'temporary';
$post->post_content = '<div class="motopress-content-wrapper">' . $content . '</div>';
$post->post_status = 'trash';
$userRole = wp_get_current_user()->roles[0];
$optionName = 'motopress_tmp_post_id_' . $userRole;
$id = get_option($optionName);
if ($id) {
if (is_null(get_post($id))) {
$id = wp_insert_post($post, false);
update_option($optionName, $id);
}
} else {
$id = wp_insert_post($post, false);
add_option($optionName, $id);
}
$post->ID = (int) $id;
global $wpdb;
$wpdb->delete($wpdb->posts, array('post_parent' => $post->ID, 'post_type' => 'revision'), array('%d', '%s'));
//@todo: remove in next version
wp_update_post($post);
wp_untrash_post($post->ID);
motopressCEClonePostmeta($post_id, $post->ID);
do_action('mp_post_meta', $post->ID, $post->post_type);
do_action('mp_theme_fix', $post_id, $post->ID, $post->post_type);
$pageTemplate = get_post_meta($post_id, '_wp_page_template', true);
$pageTemplate = (!$pageTemplate or empty($pageTemplate)) ? 'default' : $pageTemplate;
update_post_meta($post->ID, '_wp_page_template', $pageTemplate);
return $post->ID;
}
示例13: handle_manage_page_postback
/**
* Default function for handling manage page post backs.
*
*/
public function handle_manage_page_postback()
{
global $wpdb;
if (!current_user_can('edit_pages')) {
wp_die(__('Cheatin’ uh?'));
}
// Handle bulk actions
if (isset($_POST['doaction']) || isset($_POST['doaction2']) || isset($_POST['delete_all']) || isset($_POST['delete_all2']) || isset($_POST['bulk_edit'])) {
check_admin_referer('bulk-' . $this->get_content_type());
$sendback = wp_get_referer();
if (isset($_POST['delete_all']) || isset($_POST['delete_all2'])) {
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_POST['post_status']);
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type=%s AND post_status = %s", $this->get_content_type(), $post_status));
$doaction = 'delete';
} elseif (($_POST['action'] != -1 || $_POST['action2'] != -1) && isset($_POST['post'])) {
$post_ids = array_map('intval', (array) $_POST['post']);
$doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
} else {
wp_redirect($sendback);
}
//handle case where trash isn't available yet on VIP
if ($doaction == 'trash' && !function_exists('wp_trash_post')) {
$doaction = 'delete';
}
switch ($doaction) {
case 'trash':
$trashed = 0;
foreach ((array) $post_ids as $post_id) {
if (!current_user_can('delete_page', $post_id)) {
wp_die(__('You are not allowed to move this page to the trash.'));
}
if (!wp_trash_post($post_id)) {
wp_die(__('Error in moving to trash...'));
}
$trashed++;
}
$sendback = add_query_arg('trashed', $trashed, $sendback);
break;
case 'untrash':
$untrashed = 0;
foreach ((array) $post_ids as $post_id) {
if (!current_user_can('delete_page', $post_id)) {
wp_die(__('You are not allowed to restore this page from the trash.'));
}
if (!wp_untrash_post($post_id)) {
wp_die(__('Error in restoring from trash...'));
}
$untrashed++;
}
$sendback = add_query_arg('untrashed', $untrashed, $sendback);
break;
case 'delete':
$deleted = 0;
foreach ((array) $post_ids as $post_id) {
$post_del =& get_post($post_id);
if (!current_user_can('delete_page', $post_id)) {
wp_die(__('You are not allowed to delete this page.'));
}
if ($post_del->post_type == 'attachment') {
if (!wp_delete_attachment($post_id)) {
wp_die(__('Error in deleting...'));
}
} else {
if (!wp_delete_post($post_id)) {
wp_die(__('Error in deleting...'));
}
}
$deleted++;
}
$sendback = add_query_arg('deleted', $deleted, $sendback);
break;
case 'edit':
$_POST['post_type'] = $this->get_content_type();
$done = bulk_edit_posts($_POST);
if (is_array($done)) {
$done['updated'] = count($done['updated']);
$done['skipped'] = count($done['skipped']);
$done['locked'] = count($done['locked']);
$sendback = add_query_arg($done, $sendback);
}
break;
}
if (isset($_POST['action'])) {
$sendback = remove_query_arg(array('action', 'action2', 'post_parent', 'page_template', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view', 'post_type'), $sendback);
}
wp_redirect($sendback);
exit;
} elseif (isset($_POST['_wp_http_referer']) && !empty($_POST['_wp_http_referer'])) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
}
}
示例14: bbp_untrash_topic
/**
* Called before untrashing a topic
*
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_is_topic() To check if the passed id is a topic
* @uses do_action() Calls 'bbp_untrash_topic' with the topic id
* @uses get_post_meta() To get the list of replies which were trashed with the
* topic
* @uses wp_untrash_post() To untrash the reply
*/
function bbp_untrash_topic($topic_id = 0)
{
$topic_id = bbp_get_topic_id($topic_id);
if (empty($topic_id) || !bbp_is_topic($topic_id)) {
return false;
}
do_action('bbp_untrash_topic', $topic_id);
// Get the replies that were not previously trashed
$pre_trashed_replies = get_post_meta($topic_id, '_bbp_pre_trashed_replies', true);
// There are replies to untrash
if (!empty($pre_trashed_replies)) {
// Maybe reverse the trashed replies array
if (is_array($pre_trashed_replies)) {
$pre_trashed_replies = array_reverse($pre_trashed_replies);
}
// Loop through replies
foreach ((array) $pre_trashed_replies as $reply) {
wp_untrash_post($reply);
}
}
}
示例15: bbp_untrash_forum_topics
/**
* Trash all topics inside a forum
*
* @since bbPress (r3668)
*
* @param int $forum_id
* @uses bbp_get_forum_id() To validate the forum ID
* @uses bbp_is_forum() To make sure it's a forum
* @uses get_post_meta() To update the forum meta of trashed topics
* @uses wp_untrash_post() To trash the post
* @return If forum is not valid
*/
function bbp_untrash_forum_topics($forum_id = 0)
{
// Validate forum ID
$forum_id = bbp_get_forum_id($forum_id);
if (empty($forum_id)) {
return;
}
// Get the topics that were not previously trashed
$pre_trashed_topics = get_post_meta($forum_id, '_bbp_pre_trashed_topics', true);
// There are topics to untrash
if (!empty($pre_trashed_topics)) {
// Maybe reverse the trashed topics array
if (is_array($pre_trashed_topics)) {
$pre_trashed_topics = array_reverse($pre_trashed_topics);
}
// Loop through topics
foreach ((array) $pre_trashed_topics as $topic) {
wp_untrash_post($topic);
}
}
}