PluginProbe
ElasticPress / 4.7.2
ElasticPress v4.7.2
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
elasticpress / includes / classes / Feature / Facets / Block.php

Block.php in ElasticPress 4.7.2, at includes/classes/Feature/Facets/Block.php

59 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Abstract Facet Block class.
4 *
5 * @since 4.7.0
6 * @package elasticpress
7 */
8
9 namespace ElasticPress\Feature\Facets;
10
11 /**
12 * Abstract Facet Block class.
13 */
14 abstract class Block {
15
16 /**
17 * Setup hooks and filters for facet block.
18 */
19 abstract public function setup();
20
21 /**
22 * Register facet block.
23 */
24 abstract public function register_block();
25
26 /**
27 * Setup REST endpoints for facet feature.
28 */
29 abstract public function setup_endpoints();
30
31 /**
32 * Render the block.
33 *
34 * @param array $attributes Block attributes.
35 * @return string
36 */
37 abstract public function render_block( $attributes );
38
39 /**
40 * Outputs the block preview
41 *
42 * @param \WP_REST_Request $request REST request
43 * @return string
44 */
45 abstract public function render_block_preview( $request );
46
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;
57 }
58 }
59