本文整理汇总了PHP中wp_untrash_post函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_untrash_post函数的具体用法?PHP wp_untrash_post怎么用?PHP wp_untrash_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_untrash_post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:32,代码来源:counts.php
示例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);
}
}
开发者ID:acutedeveloper,项目名称:havering-intranet-development,代码行数:11,代码来源:Children_Events.php
示例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);
}
}
开发者ID:edgarter,项目名称:wecare,代码行数:8,代码来源:wpml-post-translation.class.php
示例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);
}
}
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:8,代码来源:class.tickets.php
示例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);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:wpInsertPost.php
示例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);
}
}
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:10,代码来源:class.event.php
示例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);
}
}
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:11,代码来源:class.order.php
示例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);
}
}
开发者ID:AlexanderDolgan,项目名称:ojahuri,代码行数:20,代码来源:actions.php
示例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
}
}
开发者ID:briancompton,项目名称:knightsplaza,代码行数:23,代码来源:class-ai1ec-events-controller.php
示例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);
}
}
}
开发者ID:henk23,项目名称:wp-theatre,代码行数:19,代码来源:wpt_setup.php
示例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;
}
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:17,代码来源:api-field.php
示例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;
}
开发者ID:vova95,项目名称:motoWidget,代码行数:36,代码来源:renderContent.php
示例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;
}
}
开发者ID:voceconnect,项目名称:cms-press,代码行数:96,代码来源:cp-custom-content-handler-base.php
示例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);
}
}
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:31,代码来源:functions.php
示例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);
}
}
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:33,代码来源:functions.php
示例16: process_bulk_action
/**
* Process the bulk actions
*/
public function process_bulk_action()
{
$ids = isset($_GET['post']) ? $_GET['post'] : false;
$action = $this->current_action();
if (!is_array($ids)) {
$ids = array($ids);
}
if (empty($action)) {
return;
}
foreach ($ids as $id) {
// Detect when a bulk action is being triggered...
if ('trash' === $this->current_action()) {
wp_trash_post($id);
}
if ('publish' === $this->current_action()) {
wp_publish_post($id);
}
if ('pending' === $this->current_action()) {
// Update post
$u_post = array();
$u_post['ID'] = $id;
$u_post['post_status'] = 'pending';
// Update the post into the database
wp_update_post($u_post);
}
if ('delete' === $this->current_action()) {
wp_delete_post($id, true);
}
if ('restore' === $this->current_action()) {
wp_untrash_post($id);
}
do_action('ap_moderate_table_do_bulk_action', $id, $this->current_action());
}
}
开发者ID:haythameyd,项目名称:powrly,代码行数:38,代码来源:flagged.php
示例17: bulk_untrash
/**
* Bulk untrash.
*
* @param array $webhooks
*/
private function bulk_untrash($webhooks)
{
foreach ($webhooks as $webhook_id) {
wp_untrash_post($webhook_id);
}
$qty = count($webhooks);
delete_transient('woocommerce_webhook_ids');
// Redirect to webhooks page
wp_redirect(admin_url('admin.php?page=wc-settings&tab=api§ion=webhooks&status=trash&untrashed=' . $qty));
exit;
}
开发者ID:coderkevin,项目名称:woocommerce,代码行数:16,代码来源:class-wc-admin-webhooks.php
示例18: acf_untrash_field_group
function acf_untrash_field_group($selector = 0)
{
// disable JSON to avoid conflicts between DB and JSON
acf_disable_local();
// load the origional field gorup
$field_group = acf_get_field_group($selector);
// bail early if field group did not load correctly
if (empty($field_group)) {
return false;
}
// get fields
$fields = acf_get_fields($field_group);
if (!empty($fields)) {
foreach ($fields as $field) {
acf_untrash_field($field['ID']);
}
}
// delete
wp_untrash_post($field_group['ID']);
// action for 3rd party customization
do_action('acf/untrash_field_group', $field_group);
// return
return true;
}
开发者ID:kochira,项目名称:competstrat,代码行数:24,代码来源:api-field-group.php
示例19: restore_post
function restore_post($path, $blog_id, $post_id)
{
$args = $this->query_args();
$post = get_post($post_id);
if (!$post || is_wp_error($post)) {
return new WP_Error('unknown_post', 'Unknown post', 404);
}
if (!current_user_can('delete_post', $post->ID)) {
return new WP_Error('unauthorized', 'User cannot restore trashed posts', 403);
}
/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
do_action('wpcom_json_api_objects', 'posts');
wp_untrash_post($post->ID);
return $this->get_post_by('ID', $post->ID, $args['context']);
}
开发者ID:s-a-s-k-i-a,项目名称:jetpack,代码行数:15,代码来源:class.wpcom-json-api-update-post-v1-1-endpoint.php
示例20: bbp_toggle_reply_handler
/**
* Handles the front end spamming/unspamming and trashing/untrashing/deleting of
* replies
*
* @since bbPress (r2740)
*
* @param string $action The requested action to compare this function to
* @uses bbp_get_reply() To get the reply
* @uses current_user_can() To check if the user is capable of editing or
* deleting the reply
* @uses check_ajax_referer() To verify the nonce and check the referer
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_is_reply_spam() To check if the reply is marked as spam
* @uses bbp_spam_reply() To make the reply as spam
* @uses bbp_unspam_reply() To unmark the reply as spam
* @uses wp_trash_post() To trash the reply
* @uses wp_untrash_post() To untrash the reply
* @uses wp_delete_post() To delete the reply
* @uses do_action() Calls 'bbp_toggle_reply_handler' with success, post data
* and action
* @uses bbp_get_reply_url() To get the reply url
* @uses wp_safe_redirect() To redirect to the reply
* @uses bbPress::errors:add() To log the error messages
*/
function bbp_toggle_reply_handler($action = '')
{
// Bail if required GET actions aren't passed
if (empty($_GET['reply_id'])) {
return;
}
// Setup possible get actions
$possible_actions = array('bbp_toggle_reply_spam', 'bbp_toggle_reply_trash');
// Bail if actions aren't meant for this function
if (!in_array($action, $possible_actions)) {
return;
}
$failure = '';
// Empty failure string
$view_all = false;
// Assume not viewing all
$reply_id = (int) $_GET['reply_id'];
// What's the reply id?
$success = false;
// Flag
$post_data = array('ID' => $reply_id);
// Prelim array
// Make sure reply exists
$reply = bbp_get_reply($reply_id);
if (empty($reply)) {
return;
}
// What is the user doing here?
if (!current_user_can('edit_reply', $reply->ID) || 'bbp_toggle_reply_trash' === $action && !current_user_can('delete_reply', $reply->ID)) {
bbp_add_error('bbp_toggle_reply_permission', __('<strong>ERROR:</strong> You do not have the permission to do that!', 'bbpress'));
return;
}
// What action are we trying to perform?
switch ($action) {
// Toggle spam
case 'bbp_toggle_reply_spam':
check_ajax_referer('spam-reply_' . $reply_id);
$is_spam = bbp_is_reply_spam($reply_id);
$success = $is_spam ? bbp_unspam_reply($reply_id) : bbp_spam_reply($reply_id);
$failure = $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the reply as spam!', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the reply as spam!', 'bbpress');
$view_all = !$is_spam;
break;
// Toggle trash
// Toggle trash
case 'bbp_toggle_reply_trash':
$sub_action = in_array($_GET['sub_action'], array('trash', 'untrash', 'delete')) ? $_GET['sub_action'] : false;
if (empty($sub_action)) {
break;
}
switch ($sub_action) {
case 'trash':
check_ajax_referer('trash-' . bbp_get_reply_post_type() . '_' . $reply_id);
$view_all = true;
$success = wp_trash_post($reply_id);
$failure = __('<strong>ERROR</strong>: There was a problem trashing the reply!', 'bbpress');
break;
case 'untrash':
check_ajax_referer('untrash-' . bbp_get_reply_post_type() . '_' . $reply_id);
$success = wp_untrash_post($reply_id);
$failure = __('<strong>ERROR</strong>: There was a problem untrashing the reply!', 'bbpress');
break;
case 'delete':
check_ajax_referer('delete-' . bbp_get_reply_post_type() . '_' . $reply_id);
$success = wp_delete_post($reply_id);
$failure = __('<strong>ERROR</strong>: There was a problem deleting the reply!', 'bbpress');
break;
}
break;
}
// Do additional reply toggle actions
do_action('bbp_toggle_reply_handler', $success, $post_data, $action);
// No errors
if (false !== $success && !is_wp_error($success)) {
/** Redirect **********************************************************/
// Redirect to
$redirect_to = bbp_get_redirect_to();
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:functions.php
注:本文中的wp_untrash_post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论