Skip to content
6 changes: 6 additions & 0 deletions includes/classes/Screen/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public function action_admin_init() {
'token' => '',
];

// Preserve the existing token if the field was left empty (it is always empty on load).
if ( empty( $credentials['token'] ) ) {
$prev_credentials = Utils\get_epio_credentials();
$credentials['token'] = $prev_credentials['token'];
}

Utils\update_option( 'ep_credentials', $credentials );
}

Expand Down
4 changes: 2 additions & 2 deletions includes/partials/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@
*/
if ( apply_filters( 'ep_admin_show_credentials', true ) ) :
?>
<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">
<input <?php if ( defined( 'EP_CREDENTIALS' ) && EP_CREDENTIALS ) : ?>disabled<?php endif; ?> type="password" value="" autocomplete="new-password" placeholder="<?php echo esc_attr( $credentials['token'] ? '••••••••' : '' ); ?>" name="ep_credentials[token]" id="ep_token">
Comment thread
faisalahammad marked this conversation as resolved.
Outdated
<?php endif ?>
<?php if ( defined( 'EP_CREDENTIALS' ) && EP_CREDENTIALS ) : ?>
<p class="description"><?php esc_html_e( 'Your Subscription Token is set in wp-config.php', 'elasticpress' ); ?></p>
<?php else : ?>
<p class="description"><?php esc_html_e( 'Plug in your subscription token here.', 'elasticpress' ); ?></p>
<p class="description"><?php esc_html_e( 'Your subscription token is stored securely and will not be displayed. Enter a new value to update it.', 'elasticpress' ); ?></p>
<?php endif; ?>
</td>
</tr>
Expand Down