$data Post data about to be saved. * @return array */ public function force_private( array $data ): array { if ( Post_Type::NAME === $data['post_type'] && ! in_array( $data['post_status'], self::KEPT_STATUSES, true ) ) { $data['post_status'] = 'private'; } return $data; } /** * Drops the "Private:" prefix from page titles. * * @param string $format Title format, "Private: %s" by default. * @param \WP_Post $post Post whose title is shown. * @return string */ public function drop_title_prefix( string $format, \WP_Post $post ): string { return Post_Type::NAME === $post->post_type ? '%s' : $format; } /** * Restores pages from the trash as `private` (core restores to `draft`). * * @param string $status Status core picked for the restored post. * @param int $post_id Restored post ID. * @return string */ public function restore_as_private( string $status, int $post_id ): string { return Post_Type::NAME === get_post_type( $post_id ) ? 'private' : $status; } }