| @@ -28,6 +28,28 @@ | ||
| 28 | 28 | * |
| 29 | 29 | * @param array $attributes Block attributes. |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - abstract public function render_block( $attributes ); | |
| 32 | + abstract public function render_block( $attributes ); | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Check if facets should be enabled in the editor. | |
| 36 | + * | |
| 37 | + * @since 5.3.0 | |
| 38 | + * @return boolean | |
| 39 | + */ | |
| 40 | + public function is_facet_enabled_in_editor(): bool { | |
| 41 | + global $pagenow; | |
| 42 | + | |
| 43 | + $in_editor = in_array( $pagenow, [ 'post-new.php', 'post.php' ], true ); | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Filter if facet should be enabled in the editor. Default: false | |
| 47 | + * | |
| 48 | + * @hook ep_facet_enabled_in_editor | |
| 49 | + * @since 5.1.0 | |
| 50 | + * @param {bool} $enabled | |
| 51 | + * @return {bool} If enabled or not | |
| 52 | + */ | |
| 53 | + return ! ( $in_editor && ! apply_filters( 'ep_facet_enabled_in_editor', false ) ); | |
| 54 | + } | |
| 33 | 55 | } |