コード例 #1
0
 /**
  * Builds a reCAPTCHA™ JavaScript `script` tag for display.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param string $theme Optional. The theme used in display. Defaults to `clean`.
  * @param string $tabindex Optional. Value of `tabindex=""` attribute. Defaults to `-1`.
  * @param string $error Optional. An error message to display.
  * @return string HTML markup for JavaScript tag.
  */
 public static function recaptcha_script_tag($theme = FALSE, $tabindex = FALSE, $error = FALSE)
 {
     $theme = $theme ? $theme : "clean";
     $tabindex = strlen($tabindex) ? (int) $tabindex : -1;
     $keys = c_ws_plugin__s2member_utils_captchas::recaptcha_keys();
     $options = '<script type="text/javascript">' . "if(typeof RecaptchaOptions !== 'object'){ var RecaptchaOptions = {theme: '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($theme) . "', lang: '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["recaptcha"]["lang"]) . "', tabindex: " . $tabindex . " }; }" . '</script>' . "\n";
     $no_tabindex_icons = '<script type="text/javascript">' . "if(typeof jQuery === 'function'){ jQuery('td a[id^=\"recaptcha\"]').removeAttr('tabindex'); }" . '</script>';
     $adjustments = !apply_filters("c_ws_plugin__s2member_utils_tabindex_recaptcha_icons", false, get_defined_vars()) ? $no_tabindex_icons : "";
     return $options . '<script type="text/javascript" src="' . esc_attr('https://www.google.com/recaptcha/api/challenge?k=' . urlencode($keys["public"])) . '' . ($error ? '&amp;error=' . urlencode($error) : '') . '"></script>' . $adjustments;
 }
コード例 #2
0
 /**
  * Builds a reCAPTCHA™ JavaScript `script` tag for display.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param string $theme Optional. The theme used in display. Defaults to `clean`.
  * @param string $tabindex Optional. Value of `tabindex=""` attribute. Defaults to `-1`.
  * @param string $error Optional. An error message to display.
  * @return string HTML markup for JavaScript tag.
  */
 public static function recaptcha_script_tag($theme = '', $tabindex = '', $error = '')
 {
     $theme = $theme ? $theme : 'clean';
     $tabindex = strlen($tabindex) ? (int) $tabindex : -1;
     $keys = c_ws_plugin__s2member_utils_captchas::recaptcha_keys();
     if (self::recaptcha_version() === '2') {
         $theme = !$theme || in_array($theme, array('red', 'white', 'clean', 'blackglass'), TRUE) ? 'light' : $theme;
         return '<div class="g-recaptcha" data-sitekey="' . esc_attr($keys['public']) . '" data-size="normal" data-theme="' . esc_attr($theme) . '" data-tabindex="' . esc_attr($tabindex) . '"></div>' . '<script src="https://www.google.com/recaptcha/api.js"></script>';
     }
     $options = '<script type="text/javascript">' . "if(typeof RecaptchaOptions !== 'object'){ var RecaptchaOptions = {theme: '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($theme) . "', lang: '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($GLOBALS['WS_PLUGIN__']['s2member']['c']['recaptcha']['lang']) . "', tabindex: " . $tabindex . " }; }" . '</script>' . "\n";
     $no_tabindex_icons = '<script type="text/javascript">' . "if(typeof jQuery === 'function'){ jQuery('td a[id^=\"recaptcha\"]').removeAttr('tabindex'); }" . '</script>';
     $adjustments = !apply_filters('c_ws_plugin__s2member_utils_tabindex_recaptcha_icons', false, get_defined_vars()) ? $no_tabindex_icons : '';
     return $options . '<script type="text/javascript" src="' . esc_attr('https://www.google.com/recaptcha/api/challenge?k=' . urlencode($keys['public'])) . ($error ? '&amp;error=' . urlencode($error) : '') . '"></script>' . $adjustments;
 }