PluginProbe
ElasticPress / 4.3.1
ElasticPress v4.3.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.3.1, at elasticpress.php

242 lines 5.8 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.3.1
7 * Requires at least: 5.6
8 * Requires PHP: 7.0
9 * Author: 10up
10 * Author URI: http://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.3.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 add_action( 'plugins_loaded', __NAMESPACE__ . '\register_indexable_posts' );
169
170 /**
171 * Set the availability of dashboard sync functionality. Defaults to true (enabled).
172 *
173 * Sync can be disabled by defining EP_DASHBOARD_SYNC as false in wp-config.php.
174 * NOTE: Must be defined BEFORE `require_once(ABSPATH . 'wp-settings.php');` in wp-config.php.
175 *
176 * @since 2.3
177 */
178 if ( ! defined( 'EP_DASHBOARD_SYNC' ) ) {
179 define( 'EP_DASHBOARD_SYNC', true );
180 }
181
182 /**
183 * Setup installer
184 */
185 Installer::factory();
186
187 /**
188 * Setup screen
189 */
190 Screen::factory();
191
192 /**
193 * Setup dashboard
194 */
195 require_once __DIR__ . '/includes/dashboard.php';
196 Dashboard\setup();
197
198 /**
199 * WP CLI Commands
200 */
201 if ( defined( 'WP_CLI' ) && WP_CLI ) {
202 WP_CLI::add_command( 'elasticpress', __NAMESPACE__ . '\Command' );
203 }
204
205 /**
206 * Setup upgrades
207 */
208 Upgrades::factory();
209
210 /**
211 * Handle upgrades. Certain version require a re-sync on upgrade.
212 * Deprecated in favor of `\ElasticPress\Upgrades::factory()`.
213 *
214 * @since 2.2
215 */
216 function handle_upgrades() {
217 _deprecated_function( __CLASS__, '3.5.2', '\ElasticPress\Upgrades::factory()' );
218 }
219
220 /**
221 * Load text domain and handle debugging
222 *
223 * @since 2.2
224 */
225 function setup_misc() {
226 load_plugin_textdomain( 'elasticpress', false, basename( __DIR__ ) . '/lang' ); // Load any available translations first.
227
228 if ( is_user_logged_in() && ! defined( 'WP_EP_DEBUG' ) ) {
229 require_once ABSPATH . 'wp-admin/includes/plugin.php';
230 define( 'WP_EP_DEBUG', is_plugin_active( 'debug-bar-elasticpress/debug-bar-elasticpress.php' ) );
231 }
232 }
233 add_action( 'plugins_loaded', __NAMESPACE__ . '\setup_misc' );
234
235 /**
236 * Fires after Elasticpress plugin is loaded
237 *
238 * @since 2.0
239 * @hook elasticpress_loaded
240 */
241 do_action( 'elasticpress_loaded' );
242