Filter
uncanny-automator
wwlc_filter_address2_field_form_placeholder
Filters the placeholder text for the Address Line 2 field on wholesale registration forms.
add_filter( 'wwlc_filter_address2_field_form_placeholder', $callback, 10, 1 );
Description
This filter hook allows modification of the placeholder text for the "Address Line 2" field on forms, typically within the Wholesale Suite integration. Developers can dynamically change this placeholder by filtering `wwlc_filter_address2_field_form_placeholder`. The default placeholder is retrieved from the WordPress option `wwlc_fields_address2_placeholder`.
Usage
add_filter( 'wwlc_filter_address2_field_form_placeholder', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to filter the placeholder text for the Address Line 2 field.
*
* This function modifies the default placeholder text for the Address Line 2
* field in a WordPress form, likely used for wholesale registration or account details.
*
* @param string $placeholder The current placeholder text for the Address Line 2 field.
* @return string The modified placeholder text.
*/
add_filter( 'wwlc_filter_address2_field_form_placeholder', 'my_custom_address2_placeholder', 10, 1 );
function my_custom_address2_placeholder( $placeholder ) {
// Get the option from the WordPress database.
// The default value is an empty string if the option is not set.
$saved_placeholder = get_option( 'wwlc_fields_address2_placeholder', '' );
// If the saved placeholder is not empty, use it. Otherwise, fall back to a default.
if ( ! empty( $saved_placeholder ) ) {
return esc_attr( $saved_placeholder ); // Sanitize for attribute usage.
} else {
// Provide a more descriptive default placeholder if nothing is saved.
return esc_attr__( 'Apartment, suite, unit, etc. (Optional)', 'my-text-domain' );
}
}
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:135
'placeholder' => apply_filters( 'wwlc_filter_address1_field_form_placeholder', get_option( 'wwlc_fields_address_placeholder', '' ) ),
),
'wwlc_address_2' => array(
'label' => apply_filters( 'wwlc_filter_address2_field_form_label', esc_html__( 'Address line 2', 'uncanny-automator' ) ),
'type' => 'text',
'required' => false,
'active' => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
'placeholder' => apply_filters( 'wwlc_filter_address2_field_form_placeholder', get_option( 'wwlc_fields_address2_placeholder', '' ) ),
),
'wwlc_city' => array(
'label' => apply_filters( 'wwlc_filter_city_field_form_label', esc_html__( 'City', '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_city_field_form_placeholder', get_option( 'wwlc_fields_city_placeholder', '' ) ),