diff --git a/includes/post_type.php b/includes/post_type.php index 16422f3..ed64322 100644 --- a/includes/post_type.php +++ b/includes/post_type.php @@ -29,6 +29,8 @@ class CPTDA_Post_Types { */ private $post_types = array(); + private $name; + public function __construct() { add_action( 'wp_loaded', array( $this, 'setup' ) ); } @@ -153,8 +155,8 @@ private function publish_scheduled_posts() { } foreach ( $future_types as $name ) { - remove_action( "future_{$name}", '_future_post_hook' ); - add_action( "future_{$name}", array( $this, '_future_post_hook' ) ); + remove_action( 'future_' . $name, '_future_post_hook', 5, 2 ); + add_action( "future_{$name}", array( $this, '_future_post_hook' ), 10 , 2 ); } } @@ -162,11 +164,12 @@ private function publish_scheduled_posts() { * Set new post's post_status to "publish" if the post is sceduled. * * @since 1.2.0 - * @param int $post_id Post ID. + * @param int $post_id Post ID (deprecated argument). + * @param WP_Post $post Post object. * @return void */ - public function _future_post_hook( $post_id ) { - $post = get_post( $post_id ); + public function _future_post_hook( $post_id, $post ) { + $post = get_post( $post ); /** * Filter whether to publish posts with future dates from a specific post type. @@ -176,7 +179,7 @@ public function _future_post_hook( $post_id ) { */ $publish = apply_filters( "cptda_publish_future_{$post->post_type}", true ); if ( (bool) $publish ) { - wp_publish_post( $post_id ); + wp_publish_post( $post ); } }