diff --git a/src/Actions.php b/src/Actions.php index 257f1ff..3c0b12b 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -46,21 +46,21 @@ public function maybe_register_assets() { * Bail if tracked_user_roles is empty (which means no roles should be tracked) or, * if current role should not be tracked. */ - if ( ( ! empty( $user_role ) && ! isset( $settings[ 'tracked_user_roles' ] ) ) || - ( ! empty( $user_role ) && ! in_array( $user_role, $settings[ 'tracked_user_roles' ], true ) ) ) { + if ( ( ! empty( $user_role ) && ! isset( $settings[ 'tracked_user_roles' ] ) ) || ( ! empty( $user_role ) && ! in_array( $user_role, $settings[ 'tracked_user_roles' ], true ) ) ) { return; // @codeCoverageIgnore } - $version = - Helpers::proxy_enabled() && file_exists( Helpers::get_js_path() ) ? filemtime( Helpers::get_js_path() ) : - PLAUSIBLE_ANALYTICS_VERSION; + $version = Helpers::proxy_enabled() && file_exists( Helpers::get_js_path() ) ? filemtime( Helpers::get_js_path() ) : PLAUSIBLE_ANALYTICS_VERSION; wp_enqueue_script( 'plausible-analytics', Helpers::get_js_url( true ), '', $version, - apply_filters( 'plausible_load_js_in_footer', false ) + [ + 'in_footer' => apply_filters( 'plausible_load_js_in_footer', false ), + 'strategy' => 'defer', + ] ); // Goal tracking inline script (Don't disable this as it is required by 404). @@ -131,13 +131,13 @@ public function admin_bar_node( $admin_bar ) { return; // @codeCoverageIgnore } - $settings = Helpers::get_settings(); + $settings = Helpers::get_settings(); $current_user = wp_get_current_user(); $has_access = false; $user_roles_have_access = array_merge( [ 'administrator' ], - $settings['expand_dashboard_access'] ?? [] + $settings[ 'expand_dashboard_access' ] ?? [] ); foreach ( $current_user->roles as $role ) { @@ -157,9 +157,7 @@ public function admin_bar_node( $admin_bar ) { 'title' => 'Plausible Analytics', ]; - - if ( ! empty( $settings[ 'enable_analytics_dashboard' ] ) || - ( ! empty( $settings[ 'self_hosted_domain' ] ) && ! empty( $settings[ 'self_hosted_shared_link' ] ) ) ) { + if ( ! empty( $settings[ 'enable_analytics_dashboard' ] ) || ( ! empty( $settings[ 'self_hosted_domain' ] ) && ! empty( $settings[ 'self_hosted_shared_link' ] ) ) ) { $args[] = [ 'id' => 'view-analytics', 'title' => esc_html__( 'View Analytics', 'plausible-analytics' ), diff --git a/src/Filters.php b/src/Filters.php index 8255123..b8e9178 100644 --- a/src/Filters.php +++ b/src/Filters.php @@ -56,7 +56,7 @@ public function add_plausible_attributes( $tag, $handle ) { /** * the data-cfasync ensures this script isn't processed by CF Rocket Loader @see https://developers.cloudflare.com/speed/optimization/content/rocket-loader/ignore-javascripts/ */ - $params = "defer data-domain='{$domain_name}' data-api='{$api_url}' data-cfasync='false'"; + $params = "data-domain='{$domain_name}' data-api='{$api_url}' data-cfasync='false'"; // Triggered when exclude pages is enabled. if ( ! empty( $settings[ 'excluded_pages' ] ) && $settings[ 'excluded_pages' ] ) {