/** * Check if the 'blacklist' GET param is set, and prepare to blacklist * the item. * * @since 4.4 */ function wprss_check_if_blacklist_item() { // If the GET param is not set, do nothing. Return. if (empty($_GET['wprss_blacklist'])) { return; } // Get the ID from the GET param $ID = $_GET['wprss_blacklist']; // If the post does not exist, stop. Show a message if (get_post($ID) === NULL) { wp_die(__('The item you are trying to blacklist does not exist', WPRSS_TEXT_DOMAIN)); } // If the post type is not correct, if (get_post_meta($ID, 'wprss_item_permalink', TRUE) === '' || get_post_status($ID) !== 'trash') { wp_die(__('The item you are trying to blacklist is not valid!', WPRSS_TEXT_DOMAIN)); } check_admin_referer('blacklist-item-' . $ID, 'wprss_blacklist_item'); wprss_blacklist_item($ID); // Get the current post type for the current page $post_type = isset($_GET['post_type']) ? $_GET['post_type'] : 'post'; // Check the current page, and generate the URL query string for the page $paged = isset($_GET['paged']) ? '&paged=' . $_GET['paged'] : ''; // Set the notice transient set_transient('wprss_item_blacklist_notice', 'true'); // Refresh the page without the GET parameter wp_redirect(admin_url("edit.php?post_type={$post_type}&post_status=trash" . $paged)); exit; }
/** * Check if the 'blacklist' GET param is set, and prepare to blacklist * the item. * * @since 4.4 */ function wprss_check_if_blacklist_item() { // If the GET param is not set, do nothing. Return. if (empty($_GET['wprss_blacklist'])) { return; } // Get the ID from the GET param $ID = $_GET['wprss_blacklist']; // If the post does not exist, stop. Show a message if (get_post($ID) === NULL) { wp_die('The item you are trying to blacklist does not exist'); } // If the post type is not correct, if (get_post_type($ID) !== wprss_blacklist_post_type()) { wp_die('The item you are trying to blacklist is not valid!'); } wprss_blacklist_item($ID); // Check the current page, and generate the URL query string for the page $paged = isset($_GET['paged']) ? '&paged=' . $_GET['paged'] : ''; // Get the blacklisting post type $post_type = wprss_blacklist_post_type(); // Refresh the page without the GET parameter header('Location: ' . admin_url("edit.php?post_type={$post_type}" . $paged)); exit; }