PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Controllers / Ajax / GoogleRecaptchaController.php

GoogleRecaptchaController.php in Depicter — Popup & Slider Builder trunk, at app/src/Controllers/Ajax/GoogleRecaptchaController.php

38 lines 891 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\Controllers\Ajax;
4
5 use Depicter\Utility\Sanitize;
6 use WPEmerge\Requests\RequestInterface;
7
8 class GoogleRecaptchaController
9 {
10
11 /**
12 * form submit spam checker
13 *
14 * @param RequestInterface $request
15 * @param $view
16 *
17 * @return \Psr\Http\Message\ResponseInterface
18 */
19 public function verify( RequestInterface $request, $view ) {
20 $token = Sanitize::textfield( $request->body( 'g-recaptcha-response', '' ) );
21
22 if ( empty( $token ) ) {
23 return \Depicter::json([
24 'errors' => [ __( 'google recaptcha response parameter required.', 'depicter' ) ]
25 ])->withStatus( 400 );
26 }
27
28 $isValid = \Depicter::recaptcha()->verify( $token );
29 if ( $isValid['success'] ) {
30 return \Depicter::json( [ 'success' => true ] )->withStatus( 200 );
31 }
32
33 return \Depicter::json([
34 'errors' => [ $isValid['message'] ]
35 ])->withStatus( 400 );
36 }
37 }
38