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 | elasticpress.php +115 -29 4.2.25.3.5 View file →
@@ -2,16 +2,17 @@
2 2 /**
3 3 * Plugin Name: ElasticPress
4 4 * Plugin URI: https://github.com/10up/ElasticPress
5 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
6 + * Version: 5.3.5
7 + * Requires at least: 6.2
8 + * Requires PHP: 7.4
9 9 * Author: 10up
10 - * Author URI: http://10up.com
10 + * Author URI: https://10up.com
11 11 * License: GPL v2 or later
12 12 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
13 13 * Text Domain: elasticpress
14 + * Domain Path: /lang
14 15 *
15 16 * This program derives work from Alley Interactive's SearchPress
16 17 * and Automattic's VIP search plugin:
17 18 *
@@ -22,9 +23,9 @@
22 23 */
23 24
24 25 namespace ElasticPress;
25 26
26 -use \WP_CLI as WP_CLI;
27 +use WP_CLI;
27 28
28 29 if ( ! defined( 'ABSPATH' ) ) {
29 30 exit; // Exit if accessed directly.
30 31 }
@@ -31,10 +32,41 @@
31 32
32 33 define( 'EP_URL', plugin_dir_url( __FILE__ ) );
33 34 define( 'EP_PATH', plugin_dir_path( __FILE__ ) );
34 35 define( 'EP_FILE', plugin_basename( __FILE__ ) );
35 -define( 'EP_VERSION', '4.2.2' );
36 +define( 'EP_VERSION', '5.3.5' );
36 37
38 +define( 'EP_PHP_VERSION_MIN', '7.4' );
39 +
40 +if ( ! version_compare( phpversion(), EP_PHP_VERSION_MIN, '>=' ) ) {
41 + add_action(
42 + 'admin_notices',
43 + function () {
44 + ?>
45 + <div class="notice notice-error">
46 + <p>
47 + <?php
48 + echo wp_kses_post(
49 + sprintf(
50 + /* translators: %s: Minimum required PHP version */
51 + __( 'ElasticPress requires PHP version %s or later. Please upgrade PHP or disable the plugin.', 'elasticpress' ),
52 + EP_PHP_VERSION_MIN
53 + )
54 + );
55 + ?>
56 + </p>
57 + </div>
58 + <?php
59 + }
60 + );
61 + return;
62 +}
63 +
64 +// Require Composer autoloader if it exists.
65 +if ( file_exists( __DIR__ . '/vendor-prefixed/autoload.php' ) ) {
66 + require_once __DIR__ . '/vendor-prefixed/autoload.php';
67 +}
68 +
37 69 /**
38 70 * PSR-4-ish autoloading
39 71 *
40 72 * @since 2.6
@@ -39,9 +71,9 @@
39 71 *
40 72 * @since 2.6
41 73 */
42 74 spl_autoload_register(
43 - function( $class ) {
75 + function ( $class_name ) {
44 76 // project-specific namespace prefix.
45 77 $prefix = 'ElasticPress\\';
46 78
47 79 // base directory for the namespace prefix.
@@ -49,13 +81,13 @@
49 81
50 82 // does the class use the namespace prefix?
51 83 $len = strlen( $prefix );
52 84
53 - if ( strncmp( $prefix, $class, $len ) !== 0 ) {
85 + if ( strncmp( $prefix, $class_name, $len ) !== 0 ) {
54 86 return;
55 87 }
56 88
57 - $relative_class = substr( $class, $len );
89 + $relative_class = substr( $class_name, $len );
58 90
59 91 $file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
60 92
61 93 // if the file exists, require it.
@@ -73,9 +105,9 @@
73 105 * We don't check minor releases so if your ES version if 7.10.1, we consider that 7.10 in our comparison.
74 106 *
75 107 * @since 2.2
76 108 */
77 -define( 'EP_ES_VERSION_MAX', '7.10' );
109 +define( 'EP_ES_VERSION_MAX', '9.999' );
78 110 define( 'EP_ES_VERSION_MIN', '5.2' );
79 111
80 112 require_once __DIR__ . '/includes/compat.php';
81 113 require_once __DIR__ . '/includes/utils.php';
@@ -88,15 +120,29 @@
88 120 define( 'EP_IS_NETWORK', true );
89 121 }
90 122
91 123 /**
124 + * Return the ElasticPress container
125 + *
126 + * @since 4.7.0
127 + * @return Container
128 + */
129 +function get_container() {
130 + static $container = null;
131 +
132 + if ( ! $container ) {
133 + $container = new Container();
134 + }
135 +
136 + return $container;
137 +}
138 +
139 +/**
92 140 * Sets up the indexables and features.
93 141 *
94 142 * @return void
95 143 */
96 144 function register_indexable_posts() {
97 - global $wp_version;
98 -
99 145 /**
100 146 * Handle indexables
101 147 */
102 148 Indexables::factory()->register( new Indexable\Post\Post() );
@@ -116,8 +162,12 @@
116 162 new Feature\Autosuggest\Autosuggest()
117 163 );
118 164
119 165 Features::factory()->register_feature(
166 + new Feature\DidYouMean\DidYouMean()
167 + );
168 +
169 + Features::factory()->register_feature(
120 170 new Feature\WooCommerce\WooCommerce()
121 171 );
122 172
123 173 Features::factory()->register_feature(
@@ -139,25 +189,42 @@
139 189 Features::factory()->register_feature(
140 190 new Feature\Documents\Documents()
141 191 );
142 192
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 - }
193 + Features::factory()->register_feature(
194 + new Feature\AcfRepeater\AcfRepeater()
195 + );
148 196
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 - }
197 + Features::factory()->register_feature(
198 + new Feature\Comments\Comments()
199 + );
154 200
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 - }
201 + Features::factory()->register_feature(
202 + new Feature\Terms\Terms()
203 + );
204 +
205 + /**
206 + * Register search algorithms
207 + */
208 + SearchAlgorithms::factory()->register( new SearchAlgorithm\DefaultAlgorithm() );
209 + SearchAlgorithms::factory()->register( new SearchAlgorithm\Version_350() );
210 + SearchAlgorithms::factory()->register( new SearchAlgorithm\Version_400() );
211 +
212 + /**
213 + * Filter the query logger object
214 + *
215 + * @since 4.4.0
216 + * @hook ep_query_logger
217 + * @param {QueryLogger} $query_logger Default query logger
218 + * @return {QueryLogger} New query logger
219 + */
220 + $query_logger = apply_filters( 'ep_query_logger', new \ElasticPress\QueryLogger() );
221 + get_container()->set( '\ElasticPress\QueryLogger', $query_logger, true );
222 +
223 + get_container()->set( '\ElasticPress\AdminBar', new \ElasticPress\AdminBar(), true );
224 + get_container()->set( '\ElasticPress\BlockTemplateUtils', new \ElasticPress\BlockTemplateUtils(), true );
225 + get_container()->set( '\ElasticPress\ElasticPressIo', new \ElasticPress\ElasticPressIo() );
226 + get_container()->set( '\ElasticPress\ElementorUtils', new \ElasticPress\ElementorUtils(), true );
160 227 }
161 228 add_action( 'plugins_loaded', __NAMESPACE__ . '\register_indexable_posts' );
162 229
163 230 /**
@@ -215,10 +282,8 @@
215 282 *
216 283 * @since 2.2
217 284 */
218 285 function setup_misc() {
219 - load_plugin_textdomain( 'elasticpress', false, basename( __DIR__ ) . '/lang' ); // Load any available translations first.
220 -
221 286 if ( is_user_logged_in() && ! defined( 'WP_EP_DEBUG' ) ) {
222 287 require_once ABSPATH . 'wp-admin/includes/plugin.php';
223 288 define( 'WP_EP_DEBUG', is_plugin_active( 'debug-bar-elasticpress/debug-bar-elasticpress.php' ) );
224 289 }
@@ -223,8 +288,29 @@
223 288 define( 'WP_EP_DEBUG', is_plugin_active( 'debug-bar-elasticpress/debug-bar-elasticpress.php' ) );
224 289 }
225 290 }
226 291 add_action( 'plugins_loaded', __NAMESPACE__ . '\setup_misc' );
292 +
293 +/**
294 + * Load text domain
295 + *
296 + * @since 5.1.4
297 + */
298 +function i18n() {
299 + load_plugin_textdomain( 'elasticpress', false, basename( __DIR__ ) . '/lang' );
300 +}
301 +add_action( 'init', __NAMESPACE__ . '\i18n' );
302 +
303 +/**
304 + * Set up role(s) with EP capability
305 + */
306 +function setup_roles() {
307 + // add custom capabilities to admin role
308 + $role = get_role( 'administrator' );
309 +
310 + $role->add_cap( Utils\get_capability() );
311 +}
312 +register_activation_hook( __FILE__, __NAMESPACE__ . '\setup_roles' );
227 313
228 314 /**
229 315 * Fires after Elasticpress plugin is loaded
230 316 *