当前位置: 首页>>代码示例>>PHP>>正文


PHP bulk_edit_posts函数代码示例

本文整理汇总了PHP中bulk_edit_posts函数的典型用法代码示例。如果您正苦于以下问题:PHP bulk_edit_posts函数的具体用法?PHP bulk_edit_posts怎么用?PHP bulk_edit_posts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bulk_edit_posts函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_bulk_action

 public function process_bulk_action()
 {
     global $pagenow, $wpdb;
     if (!isset($_REQUEST['_wpnonce'])) {
         return;
     }
     $nonce = esc_attr($_REQUEST['_wpnonce']);
     if (!wp_verify_nonce($nonce, 'bulk-donations')) {
         wp_die(__('Invalid Nonce for deleting WC Donation Orders', WC_QD_TXT));
     }
     $doaction = $this->current_action();
     if ($doaction) {
         $pagenum = $this->get_pagenum();
         $sendback = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer());
         if (!$sendback) {
             $sendback = admin_url($parent_file);
         }
         $sendback = add_query_arg('paged', $pagenum, $sendback);
         if (strpos($sendback, 'post.php') !== false) {
             $sendback = admin_url($post_new_file);
         }
         if (isset($_REQUEST['post'])) {
             $post_ids = array_map('intval', $_REQUEST['post']);
         }
         var_dump($this->screen);
         if ('delete_all' == $doaction) {
             // Prepare for deletion of all posts with a specified post status (i.e. Empty trash).
             $post_status = preg_replace('/[^a-z0-9_-]+/i', '', 'trash');
             // Validate the post status exists.
             if (get_post_status_object($post_status)) {
                 $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type=%s AND post_status = %s", 'shop_order', $post_status));
             }
             $doaction = 'delete';
         }
         $total_post = count($post_ids);
         $ids = implode(', ', $post_ids);
         $Notice_Txt = '';
         switch ($doaction) {
             case 'trash':
                 $trashed = $locked = 0;
                 foreach ((array) $post_ids as $post_id) {
                     if (!current_user_can('delete_post', $post_id)) {
                         wp_die(__('You are not allowed to move this item to the Trash.'));
                     }
                     if (wp_check_post_lock($post_id)) {
                         $locked++;
                         continue;
                     }
                     if (!wp_trash_post($post_id)) {
                         wp_die(__('Error in moving to Trash.'));
                     }
                     $trashed++;
                     $Notice_Txt = ' Trashed ';
                 }
                 $sendback = add_query_arg(array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked), $sendback);
                 wc_qd_notice(sprintf(_n('%s Donation Order Trashed  ( %s )', '%s Donation Orders Trashed  ( %s )', $total_post, $ids, WC_QD_TXT), $total_post, $ids));
                 break;
             case 'untrash':
                 $untrashed = 0;
                 foreach ((array) $post_ids as $post_id) {
                     if (!current_user_can('delete_post', $post_id)) {
                         wp_die(__('You are not allowed to restore this item from the Trash.'));
                     }
                     if (!wp_untrash_post($post_id)) {
                         wp_die(__('Error in restoring from Trash.'));
                     }
                     $untrashed++;
                 }
                 $sendback = add_query_arg('untrashed', $untrashed, $sendback);
                 wc_qd_notice(sprintf(_n('%s Donation Order restored from trash  ( %s )', '%s Donation Orders restored from trash ( %s )', $total_post, $ids, WC_QD_TXT), $total_post, $ids));
                 break;
             case 'delete':
                 $deleted = 0;
                 foreach ((array) $post_ids as $post_id) {
                     $post_del = get_post($post_id);
                     if (!current_user_can('delete_post', $post_id)) {
                         wp_die(__('You are not allowed to delete this item.'));
                     }
                     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);
                 wc_qd_notice(sprintf(_n('%s Donation Order permanently deleted  ( %s )', '%s Donation Orders permanently deleted ( %s )', $total_post, $ids, WC_QD_TXT), $total_post, $ids));
                 break;
             case 'edit':
                 if (isset($_REQUEST['bulk_edit'])) {
                     $done = bulk_edit_posts($_REQUEST);
                     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);
//.........这里部分代码省略.........
开发者ID:Negative-Network,项目名称:woocommerce-quick-donation,代码行数:101,代码来源:wp-donation-listing-table.php

示例2: check_admin_referer

                     }
                 }
                 $deleted++;
             }
         }
         break;
     case 'edit':
         if (isset($_GET['post']) && isset($_GET['bulk_edit'])) {
             check_admin_referer('bulk-pages');
             if (-1 == $_GET['_status']) {
                 $_GET['post_status'] = null;
                 unset($_GET['_status'], $_GET['post_status']);
             } else {
                 $_GET['post_status'] = $_GET['_status'];
             }
             $done = bulk_edit_posts($_GET);
         }
         break;
 }
 $sendback = wp_get_referer();
 if (strpos($sendback, 'page.php') !== false) {
     $sendback = admin_url('page-new.php');
 } elseif (strpos($sendback, 'attachments.php') !== false) {
     $sendback = admin_url('attachments.php');
 }
 if (isset($done)) {
     $done['updated'] = count($done['updated']);
     $done['skipped'] = count($done['skipped']);
     $done['locked'] = count($done['locked']);
     $sendback = add_query_arg($done, $sendback);
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:edit-pages.php

示例3: 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

示例4: nxt_die

                if ($post_del->post_type == 'attachment') {
                    if (!nxt_delete_attachment($post_id)) {
                        nxt_die(__('Error in deleting...'));
                    }
                } else {
                    if (!nxt_delete_post($post_id)) {
                        nxt_die(__('Error in deleting...'));
                    }
                }
                $deleted++;
            }
            $sendback = add_query_arg('deleted', $deleted, $sendback);
            break;
        case 'edit':
            if (isset($_REQUEST['bulk_edit'])) {
                $done = bulk_edit_posts($_REQUEST);
                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;
    }
    $sendback = remove_query_arg(array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback);
    nxt_redirect($sendback);
    exit;
} elseif (!empty($_REQUEST['_nxt_http_referer'])) {
    nxt_redirect(remove_query_arg(array('_nxt_http_referer', '_nxtnonce'), stripslashes($_SERVER['REQUEST_URI'])));
    exit;
开发者ID:nxtclass,项目名称:NXTClass,代码行数:31,代码来源:edit.php

示例5: test_bulk_edit_posts_stomping

 /**
  * @ticket 27792
  */
 function test_bulk_edit_posts_stomping()
 {
     wp_set_current_user(self::$admin_id);
     $post1 = self::factory()->post->create(array('post_author' => self::$author_ids[0], 'comment_status' => 'open', 'ping_status' => 'open', 'post_status' => 'publish'));
     $post2 = self::factory()->post->create(array('post_author' => self::$author_ids[1], 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'draft'));
     $request = array('post_type' => 'post', 'post_author' => -1, 'ping_status' => -1, 'comment_status' => -1, '_status' => -1, 'post' => array($post1, $post2));
     bulk_edit_posts($request);
     $post = get_post($post2);
     // Check that the first post's values don't stomp the second post.
     $this->assertEquals('draft', $post->post_status);
     $this->assertEquals(self::$author_ids[1], $post->post_author);
     $this->assertEquals('closed', $post->comment_status);
     $this->assertEquals('closed', $post->ping_status);
 }
开发者ID:inpsyde,项目名称:wordpress-dev,代码行数:17,代码来源:includesPost.php

示例6: test_bulk_edit_posts_stomping

	/**
	 * @ticket 27792
	 */
	function test_bulk_edit_posts_stomping() {
		$admin = $this->factory->user->create( array( 'role' => 'administrator' ) );
		$users = $this->factory->user->create_many( 2, array( 'role' => 'author' ) );
		wp_set_current_user( $admin );

		$post1 = $this->factory->post->create( array(
			'post_author'    => $users[0],
			'comment_status' => 'open',
			'ping_status'    => 'open',
			'post_status'    => 'publish',
		) );

		$post2 = $this->factory->post->create( array(
			'post_author'    => $users[1],
			'comment_status' => 'closed',
			'ping_status'    => 'closed',
			'post_status'    => 'draft',
		) );

		$request = array(
			'post_type'        => 'post',
			'post_author'      => -1,
			'ping_status'      => -1,
			'comment_status'   => -1,
			'_status'          => -1,
			'post'             => array( $post1, $post2 ),
		);

		$done = bulk_edit_posts( $request );

		$post = get_post( $post2 );

		// Check that the first post's values don't stomp the second post.
		$this->assertEquals( 'draft', $post->post_status );
		$this->assertEquals( $users[1], $post->post_author );
		$this->assertEquals( 'closed', $post->comment_status );
		$this->assertEquals( 'closed', $post->ping_status );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:41,代码来源:includesPost.php

示例7: bulk_edit_ideas_status

 /**
  * Bulk edit ideas status
  *
  * Used when a group changes status and when a private/hidden group
  * removes ideas.
  *
  * @package WP Idea Stream
  * @subpackage buddypress/groups
  *
  * @since  2.0.0
  *
  * @param  array  $args bulk edit args
  * @uses   wp_parse_args() to merge args with defaults
  * @uses   bulk_edit_posts() to bulk edit the ideas stati
  * @uses   wp_idea_stream_get_post_type() to get the ideas post type identifier
  * @return array        associative array of the bulk result (updated, skipped, locked)
  */
 public static function bulk_edit_ideas_status($args = array())
 {
     if (!is_array($args)) {
         return false;
     }
     $r = wp_parse_args($args, array('status' => 'publish', 'ideas' => array()));
     if (empty($r['ideas'])) {
         return false;
     }
     // We might need an admin file if on group's manage screen
     if (!function_exists('bulk_edit_posts')) {
         require_once ABSPATH . 'wp-admin/includes/post.php';
     }
     // Finally bulk edit the ideas.
     return bulk_edit_posts(array('post_type' => wp_idea_stream_get_post_type(), '_status' => $r['status'], 'post' => (array) $r['ideas']));
 }
开发者ID:mrjarbenne,项目名称:wp-idea-stream,代码行数:33,代码来源:groups.php

示例8: tm_admin_init


//.........这里部分代码省略.........
                 foreach ((array) $post_ids as $post_id) {
                     if (!current_user_can('delete_post', $post_id)) {
                         wp_die(__('You are not allowed to restore this item from the Trash.', TM_EPO_TRANSLATION));
                     }
                     if (!wp_untrash_post($post_id)) {
                         wp_die(__('Error in restoring from Trash.', TM_EPO_TRANSLATION));
                     }
                     $untrashed++;
                 }
                 $sendback = add_query_arg(array('from_bulk' => 1, '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_post', $post_id)) {
                         wp_die(__('You are not allowed to delete this item.', TM_EPO_TRANSLATION));
                     }
                     if ($post_del->post_type == 'attachment') {
                         if (!wp_delete_attachment($post_id)) {
                             wp_die(__('Error in deleting.', TM_EPO_TRANSLATION));
                         }
                     } else {
                         if (!wp_delete_post($post_id)) {
                             wp_die(__('Error in deleting.', TM_EPO_TRANSLATION));
                         }
                     }
                     $deleted++;
                 }
                 $sendback = add_query_arg(array('from_bulk' => 1, 'deleted' => $deleted), $sendback);
                 break;
             case 'edit':
                 if (isset($_REQUEST['bulk_edit'])) {
                     $done = bulk_edit_posts($_REQUEST);
                     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;
         }
         $sendback = remove_query_arg(array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback);
         $sendback = esc_url_raw($sendback);
         wp_redirect($sendback);
         exit;
     } elseif ($doaction && !isset($_REQUEST['tm_bulk'])) {
         if (isset($_GET['post'])) {
             $post_id = $post_ID = (int) $_GET['post'];
         } elseif (isset($_POST['post_ID'])) {
             $post_id = $post_ID = (int) $_POST['post_ID'];
         } elseif (isset($_REQUEST['ids'])) {
             $post_id = $post_ID = (int) $_REQUEST['ids'];
         } else {
             $post_id = $post_ID = 0;
         }
         global $post;
         $post = $post_type = $post_type_object = null;
         if ($post_id) {
             $post = get_post($post_id);
         }
         if ($post) {
             $post_type = $post->post_type;
             if ($post_type != TM_EPO_GLOBAL_POST_TYPE) {
                 $edit_link = admin_url('post.php?action=edit&post=' . $post_id);
开发者ID:baden03,项目名称:access48,代码行数:67,代码来源:class-tm-epo-admin-global-base.php


注:本文中的bulk_edit_posts函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。