Use the following PHP functions, hooks, and frontend integration points for WebberZone Link Warnings. All hooks use the wzlw prefix.
PHP wrapper functions
These global functions are defined in includes/options-api.php and are available after the plugin loads. The plugin instance accessor has its own namespace, as shown below.
wzlw_get_settings()
Returns the saved settings array after the wzlw_get_settings filter. It does not merge missing keys with defaults. Use wzlw_get_option() to read one setting with its fallback, or Options_API::get_settings_with_defaults() for a merged array.
Returns: array
wzlw_get_option( $key, $default_value )
Returns a single setting value. Falls back to the registered default if the key is not set. If $default_value is provided, it takes priority over the registered default.
Parameters:
$key(string): The setting key.$default_value(mixed, optional): Fallback value. Defaultnull.
Returns: mixed
wzlw_update_option( $key, $value )
Updates a single setting in the database and the in-memory cache.
Parameters:
$key(string): The setting key.$value(mixed): The new value.
Returns: bool: true if the option was updated.
wzlw_delete_option( $key )
Removes a single key from the settings array.
Parameters:
$key(string): The setting key to remove.
Returns: bool
wzlw_update_settings( $settings, $merge, $autoload )
Replaces or merges the entire settings array.
Parameters:
$settings(array): Settings to save.$merge(bool, optional): Whether to merge with existing settings. Defaulttrue.$autoload(bool, optional): Whether to autoload the option. Defaulttrue.
Returns: bool
wzlw_settings_defaults()
Returns the default settings array derived from the registered settings fields. Call it after init, because building the field definitions uses translated strings.
Returns: array
wzlw_get_default_option( $key )
Returns the default value for a specific setting key.
Parameters:
$key(string): The setting key.
Returns: mixed: The default value, or false if the key does not exist.
wzlw_settings_reset()
Resets all settings to their defaults.
Returns: bool
wzlw_is_disabled_for_current_user()
Returns whether warnings are hidden from the current user under the Disable Warnings For setting. Link attributes are still applied for these users.
Returns: bool
Filter hooks
wzlw_get_settings
Filters the saved settings array when the per-request settings cache is populated. Missing keys have not been merged with defaults.
Parameters:
$settings(array): The saved settings array.
Returns: array
wzlw_is_disabled_for_current_user
Filters whether warnings are hidden from the current user.
Parameters:
$disabled(bool): True if warnings are disabled for the current user.
Returns: bool
wzlw_link_rules
Filters the Link Rules before they are validated. Rules are checked in order and the first match wins. Patterns use the same syntax as the Rules tab. Rules with a missing or invalid pattern, action or ID are dropped.
Parameters:
$rules(array[]): Rules, each withid,pattern,actionand optionalmessagekeys.actionis one ofmodal,inline,inline_modal,redirect,inline_redirectorexclude.$settings(array): The plugin settings.
Returns: array[]
wzlw_excluded_domains
Filters the excluded domains list while a link is being classified. PHP is the only place this filter runs (the browser-side scan cannot repeat it), so links PHP excluded through this filter carry a per-request token (data-wzlw-excluded with the value of Content_Processor::get_exclusion_token()) that the JavaScript trusts.
Parameters:
$domains(array): Excluded domain entries, as configured in the Excluded Domains setting. Wildcard entries keep their*.prefix.$link_host(string): The lowercased host of the link being checked.
Returns: array
wzlw_get_option
Filters an individual option after its saved value or fallback is selected.
Parameters:
$value(mixed): The selected value.$key(string): The option key.$default_value(mixed): The resolved fallback.
Returns: mixed: The option value.
wzlw_get_option_{$key}
Filters one option after the general wzlw_get_option filter.
Parameters:
$value(mixed): The value after the general filter.$key(string): The option key.$default_value(mixed): The resolved fallback.
Returns: mixed
wzlw_update_option
Filters a single setting before wzlw_update_option() saves it.
Parameters:
$value(mixed): The value to save.$key(string): The option key.
Returns: mixed
wzlw_settings_defaults
Filters the defaults used by the settings framework and the translation-free single-option fallback path.
Parameters:
$defaults(array): Defaults keyed by option ID. Display-text values can be empty in the translation-free path.
Returns: array
wzlw_icon_options
Filters the choices shown in Icon Style.
Parameters:
$options(array): Labels keyed by icon ID.
Returns: array
wzlw_icon_map
Filters the characters used for icon IDs, including the download icon.
Parameters:
$map(array): Characters keyed by icon ID. Pair new IDs withwzlw_icon_optionsso they can be selected.
Returns: array
Action hooks
wzlw_activate
Runs after the per-site activation routine flushes rewrite rules and sets its activation transient.
Parameters: none. On network activation, this action runs inside the per-site activation routine for each selected site.
wzlw_deactivate
Runs after deactivation tasks, including transient cleanup and rewrite-rule flushing.
Parameters: none. On network deactivation, this action runs after the per-site deactivation loop.
Accessing the plugin instance
Use the namespaced accessor defined in the main plugin file:
It returns WebberZone\Link_Warnings\Main. The public content_processor, frontend_handler, and redirect_handler components are initialized on plugins_loaded. The admin component is initialized on init in admin requests.
For a merged settings array:
Call this after init because the merged-default path builds translated field definitions.
JavaScript objects
wzlwSettings
The wzlw-modal script receives the frontend configuration. It includes warningMethod, scope, linkRules, downloadExtensions, downloadScope, warningsDisabled, isPreview, excludedDomains, excludedToken, class lists, link-attribute lists, modal text, dismissal settings, and the signing endpoint configuration (ajaxUrl, nonce, redirectBaseUrl).
Use PHP settings and filters to configure behavior. The script captures settings during initialization; changing this object afterward does not rerun the scan.
wzlwRedirect
The redirect page script receives destination and countdown. When confirmation is required, these are an empty string and 0. The timer also requires a .wzlw-countdown-number element and a positive countdown.
Data attributes
These attributes describe processed links. Treat them as plugin-managed output rather than a public way to bypass warnings.
| Attribute | Purpose |
|---|---|
data-wzlw-url | Destination used for click handling. The browser revalidates the anchor’s actual href. |
data-wzlw-external | Marks external-link classification. |
data-wzlw-blank | Marks a processed non-external link that opens a new tab. |
data-wzlw-download | Marks configured download classification. |
data-wzlw-redirect-url | Signed redirect endpoint URL. |
data-wzlw-rule | ID of the matching warning rule. |
data-wzlw-method | Warning method assigned by that rule. |
data-wzlw-excluded | Per-request token preserving a PHP exclusion in the browser scan. |
data-wzlw-token | Per-request token paired with wzlw-processed to identify PHP-processed markup. |
data-wzlw-indicator | Per-request token that prevents duplicate indicator insertion during repeated PHP processing. |
data-wzlw-signing | Temporary browser marker while an AJAX signing request is pending. |
Cached markup without the current token is classified again. Matching existing indicator markup can prevent duplicate presentation, but never skips classification or click warnings.
CSS handles
| Handle | Source file | Where loaded |
|---|---|---|
wzlw-frontend | includes/assets/css/frontend.css | Frontend pages, for indicators and modals. |
wzlw-redirect | includes/assets/css/redirect.css | Redirect endpoint. |
Styles use -rtl variants when is_rtl() is true. Minified variants load unless SCRIPT_DEBUG is enabled. See Styling WebberZone Link Warnings for classes and custom properties.
Script handles
| Handle | Source file | Purpose |
|---|---|---|
wzlw-modal | includes/admin/js/modal.js | Sitewide link scan, modal handling, signing requests, and redirect navigation. |
wzlw-redirect | includes/assets/js/redirect.js | Redirect-page countdown. |
Minified variants load unless SCRIPT_DEBUG is enabled. For template overrides, see Customizing the redirect screen.
