Language elements

The plugin defines some language elements that may need to be overwritten. These are used in the booking-form-single.html file in the form template.

Use is simply based on the principle of text exchange. The following IDs will be replaced:

  • [NAME] -> Your name:
  • [EMAIL] -> Your email:
  • [EMAIL_DESCRIPTION] -> We will send a confirmation link to this address.
  • [PHONE] -> Your phone:
  • [MESSAGE] -> Your message:
  • [GDPR] -> I accept the <a href=”%s” target=”_blank”>privacy policy</a>.
    Where %s is the link to the „Privacy Policy” page.
  • [BOOKING] -> I\’m booking

The plugin does not yet handle language-specific templates, so it may be necessary to overwrite texts individually. To do this, you need to place the following code in the (child) theme functions.php file:

function my_booking_translate_text( $translation, $text, $domain ) {

	if ( $domain === 'book-an-appointment' ) {
        
        // We only ask once
        if (!defined('BOOKING_LOCALE')) {
            define('BOOKING_LOCALE', get_locale());                
        }
        
        switch ($text){ 
            case 'Your name:':
                // Modify if required
                // $translation = 'Name:';
                break;
            case 'Your email:':
                break;
            case 'We will send a confirmation link to this address.':
                break;
            case 'Your phone:':
                break;
            case 'Your message:':
                break;
            case 'I\'m booking':
                break;
                
            case 'I accept the <a href="%s" target="_blank">privacy policy</a>.':
                if (BOOKING_LOCALE == 'en_GB') {
                    // %s = get_privacy_policy_url()
                    $translation = 'I have read <a href="%s" target="_blank">privacy notice</a>.';
                }
                break;
            
            default :
        }
    }

    return $translation;
}
add_filter( 'gettext', 'my_booking_translate_text', 10, 3 );

The code above is of course just a sample. It must be modified as required.

In the sample in the customize-samples folder, the booking.php file contains this function.