\ReCaptchaCaptchaTheme

CaptchaTheme Handle custom theming, reCAPTCHA's options and users language

Summary

Methods
Properties
Constants
custom_theme()
setTranslation()
clientLang()
No public properties found
No constants found
_theme()
i18n()
$_recaptchaOptions
$_standardThemes
$_optionsWrapper
$_builtInlang
N/A
No private methods found
No private properties found
N/A

Properties

$_recaptchaOptions

$_recaptchaOptions : array

reCAPTCHA Theme default options RecaptchaOptions Reference: {@link: https://developers.google.com/recaptcha/docs/customization}

Type

array

$_standardThemes

$_standardThemes : array

List of Standard Theme names available Standard names Reference: {@link: https://developers.google.com/recaptcha/docs/customization#Standard_Themes}

Type

array

$_optionsWrapper

$_optionsWrapper : string

Theme JavaScript wrapper

Type

string

$_builtInlang

$_builtInlang : array

For comparison of built in i18n languages

Type

array

Methods

custom_theme()

custom_theme(string $widget_id) : string

Custom Theme Template In order to use a custom theme, you must set reCAPTCHA options correctly, also provide a custom CSS to display it properly.

Fully custom theme reference: {@link: https://developers.google.com/recaptcha/docs/customization#Custom_Theming}

Parameters

string $widget_id

The ID name for wrapper container

Returns

string

setTranslation()

setTranslation(string $language, string $path) : void

Custom Translations

In order to use custom translation (even if it is not built in specially for a custom theme), the translations must be set manually by this method or by passing the lang two letters code to instance constructor. It will set translation by a lang code given and overwrites other languages set in an external captcha_config file.

NOTE: If translate file recaptcha.lang[lang_code].php with its respective translation strings within a folder i18n is not found a default lang English 'en' will be used instead.

To use an external file for a custom lang translation you must create a copy of some lang file already done within the folder I18n and rename it as 'recaptcha.lang[lang_code].php' place it wherever you want and tell as second parameter its absolute $path without filename

Parameters

string $language

Two letter language code e.g: (Italian = 'it')

string $path

Optional path to translate file

clientLang()

clientLang() : string

Get user's browser language preference

Returns

string

_theme()

_theme(string $theme_name, array $options) : string

Standard Theme Display's Theme customization for reCAPTCHA widget by writting a snippet for Standard_Themes and Custom_Theming

Parameters

string $theme_name

Optional theme name. NOTE: overwrite theme if it's set in an external config

array $options

reCAPTCHA Associative array of available options. NOTE: overwrite options set in an external config

Returns

string —

Standard_Theme | Custom_Theme | Fallback default reCAPTCHA theme

i18n()

i18n(string $key, string $path) : array|string

Fetch I18n language line

Parameters

string $key

The string translated

string $path

Optional path to your own language file

Returns

array|string