Permanently delete config post types when trashed
This commit is contained in:
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
* Registers post types and taxonomies
|
* Registers post types and taxonomies
|
||||||
*
|
*
|
||||||
* @class SP_Post_types
|
* @class SP_Post_types
|
||||||
* @version 1.3
|
* @version 1.4
|
||||||
* @package SportsPress/Classes
|
* @package SportsPress/Classes
|
||||||
* @category Class
|
* @category Class
|
||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
@@ -22,6 +22,7 @@ class SP_Post_types {
|
|||||||
public function __construct() {
|
public function __construct() {
|
||||||
add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 );
|
add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 );
|
||||||
add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
|
add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
|
||||||
|
add_action( 'wp_trash_post', array( $this, 'delete_config_post' ) );
|
||||||
add_filter( 'the_posts', array( $this, 'display_scheduled_events' ) );
|
add_filter( 'the_posts', array( $this, 'display_scheduled_events' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,6 +579,13 @@ class SP_Post_types {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete_config_post( $post_id ) {
|
||||||
|
$post_type = get_post_type( $post_id );
|
||||||
|
if ( is_sp_config_type( $post_type ) ) {
|
||||||
|
wp_delete_post( $post_id, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function display_scheduled_events( $posts ) {
|
public function display_scheduled_events( $posts ) {
|
||||||
global $wp_query, $wpdb;
|
global $wp_query, $wpdb;
|
||||||
if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['sp_event'] )) {
|
if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['sp_event'] )) {
|
||||||
|
|||||||
Reference in New Issue
Block a user