[wp-trac] [WordPress Trac] #35871: before_delete_post incorrectly triggered from edit.php to post.php
WordPress Trac
noreply at wordpress.org
Fri Feb 19 10:44:20 UTC 2016
#35871: before_delete_post incorrectly triggered from edit.php to post.php
-------------------------------+-----------------------------
Reporter: Jonathandejong | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 4.4.2
Severity: normal | Keywords:
Focuses: administration |
-------------------------------+-----------------------------
It seems there's a bug where {{{before_delete_post}}} triggers when
clicking the post name (on edit.php) to go to the post.php admin edit
screen. I have this code
{{{#!php
<?php
add_action('before_delete_post', $plugin_admin, 'prevent_club_deletion',
5);
public function prevent_club_deletion() {
global $post_type;
if ( $post_type != 'club' )
return;
$redirect = ( isset($_SERVER["HTTP_REFERER"]) ?
$_SERVER["HTTP_REFERER"] : get_admin_url(1, 'edit.php?post_type=club') );
wp_redirect( $redirect );
exit();
}
}}}
It randomly triggers the redirect when attempting to head into single edit
screen for a post. It's a hierarchical CPT and the bug occurs for both
parent and child pages. Tested with custom theme (no hooks really) and no
plugins activated (except the one that creates the CPT and this hook).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35871>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list