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/dashboard.php +87 -159 4.7.05.3.5 View file →
@@ -7,16 +7,15 @@
7 7 */
8 8
9 9 namespace ElasticPress\Dashboard;
10 10
11 -use ElasticPress\Utils as Utils;
11 +use ElasticPress\AdminNotices;
12 12 use ElasticPress\Elasticsearch;
13 13 use ElasticPress\Features;
14 -use ElasticPress\Indexables;
15 14 use ElasticPress\Installer;
16 -use ElasticPress\AdminNotices;
17 15 use ElasticPress\Screen;
18 16 use ElasticPress\Stats;
17 +use ElasticPress\Utils;
19 18
20 19 if ( ! defined( 'ABSPATH' ) ) {
21 20 exit; // Exit if accessed directly.
22 21 }
@@ -29,15 +28,13 @@
29 28 function setup() {
30 29 if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { // Must be network admin in multisite.
31 30 add_action( 'network_admin_menu', __NAMESPACE__ . '\action_admin_menu' );
32 31 add_action( 'admin_bar_menu', __NAMESPACE__ . '\action_network_admin_bar_menu', 50 );
33 - } else {
34 - add_action( 'admin_menu', __NAMESPACE__ . '\action_admin_menu' );
35 32 }
36 33
34 + add_action( 'admin_menu', __NAMESPACE__ . '\action_admin_menu' );
37 35 add_action( 'wp_ajax_ep_save_feature', __NAMESPACE__ . '\action_wp_ajax_ep_save_feature' );
38 36 add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\action_admin_enqueue_dashboard_scripts' );
39 - add_action( 'admin_init', __NAMESPACE__ . '\action_admin_init' );
40 37 add_action( 'admin_init', __NAMESPACE__ . '\maybe_clear_es_info_cache' );
41 38 add_action( 'admin_init', __NAMESPACE__ . '\maybe_skip_install' );
42 39 add_action( 'wp_ajax_ep_notice_dismiss', __NAMESPACE__ . '\action_wp_ajax_ep_notice_dismiss' );
43 40 add_action( 'admin_notices', __NAMESPACE__ . '\maybe_notice' );
@@ -46,10 +43,10 @@
46 43 add_filter( 'network_admin_plugin_action_links', __NAMESPACE__ . '\filter_plugin_action_links', 10, 2 );
47 44 add_action( 'ep_add_query_log', __NAMESPACE__ . '\log_version_query_error' );
48 45 add_filter( 'ep_analyzer_language', __NAMESPACE__ . '\use_language_in_setting', 10, 2 );
49 46 add_filter( 'wp_kses_allowed_html', __NAMESPACE__ . '\filter_allowed_html', 10, 2 );
50 - add_action( 'rest_api_init', __NAMESPACE__ . '\setup_endpoint' );
51 47 add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\block_assets' );
48 + add_action( 'init', __NAMESPACE__ . '\register_react_jsx_runtime', 1 );
52 49
53 50 if ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) {
54 51 add_action( 'block_categories_all', __NAMESPACE__ . '\block_categories' );
55 52 } else {
@@ -73,8 +70,29 @@
73 70 }
74 71 }
75 72
76 73 /**
74 + * Register the `react-jsx-runtime` script handle on WordPress versions that
75 + * do not ship it. WordPress added it in 6.6; 10up-toolkit emits it as a
76 + * dependency of the React admin and Instant Results bundles, and without the
77 + * handle those scripts never print on WordPress 6.2.
78 + *
79 + * @since 5.3.4
80 + * @return void
81 + */
82 +function register_react_jsx_runtime() {
83 + if ( wp_script_is( 'react-jsx-runtime', 'registered' ) ) {
84 + return;
85 + }
86 +
87 + wp_register_script( 'react-jsx-runtime', false, [ 'react' ], '18', true );
88 + wp_add_inline_script(
89 + 'react-jsx-runtime',
90 + 'window.ReactJSXRuntime=window.ReactJSXRuntime||{Fragment:window.React.Fragment,jsx:function(type,config,maybeKey){var props=Object.assign({},config);if(maybeKey!==undefined){props.key=maybeKey;}return window.React.createElement(type,props);},jsxs:function(type,config,maybeKey){var props=Object.assign({},config);if(maybeKey!==undefined){props.key=maybeKey;}return window.React.createElement(type,props);}};'
91 + );
92 +}
93 +
94 +/**
77 95 * Add ep-html kses context
78 96 *
79 97 * @param array $allowedtags HTML tags
80 98 * @param string $context Context string
@@ -138,17 +156,16 @@
138 156 * @param array $query The version query.
139 157 * @since 3.0
140 158 */
141 159 function log_version_query_error( $query ) {
142 - $is_network = defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK;
160 + // Ignore fake requests like the autosuggest template generation
161 + if ( ! empty( $query['request'] ) && is_array( $query['request'] ) && ! empty( $query['request']['is_ep_fake_request'] ) ) {
162 + return;
163 + }
143 164
144 165 $logging_key = 'logging_ep_es_info';
145 166
146 - if ( $is_network ) {
147 - $logging = get_site_transient( $logging_key );
148 - } else {
149 - $logging = get_transient( $logging_key );
150 - }
167 + $logging = Utils\get_transient( $logging_key );
151 168
152 169 // Are we logging the version query results?
153 170 if ( '1' === $logging ) {
154 171 /**
@@ -175,17 +192,11 @@
175 192
176 193 // Store the response code, and remove the flag that says
177 194 // we're logging the response code so we don't log additional
178 195 // queries.
179 - if ( $is_network ) {
180 - set_site_transient( $response_code_key, $response_code, $cache_time );
181 - set_site_transient( $response_error_key, $response_error, $cache_time );
182 - delete_site_transient( $logging_key );
183 - } else {
184 - set_transient( $response_code_key, $response_code, $cache_time );
185 - set_transient( $response_error_key, $response_error, $cache_time );
186 - delete_transient( $logging_key );
187 - }
196 + Utils\set_transient( $response_code_key, $response_code, $cache_time );
197 + Utils\set_transient( $response_error_key, $response_error, $cache_time );
198 + Utils\delete_transient( $logging_key );
188 199 }
189 200 }
190 201
191 202 /**
@@ -197,9 +208,9 @@
197 208 if ( ! is_admin() && ! is_network_admin() ) {
198 209 return;
199 210 }
200 211
201 - if ( empty( $_GET['ep-skip-install'] ) || empty( $_GET['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['nonce'] ), 'ep-skip-install' ) || ! in_array( Screen::factory()->get_current_screen(), [ 'install' ], true ) ) { // phpcs:ignore WordPress.Security.NonceVerification
212 + if ( empty( $_GET['ep-skip-install'] ) || empty( $_GET['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['nonce'] ), 'ep-skip-install' ) || ! in_array( Screen::factory()->get_current_screen(), [ 'install' ], true ) ) {
202 213 return;
203 214 }
204 215
205 216 if ( ! empty( $_GET['ep-skip-features'] ) ) {
@@ -231,9 +242,13 @@
231 242 if ( ! is_admin() && ! is_network_admin() ) {
232 243 return;
233 244 }
234 245
235 - if ( empty( $_GET['ep-retry'] ) && ! in_array( Screen::factory()->get_current_screen(), [ 'dashboard', 'settings', 'install' ], true ) ) { // phpcs:ignore WordPress.Security.NonceVerification
246 + $isset_retry = ! empty( $_GET['ep-retry'] ) &&
247 + ! empty( $_GET['ep_retry_nonce'] ) &&
248 + wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['ep_retry_nonce'] ) ), 'ep_retry_nonce' );
249 +
250 + if ( ! $isset_retry && ! in_array( Screen::factory()->get_current_screen(), [ 'dashboard', 'settings', 'install' ], true ) ) {
236 251 return;
237 252 }
238 253
239 254 if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
@@ -241,10 +256,10 @@
241 256 } else {
242 257 delete_transient( 'ep_es_info' );
243 258 }
244 259
245 - if ( ! empty( $_GET['ep-retry'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
246 - wp_safe_redirect( remove_query_arg( 'ep-retry' ) );
260 + if ( $isset_retry ) {
261 + wp_safe_redirect( remove_query_arg( [ 'ep-retry', 'ep_retry_nonce' ] ) );
247 262 exit();
248 263 }
249 264 }
250 265
@@ -304,17 +319,10 @@
304 319 * @param bool $force Force ES info hard lookup.
305 320 * @since 3.0
306 321 */
307 322 function maybe_notice( $force = false ) {
308 - // Admins only.
309 - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
310 - if ( ! is_super_admin() || ! is_network_admin() ) {
311 - return false;
312 - }
313 - } else {
314 - if ( is_network_admin() || ! current_user_can( Utils\get_capability() ) ) {
315 - return false;
316 - }
323 + if ( ! current_user_can( Utils\get_capability() ) ) {
324 + return false;
317 325 }
318 326
319 327 /**
320 328 * Filter how long results of Elasticsearch version query are stored
@@ -325,21 +333,13 @@
325 333 * @return {int} New time in seconds
326 334 */
327 335 $cache_time = apply_filters( 'ep_es_info_cache_expiration', ( 5 * MINUTE_IN_SECONDS ) );
328 336
329 - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
330 - set_site_transient(
331 - 'logging_ep_es_info',
332 - '1',
333 - $cache_time
334 - );
335 - } else {
336 - $a = set_transient(
337 - 'logging_ep_es_info',
338 - '1',
339 - $cache_time
340 - );
341 - }
337 + Utils\set_transient(
338 + 'logging_ep_es_info',
339 + '1',
340 + $cache_time
341 + );
342 342
343 343 // Fetch ES version
344 344 Elasticsearch::factory()->get_elasticsearch_version( $force );
345 345
@@ -347,13 +347,14 @@
347 347
348 348 $notices = AdminNotices::factory()->get_notices();
349 349
350 350 foreach ( $notices as $notice_key => $notice ) {
351 + $class = 'notice notice-' . $notice['type'];
352 + if ( $notice['dismiss'] ) {
353 + $class .= ' is-dismissible';
354 + }
351 355 ?>
352 - <div data-ep-notice="<?php echo esc_attr( $notice_key ); ?>" class="notice notice-<?php echo esc_attr( $notice['type'] ); ?> <?php
353 - if ( $notice['dismiss'] ) :
354 - ?>
355 - is-dismissible<?php endif; ?>">
356 + <div data-ep-notice="<?php echo esc_attr( $notice_key ); ?>" class="<?php echo esc_attr( $class ); ?>">
356 357 <p>
357 358 <?php echo wp_kses( $notice['html'], 'ep-html' ); ?>
358 359 </p>
359 360 </div>
@@ -469,9 +470,19 @@
469 470
470 471 wp_localize_script( 'ep_admin_sites_scripts', 'epsa', $data );
471 472 }
472 473
473 - if ( in_array( Screen::factory()->get_current_screen(), [ 'dashboard', 'settings', 'install', 'health', 'weighting', 'synonyms', 'sync', 'status-report' ], true ) ) {
474 + $general_ep_screens = [ 'dashboard', 'settings', 'install', 'health', 'weighting', 'synonyms', 'sync', 'status-report' ];
475 + /**
476 + * Filter the query logger object
477 + *
478 + * @since 5.3.3
479 + * @hook elasticpress_general_ep_screens
480 + * @param {array} $general_ep_screens The general ElasticPress screens.
481 + * @return {array} The filtered general ElasticPress screens.
482 + */
483 + $general_ep_screens = apply_filters( 'elasticpress_general_ep_screens', $general_ep_screens );
484 + if ( in_array( Screen::factory()->get_current_screen(), $general_ep_screens, true ) ) {
474 485 wp_enqueue_style(
475 486 'ep_admin_styles',
476 487 EP_URL . 'dist/css/dashboard-styles.css',
477 488 Utils\get_asset_info( 'dashboard-styles', 'dependencies' ),
@@ -487,20 +498,8 @@
487 498
488 499 wp_set_script_translations( 'ep_admin_script', 'elasticpress' );
489 500 }
490 501
491 - if ( in_array( Screen::factory()->get_current_screen(), [ 'weighting', 'install' ], true ) ) {
492 - wp_enqueue_script(
493 - 'ep_weighting_script',
494 - EP_URL . 'dist/js/weighting-script.js',
495 - Utils\get_asset_info( 'weighting-script', 'dependencies' ),
496 - Utils\get_asset_info( 'weighting-script', 'version' ),
497 - true
498 - );
499 -
500 - wp_set_script_translations( 'ep_weighting_script', 'elasticpress' );
501 - }
502 -
503 502 if ( in_array( Screen::factory()->get_current_screen(), [ 'dashboard', 'install' ], true ) ) {
504 503 wp_enqueue_script(
505 504 'ep_dashboard_scripts',
506 505 EP_URL . 'dist/js/dashboard-script.js',
@@ -510,11 +509,9 @@
510 509 );
511 510
512 511 wp_set_script_translations( 'ep_dashboard_scripts', 'elasticpress' );
513 512
514 - $sync_url = ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) ?
515 - network_admin_url( 'admin.php?page=elasticpress-sync&do_sync' ) :
516 - admin_url( 'admin.php?page=elasticpress-sync&do_sync' );
513 + $sync_url = Utils\get_sync_url( true );
517 514
518 515 $skip_url = ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) ?
519 516 network_admin_url( 'admin.php?page=elasticpress' ) :
520 517 admin_url( 'admin.php?page=elasticpress' );
@@ -533,20 +530,8 @@
533 530
534 531 wp_localize_script( 'ep_dashboard_scripts', 'epDash', $data );
535 532 }
536 533
537 - if ( in_array( Screen::factory()->get_current_screen(), [ 'settings' ], true ) ) {
538 - wp_enqueue_script(
539 - 'ep_settings_scripts',
540 - EP_URL . 'dist/js/settings-script.js',
541 - Utils\get_asset_info( 'settings-script', 'dependencies' ),
542 - Utils\get_asset_info( 'settings-script', 'version' ),
543 - true
544 - );
545 -
546 - wp_set_script_translations( 'ep_settings_scripts', 'elasticpress' );
547 - }
548 -
549 534 if ( in_array( Screen::factory()->get_current_screen(), [ 'health' ], true ) && ! empty( Utils\get_host() ) ) {
550 535 Stats::factory()->build_stats();
551 536
552 537 $data = Stats::factory()->get_localized();
@@ -580,73 +565,18 @@
580 565 array(
581 566 'nonce' => wp_create_nonce( 'ep_admin_nonce' ),
582 567 )
583 568 );
584 -}
585 569
586 -/**
587 - * Admin-init actions
588 - *
589 - * Sets up Settings API.
590 - *
591 - * @since 1.9
592 - * @return void
593 - */
594 -function action_admin_init() {
595 - $post = wp_unslash( $_POST );
596 -
597 - // Save options for multisite.
598 - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK && isset( $post['ep_language'] ) ) {
599 - check_admin_referer( 'elasticpress-options' );
600 -
601 - $language = sanitize_text_field( $post['ep_language'] );
602 - Utils\update_option( 'ep_language', $language );
603 -
604 - if ( isset( $post['ep_host'] ) ) {
605 - $host = esc_url_raw( trim( $post['ep_host'] ) );
606 - Utils\update_option( 'ep_host', $host );
607 - }
608 -
609 - if ( isset( $post['ep_credentials'] ) ) {
610 - $credentials = ( isset( $post['ep_credentials'] ) ) ? Utils\sanitize_credentials( $post['ep_credentials'] ) : [
611 - 'username' => '',
612 - 'token' => '',
613 - ];
614 -
615 - Utils\update_option( 'ep_credentials', $credentials );
616 - }
617 -
618 - if ( isset( $post['ep_bulk_setting'] ) ) {
619 - Utils\update_option( 'ep_bulk_setting', intval( $post['ep_bulk_setting'] ) );
620 - }
621 - } else {
622 - register_setting( 'elasticpress', 'ep_host', 'esc_url_raw' );
623 - register_setting( 'elasticpress', 'ep_credentials', 'ep_sanitize_credentials' );
624 - register_setting( 'elasticpress', 'ep_language', 'sanitize_text_field' );
625 - register_setting(
626 - 'elasticpress',
627 - 'ep_bulk_setting',
628 - [
629 - 'type' => 'integer',
630 - 'sanitize_callback' => __NAMESPACE__ . '\sanitize_bulk_settings',
631 - ]
632 - );
633 - }
570 + wp_enqueue_style(
571 + 'ep_general_styles',
572 + EP_URL . 'dist/css/general-styles.css',
573 + Utils\get_asset_info( 'general-styles', 'dependencies' ),
574 + Utils\get_asset_info( 'general-styles', 'version' )
575 + );
634 576 }
635 577
636 578 /**
637 - * Sanitize bulk settings.
638 - *
639 - * @param int $bulk_settings Number of bulk content items
640 - * @return int
641 - */
642 -function sanitize_bulk_settings( $bulk_settings = 350 ) {
643 - $bulk_settings = absint( $bulk_settings );
644 -
645 - return ( 0 === $bulk_settings ) ? 350 : $bulk_settings;
646 -}
647 -
648 -/**
649 579 * Output current ElasticPress dashboard screen
650 580 *
651 581 * @since 3.0
652 582 */
@@ -662,8 +592,17 @@
662 592 * @since 1.9
663 593 * @return void
664 594 */
665 595 function action_admin_menu() {
596 + Installer::factory()->calculate_install_status();
597 + if ( true !== Installer::factory()->get_install_status() && ! Utils\is_top_level_admin_context() ) {
598 + return;
599 + }
600 +
601 + if ( ! Utils\is_site_indexable() && ! is_network_admin() ) {
602 + return;
603 + }
604 +
666 605 $capability = ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) ? Utils\get_network_capability() : Utils\get_capability();
667 606
668 607 add_menu_page(
669 608 'ElasticPress',
@@ -670,11 +609,15 @@
670 609 'ElasticPress',
671 610 $capability,
672 611 'elasticpress',
673 612 __NAMESPACE__ . '\resolve_screen',
674 - 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNzMgNzEuMyIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNzMgNzEuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGQ9Ik0zNi41LDQuN0MxOS40LDQuNyw1LjYsMTguNiw1LjYsMzUuN2MwLDEwLDQuNywxOC45LDEyLjEsMjQuNWw0LjUtNC41YzAuMS0wLjEsMC4xLTAuMiwwLjItMC4zbDAuNy0wLjdsNi40LTYuNGMyLjEsMS4yLDQuNSwxLjksNy4xLDEuOWM4LDAsMTQuNS02LjUsMTQuNS0xNC41cy02LjUtMTQuNS0xNC41LTE0LjVTMjIsMjcuNiwyMiwzNS42YzAsMi44LDAuOCw1LjMsMi4xLDcuNWwtNi40LDYuNGMtMi45LTMuOS00LjYtOC43LTQuNi0xMy45YzAtMTIuOSwxMC41LTIzLjQsMjMuNC0yMy40czIzLjQsMTAuNSwyMy40LDIzLjRTNDkuNCw1OSwzNi41LDU5Yy0yLjEsMC00LjEtMC4zLTYtMC44bC0wLjYsMC42bC01LjIsNS40YzMuNiwxLjUsNy42LDIuMywxMS44LDIuM2MxNy4xLDAsMzAuOS0xMy45LDMwLjktMzAuOVM1My42LDQuNywzNi41LDQuN3oiLz48L3N2Zz4='
613 + 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNzMgNzEuMyIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNzMgNzEuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGQ9Ik0zNi41LDQuN0MxOS40LDQuNyw1LjYsMTguNiw1LjYsMzUuN2MwLDEwLDQuNywxOC45LDEyLjEsMjQuNWw0LjUtNC41YzAuMS0wLjEsMC4xLTAuMiwwLjItMC4zbDAuNy0wLjdsNi40LTYuNGMyLjEsMS4yLDQuNSwxLjksNy4xLDEuOWM4LDAsMTQuNS02LjUsMTQuNS0xNC41cy02LjUtMTQuNS0xNC41LTE0LjVTMjIsMjcuNiwyMiwzNS42YzAsMi44LDAuOCw1LjMsMi4xLDcuNWwtNi40LDYuNGMtMi45LTMuOS00LjYtOC43LTQuNi0xMy45YzAtMTIuOSwxMC41LTIzLjQsMjMuNC0yMy40czIzLjQsMTAuNSwyMy40LDIzLjRTNDkuNCw1OSwzNi41LDU5Yy0yLjEsMC00LjEtMC4zLTYtMC44bC0wLjYsMC42bC01LjIsNS40YzMuNiwxLjUsNy42LDIuMywxMS44LDIuM2MxNy4xLDAsMzAuOS0xMy45LDMwLjktMzAuOVM1My42LDQuNywzNi41LDQuN3oiIGZpbGw9IiNhN2FhYWQiLz48L3N2Zz4='
675 614 );
676 615
616 + if ( ! Utils\is_top_level_admin_context() ) {
617 + return;
618 + }
619 +
677 620 add_submenu_page(
678 621 'elasticpress',
679 622 esc_html__( 'ElasticPress Features', 'elasticpress' ),
680 623 esc_html__( 'Features', 'elasticpress' ),
@@ -729,9 +672,9 @@
729 672 * @since 4.7.0
730 673 * @param string $format Format of the return ('locales' or 'elasticsearch' )
731 674 * @return array
732 675 */
733 -function get_available_languages( string $format = 'elasticsearch' ) : array {
676 +function get_available_languages( string $format = 'elasticsearch' ): array {
734 677 /**
735 678 * Filter available languages in Elasticsearch.
736 679 *
737 680 * The returned array should follow the format `Elasticsearch analyzer name => [ WordPress language package names ]`.
@@ -969,23 +912,8 @@
969 912 return wp_send_json_success( $data );
970 913 }
971 914
972 915 /**
973 - * Registers the API endpoint
974 - */
975 -function setup_endpoint() {
976 - register_rest_route(
977 - 'elasticpress/v1',
978 - 'indexing_status',
979 - [
980 - 'methods' => 'GET',
981 - 'callback' => __NAMESPACE__ . '\handle_indexing_status',
982 - 'permission_callback' => '__return_true',
983 - ]
984 - );
985 -}
986 -
987 -/**
988 916 * Handle the fetch for indexing status
989 917 */
990 918 function handle_indexing_status() {
991 919 $indexing_status = \ElasticPress\Utils\get_indexing_status();
@@ -1026,9 +954,9 @@
1026 954 'title' => 'ElasticPress',
1027 955 ];
1028 956
1029 957 return $block_categories;
1030 -};
958 +}
1031 959
1032 960 /**
1033 961 * Enqueue shared block editor assets.
1034 962 *