VOOZH about

URL: https://webberzone.com/support/knowledgebase/webberzone-link-warnings-developer-reference/

⇱ WebberZone Link Warnings Developer Reference - WebberZone


Skip to content
Skip to content

This article covers the filters, actions, PHP functions, and 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.

wzlw_get_settings()

Returns the full settings array, merged with defaults.

$settings = wzlw_get_settings();

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.

$method = wzlw_get_option( 'warning_method', 'inline' );

Parameters:

  • $key (string) — The setting key.
  • $default_value (mixed, optional) — Fallback value. Default null.

Returns: mixed

wzlw_update_option( $key, $value )

Updates a single setting in the database and the in-memory cache.

wzlw_update_option( 'warning_method', 'modal' );

Parameters:

  • $key (string) — The setting key.
  • $value (mixed) — The new value.

Returns: booltrue if the option was updated.

wzlw_delete_option( $key )

Removes a single key from the settings array.

wzlw_delete_option( 'excluded_domains' );

Returns: bool

wzlw_update_settings( $settings, $merge, $autoload )

Replaces or merges the entire settings array.

// Merge new values into existing settings.
wzlw_update_settings( array( 'warning_method' => 'redirect' ) );

// Replace all settings (no merge).
wzlw_update_settings( $new_settings, false );

Parameters:

  • $settings (array) — Settings to save.
  • $merge (bool, optional) — Whether to merge with existing settings. Default true.
  • $autoload (bool, optional) — Whether to autoload the option. Default true.

Returns: bool

wzlw_settings_defaults()

Returns the default settings array as derived from the registered settings fields.

$defaults = wzlw_settings_defaults();

Returns: array

wzlw_get_default_option( $key )

Returns the default value for a specific setting key.

$default_method = wzlw_get_default_option( 'warning_method' ); // 'inline_modal'

Returns: mixed — The default value, or false if the key does not exist.

wzlw_settings_reset()

Resets all settings to their defaults.

wzlw_settings_reset();

Returns: bool

Filter hooks

wzlw_get_settings

Filters the full settings array after it is retrieved and merged with defaults.

add_filter( 'wzlw_get_settings', function ( array $settings ): array {
 // Force modal method on all sites.
 $settings['warning_method'] = 'modal';
 return $settings;
} );

Parameters:

  • $settings (array) — The merged settings array.

wzlw_get_option

Filters the value of any individual setting when retrieved via wzlw_get_option().

add_filter( 'wzlw_get_option', function ( $value, string $key, $default ) {
 if ( 'redirect_countdown' === $key ) {
 return 10; // Override countdown to 10 seconds.
 }
 return $value;
}, 10, 3 );

Parameters:

  • $value (mixed) — The setting value.
  • $key (string) — The setting key.
  • $default_value (mixed) — The default value.

wzlw_get_option_{$key}

Key-specific variant of the above filter. Fires only for the named key.

add_filter( 'wzlw_get_option_warning_method', function ( $value ) {
 if ( wp_is_mobile() ) {
 return 'inline'; // Use inline-only on mobile devices.
 }
 return $value;
} );

wzlw_update_option

Filters a setting value before saving it to the database.

add_filter( 'wzlw_update_option', function ( $value, string $key ) {
 if ( 'redirect_countdown' === $key ) {
 return max( 3, (int) $value ); // Enforce minimum 3 seconds.
 }
 return $value;
}, 10, 2 );

Parameters:

  • $value (mixed) — The value being saved.
  • $key (string) — The setting key.

wzlw_excluded_domains

Filters the list of excluded domains before the external link check runs. Use this to add domains programmatically without modifying the settings.

add_filter( 'wzlw_excluded_domains', function ( array $domains, string $link_host ): array {
 $domains[] = 'cdn.example.com';
 $domains[] = 'assets.example.com';
 return $domains;
}, 10, 2 );

Parameters:

  • $domains (array) — Array of excluded domain strings.
  • $link_host (string) — The host of the link being evaluated.

wzlw_settings_defaults

Filters the default settings array. Useful for changing defaults in a must-use plugin or theme.

add_filter( 'wzlw_settings_defaults', function ( array $defaults ): array {
 $defaults['warning_method'] = 'redirect';
 $defaults['redirect_countdown'] = 10;
 return $defaults;
} );

