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 / includes / classes / Feature / Users / Users.php

Users.php in ElasticPress 4.2.2, at includes/classes/Feature/Users/Users.php

106 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Users feature
4 *
5 * @since 1.9
6 * @package elasticpress
7 */
8
9 namespace ElasticPress\Feature\Users;
10
11 use ElasticPress\Feature as Feature;
12 use ElasticPress\Indexables as Indexables;
13 use ElasticPress\Indexable as Indexable;
14 use ElasticPress\FeatureRequirementsStatus as FeatureRequirementsStatus;
15 use ElasticPress\Utils as Utils;
16
17 /**
18 * Users feature class
19 */
20 class Users extends Feature {
21 /**
22 * Initialize feature setting it's config
23 *
24 * @since 3.0
25 */
26 public function __construct() {
27 $this->slug = 'users';
28
29 $this->title = esc_html__( 'Users', 'elasticpress' );
30
31 $this->summary = __( 'Improve user search relevancy and query performance.', 'elasticpress' );
32
33 $this->docs_url = __( 'https://elasticpress.zendesk.com/hc/en-us/articles/360050447492-Configuring-ElasticPress-via-the-Plugin-Dashboard#users', 'elasticpress' );
34
35 $this->requires_install_reindex = true;
36
37 parent::__construct();
38 }
39
40 /**
41 * Hook search functionality
42 *
43 * @since 3.0
44 */
45 public function setup() {
46 Indexables::factory()->register( new Indexable\User\User() );
47
48 add_action( 'init', [ $this, 'search_setup' ] );
49 }
50
51 /**
52 * Setup feature on each page load
53 *
54 * @since 3.0
55 */
56 public function search_setup() {
57 add_filter( 'ep_elasticpress_enabled', [ $this, 'integrate_search_queries' ], 10, 2 );
58 }
59
60 /**
61 * Output feature box long text
62 *
63 * @since 3.0
64 */
65 public function output_feature_box_long() {
66 ?>
67 <p><?php esc_html_e( 'This feature will empower your website to overcome traditional WordPress user search and query limitations that can present themselves at scale.', 'elasticpress' ); ?></p>
68 <p><?php esc_html_e( 'Be aware that storing user data may bound you to certain legal obligations depending on your local government regulations.', 'elasticpress' ); ?></p>
69 <?php
70 }
71
72 /**
73 * Enable integration on search queries
74 *
75 * @param bool $enabled Whether EP is enabled
76 * @param WP_User_Query $query Current query object.
77 * @since 3.0
78 * @return bool
79 */
80 public function integrate_search_queries( $enabled, $query ) {
81 if ( ! is_a( $query, 'WP_User_Query' ) ) {
82 return $enabled;
83 }
84
85 if ( isset( $query->query_vars['ep_integrate'] ) && ! filter_var( $query->query_vars['ep_integrate'], FILTER_VALIDATE_BOOLEAN ) ) {
86 $enabled = false;
87 } elseif ( ! empty( $query->query_vars['search'] ) ) {
88 $enabled = true;
89 }
90
91 return $enabled;
92 }
93
94 /**
95 * Determine feature reqs status
96 *
97 * @since 2.2
98 * @return FeatureRequirementsStatus
99 */
100 public function requirements_status() {
101 $status = new FeatureRequirementsStatus( 1 );
102
103 return $status;
104 }
105 }
106