Skip to content

Commit

Permalink
Merge pull request #64 from alleyinteractive/feature/support-elastics…
Browse files Browse the repository at this point in the history
…earch-plugins

Handling `archiveless` posts in Elasticsearch plugins
  • Loading branch information
renatonascalves authored Nov 13, 2023
2 parents 8d9b71d + 73d6d8b commit e128ef9
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 @@ -67,6 +67,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 @@ -76,6 +80,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 e128ef9

Please sign in to comment.