wzlw_registered_settings

Filters the registered settings array. Use this to add, remove, or modify settings fields on the admin page.

add_filter( 'wzlw_registered_settings', function ( array $settings ): array {
 // Remove the redirect countdown field.
 unset( $settings['display']['redirect_countdown'] );
 return $settings;
} );

wzlw_settings_sections

Filters the settings page tab definitions.

add_filter( 'wzlw_settings_sections', function ( array $sections ): array {
 $sections['custom'] = esc_html__( 'Custom', 'my-plugin' );
 return $sections;
} );

Section-specific filters

Each settings section has its own filter, fired when the section’s fields are defined:

  • wzlw_settings_general — General tab fields.
  • wzlw_settings_display — Display tab fields.
  • wzlw_settings_advanced — Advanced tab fields.
add_filter( 'wzlw_settings_advanced', function ( array $settings ): array {
 $settings['my_custom_field'] = array(
 'id' => 'my_custom_field',
 'name' => 'My Custom Field',
 'desc' => 'Description of the field.',
 'type' => 'text',
 'default' => '',
 );
 return $settings;
} );

wzlw_settings_sanitize

Filters the settings array immediately before it is saved. Runs on every settings save.

add_filter( 'wzlw_settings_sanitize', function ( array $settings ): array {
 // Ensure countdown is never below 3.
 if ( isset( $settings['redirect_countdown'] ) ) {
 $settings['redirect_countdown'] = max( 3, (int) $settings['redirect_countdown'] );
 }
 return $settings;
} );

Accessing the plugin instance

The main plugin singleton is accessible via the wzlw() function:

$plugin = wzlw();

// Access sub-components.
$plugin->content_processor;
$plugin->frontend_handler;
$plugin->redirect_handler;
$plugin->admin; // Only available in admin context.

Content processing hooks

The plugin filters content on two standard WordPress hooks:

  • the_content at priority 999
  • the_excerpt at priority 999

The high priority ensures the plugin runs after most other content filters. If you need to run after the plugin, use a priority above 999.

To prevent the plugin from processing specific content, you can remove the filter temporarily:

remove_filter( 'the_content', array( wzlw()->content_processor, 'process_content' ), 999 );
echo apply_filters( 'the_content', $my_content );
add_filter( 'the_content', array( wzlw()->content_processor, 'process_content' ), 999 );

JavaScript objects

The plugin exposes two JavaScript objects on the frontend, depending on the active warning method.

wzlwSettings

Available when the warning method includes a modal or redirect component. Localised via wp_localize_script() on the wzlw-modal handle.

wzlwSettings.modalTitle // Modal heading text.
wzlwSettings.modalMessage // Modal body text.
wzlwSettings.continueText // Continue button label.
wzlwSettings.cancelText // Cancel button label.
wzlwSettings.warningMethod // Active warning method string.

wzlwRedirect

Available on the redirect interstitial page only. Localised on the wzlw-redirect handle.

wzlwRedirect.destination // The external URL.
wzlwRedirect.countdown // Countdown duration in seconds.

Data attributes

The plugin adds the following data- attributes to processed external links when a modal or redirect method is active:

AttributeValue
data-wzlw-external"true" — marks the link as an external link handled by the plugin.
data-wzlw-urlThe escaped external URL.
data-wzlw-redirect-urlThe full redirect interstitial URL for this destination.

The frontend JavaScript uses data-wzlw-external as the selector for click delegation.

CSS handles

Use these handles when declaring stylesheet dependencies:

HandleFileLoaded on
wzlw-frontendincludes/assets/css/frontend.cssAll frontend pages.
wzlw-redirectincludes/assets/css/redirect.cssRedirect interstitial page only.

Script handles

HandleFileLoaded on
wzlw-modalincludes/admin/js/modal.jsFrontend, when method includes modal or redirect.
wzlw-redirectincludes/assets/js/redirect.jsRedirect interstitial page only.

Was this article helpful?

Maximum 500 characters

Thank you for your feedback!

0% found this helpful (0 votes)

Related Articles

Leave a Reply Cancel reply

External URL: