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);
                     }
                 }
                 break;
         }
     }
     $sendback = remove_query_arg(array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback);
     wp_redirect($sendback);
     exit;
 }
                     }
                 }
                 $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);
 }
 /**
  * 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;
     }
 }
Ejemplo n.º 4
0
                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;
Ejemplo n.º 5
0
 /**
  * @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);
 }
	/**
	 * @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 );
	}
Ejemplo n.º 7
0
 /**
  * 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']));
 }
 /**
  *  Pre-render actions
  */
 public function tm_admin_init()
 {
     /**
      *  Custom filters for the edit and delete links.
      */
     add_filter('get_edit_post_link', array($this, 'tm_get_edit_post_link'), 10, 3);
     add_filter('get_delete_post_link', array($this, 'tm_get_delete_post_link'), 10, 3);
     /*
      *  Check if we are on the plugin page
      */
     if (!isset($_GET['page']) || $_GET['page'] != 'tm-global-epo') {
         return;
     }
     // remove annoying messages that mess up the interface
     remove_all_actions('admin_notices');
     // WPML: set correct language according to post
     TM_EPO_WPML()->set_post_lang();
     // save meta data
     add_action('save_post', array($this, 'tm_save_postdata'), 1, 2);
     //global $typenow;
     //if ( ! $typenow ){
     //wp_die( __( 'Invalid post type', TM_EPO_TRANSLATION ) );
     //}
     if (!class_exists('WP_List_Table')) {
         wp_die(__('Something went wrong with WordPress.', TM_EPO_TRANSLATION));
     }
     global $bulk_counts, $bulk_messages, $general_messages;
     $post_type = 'product';
     $post_type_object = get_post_type_object($post_type);
     if (!$post_type_object) {
         wp_die(__('WooCommerce is not enabled!', TM_EPO_TRANSLATION));
     }
     if (!current_user_can($post_type_object->cap->edit_posts)) {
         wp_die(__('Cheatin’ uh?', TM_EPO_TRANSLATION));
     }
     $this->tm_list_table = $this->get_wp_list_table('TM_EPO_ADMIN_Global_List_Table');
     $post_type = $this->tm_list_table->screen->post_type;
     $pagenum = $this->tm_list_table->get_pagenum();
     $parent_file = "edit.php?post_type=product&page=" . TM_EPO_GLOBAL_POST_TYPE_PAGE_HOOK;
     $submenu_file = "edit.php?post_type=product&page=" . TM_EPO_GLOBAL_POST_TYPE_PAGE_HOOK;
     $post_new_file = "edit.php?post_type=product&page=" . TM_EPO_GLOBAL_POST_TYPE_PAGE_HOOK . "&action=add";
     $doaction = $this->tm_list_table->current_action();
     $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);
     $sendback = esc_url_raw($sendback);
     /**
      * Bulk actions
      */
     if ($doaction && isset($_REQUEST['tm_bulk'])) {
         check_admin_referer('bulk-posts');
         if ('delete_all' == $doaction) {
             $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
             if (get_post_status_object($post_status)) {
                 // Check if the post status exists first
                 global $wpdb;
                 $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type=%s AND post_status = %s", $post_type, $post_status));
             }
             $doaction = 'delete';
         } elseif (isset($_REQUEST['ids'])) {
             $post_ids = explode(',', $_REQUEST['ids']);
         } elseif (!empty($_REQUEST['post'])) {
             $post_ids = array_map('intval', $_REQUEST['post']);
         }
         if (!isset($post_ids)) {
             wp_redirect($sendback);
             exit;
         }
         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.', TM_EPO_TRANSLATION));
                     }
                     if (wp_check_post_lock($post_id)) {
                         $locked++;
                         continue;
                     }
                     if (!wp_trash_post($post_id)) {
                         wp_die(__('Error in moving to Trash.', TM_EPO_TRANSLATION));
                     }
                     $trashed++;
                 }
                 $sendback = add_query_arg(array('from_bulk' => 1, 'trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked), $sendback);
                 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.', 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);
                 wp_redirect($edit_link);
                 exit;
             }
             $post_type_object = get_post_type_object($post_type);
         }
         switch ($doaction) {
             case 'export':
                 $this->tm_export_form_action($post_id);
                 $_redirect = remove_query_arg(array('action', 'post', '_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']));
                 $_redirect = add_query_arg('message', 21, $_redirect);
                 $_redirect = esc_url_raw($_redirect);
                 wp_redirect($_redirect);
                 break;
             case 'clone':
                 $this->tm_clone_form_action($post_id);
                 $_redirect = remove_query_arg(array('action', 'post', '_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']));
                 $_redirect = esc_url_raw($_redirect);
                 wp_redirect($_redirect);
                 exit;
                 break;
             case 'trash':
                 check_admin_referer('trash-post_' . $post_id);
                 if (!$post) {
                     wp_die(__('The item you are trying to move to the Trash no longer exists.', TM_EPO_TRANSLATION));
                 }
                 if (!$post_type_object) {
                     wp_die(__('Unknown post type.', TM_EPO_TRANSLATION));
                 }
                 if (!current_user_can('delete_post', $post_id)) {
                     wp_die(__('You are not allowed to move this item to the Trash.', TM_EPO_TRANSLATION));
                 }
                 if ($user_id = wp_check_post_lock($post_id)) {
                     $user = get_userdata($user_id);
                     wp_die(sprintf(__('You cannot move this item to the Trash. %s is currently editing.', TM_EPO_TRANSLATION), $user->display_name));
                 }
                 if (!wp_trash_post($post_id)) {
                     wp_die(__('Error in moving to Trash.', TM_EPO_TRANSLATION));
                 }
                 wp_redirect(esc_url_raw(add_query_arg(array('trashed' => 1, 'ids' => $post_id), $sendback)));
                 exit;
                 break;
             case 'untrash':
                 check_admin_referer('untrash-post_' . $post_id);
                 if (!$post) {
                     wp_die(__('The item you are trying to restore from the Trash no longer exists.', TM_EPO_TRANSLATION));
                 }
                 if (!$post_type_object) {
                     wp_die(__('Unknown post type.', TM_EPO_TRANSLATION));
                 }
                 if (!current_user_can('delete_post', $post_id)) {
                     wp_die(__('You are not allowed to move this item out of the Trash.', TM_EPO_TRANSLATION));
                 }
                 if (!wp_untrash_post($post_id)) {
                     wp_die(__('Error in restoring from Trash.', TM_EPO_TRANSLATION));
                 }
                 wp_redirect(esc_url_raw(add_query_arg('untrashed', 1, $sendback)));
                 exit;
                 break;
             case 'delete':
                 check_admin_referer('delete-post_' . $post_id);
                 if (!$post) {
                     wp_die(__('This item has already been deleted.', TM_EPO_TRANSLATION));
                 }
                 if (!$post_type_object) {
                     wp_die(__('Unknown post type.', TM_EPO_TRANSLATION));
                 }
                 if (!current_user_can('delete_post', $post_id)) {
                     wp_die(__('You are not allowed to delete this item.', TM_EPO_TRANSLATION));
                 }
                 $force = !EMPTY_TRASH_DAYS;
                 if ($post->post_type == 'attachment') {
                     $force = $force || !MEDIA_TRASH;
                     if (!wp_delete_attachment($post_id, $force)) {
                         wp_die(__('Error in deleting.', TM_EPO_TRANSLATION));
                     }
                 } else {
                     if (!wp_delete_post($post_id, $force)) {
                         wp_die(__('Error in deleting.', TM_EPO_TRANSLATION));
                     }
                 }
                 wp_redirect(esc_url_raw(add_query_arg('deleted', 1, $sendback)));
                 exit;
                 break;
             case 'editpost':
                 check_admin_referer('update-post_' . $post_id);
                 $post_id = edit_post();
                 // Session cookie flag that the post was saved
                 if (isset($_COOKIE['wp-saving-post-' . $post_id])) {
                     setcookie('wp-saving-post-' . $post_id, 'saved');
                 }
                 $this->redirect_post($post_id);
                 exit;
                 break;
             case 'edit':
                 if (empty($post_id)) {
                     wp_redirect(admin_url($parent_file));
                     exit;
                 }
                 if (!$post) {
                     wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?', TM_EPO_TRANSLATION));
                 }
                 if (!$post_type_object) {
                     wp_die(__('Unknown post type.', TM_EPO_TRANSLATION));
                 }
                 if (!current_user_can('edit_post', $post_id)) {
                     wp_die(__('You are not allowed to edit this item.', TM_EPO_TRANSLATION));
                 }
                 if ('trash' == $post->post_status) {
                     wp_die(__('You can’t edit this item because it is in the Trash. Please restore it and try again.', TM_EPO_TRANSLATION));
                 }
                 break;
             case 'add':
                 $post_type = $this->tm_list_table->screen->post_type;
                 $post_type_object = get_post_type_object($post_type);
                 if (!current_user_can($post_type_object->cap->edit_posts) || !current_user_can($post_type_object->cap->create_posts)) {
                     wp_die(__('Cheatin’ uh?', TM_EPO_TRANSLATION));
                 }
                 break;
             case 'import':
                 $this->import();
                 break;
             case 'download':
                 $this->download();
                 break;
         }
     } elseif (!empty($_REQUEST['_wp_http_referer'])) {
         wp_redirect(esc_url_raw(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))));
         exit;
     }
     /**
      * We get here if we are in the list view.
      */
     $bulk_counts = array('updated' => isset($_REQUEST['updated']) ? absint($_REQUEST['updated']) : 0, 'locked' => isset($_REQUEST['locked']) ? absint($_REQUEST['locked']) : 0, 'deleted' => isset($_REQUEST['deleted']) ? absint($_REQUEST['deleted']) : 0, 'trashed' => isset($_REQUEST['trashed']) ? absint($_REQUEST['trashed']) : 0, 'untrashed' => isset($_REQUEST['untrashed']) ? absint($_REQUEST['untrashed']) : 0);
     $bulk_messages = array();
     $bulk_messages[$post_type] = array('updated' => _n('%s post updated.', '%s posts updated.', $bulk_counts['updated']), 'locked' => _n('%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked']), 'deleted' => _n('%s post permanently deleted.', '%s posts permanently deleted.', $bulk_counts['deleted']), 'trashed' => _n('%s post moved to the Trash.', '%s posts moved to the Trash.', $bulk_counts['trashed']), 'untrashed' => _n('%s post restored from the Trash.', '%s posts restored from the Trash.', $bulk_counts['untrashed']));
     $bulk_counts = array_filter($bulk_counts);
     $general_messages = array();
     $general_messages[$post_type] = array(21 => __('The selected form does not contain any sections', TM_EPO_TRANSLATION));
     $general_messages = array_filter($general_messages);
 }