diff --git a/src/Actions.php b/src/Actions.php index 29918a7..e7ab70e 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -71,11 +71,16 @@ public function maybe_register_assets() { $data = wp_json_encode( [ 'props' => [ - 'path' => 'documentation.location.pathname', + 'path' => 'document.location.pathname', ], ] ); + /** + * Documentation.location.pathname is a variable. @see wp_json_encode() doesn't allow passing variable, only strings. This fixes that. + */ + $data = str_replace( '"document.location.pathname"', 'document.location.pathname', $data ); + wp_add_inline_script( 'plausible-analytics', "document.addEventListener('DOMContentLoaded', function () { plausible( '404', $data ); });"