芝麻web文件管理V1.00
', '
' . $recaptcha . '', $output );
} else {
$output = str_replace( '', $recaptcha . '', $output );
}
return $output;
}
}
if ( ! function_exists( 'gglcptch_password_form_cookie' ) ) {
/**
* Add google captcha to the protected post password form
*
* @param array $expire Expire time.
* @return array $expire Expire time.
*/
function gglcptch_password_form_cookie( $expire ) {
if ( isset( $_POST['g-recaptcha-response'] ) ) {
$gglcptch_check = gglcptch_check( 'password_form' );
if ( ! $gglcptch_check['response'] ) {
setcookie( 'gglcptch_password_form_errors', $gglcptch_check['errors']->get_error_message( 'gglcptch_error' ), time() + 300, COOKIEPATH, COOKIE_DOMAIN, false );
} else {
setcookie( 'gglcptch_password_form_errors', '', -1, COOKIEPATH, COOKIE_DOMAIN, false );
}
}
return $expire;
}
}
if ( ! function_exists( 'gglcptch_password_form_check' ) ) {
/**
* Check google captcha in protected post password form
*
* @param bool $required Flag for required password form.
* @param object $post Post object.
* @return bool $required Flag for required password form.
*/
function gglcptch_password_form_check( $required, $post ) {
if ( isset( $_COOKIE['gglcptch_password_form_errors'] ) ) {
$required = true;
}
return $required;
}
}
if ( ! function_exists( 'gglcptch_signup_display' ) ) {
/**
* Add google captcha to the multisite login form
*
* @param array $errors Login form errors.
*/
function gglcptch_signup_display( $errors ) {
$error_message = $errors->get_error_message( 'gglcptch_error' );
if ( ! empty( $error_message ) ) {
printf( '
%s
', wp_kses_post( $error_message ) );
}
$error_message = $errors->get_error_message( 'lmttmpts_error' );
if ( ! empty( $error_message ) ) {
printf( '
%s
', wp_kses_post( $error_message ) );
}
echo gglcptch_display();
}
}
if ( ! function_exists( 'gglcptch_signup_check' ) ) {
/**
* Check google captcha in multisite login form
*
* @param array $result Result/Error.
* @return array $result Result/Error.
*/
function gglcptch_signup_check( $result ) {
global $current_user;
if ( is_admin() && ! defined( 'DOING_AJAX' ) && ! empty( $current_user->data->ID ) ) {
return $result;
}
$gglcptch_check = gglcptch_check( 'registration_form' );
if ( ! $gglcptch_check['response'] ) {
$result['errors'] = $gglcptch_check['errors'];
return $result;
}
return $result;
}
}
if ( ! function_exists( 'gglcptch_commentform_display' ) ) {
/**
* Add google captcha to the comment form
*
* @return bool true
*/
function gglcptch_commentform_display() {
if ( gglcptch_is_hidden_for_role() ) {
return;
}
echo gglcptch_display();
return true;
}
}
if ( ! function_exists( 'gglcptch_commentform_check' ) ) {
/**
* Check JS enabled for comment form
*/
function gglcptch_commentform_check() {
$gglcptch_check = gglcptch_check( 'comments_form' );
if ( ! $gglcptch_check['response'] ) {
$message = gglcptch_get_message( $gglcptch_check['reason'] ) . '
';
if ( ! empty( $gglcptch_check['errors'] ) && is_wp_error( $gglcptch_check['errors'] ) ){
$lmttmpts_error = $gglcptch_check['errors']->get_error_message( 'lmttmpts_error' );
if ( ! empty( $lmttmpts_error ) ) {
$message .= sprintf(
'
%s: %s
',
__( 'Error', 'google-captcha' ),
$gglcptch_check['errors']->get_error_message( 'lmttmpts_error' )
);
}
}
$error_message = sprintf(
'
%s: %s %s',
__( 'Error', 'google-captcha' ),
$message,
__( 'Click the BACK button on your browser and try again.', 'google-captcha' )
);
wp_die( wp_kses_post( $error_message ) );
}
}
}
if ( ! function_exists( 'gglcptch_contact_form_check' ) ) {
/**
* Check google captcha in BWS Contact Form
*
* @param bool $allow (Optional) reCaptcha for contact form.
* @return bool $allow Result check.
*/
function gglcptch_contact_form_check( $allow = true ) {
if ( ! $allow || is_string( $allow ) || is_wp_error( $allow ) ) {
return $allow;
}
$gglcptch_check = gglcptch_check( 'contact_form' );
if ( ! $gglcptch_check['response'] ) {
return $gglcptch_check['errors'];
}
return $allow;
}
}
if ( ! function_exists( 'gglcptch_testimonials_check' ) ) {
/**
* Check google captcha in BWS Testimonial
*
* @param bool $allow (Optional) reCaptcha for testimonials.
* @return bool $allow Result check.
*/
function gglcptch_testimonials_check( $allow = true ) {
global $gglcptch_check;
if ( ! $allow || is_string( $allow ) || is_wp_error( $allow ) ) {
return $allow;
}
$gglcptch_check = gglcptch_check( 'testimonials' );
if ( ! $gglcptch_check['response'] ) {
return $gglcptch_check['errors'];
}
return $allow;
}
}