Skip to content

Commit

Permalink
Improved: logic of previous fix should be moved to get_settings()
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan0sz committed May 31, 2024
1 parent 6f3039b commit 9114820
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ public static function get_settings() {

$settings = get_option( 'plausible_analytics_settings', [] );

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

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

return apply_filters( 'plausible_analytics_settings', wp_parse_args( $settings, $defaults ) );
}

Expand Down Expand Up @@ -286,17 +297,6 @@ 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 9114820

Please sign in to comment.