Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ Filters the Rollbar JavaScript configuration.

* `array $config` - The Rollbar JavaScript configuration array.

#### `apply_filters('rollbar_js_nonce', string|null $nonce)`

Filter that can be used to set the nonce attribute value of the frontend JS script.

**Since: 3.1.0**

**Parameters**

* `string|null $nonce` - The nonce value to be used in the script tag. If `null` the attribute is excluded. Default
is `null`.

#### `apply_filters('rollbar_plugin_settings', array $settings)`

Filters the Rollbar plugin settings.
Expand Down
11 changes: 10 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,16 @@ public function initJsLogging(): void
return;
}

$rollbarJs = RollbarJsHelper::buildJs($this->buildJsConfig());
/**
* Filter that can be used to set the nonce attribute value of the frontend JS script.
*
* @param string|null $nonce The nonce value to be used in the script tag. If `null` the attribute is excluded.
* Default is `null`.
* @since 3.1.0
*/
$nonce = apply_filters('rollbar_js_nonce', null);

$rollbarJs = RollbarJsHelper::buildJs($this->buildJsConfig(), nonce: $nonce);

echo $rollbarJs;
}
Expand Down