PluginProbe
ElasticPress / 5.3.5
ElasticPress v5.3.5
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
← All changes | includes/classes/Feature/Facets/Block.php +17 -20 4.7.15.3.5 View file →
@@ -23,36 +23,33 @@
23 23 */
24 24 abstract public function register_block();
25 25
26 26 /**
27 - * Setup REST endpoints for facet feature.
28 - */
29 - abstract public function setup_endpoints();
30 -
31 - /**
32 27 * Render the block.
33 28 *
34 29 * @param array $attributes Block attributes.
35 30 * @return string
36 31 */
37 - abstract public function render_block( $attributes );
32 + abstract public function render_block( $attributes );
38 33
39 34 /**
40 - * Outputs the block preview
35 + * Check if facets should be enabled in the editor.
41 36 *
42 - * @param \WP_REST_Request $request REST request
43 - * @return string
37 + * @since 5.3.0
38 + * @return boolean
44 39 */
45 - abstract public function render_block_preview( $request );
40 + public function is_facet_enabled_in_editor(): bool {
41 + global $pagenow;
46 42
47 - /**
48 - * Check if the current user has permission to view the facets REST endpoint.
49 - *
50 - * @return true|\WP_Error
51 - */
52 - public function check_facets_rest_permission() {
53 - if ( ! current_user_can( 'edit_theme_options' ) ) {
54 - return new \WP_Error( 'ep_rest_forbidden', esc_html__( 'Sorry, you cannot view this resource.', 'elasticpress' ), array( 'status' => 401 ) );
55 - }
56 - return true;
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 ) );
57 54 }
58 55 }