PluginProbe
ElasticPress / 4.4.1
ElasticPress v4.4.1
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 / elasticpress.php

elasticpress.php in ElasticPress 4.4.1, at elasticpress.php

255 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: ElasticPress
4 * Plugin URI: https://github.com/10up/ElasticPress
5 * Description: A fast and flexible search and query engine for WordPress.
6 * Version: 4.4.1
7 * Requires at least: 5.6
8 * Requires PHP: 7.0
9 * Author: 10up
10 * Author URI: https://10up.com
11 * License: GPL v2 or later
12 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
13 * Text Domain: elasticpress
14 *
15 * This program derives work from Alley Interactive's SearchPress
16 * and Automattic's VIP search plugin:
17 *
18 * Copyright (C) 2012-2013 Automattic
19 * Copyright (C) 2013 SearchPress
20 *
21 * @package elasticpress
22 */
23
24 namespace ElasticPress;
25
26 use \WP_CLI as WP_CLI;
27
28 if ( ! defined( 'ABSPATH' ) ) {
29 exit; // Exit if accessed directly.
30 }
31
32 define( 'EP_URL', plugin_dir_url( __FILE__ ) );
33 define( 'EP_PATH', plugin_dir_path( __FILE__ ) );
34 define( 'EP_FILE', plugin_basename( __FILE__ ) );
35 define( 'EP_VERSION', '4.4.1' );
36
37 /**
38 * PSR-4-ish autoloading
39 *
40 * @since 2.6
41 */
42 spl_autoload_register(
43 function( $class ) {
44 // project-specific namespace prefix.
45 $prefix = 'ElasticPress\\';
46
47 // base directory for the namespace prefix.
48 $base_dir = __DIR__ . '/includes/classes/';
49
50 // does the class use the namespace prefix?
51 $len = strlen( $prefix );
52
53 if ( strncmp( $prefix, $class, $len ) !== 0 ) {
54 return;
55 }
56
57 $relative_class = substr( $class, $len );
58
59 $file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
60
61 // if the file exists, require it.
62 if ( file_exists( $file ) ) {
63 require $file;
64 }
65 }
66 );
67
68 /**
69 * We compare the current ES version to this compatibility version number. Compatibility is true when:
70 *
71 * EP_ES_VERSION_MIN <= YOUR ES VERSION <= EP_ES_VERSION_MAX
72 *
73 * We don't check minor releases so if your ES version if 7.10.1, we consider that 7.10 in our comparison.
74 *
75 * @since 2.2
76 */
77 define( 'EP_ES_VERSION_MAX', '7.10' );
78 define( 'EP_ES_VERSION_MIN', '5.2' );
79
80 require_once __DIR__ . '/includes/compat.php';
81 require_once __DIR__ . '/includes/utils.php';
82 require_once __DIR__ . '/includes/health-check.php';
83
84 // Define a constant if we're network activated to allow plugin to respond accordingly.
85 $network_activated = Utils\is_network_activated( EP_FILE );
86
87 if ( $network_activated ) {
88 define( 'EP_IS_NETWORK', true );
89 }
90
91 /**
92 * Sets up the indexables and features.
93 *
94 * @return void
95 */
96 function register_indexable_posts() {
97 global $wp_version;
98
99 /**
100 * Handle indexables
101 */
102 Indexables::factory()->register( new Indexable\Post\Post() );
103
104 /**
105 * Handle features
106 */
107 Features::factory()->register_feature(
108 new Feature\Search\Search()
109 );
110
111 Features::factory()->register_feature(
112 new Feature\InstantResults\InstantResults()
113 );
114
115 Features::factory()->register_feature(
116 new Feature\Autosuggest\Autosuggest()
117 );
118
119 Features::factory()->register_feature(
120 new Feature\WooCommerce\WooCommerce()
121 );
122
123 Features::factory()->register_feature(
124 new Feature\Facets\Facets()
125 );
126
127 Features::factory()->register_feature(
128 new Feature\RelatedPosts\RelatedPosts()
129 );
130
131 Features::factory()->register_feature(
132 new Feature\SearchOrdering\SearchOrdering()
133 );
134
135 Features::factory()->register_feature(
136 new Feature\ProtectedContent\ProtectedContent()
137 );
138
139 Features::factory()->register_feature(
140 new Feature\Documents\Documents()
141 );
142
143 if ( version_compare( $wp_version, '5.3', '>=' ) || 0 === stripos( $wp_version, '5.3-' ) ) {
144 Features::factory()->register_feature(
145 new Feature\Comments\Comments()
146 );
147 }
148
149 if ( version_compare( $wp_version, '5.1', '>=' ) || 0 === stripos( $wp_version, '5.1-' ) ) {
150 Features::factory()->register_feature(
151 new Feature\Users\Users()
152 );
153 }
154
155 if ( version_compare( $wp_version, '5.3', '>=' ) || 0 === stripos( $wp_version, '5.3-' ) ) {
156 Features::factory()->register_feature(
157 new Feature\Terms\Terms()
158 );
159 }
160
161 /**
162 * Register search algorithms
163 */
164 SearchAlgorithms::factory()->register( new SearchAlgorithm\DefaultAlgorithm() );
165 SearchAlgorithms::factory()->register( new SearchAlgorithm\Version_350() );
166 SearchAlgorithms::factory()->register( new SearchAlgorithm\Version_400() );
167
168 /**
169 * Filter the query logger object
170 *
171 * @since 4.4.0
172 * @hook ep_query_logger
173 * @param {QueryLogger} $query_logger Default query logger
174 * @return {QueryLogger} New query logger
175 */
176 $query_logger = apply_filters( 'ep_query_logger', new \ElasticPress\QueryLogger() );
177 if ( method_exists( $query_logger, 'setup' ) ) {
178 $query_logger->setup();
179 }
180 }
181 add_action( 'plugins_loaded', __NAMESPACE__ . '\register_indexable_posts' );
182
183 /**
184 * Set the availability of dashboard sync functionality. Defaults to true (enabled).
185 *
186 * Sync can be disabled by defining EP_DASHBOARD_SYNC as false in wp-config.php.
187 * NOTE: Must be defined BEFORE `require_once(ABSPATH . 'wp-settings.php');` in wp-config.php.
188 *
189 * @since 2.3
190 */
191 if ( ! defined( 'EP_DASHBOARD_SYNC' ) ) {
192 define( 'EP_DASHBOARD_SYNC', true );
193 }
194
195 /**
196 * Setup installer
197 */
198 Installer::factory();
199
200 /**
201 * Setup screen
202 */
203 Screen::factory();
204
205 /**
206 * Setup dashboard
207 */
208 require_once __DIR__ . '/includes/dashboard.php';
209 Dashboard\setup();
210
211 /**
212 * WP CLI Commands
213 */
214 if ( defined( 'WP_CLI' ) && WP_CLI ) {
215 WP_CLI::add_command( 'elasticpress', __NAMESPACE__ . '\Command' );
216 }
217
218 /**
219 * Setup upgrades
220 */
221 Upgrades::factory();
222
223 /**
224 * Handle upgrades. Certain version require a re-sync on upgrade.
225 * Deprecated in favor of `\ElasticPress\Upgrades::factory()`.
226 *
227 * @since 2.2
228 */
229 function handle_upgrades() {
230 _deprecated_function( __CLASS__, '3.5.2', '\ElasticPress\Upgrades::factory()' );
231 }
232
233 /**
234 * Load text domain and handle debugging
235 *
236 * @since 2.2
237 */
238 function setup_misc() {
239 load_plugin_textdomain( 'elasticpress', false, basename( __DIR__ ) . '/lang' ); // Load any available translations first.
240
241 if ( is_user_logged_in() && ! defined( 'WP_EP_DEBUG' ) ) {
242 require_once ABSPATH . 'wp-admin/includes/plugin.php';
243 define( 'WP_EP_DEBUG', is_plugin_active( 'debug-bar-elasticpress/debug-bar-elasticpress.php' ) );
244 }
245 }
246 add_action( 'plugins_loaded', __NAMESPACE__ . '\setup_misc' );
247
248 /**
249 * Fires after Elasticpress plugin is loaded
250 *
251 * @since 2.0
252 * @hook elasticpress_loaded
253 */
254 do_action( 'elasticpress_loaded' );
255