Tribe__PUE__Checker::check_for_api_key_error( string $value, string $field_id, object $validated_field )
Clears out the site external site option and re-checks the license key
Contents
Parameters
- $value
-
(string) (Required) The value of the option.
- $field_id
-
(string) (Required) The ID of the field.
- $validated_field
-
(object) (Required) The validated field.
Return
(string)
Source
File: src/Tribe/PUE/Checker.php
public function check_for_api_key_error( $value, $field_id, $validated_field ) {
// Only hook into our option
if ( $this->pue_install_key !== $field_id ) {
return $value;
}
if ( 'service' !== $this->context ) {
$this->check_for_updates( array(), true );
}
$network_option = false;
if ( ! empty( $validated_field->field['network_option'] ) ) {
$network_option = (boolean) $validated_field->field['network_option'];
}
$key_type = 'local';
if ( $network_option ) {
$key_type = 'network';
}
$current_key = $this->get_key( $key_type );
// if we are saving this PUE key, we need to make sure we update the license key notices
// appropriately. Otherwise, we could have an invalid license key in place but the notices
// aren't being thrown globally
$query_args = $this->get_validate_query();
$query_args['key'] = sanitize_text_field( $value );
$this->license_key_status( $query_args );
return $value;
}