Skip to content

Commit

Permalink
Handling archiveless posts in Elasticsearch plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
renatonascalves committed Nov 10, 2023
1 parent bd86603 commit 73d6d8b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions inc/class-archiveless.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );
Expand All @@ -74,6 +78,18 @@ protected function __construct() {
}
}

/**
* Add the `archiveless` post status to the list of indexable post statuses.
*
* @see <https://github.com/alleyinteractive/archiveless/issues/62>
*
* @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.
*
Expand Down

0 comments on commit 73d6d8b

Please sign in to comment.