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 / partials / settings-page.php

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

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