Filter
uncanny-automator
wwlc_filter_postcode_field_form_label
Filters the label for the postcode field within forms, allowing customization of its display text.
add_filter( 'wwlc_filter_postcode_field_form_label', $callback, 10, 1 );
Description
Filters the default label for the "Postcode" field in Wholesale Suite forms. Developers can modify this label for custom display or localization. This hook fires when the postcode field is being rendered, allowing for dynamic label changes.
Usage
add_filter( 'wwlc_filter_postcode_field_form_label', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the wwlc_filter_postcode_field_form_label hook.
* This example changes the default 'Postcode' label to 'Zip/Postal Code'
* if a specific option is enabled.
*/
add_filter( 'wwlc_filter_postcode_field_form_label', 'my_custom_postcode_label', 10, 1 );
/**
* Custom function to modify the postcode field label.
*
* @param string $label The original label for the postcode field.
* @return string The modified label for the postcode field.
*/
function my_custom_postcode_label( $label ) {
// Check if a custom option is set to use 'Zip/Postal Code' instead.
if ( get_option( 'myplugin_use_zip_postal_code_label', 'no' ) === 'yes' ) {
// Return the custom label, ensuring it's escaped for security.
return esc_html__( 'Zip/Postal Code', 'my-plugin-textdomain' );
}
// Otherwise, return the original label.
return $label;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/integrations/wholesale-suite/helpers/wholesale-suite-helpers.php:152
'label' => apply_filters( 'wwlc_filter_state_field_form_label', esc_html__( 'State', 'uncanny-automator' ) ),
'type' => 'text',
'required' => ( get_option( 'wwlc_fields_require_address_field' ) == 'yes' ) ? true : false,
'active' => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
'placeholder' => apply_filters( 'wwlc_filter_state_field_form_placeholder', get_option( 'wwlc_fields_state_placeholder', '' ) ),
),
'wwlc_postcode' => array(
'label' => apply_filters( 'wwlc_filter_postcode_field_form_label', esc_html__( 'Postcode', 'uncanny-automator' ) ),
'type' => 'text',
'required' => ( get_option( 'wwlc_fields_require_address_field' ) == 'yes' ) ? true : false,
'active' => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
'placeholder' => apply_filters( 'wwlc_filter_postcode_field_form_placeholder', get_option( 'wwlc_fields_postcode_placeholder', '' ) ),
),
'wwlc_role' => array(
'label' => esc_html__( 'Role', 'uncanny-automator' ),