PluginProbe
ElasticPress / 4.6.0
ElasticPress v4.6.0
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 / partials / settings-page.php

settings-page.php in ElasticPress 4.6.0, at includes/partials/settings-page.php

220 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for ElasticPress settings page
4 *
5 * @since 2.1
6 * @package elasticpress
7 */
8
9 use ElasticPress\Utils as Utils;
10 use ElasticPress\Elasticsearch as Elasticsearch;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly.
14 }
15
16 $action = 'options.php';
17
18 $index_meta = Utils\get_option( 'ep_index_meta', [] );
19
20 if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
21 $action = '';
22 }
23
24 $version = Elasticsearch::factory()->get_elasticsearch_version();
25
26 $host = Utils\get_host();
27 $is_epio = Utils\is_epio();
28 $credentials = Utils\get_epio_credentials();
29 $wpconfig = defined( 'EP_HOST' ) && EP_HOST;
30
31 $bulk_setting = Utils\get_option( 'ep_bulk_setting', 350 );
32 ?>
33
34 <?php require_once __DIR__ . '/header.php'; ?>
35
36 <div class="error-overlay <?php if ( ! empty( $index_meta ) ) : ?>syncing<?php endif; ?>"></div>
37 <div class="wrap">
38 <h1><?php esc_html_e( 'Settings', 'elasticpress' ); ?></h1>
39
40 <form action="<?php echo esc_url( $action ); ?>" method="post" class="ep-settings">
41 <?php settings_fields( 'elasticpress' ); ?>
42 <?php settings_errors(); ?>
43
44 <div class="ep-credentials">
45 <?php if ( ! $wpconfig ) : ?>
46 <h2 class="nav-tab-wrapper ep-credentials-tabs">
47 <button class="nav-tab ep-credentials-tab <?php if ( ! $host || $is_epio ) { ?>nav-tab-active initial<?php } ?>" data-epio type="button">
48 <img src="<?php echo esc_url( plugins_url( '/images/logo-icon.svg', dirname( __DIR__ ) ) ); ?>" width="16" height="16" alt="ElasticPress.io" />
49 <span>ElasticPress.io</span>
50 </button>
51 <button class="nav-tab ep-credentials-tab <?php if ( $host && ! $is_epio ) { ?>nav-tab-active initial<?php } ?>" type="button">
52 <span>Third-Party/Self-Hosted</span>
53 </button>
54 </h2>
55 <?php endif; ?>
56
57 <fieldset class="<?php if ( $wpconfig ) { ?>predefined<?php } ?>">
58 <?php if ( $is_epio || ! $wpconfig ) : ?>
59 <p class="ep-legend ep-additional-fields <?php if ( $host && ! $is_epio ) { ?>hidden<?php } ?>" aria-hidden="<?php if ( $host && ! $is_epio ) { ?>true<?php } else { ?>false<?php } ?>">
60 <a href="https://elasticpress.io/" target="_blank" rel="noreferrer noopener">ElasticPress.io</a> is a hosted Elasticsearch service built for ElasticPress, powered by <a href="https://10up.com/" target="_blank" rel="noreferrer noopener">10up</a>.
61 </p>
62 <?php endif; ?>
63 <table class="form-table">
64 <tbody>
65 <tr class="ep-host-row">
66 <th scope="row">
67 <label for="ep_host">
68 <?php if ( $is_epio ) : ?>
69 <?php esc_html_e( 'ElasticPress.io Host URL', 'elasticpress' ); ?>
70 <?php else : ?>
71 <?php esc_html_e( 'Elasticsearch Host URL', 'elasticpress' ); ?>
72 <?php endif; ?>
73 </label>
74 </th>
75 <td>
76 <?php
77 /**
78 * Filter whether to show host field in admin UI or not
79 *
80 * @hook ep_admin_show_host
81 * @param {boolean} $show True to show
82 * @return {boolean} New value
83 */
84 $show_host = apply_filters( 'ep_admin_show_host', true );
85 $disabled = $wpconfig || ! $show_host;
86 $value = $show_host ? esc_url( $host ) : __( '••••••••••••••••', 'elasticpress' );
87 ?>
88 <input <?php disabled( $disabled, true, true ); ?> placeholder="https://" type="text" value="<?php echo esc_attr( $value ); ?>" name="ep_host" id="ep_host">
89 <?php if ( $show_host ) : ?>
90 <?php if ( $wpconfig ) : ?>
91 <p class="description ep-host-legend"><?php esc_html_e( 'Host already defined in wp-config.php.', 'elasticpress' ); ?></p>
92 <?php elseif ( $is_epio ) : ?>
93 <p class="description ep-host-legend"><?php esc_html_e( 'Plug in your ElasticPress.io server here.', 'elasticpress' ); ?></p>
94 <?php else : ?>
95 <p class="description ep-host-legend"><?php esc_html_e( 'Plug in your Elasticsearch server here.', 'elasticpress' ); ?></p>
96 <?php endif; ?>
97 <?php endif; ?>
98 </td>
99 </tr>
100 <?php if ( $is_epio || ! $wpconfig ) : ?>
101
102 <tr class="ep-additional-fields <?php if ( $host && ! $is_epio ) { ?>hidden<?php } ?>" aria-hidden="<?php if ( $host && ! $is_epio ) { ?>true<?php } else { ?>false<?php } ?>">
103 <th scope="row">
104 <label for="ep_username"><?php esc_html_e( 'Subscription ID', 'elasticpress' ); ?></label>
105 </th>
106 <td>
107 <?php
108 /**
109 * Filter whether to show epio credentials fields in admin UI or not
110 *
111 * @hook ep_admin_show_credentials
112 * @param {boolean} $show True to show
113 * @return {boolean} New value
114 */
115 if ( apply_filters( 'ep_admin_show_credentials', true ) ) :
116 ?>
117 <input <?php if ( defined( 'EP_CREDENTIALS' ) && EP_CREDENTIALS ) : ?>disabled<?php endif; ?> type="text" value="<?php echo esc_attr( $credentials['username'] ); ?>" name="ep_credentials[username]" id="ep_username">
118 <?php endif ?>
119 <?php if ( defined( 'EP_CREDENTIALS' ) && EP_CREDENTIALS ) : ?>
120 <p class="description"><?php esc_html_e( 'Your Subscription ID is set in wp-config.php', 'elasticpress' ); ?></p>
121 <?php else : ?>
122 <p class="description"><?php esc_html_e( 'Plug in your subscription ID (or subscription name) here.', 'elasticpress' ); ?></p>
123 <?php endif; ?>
124 </td>
125 </tr>
126
127 <tr class="ep-additional-fields <?php if ( $host && ! $is_epio ) { ?>hidden<?php } ?>" aria-hidden="<?php if ( $host && ! $is_epio ) { ?>true<?php } else { ?>false<?php } ?>">
128 <th scope="row">
129 <label for="ep_token"><?php esc_html_e( 'Subscription Token', 'elasticpress' ); ?></label>
130 </th>
131 <td>
132 <?php
133 /**
134 * Filter whether to show epio credentials fields in admin UI or not
135 *
136 * @hook ep_admin_show_credentials
137 * @param {boolean} $show True to show
138 * @return {boolean} New value
139 */
140 if ( apply_filters( 'ep_admin_show_credentials', true ) ) :
141 ?>
142 <input <?php if ( defined( 'EP_CREDENTIALS' ) && EP_CREDENTIALS ) : ?>disabled<?php endif; ?> type="text" value="<?php echo esc_attr( $credentials['token'] ); ?>" name="ep_credentials[token]" id="ep_token">
143 <?php endif ?>
144 <?php if ( defined( 'EP_CREDENTIALS' ) && EP_CREDENTIALS ) : ?>
145 <p class="description"><?php esc_html_e( 'Your Subscription Token is set in wp-config.php', 'elasticpress' ); ?></p>
146 <?php else : ?>
147 <p class="description"><?php esc_html_e( 'Plug in your subscription token here.', 'elasticpress' ); ?></p>
148 <?php endif; ?>
149 </td>
150 </tr>
151 <?php endif; ?>
152 </tbody>
153 </table>
154 </fieldset>
155 </div>
156
157 <div class="ep-credentials-general">
158 <table class="form-table">
159 <tbody>
160 <tr>
161 <th scope="row">
162 <label for="ep_language"><?php esc_html_e( 'Elasticsearch Language', 'elasticpress' ); ?></label>
163 </th>
164 <td>
165 <?php
166 $ep_language = Utils\get_language();
167
168 wp_dropdown_languages(
169 [
170 'id' => 'ep_language',
171 'name' => 'ep_language',
172 'selected' => $ep_language,
173 ]
174 );
175 ?>
176 <p class="description"><?php esc_html_e( 'Default language for your Elasticsearch mapping.', 'elasticpress' ); ?></p>
177 </td>
178 </tr>
179 <tr>
180 <th scope="row">
181 <label><?php esc_html_e( 'Elasticsearch Version', 'elasticpress' ); ?></label></th>
182 <td>
183 <?php if ( $is_epio ) : ?>
184 <?php esc_html_e( 'ElasticPress.io Managed Platform' ); ?>
185 <?php else : ?>
186 <?php if ( ! empty( $version ) ) : ?>
187 <?php echo esc_html( $version ); ?>
188 <?php else : ?>
189 &mdash;
190 <?php endif; ?>
191 <?php endif; ?>
192 </td>
193 </tr>
194 <?php if ( ! empty( $host ) && ! has_filter( 'ep_index_posts_per_page' ) ) : ?>
195 <tr>
196 <th scope="row">
197 <label for="ep_bulk_setting"><?php esc_html_e( 'Content Items per Index Cycle ', 'elasticpress' ); ?></label>
198 </th>
199 <td>
200 <input type="text" name="ep_bulk_setting" id="ep_bulk_setting" value="<?php echo absint( $bulk_setting ); ?>">
201 </td>
202 </tr>
203 <?php endif; ?>
204 </tbody>
205 </table>
206 </div>
207
208 <?php
209 /**
210 * Fires after settings table is displayed for inserting custom settings.
211 *
212 * @hook ep_settings_custom
213 */
214 do_action( 'ep_settings_custom' );
215 ?>
216
217 <input type="submit" <?php if ( ! empty( $index_meta ) ) : ?>disabled<?php endif; ?> name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'elasticpress' ); ?>">
218 </form>
219 </div>
220