From 73d6d8be3fd45520f30faa6481537151a6197da7 Mon Sep 17 00:00:00 2001 From: Renato Alves <19148962+renatonascalves@users.noreply.github.com> Date: Fri, 10 Nov 2023 09:11:56 -0300 Subject: [PATCH] Handling `archiveless` posts in Elasticsearch plugins --- inc/class-archiveless.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/inc/class-archiveless.php b/inc/class-archiveless.php index 7bb35d3c..03581613 100644 --- a/inc/class-archiveless.php +++ b/inc/class-archiveless.php @@ -65,6 +65,10 @@ protected function __construct() { add_action( 'save_post', [ $this, 'save_post' ] ); add_action( 'wp_head', [ $this, 'on_wp_head' ] ); + // Third-party plugin support. + add_filter( 'ep_indexable_post_status', [ $this, 'filter__elasticsearch_indexable_post_statuses' ] ); + add_filter( 'sp_config_sync_statuses', [ $this, 'filter__elasticsearch_indexable_post_statuses' ] ); + if ( is_admin() ) { add_action( 'post_submitbox_misc_actions', [ $this, 'add_ui' ] ); add_action( 'add_meta_boxes', [ $this, 'fool_edit_form' ] ); @@ -74,6 +78,18 @@ protected function __construct() { } } + /** + * Add the `archiveless` post status to the list of indexable post statuses. + * + * @see + * + * @param string[] $post_statuses The list of indexable post statuses. + * @return string[] + */ + public function filter__elasticsearch_indexable_post_statuses( $post_statuses ): array { + return array_unique( array_merge( $post_statuses, [ self::$status ] ) ); + } + /** * Instance method. Initializes the instance, if not done already, and returns it. *