@@ -31,67 +31,67 @@ |
||
31 | 31 | */ |
32 | 32 | class ReCaptcha |
33 | 33 | { |
34 | - /** |
|
35 | - * Version of this client library. |
|
36 | - * @const string |
|
37 | - */ |
|
38 | - const VERSION = 'php_1.1.1'; |
|
34 | + /** |
|
35 | + * Version of this client library. |
|
36 | + * @const string |
|
37 | + */ |
|
38 | + const VERSION = 'php_1.1.1'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Shared secret for the site. |
|
42 | - * @var type string |
|
43 | - */ |
|
44 | - private $secret; |
|
40 | + /** |
|
41 | + * Shared secret for the site. |
|
42 | + * @var type string |
|
43 | + */ |
|
44 | + private $secret; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Method used to communicate with service. Defaults to POST request. |
|
48 | - * @var RequestMethod |
|
49 | - */ |
|
50 | - private $requestMethod; |
|
46 | + /** |
|
47 | + * Method used to communicate with service. Defaults to POST request. |
|
48 | + * @var RequestMethod |
|
49 | + */ |
|
50 | + private $requestMethod; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Create a configured instance to use the reCAPTCHA service. |
|
54 | - * |
|
55 | - * @param string $secret shared secret between site and reCAPTCHA server. |
|
56 | - * @param RequestMethod $requestMethod method used to send the request. Defaults to POST. |
|
57 | - */ |
|
58 | - public function __construct($secret, RequestMethod $requestMethod = null) |
|
59 | - { |
|
60 | - if (empty($secret)) { |
|
61 | - throw new \RuntimeException('No secret provided'); |
|
62 | - } |
|
52 | + /** |
|
53 | + * Create a configured instance to use the reCAPTCHA service. |
|
54 | + * |
|
55 | + * @param string $secret shared secret between site and reCAPTCHA server. |
|
56 | + * @param RequestMethod $requestMethod method used to send the request. Defaults to POST. |
|
57 | + */ |
|
58 | + public function __construct($secret, RequestMethod $requestMethod = null) |
|
59 | + { |
|
60 | + if (empty($secret)) { |
|
61 | + throw new \RuntimeException('No secret provided'); |
|
62 | + } |
|
63 | 63 | |
64 | - if (!is_string($secret)) { |
|
65 | - throw new \RuntimeException('The provided secret must be a string'); |
|
66 | - } |
|
64 | + if (!is_string($secret)) { |
|
65 | + throw new \RuntimeException('The provided secret must be a string'); |
|
66 | + } |
|
67 | 67 | |
68 | - $this->secret = $secret; |
|
68 | + $this->secret = $secret; |
|
69 | 69 | |
70 | - if (!is_null($requestMethod)) { |
|
71 | - $this->requestMethod = $requestMethod; |
|
72 | - } else { |
|
73 | - $this->requestMethod = new RequestMethod\Post(); |
|
74 | - } |
|
75 | - } |
|
70 | + if (!is_null($requestMethod)) { |
|
71 | + $this->requestMethod = $requestMethod; |
|
72 | + } else { |
|
73 | + $this->requestMethod = new RequestMethod\Post(); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Calls the reCAPTCHA siteverify API to verify whether the user passes |
|
79 | - * CAPTCHA test. |
|
80 | - * |
|
81 | - * @param string $response The value of 'g-recaptcha-response' in the submitted form. |
|
82 | - * @param string $remoteIp The end user's IP address. |
|
83 | - * @return Response Response from the service. |
|
84 | - */ |
|
85 | - public function verify($response, $remoteIp = null) |
|
86 | - { |
|
87 | - // Discard empty solution submissions |
|
88 | - if (empty($response)) { |
|
89 | - $recaptchaResponse = new Response(false, array('missing-input-response')); |
|
90 | - return $recaptchaResponse; |
|
91 | - } |
|
77 | + /** |
|
78 | + * Calls the reCAPTCHA siteverify API to verify whether the user passes |
|
79 | + * CAPTCHA test. |
|
80 | + * |
|
81 | + * @param string $response The value of 'g-recaptcha-response' in the submitted form. |
|
82 | + * @param string $remoteIp The end user's IP address. |
|
83 | + * @return Response Response from the service. |
|
84 | + */ |
|
85 | + public function verify($response, $remoteIp = null) |
|
86 | + { |
|
87 | + // Discard empty solution submissions |
|
88 | + if (empty($response)) { |
|
89 | + $recaptchaResponse = new Response(false, array('missing-input-response')); |
|
90 | + return $recaptchaResponse; |
|
91 | + } |
|
92 | 92 | |
93 | - $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); |
|
94 | - $rawResponse = $this->requestMethod->submit($params); |
|
95 | - return Response::fromJson($rawResponse); |
|
96 | - } |
|
93 | + $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); |
|
94 | + $rawResponse = $this->requestMethod->submit($params); |
|
95 | + return Response::fromJson($rawResponse); |
|
96 | + } |
|
97 | 97 | } |
@@ -61,13 +61,13 @@ |
||
61 | 61 | throw new \RuntimeException('No secret provided'); |
62 | 62 | } |
63 | 63 | |
64 | - if (!is_string($secret)) { |
|
64 | + if ( ! is_string($secret)) { |
|
65 | 65 | throw new \RuntimeException('The provided secret must be a string'); |
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->secret = $secret; |
69 | 69 | |
70 | - if (!is_null($requestMethod)) { |
|
70 | + if ( ! is_null($requestMethod)) { |
|
71 | 71 | $this->requestMethod = $requestMethod; |
72 | 72 | } else { |
73 | 73 | $this->requestMethod = new RequestMethod\Post(); |
@@ -10,38 +10,38 @@ |
||
10 | 10 | */ |
11 | 11 | class Curl implements RequestMethod |
12 | 12 | { |
13 | - /** |
|
14 | - * URL to which requests are sent via cURL. |
|
15 | - * @const string |
|
16 | - */ |
|
17 | - const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
13 | + /** |
|
14 | + * URL to which requests are sent via cURL. |
|
15 | + * @const string |
|
16 | + */ |
|
17 | + const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Submit the cURL request with the specified parameters. |
|
21 | - * |
|
22 | - * @param RequestParameters $params Request parameters |
|
23 | - * @return string Body of the reCAPTCHA response |
|
24 | - */ |
|
25 | - public function submit(RequestParameters $params) |
|
26 | - { |
|
27 | - $handle = curl_init(self::SITE_VERIFY_URL); |
|
19 | + /** |
|
20 | + * Submit the cURL request with the specified parameters. |
|
21 | + * |
|
22 | + * @param RequestParameters $params Request parameters |
|
23 | + * @return string Body of the reCAPTCHA response |
|
24 | + */ |
|
25 | + public function submit(RequestParameters $params) |
|
26 | + { |
|
27 | + $handle = curl_init(self::SITE_VERIFY_URL); |
|
28 | 28 | |
29 | - $options = array( |
|
30 | - CURLOPT_POST => true, |
|
31 | - CURLOPT_POSTFIELDS => $params->toQueryString(), |
|
32 | - CURLOPT_HTTPHEADER => array( |
|
33 | - 'Content-Type: application/x-www-form-urlencoded' |
|
34 | - ), |
|
35 | - CURLINFO_HEADER_OUT => false, |
|
36 | - CURLOPT_HEADER => false, |
|
37 | - CURLOPT_RETURNTRANSFER => true, |
|
38 | - CURLOPT_SSL_VERIFYPEER => true |
|
39 | - ); |
|
40 | - curl_setopt_array($handle, $options); |
|
29 | + $options = array( |
|
30 | + CURLOPT_POST => true, |
|
31 | + CURLOPT_POSTFIELDS => $params->toQueryString(), |
|
32 | + CURLOPT_HTTPHEADER => array( |
|
33 | + 'Content-Type: application/x-www-form-urlencoded' |
|
34 | + ), |
|
35 | + CURLINFO_HEADER_OUT => false, |
|
36 | + CURLOPT_HEADER => false, |
|
37 | + CURLOPT_RETURNTRANSFER => true, |
|
38 | + CURLOPT_SSL_VERIFYPEER => true |
|
39 | + ); |
|
40 | + curl_setopt_array($handle, $options); |
|
41 | 41 | |
42 | - $response = curl_exec($handle); |
|
43 | - curl_close($handle); |
|
42 | + $response = curl_exec($handle); |
|
43 | + curl_close($handle); |
|
44 | 44 | |
45 | - return $response; |
|
46 | - } |
|
45 | + return $response; |
|
46 | + } |
|
47 | 47 | } |
@@ -80,11 +80,11 @@ |
||
80 | 80 | { |
81 | 81 | $params = array('secret' => $this->secret, 'response' => $this->response); |
82 | 82 | |
83 | - if (!is_null($this->remoteIp)) { |
|
83 | + if ( ! is_null($this->remoteIp)) { |
|
84 | 84 | $params['remoteip'] = $this->remoteIp; |
85 | 85 | } |
86 | 86 | |
87 | - if (!is_null($this->version)) { |
|
87 | + if ( ! is_null($this->version)) { |
|
88 | 88 | $params['version'] = $this->version; |
89 | 89 | } |
90 | 90 |
@@ -31,73 +31,73 @@ |
||
31 | 31 | */ |
32 | 32 | class RequestParameters |
33 | 33 | { |
34 | - /** |
|
35 | - * Site secret. |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - private $secret; |
|
34 | + /** |
|
35 | + * Site secret. |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + private $secret; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Form response. |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - private $response; |
|
40 | + /** |
|
41 | + * Form response. |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + private $response; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Remote user's IP address. |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - private $remoteIp; |
|
46 | + /** |
|
47 | + * Remote user's IP address. |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + private $remoteIp; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Client version. |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - private $version; |
|
52 | + /** |
|
53 | + * Client version. |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + private $version; |
|
57 | 57 | |
58 | - /** |
|
59 | - * Initialise parameters. |
|
60 | - * |
|
61 | - * @param string $secret Site secret. |
|
62 | - * @param string $response Value from g-captcha-response form field. |
|
63 | - * @param string $remoteIp User's IP address. |
|
64 | - * @param string $version Version of this client library. |
|
65 | - */ |
|
66 | - public function __construct($secret, $response, $remoteIp = null, $version = null) |
|
67 | - { |
|
68 | - $this->secret = $secret; |
|
69 | - $this->response = $response; |
|
70 | - $this->remoteIp = $remoteIp; |
|
71 | - $this->version = $version; |
|
72 | - } |
|
58 | + /** |
|
59 | + * Initialise parameters. |
|
60 | + * |
|
61 | + * @param string $secret Site secret. |
|
62 | + * @param string $response Value from g-captcha-response form field. |
|
63 | + * @param string $remoteIp User's IP address. |
|
64 | + * @param string $version Version of this client library. |
|
65 | + */ |
|
66 | + public function __construct($secret, $response, $remoteIp = null, $version = null) |
|
67 | + { |
|
68 | + $this->secret = $secret; |
|
69 | + $this->response = $response; |
|
70 | + $this->remoteIp = $remoteIp; |
|
71 | + $this->version = $version; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Array representation. |
|
76 | - * |
|
77 | - * @return array Array formatted parameters. |
|
78 | - */ |
|
79 | - public function toArray() |
|
80 | - { |
|
81 | - $params = array('secret' => $this->secret, 'response' => $this->response); |
|
74 | + /** |
|
75 | + * Array representation. |
|
76 | + * |
|
77 | + * @return array Array formatted parameters. |
|
78 | + */ |
|
79 | + public function toArray() |
|
80 | + { |
|
81 | + $params = array('secret' => $this->secret, 'response' => $this->response); |
|
82 | 82 | |
83 | - if (!is_null($this->remoteIp)) { |
|
84 | - $params['remoteip'] = $this->remoteIp; |
|
85 | - } |
|
83 | + if (!is_null($this->remoteIp)) { |
|
84 | + $params['remoteip'] = $this->remoteIp; |
|
85 | + } |
|
86 | 86 | |
87 | - if (!is_null($this->version)) { |
|
88 | - $params['version'] = $this->version; |
|
89 | - } |
|
87 | + if (!is_null($this->version)) { |
|
88 | + $params['version'] = $this->version; |
|
89 | + } |
|
90 | 90 | |
91 | - return $params; |
|
92 | - } |
|
91 | + return $params; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Query string representation for HTTP request. |
|
96 | - * |
|
97 | - * @return string Query string formatted parameters. |
|
98 | - */ |
|
99 | - public function toQueryString() |
|
100 | - { |
|
101 | - return http_build_query($this->toArray(), '', '&'); |
|
102 | - } |
|
94 | + /** |
|
95 | + * Query string representation for HTTP request. |
|
96 | + * |
|
97 | + * @return string Query string formatted parameters. |
|
98 | + */ |
|
99 | + public function toQueryString() |
|
100 | + { |
|
101 | + return http_build_query($this->toArray(), '', '&'); |
|
102 | + } |
|
103 | 103 | } |
@@ -16,11 +16,11 @@ |
||
16 | 16 | |
17 | 17 | <section id="primary" class="content-area"> |
18 | 18 | <div id="content" class="site-content" role="main"> |
19 | - <?php espresso_get_template_part( 'loop', 'espresso_events' ); ?> |
|
19 | + <?php espresso_get_template_part('loop', 'espresso_events'); ?> |
|
20 | 20 | </div><!-- #content --> |
21 | 21 | </section><!-- #primary --> |
22 | 22 | |
23 | 23 | <?php |
24 | -get_sidebar( 'content' ); |
|
24 | +get_sidebar('content'); |
|
25 | 25 | get_sidebar(); |
26 | 26 | get_footer(); |
@@ -18,11 +18,11 @@ |
||
18 | 18 | |
19 | 19 | <section id="primary" class="content-area"> |
20 | 20 | <div id="content" class="site-content" role="main"> |
21 | - <?php espresso_get_template_part( 'loop', 'espresso_venues' ); ?> |
|
21 | + <?php espresso_get_template_part('loop', 'espresso_venues'); ?> |
|
22 | 22 | </div><!-- #content --> |
23 | 23 | </section><!-- #primary --> |
24 | 24 | |
25 | 25 | <?php |
26 | -get_sidebar( 'content' ); |
|
26 | +get_sidebar('content'); |
|
27 | 27 | get_sidebar(); |
28 | 28 | get_footer(); |
29 | 29 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | //echo '<br/><h6 style="color:#2EA2CC;">'. __FILE__ . ' <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>'; |
3 | 3 | global $post; |
4 | -if ( espresso_display_ticket_selector( $post->ID ) && ( is_single() || ( is_archive() && espresso_display_ticket_selector_in_event_list() ))) : |
|
4 | +if (espresso_display_ticket_selector($post->ID) && (is_single() || (is_archive() && espresso_display_ticket_selector_in_event_list()))) : |
|
5 | 5 | ?> |
6 | 6 | <div class="event-tickets" style="clear: both;"> |
7 | - <?php espresso_ticket_selector( $post ); ?> |
|
7 | + <?php espresso_ticket_selector($post); ?> |
|
8 | 8 | </div> |
9 | 9 | <!-- .event-tickets --> |
10 | -<?php elseif ( ! is_single() ) : ?> |
|
11 | -<?php espresso_view_details_btn( $post ); ?> |
|
10 | +<?php elseif ( ! is_single()) : ?> |
|
11 | +<?php espresso_view_details_btn($post); ?> |
|
12 | 12 | <?php endif; ?> |
13 | 13 | \ No newline at end of file |
@@ -32,8 +32,10 @@ |
||
32 | 32 | do_action( 'AHEE__archive_espresso_venues_template__after_loop' ); |
33 | 33 | |
34 | 34 | |
35 | -else : |
|
35 | +else { |
|
36 | + : |
|
36 | 37 | // If no content, include the "No posts found" template. |
37 | 38 | espresso_get_template_part( 'content', 'none' ); |
39 | +} |
|
38 | 40 | |
39 | 41 | endif; |
@@ -10,30 +10,30 @@ |
||
10 | 10 | * @ version 4+ |
11 | 11 | */ |
12 | 12 | |
13 | -if ( have_posts() ) : ?> |
|
13 | +if (have_posts()) : ?> |
|
14 | 14 | |
15 | 15 | <header class="page-header"> |
16 | 16 | <h1 class="page-title"> |
17 | - <?php echo esc_html__( 'Event Venues', 'event_espresso' ); ?> |
|
17 | + <?php echo esc_html__('Event Venues', 'event_espresso'); ?> |
|
18 | 18 | </h1> |
19 | 19 | </header><!-- .page-header --> |
20 | 20 | |
21 | 21 | <?php |
22 | 22 | // allow other stuff |
23 | - do_action( 'AHEE__archive_espresso_venues_template__before_loop' ); |
|
23 | + do_action('AHEE__archive_espresso_venues_template__before_loop'); |
|
24 | 24 | // Start the Loop. |
25 | - while ( have_posts() ) : the_post(); |
|
25 | + while (have_posts()) : the_post(); |
|
26 | 26 | // Include the post TYPE-specific template for the content. |
27 | - espresso_get_template_part( 'content', 'espresso_venues' ); |
|
27 | + espresso_get_template_part('content', 'espresso_venues'); |
|
28 | 28 | endwhile; |
29 | 29 | // Previous/next page navigation. |
30 | 30 | espresso_pagination(); |
31 | 31 | // allow moar other stuff |
32 | - do_action( 'AHEE__archive_espresso_venues_template__after_loop' ); |
|
32 | + do_action('AHEE__archive_espresso_venues_template__after_loop'); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | else : |
36 | 36 | // If no content, include the "No posts found" template. |
37 | - espresso_get_template_part( 'content', 'none' ); |
|
37 | + espresso_get_template_part('content', 'none'); |
|
38 | 38 | |
39 | 39 | endif; |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | <div id="espresso-venue-details-dv" class="" > |
19 | 19 | <?php |
20 | 20 | // Start the Loop. |
21 | - while ( have_posts() ) : the_post(); |
|
21 | + while (have_posts()) : the_post(); |
|
22 | 22 | // Include the post TYPE-specific template for the content. |
23 | - espresso_get_template_part( 'content', 'espresso_venues' ); |
|
23 | + espresso_get_template_part('content', 'espresso_venues'); |
|
24 | 24 | // If comments are open or we have at least one comment, load up the comment template. |
25 | - if ( comments_open() || get_comments_number() ) { |
|
25 | + if (comments_open() || get_comments_number()) { |
|
26 | 26 | comments_template(); |
27 | 27 | } |
28 | 28 | endwhile; |
@@ -34,6 +34,6 @@ discard block |
||
34 | 34 | </div><!-- #primary --> |
35 | 35 | |
36 | 36 | <?php |
37 | -get_sidebar( 'content' ); |
|
37 | +get_sidebar('content'); |
|
38 | 38 | get_sidebar(); |
39 | 39 | get_footer(); |
40 | 40 | \ No newline at end of file |
@@ -34,37 +34,37 @@ |
||
34 | 34 | */ |
35 | 35 | class Post implements RequestMethod |
36 | 36 | { |
37 | - /** |
|
38 | - * URL to which requests are POSTed. |
|
39 | - * @const string |
|
40 | - */ |
|
41 | - const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
37 | + /** |
|
38 | + * URL to which requests are POSTed. |
|
39 | + * @const string |
|
40 | + */ |
|
41 | + const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Submit the POST request with the specified parameters. |
|
45 | - * |
|
46 | - * @param RequestParameters $params Request parameters |
|
47 | - * @return string Body of the reCAPTCHA response |
|
48 | - */ |
|
49 | - public function submit(RequestParameters $params) |
|
50 | - { |
|
51 | - /** |
|
52 | - * PHP 5.6.0 changed the way you specify the peer name for SSL context options. |
|
53 | - * Using "CN_name" will still work, but it will raise deprecated errors. |
|
54 | - */ |
|
55 | - $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name'; |
|
56 | - $options = array( |
|
57 | - 'http' => array( |
|
58 | - 'header' => "Content-type: application/x-www-form-urlencoded\r\n", |
|
59 | - 'method' => 'POST', |
|
60 | - 'content' => $params->toQueryString(), |
|
61 | - // Force the peer to validate (not needed in 5.6.0+, but still works |
|
62 | - 'verify_peer' => true, |
|
63 | - // Force the peer validation to use www.google.com |
|
64 | - $peer_key => 'www.google.com', |
|
65 | - ), |
|
66 | - ); |
|
67 | - $context = stream_context_create($options); |
|
68 | - return file_get_contents(self::SITE_VERIFY_URL, false, $context); |
|
69 | - } |
|
43 | + /** |
|
44 | + * Submit the POST request with the specified parameters. |
|
45 | + * |
|
46 | + * @param RequestParameters $params Request parameters |
|
47 | + * @return string Body of the reCAPTCHA response |
|
48 | + */ |
|
49 | + public function submit(RequestParameters $params) |
|
50 | + { |
|
51 | + /** |
|
52 | + * PHP 5.6.0 changed the way you specify the peer name for SSL context options. |
|
53 | + * Using "CN_name" will still work, but it will raise deprecated errors. |
|
54 | + */ |
|
55 | + $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name'; |
|
56 | + $options = array( |
|
57 | + 'http' => array( |
|
58 | + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", |
|
59 | + 'method' => 'POST', |
|
60 | + 'content' => $params->toQueryString(), |
|
61 | + // Force the peer to validate (not needed in 5.6.0+, but still works |
|
62 | + 'verify_peer' => true, |
|
63 | + // Force the peer validation to use www.google.com |
|
64 | + $peer_key => 'www.google.com', |
|
65 | + ), |
|
66 | + ); |
|
67 | + $context = stream_context_create($options); |
|
68 | + return file_get_contents(self::SITE_VERIFY_URL, false, $context); |
|
69 | + } |
|
70 | 70 | } |