Skip to content

Commit

Permalink
Adds filter for facet the block editor for posts
Browse files Browse the repository at this point in the history
For #3775
  • Loading branch information
JiveDig committed Dec 29, 2023
1 parent a34c1fa commit 2fb90c5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions includes/classes/Feature/Facets/Facets.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,23 @@ public function __construct() {
public function setup() {
global $pagenow;

// This feature should not run while in the editor.
if ( in_array( $pagenow, [ 'post-new.php', 'post.php' ], true ) ) {
return;
}

foreach ( $this->types as $type => $class ) {
/**
* Filter if facet should be enabled in the editor.
*
* @hook ep_facet_enabled_in_editor
* @since TBD
* @param {bool} $enabled If enabled
* @param {string} $type The facet type
* @return {bool} If enabled or not
*/
$enabled = apply_filters( 'ep_facet_enabled_in_editor', false, $type );

// Skip if this feature should not run while in the post editor.
if ( in_array( $pagenow, [ 'post-new.php', 'post.php' ], true ) && ! $enabled ) {
continue;
}

$this->types[ $type ]->setup();
}

Expand Down

0 comments on commit 2fb90c5

Please sign in to comment.