PluginProbe
ElasticPress / 4.2.2
ElasticPress v4.2.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 / elasticpress.php

elasticpress.php in ElasticPress 4.2.2, at elasticpress.php

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