protected function _theme($theme_name = NULL, $options = array())
	{
		if ( count($options) > 0 ) {
		 	// Avoid invalid options passed via array
			foreach ($options as $opt => $value) {
				if ( !array_key_exists($opt, $this->_recaptchaOptions) ) {
					unset($options[$opt]);
				}
			}
		}

	  	// Avoid empty values
		foreach ($this->_recaptchaOptions as $key => $value) {
			if ( NULL === $value || $value === 0 ) {
				unset($this->_recaptchaOptions[$key]);
			}
		}

		$this->_recaptchaOptions = array_merge($this->_recaptchaOptions, $options);

		if ( NULL !== $theme_name ) {
			$this->_recaptchaOptions['theme'] = $theme_name;
		}

		// Skip to default reCAPTCHA theme if there is no options
		if ( count($this->_recaptchaOptions) == 0 ) {
			return;
		}

		// Whether lang option value is not built-in try to set it from a translation file
		if ( isset($this->_recaptchaOptions['lang'])
			&& !in_array($this->_recaptchaOptions['lang'], $this->_builtInlang)
			&& !isset($this->_recaptchaOptions['custom_translations']) ) {
			$this->setTranslation($this->_recaptchaOptions['lang']);
		}

		// Whether theme empty set default theme to default for FALLBACK
		if ( !isset($this->_recaptchaOptions['theme']) && count($this->_recaptchaOptions) > 0 ) {
			$this->_recaptchaOptions['theme'] = 'red';
		}

		// Skip to default reCAPTCHA theme if it's set to 'red' and there is no options at all
		if ( $this->_recaptchaOptions['theme'] === 'red' && count($this->_recaptchaOptions) == 1 ) {
			return;
		}

		  // Whether the theme name is Standard_Themes or not
		if ( in_array($this->_recaptchaOptions['theme'], $this->_standardThemes) ) {

			unset($this->_recaptchaOptions['custom_theme_widget']);
			$js_options = json_encode($this->_recaptchaOptions);

			return sprintf($this->_optionsWrapper, $js_options);

		} elseif ( $this->_recaptchaOptions['theme'] === 'custom' ) {
			// Custom theme MUST have an option [custom_theme_widget: ID_some_widget_name] set for recaptcha
			// If this option is not set, we make it.
			if ( !isset($this->_recaptchaOptions['custom_theme_widget']) ) {
				$this->_recaptchaOptions['custom_theme_widget'] = 'recaptcha_widget';
			}

			$custom_template = $this->custom_theme($this->_recaptchaOptions['custom_theme_widget']);

			$js_options = json_encode($this->_recaptchaOptions);
			return sprintf($this->_optionsWrapper, $js_options) . $custom_template;
		}
		// FALLBACK to red one default theme
		return;
	}
protected function _theme($theme_name = NULL, $options = array())
	{
		if ( count($options) > 0 ) {
		 	// Avoid invalid options passed via array
			foreach ($options as $opt => $value) {
				if ( !array_key_exists($opt, $this->_recaptchaOptions) ) {
					unset($options[$opt]);
				}
			}
		}

	  	// Avoid empty values
		foreach ($this->_recaptchaOptions as $key => $value) {
			if ( NULL === $value || $value === 0 ) {
				unset($this->_recaptchaOptions[$key]);
			}
		}

		$this->_recaptchaOptions = array_merge($this->_recaptchaOptions, $options);

		if ( NULL !== $theme_name ) {
			$this->_recaptchaOptions['theme'] = $theme_name;
		}

		// Skip to default reCAPTCHA theme if there is no options
		if ( count($this->_recaptchaOptions) == 0 ) {
			return;
		}

		// Whether lang option value is not built-in try to set it from a translation file
		if ( isset($this->_recaptchaOptions['lang'])
			&& !in_array($this->_recaptchaOptions['lang'], $this->_builtInlang)
			&& !isset($this->_recaptchaOptions['custom_translations']) ) {
			$this->setTranslation($this->_recaptchaOptions['lang']);
		}

		// Whether theme empty set default theme to default for FALLBACK
		if ( !isset($this->_recaptchaOptions['theme']) && count($this->_recaptchaOptions) > 0 ) {
			$this->_recaptchaOptions['theme'] = 'red';
		}

		// Skip to default reCAPTCHA theme if it's set to 'red' and there is no options at all
		if ( $this->_recaptchaOptions['theme'] === 'red' && count($this->_recaptchaOptions) == 1 ) {
			return;
		}

		  // Whether the theme name is Standard_Themes or not
		if ( in_array($this->_recaptchaOptions['theme'], $this->_standardThemes) ) {

			unset($this->_recaptchaOptions['custom_theme_widget']);
			$js_options = json_encode($this->_recaptchaOptions);

			return sprintf($this->_optionsWrapper, $js_options);

		} elseif ( $this->_recaptchaOptions['theme'] === 'custom' ) {
			// Custom theme MUST have an option [custom_theme_widget: ID_some_widget_name] set for recaptcha
			// If this option is not set, we make it.
			if ( !isset($this->_recaptchaOptions['custom_theme_widget']) ) {
				$this->_recaptchaOptions['custom_theme_widget'] = 'recaptcha_widget';
			}

			$custom_template = $this->custom_theme($this->_recaptchaOptions['custom_theme_widget']);

			$js_options = json_encode($this->_recaptchaOptions);
			return sprintf($this->_optionsWrapper, $js_options) . $custom_template;
		}
		// FALLBACK to red one default theme
		return;
	}
