-
Notifications
You must be signed in to change notification settings - Fork 2
/
load.php
48 lines (44 loc) · 1.25 KB
/
load.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Altis Search Module.
*
* @package altis/search
*
* phpcs:disable PSR1.Files.SideEffects
*/
namespace Altis\Enhanced_Search;
use Altis;
add_action( 'altis.modules.init', function () {
$default_settings = [
'enabled' => true,
'index-documents' => false,
'related-posts' => false,
'facets' => false,
'woocommerce' => false,
'autosuggest' => false,
'slowlog_thresholds' => true,
'mode' => 'simple',
'strict' => true,
'field-boost' => [],
'fuzziness' => 'auto:4,7',
'users' => true,
'terms' => true,
'comments' => false,
'inline-index-settings' => true,
];
$options = [
'defaults' => $default_settings,
];
Altis\register_module( 'search', __DIR__, 'Search', $options, __NAMESPACE__ . '\\bootstrap' );
} );
// Ensure ElasticPress commands don't use debug mode as it can result
// in out of memory errors on big sites as queries are logged during bulk updates.
add_action( 'altis.loaded_autoloader', function () {
if ( ! defined( 'WP_CLI' ) || ! WP_CLI || ! isset( $_SERVER['argv'] ) ) {
return;
}
// phpcs:ignore HM.Security.ValidatedSanitizedInput -- Comparing $_SERVER value to a string directly.
if ( ( $_SERVER['argv'][1] ?? '' ) === 'elasticpress' ) {
defined( 'WP_DEBUG' ) or define( 'WP_DEBUG', false );
}
}, 5 );