Skip to content
This repository has been archived by the owner on May 9, 2019. It is now read-only.

Commit

Permalink
fix(admin): properly handle configuration in constants
Browse files Browse the repository at this point in the history
Closes: #631
  • Loading branch information
rayrutjes committed Jul 17, 2017
1 parent 115bc1d commit d07a801
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions includes/admin/class-algolia-admin-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ public function powered_by_enabled_callback() {
}

public function sanitize_application_id( $value ) {
if ( $this->plugin->get_settings()->is_application_id_in_config() ) {
$value = $this->plugin->get_settings()->get_application_id();
}
$value = sanitize_text_field( $value );

if ( empty( $value ) ) {
Expand All @@ -195,6 +198,9 @@ public function sanitize_application_id( $value ) {
}

public function sanitize_search_api_key( $value ) {
if ( $this->plugin->get_settings()->is_search_api_key_in_config() ) {
$value = $this->plugin->get_settings()->get_search_api_key();
}
$value = sanitize_text_field( $value );

if ( empty( $value ) ) {
Expand All @@ -209,6 +215,9 @@ public function sanitize_search_api_key( $value ) {
}

public function sanitize_api_key( $value ) {
if ( $this->plugin->get_settings()->is_api_key_in_config() ) {
$value = $this->plugin->get_settings()->get_api_key();
}
$value = sanitize_text_field( $value );

if ( empty( $value ) ) {
Expand Down Expand Up @@ -291,6 +300,10 @@ public function is_valid_index_name_prefix( $index_name_prefix ) {
* @return array
*/
public function sanitize_index_name_prefix( $value ) {
if ( $this->plugin->get_settings()->is_index_name_prefix_in_config() ) {
$value = $this->plugin->get_settings()->get_index_name_prefix();
}

if ( $this->is_valid_index_name_prefix( $value ) ) {
return $value;
}
Expand Down

0 comments on commit d07a801

Please sign in to comment.