Skip to content

Commit

Permalink
Fixed: make sure get_domain() returns current options are used if cur…
Browse files Browse the repository at this point in the history
…rent request is an AJAX save options request.
  • Loading branch information
Dan0sz committed May 31, 2024
1 parent c97104d commit 6f3039b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ public static function download_file( $remote_file, $local_file ) {
public static function get_domain() {
$settings = self::get_settings();

/**
* If this is an AJAX request, make sure the latest settings are used.
*/
if ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'plausible_analytics_save_options' ) {
$settings = json_decode( str_replace( '\\', '', $_POST[ 'options' ] ) );

foreach ( $settings as $setting ) {
$settings[ $setting->name ] = $setting->value;
}
}

if ( ! empty( $settings[ 'domain_name' ] ) ) {
return $settings[ 'domain_name' ];
}
Expand Down

0 comments on commit 6f3039b

Please sign in to comment.