protected function _theme ( $ theme_name = NULL , $ options = array ( ) ) { if ( count ( $ options ) > 0 ) { // Avoid invalid options passed via array foreach ( $ options as $ opt => $ value ) { if ( ! array_key_exists ( $ opt , $ this -> _recaptchaOptions ) ) { unset ( $ options [ $ opt ] ) ; } } } // Avoid empty values foreach ( $ this -> _recaptchaOptions as $ key => $ value ) { if ( NULL === $ value || $ value === 0 ) { unset ( $ this -> _recaptchaOptions [ $ key ] ) ; } } $ this -> _recaptchaOptions = array_merge ( $ this -> _recaptchaOptions , $ options ) ; if ( NULL !== $ theme_name ) { $ this -> _recaptchaOptions [ 'theme' ] = $ theme_name ; } // Skip to default reCAPTCHA theme if there is no options if ( count ( $ this -> _recaptchaOptions ) == 0 ) { return ; } // Whether lang option value is not built-in try to set it from a translation file if ( isset ( $ this -> _recaptchaOptions [ 'lang' ] ) && ! in_array ( $ this -> _recaptchaOptions [ 'lang' ] , $ this -> _builtInlang ) && ! isset ( $ this -> _recaptchaOptions [ 'custom_translations' ] ) ) { $ this -> setTranslation ( $ this -> _recaptchaOptions [ 'lang' ] ) ; } // Whether theme empty set default theme to default for FALLBACK if ( ! isset ( $ this -> _recaptchaOptions [ 'theme' ] ) && count ( $ this -> _recaptchaOptions ) > 0 ) { $ this -> _recaptchaOptions [ 'theme' ] = 'red' ; } // Skip to default reCAPTCHA theme if it's set to 'red' and there is no options at all if ( $ this -> _recaptchaOptions [ 'theme' ] === 'red' && count ( $ this -> _recaptchaOptions ) == 1 ) { return ; } // Whether the theme name is Standard_Themes or not if ( in_array ( $ this -> _recaptchaOptions [ 'theme' ] , $ this -> _standardThemes ) ) { unset ( $ this -> _recaptchaOptions [ 'custom_theme_widget' ] ) ; $ js_options = json_encode ( $ this -> _recaptchaOptions ) ; return sprintf ( $ this -> _optionsWrapper , $ js_options ) ; } elseif ( $ this -> _recaptchaOptions [ 'theme' ] === 'custom' ) { // Custom theme MUST have an option [custom_theme_widget: ID_some_widget_name] set for recaptcha // If this option is not set, we make it. if ( ! isset ( $ this -> _recaptchaOptions [ 'custom_theme_widget' ] ) ) { $ this -> _recaptchaOptions [ 'custom_theme_widget' ] = 'recaptcha_widget' ; } $ custom_template = $ this -> custom_theme ( $ this -> _recaptchaOptions [ 'custom_theme_widget' ] ) ; $ js_options = json_encode ( $ this -> _recaptchaOptions ) ; return sprintf ( $ this -> _optionsWrapper , $ js_options ) . $ custom_template ; } // FALLBACK to red one default theme return ; }
Standard Theme
Display's Theme customization for reCAPTCHA widget
by writting a snippet for Standard_Themes and Custom_Theming

@param string $theme_name Optional theme name. NOTE: overwrite theme if it's set in an external config
@param array $options reCAPTCHA Associative array of available options. NOTE: overwrite options set in an external config
@return string Standard_Theme | Custom_Theme | Fallback default reCAPTCHA theme
Standard Theme Display s Theme customization for reCAPTCHA widget by writting a snippet for Standard_Themes and Custom_Theming