PluginProbe
ElasticPress / 4.7.2
ElasticPress v4.7.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.7.2, at includes/partials/settings-page.php

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