@@ -1,8 +1,8 @@ |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p><?php |
3 | - printf( |
|
4 | - esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'), |
|
5 | - '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">', |
|
6 | - '</a>' |
|
7 | - ); ?></p> |
|
3 | + printf( |
|
4 | + esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'), |
|
5 | + '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">', |
|
6 | + '</a>' |
|
7 | + ); ?></p> |
|
8 | 8 | </div> |
9 | 9 | \ No newline at end of file |
@@ -1,93 +1,93 @@ |
||
1 | 1 | <div class="padding"> |
2 | 2 | <?php esc_html_e( |
3 | - 'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.', |
|
4 | - 'event_espresso' |
|
5 | - ); ?> |
|
3 | + 'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.', |
|
4 | + 'event_espresso' |
|
5 | + ); ?> |
|
6 | 6 | <h2><?php esc_html_e('Developer Resources', 'event_espresso'); ?></h2> |
7 | 7 | <ul> |
8 | 8 | <li> |
9 | 9 | <?php printf( |
10 | - esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'), |
|
11 | - '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">', |
|
12 | - '</a>' |
|
13 | - ); ?></li> |
|
10 | + esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'), |
|
11 | + '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">', |
|
12 | + '</a>' |
|
13 | + ); ?></li> |
|
14 | 14 | <li> |
15 | 15 | <?php printf( |
16 | - esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'), |
|
17 | - '<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
18 | - '</a>' |
|
19 | - ); ?></li> |
|
16 | + esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'), |
|
17 | + '<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
18 | + '</a>' |
|
19 | + ); ?></li> |
|
20 | 20 | <li> |
21 | 21 | <?php printf( |
22 | - esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'), |
|
23 | - '<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
24 | - '</a>', |
|
25 | - '<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">' |
|
26 | - ); ?></li> |
|
22 | + esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'), |
|
23 | + '<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
24 | + '</a>', |
|
25 | + '<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">' |
|
26 | + ); ?></li> |
|
27 | 27 | </ul> |
28 | 28 | |
29 | 29 | <h2><?php esc_html_e('Event Espresso 4 Articles for Developers', 'event_espresso'); ?></h2> |
30 | 30 | <ul> |
31 | 31 | <li> |
32 | 32 | <?php printf( |
33 | - esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'), |
|
34 | - '<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
35 | - '</a>' |
|
36 | - ); ?></li> |
|
33 | + esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'), |
|
34 | + '<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
35 | + '</a>' |
|
36 | + ); ?></li> |
|
37 | 37 | <li> |
38 | 38 | <?php printf( |
39 | - esc_html__('%1$sTheme Development%2$s', 'event_espresso'), |
|
40 | - '<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
41 | - '</a>' |
|
42 | - ); ?></li> |
|
39 | + esc_html__('%1$sTheme Development%2$s', 'event_espresso'), |
|
40 | + '<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
41 | + '</a>' |
|
42 | + ); ?></li> |
|
43 | 43 | <li> |
44 | 44 | <?php printf( |
45 | - esc_html__('%1$sCapability System%2$s', 'event_espresso'), |
|
46 | - '<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
47 | - '</a>' |
|
48 | - ); ?></li> |
|
45 | + esc_html__('%1$sCapability System%2$s', 'event_espresso'), |
|
46 | + '<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
47 | + '</a>' |
|
48 | + ); ?></li> |
|
49 | 49 | <li> |
50 | 50 | <?php printf( |
51 | - esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'), |
|
52 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">', |
|
53 | - '</a>' |
|
54 | - ); ?></li> |
|
51 | + esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'), |
|
52 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">', |
|
53 | + '</a>' |
|
54 | + ); ?></li> |
|
55 | 55 | <li> |
56 | 56 | <?php printf( |
57 | - esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'), |
|
58 | - '<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
59 | - '</a>' |
|
60 | - ); ?></li> |
|
57 | + esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'), |
|
58 | + '<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
59 | + '</a>' |
|
60 | + ); ?></li> |
|
61 | 61 | <li> |
62 | 62 | <?php printf( |
63 | - esc_html__( |
|
64 | - '%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)', |
|
65 | - 'event_espresso' |
|
66 | - ), |
|
67 | - '<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
68 | - '</a>' |
|
69 | - ); ?></li> |
|
63 | + esc_html__( |
|
64 | + '%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)', |
|
65 | + 'event_espresso' |
|
66 | + ), |
|
67 | + '<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
68 | + '</a>' |
|
69 | + ); ?></li> |
|
70 | 70 | </ul> |
71 | 71 | |
72 | 72 | <h2><?php esc_html_e('REST API Resources', 'event_espresso'); ?></h2> |
73 | 73 | <ul> |
74 | 74 | <li> |
75 | 75 | <?php printf( |
76 | - esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'), |
|
77 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">', |
|
78 | - '</a>' |
|
79 | - ); ?></li> |
|
76 | + esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'), |
|
77 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">', |
|
78 | + '</a>' |
|
79 | + ); ?></li> |
|
80 | 80 | <li> |
81 | 81 | <?php printf( |
82 | - esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'), |
|
83 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">', |
|
84 | - '</a>' |
|
85 | - ); ?></li> |
|
82 | + esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'), |
|
83 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">', |
|
84 | + '</a>' |
|
85 | + ); ?></li> |
|
86 | 86 | <li> |
87 | 87 | <?php printf( |
88 | - esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'), |
|
89 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">', |
|
90 | - '</a>' |
|
91 | - ); ?></li> |
|
88 | + esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'), |
|
89 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">', |
|
90 | + '</a>' |
|
91 | + ); ?></li> |
|
92 | 92 | </ul> |
93 | 93 | </div> |
94 | 94 | \ No newline at end of file |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getType() |
95 | 95 | { |
96 | - if (!$this->type) { |
|
96 | + if ( ! $this->type) { |
|
97 | 97 | $this->type = $this->determineType(); |
98 | 98 | } |
99 | 99 | return $this->type; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function determineType() |
107 | 107 | { |
108 | - if (!$this->getTmpFile()) { |
|
108 | + if ( ! $this->getTmpFile()) { |
|
109 | 109 | return ''; |
110 | 110 | } |
111 | 111 | $finfo = new finfo(FILEINFO_MIME_TYPE); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getExtension() |
121 | 121 | { |
122 | - if (!$this->extension) { |
|
122 | + if ( ! $this->extension) { |
|
123 | 123 | $this->extension = $this->determineExtension(); |
124 | 124 | } |
125 | 125 | return $this->extension; |
@@ -19,164 +19,164 @@ |
||
19 | 19 | */ |
20 | 20 | class FileSubmission implements FileSubmissionInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string original name on the client machine |
|
24 | - */ |
|
25 | - protected $name; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string mime type |
|
29 | - */ |
|
30 | - protected $type; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string file extension |
|
34 | - */ |
|
35 | - protected $extension; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var int in bytes |
|
39 | - */ |
|
40 | - protected $size; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string local filepath to the temporary file |
|
44 | - */ |
|
45 | - protected $tmp_file; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values |
|
49 | - * although those aren't expected. |
|
50 | - */ |
|
51 | - protected $error_code; |
|
52 | - |
|
53 | - /** |
|
54 | - * FileSubmission constructor. |
|
55 | - * @param $name |
|
56 | - * @param $tmp_file |
|
57 | - * @param $size |
|
58 | - * @param null $error_code |
|
59 | - * @throws InvalidArgumentException |
|
60 | - */ |
|
61 | - public function __construct($name, $tmp_file, $size, $error_code = null) |
|
62 | - { |
|
63 | - $this->name = basename($name); |
|
64 | - $scheme = parse_url($tmp_file, PHP_URL_SCHEME); |
|
65 | - if (in_array($scheme, ['http', 'https'])) { |
|
66 | - // Wait a minute- just local filepaths please, no URL schemes allowed! |
|
67 | - throw new InvalidArgumentException( |
|
68 | - sprintf( |
|
69 | - // @codingStandardsIgnoreStart |
|
70 | - esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'), |
|
71 | - // @codingStandardsIgnoreEnd |
|
72 | - $scheme, |
|
73 | - $tmp_file |
|
74 | - ) |
|
75 | - ); |
|
76 | - } |
|
77 | - $this->tmp_file = (string) $tmp_file; |
|
78 | - $this->size = (int) $size; |
|
79 | - $this->error_code = (int) $error_code; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function getName() |
|
86 | - { |
|
87 | - return $this->name; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Gets the file's mime type |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function getType() |
|
95 | - { |
|
96 | - if (!$this->type) { |
|
97 | - $this->type = $this->determineType(); |
|
98 | - } |
|
99 | - return $this->type; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @since 4.9.80.p |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - protected function determineType() |
|
107 | - { |
|
108 | - if (!$this->getTmpFile()) { |
|
109 | - return ''; |
|
110 | - } |
|
111 | - $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
112 | - return $finfo->file($this->getTmpFile()); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Gets the file's extension. |
|
117 | - * @since 4.9.80.p |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function getExtension() |
|
121 | - { |
|
122 | - if (!$this->extension) { |
|
123 | - $this->extension = $this->determineExtension(); |
|
124 | - } |
|
125 | - return $this->extension; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Determine's the file's extension given the temporary file. |
|
130 | - * @since 4.9.80.p |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - protected function determineExtension() |
|
134 | - { |
|
135 | - $position_of_period = strrpos($this->getName(), '.'); |
|
136 | - if ($position_of_period === false) { |
|
137 | - return ''; |
|
138 | - } |
|
139 | - return mb_substr( |
|
140 | - $this->getName(), |
|
141 | - $position_of_period + 1 |
|
142 | - ); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Gets the size of the file |
|
147 | - * @return int |
|
148 | - */ |
|
149 | - public function getSize() |
|
150 | - { |
|
151 | - return $this->size; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Gets the path to the temporary file which was uploaded. |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function getTmpFile() |
|
159 | - { |
|
160 | - return $this->tmp_file; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @since 4.9.80.p |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - public function __toString() |
|
168 | - { |
|
169 | - return $this->getName(); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Gets the error code PHP reported for the file upload. |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public function getErrorCode() |
|
177 | - { |
|
178 | - return $this->error_code; |
|
179 | - } |
|
22 | + /** |
|
23 | + * @var string original name on the client machine |
|
24 | + */ |
|
25 | + protected $name; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string mime type |
|
29 | + */ |
|
30 | + protected $type; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string file extension |
|
34 | + */ |
|
35 | + protected $extension; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var int in bytes |
|
39 | + */ |
|
40 | + protected $size; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string local filepath to the temporary file |
|
44 | + */ |
|
45 | + protected $tmp_file; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values |
|
49 | + * although those aren't expected. |
|
50 | + */ |
|
51 | + protected $error_code; |
|
52 | + |
|
53 | + /** |
|
54 | + * FileSubmission constructor. |
|
55 | + * @param $name |
|
56 | + * @param $tmp_file |
|
57 | + * @param $size |
|
58 | + * @param null $error_code |
|
59 | + * @throws InvalidArgumentException |
|
60 | + */ |
|
61 | + public function __construct($name, $tmp_file, $size, $error_code = null) |
|
62 | + { |
|
63 | + $this->name = basename($name); |
|
64 | + $scheme = parse_url($tmp_file, PHP_URL_SCHEME); |
|
65 | + if (in_array($scheme, ['http', 'https'])) { |
|
66 | + // Wait a minute- just local filepaths please, no URL schemes allowed! |
|
67 | + throw new InvalidArgumentException( |
|
68 | + sprintf( |
|
69 | + // @codingStandardsIgnoreStart |
|
70 | + esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'), |
|
71 | + // @codingStandardsIgnoreEnd |
|
72 | + $scheme, |
|
73 | + $tmp_file |
|
74 | + ) |
|
75 | + ); |
|
76 | + } |
|
77 | + $this->tmp_file = (string) $tmp_file; |
|
78 | + $this->size = (int) $size; |
|
79 | + $this->error_code = (int) $error_code; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function getName() |
|
86 | + { |
|
87 | + return $this->name; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Gets the file's mime type |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function getType() |
|
95 | + { |
|
96 | + if (!$this->type) { |
|
97 | + $this->type = $this->determineType(); |
|
98 | + } |
|
99 | + return $this->type; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @since 4.9.80.p |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + protected function determineType() |
|
107 | + { |
|
108 | + if (!$this->getTmpFile()) { |
|
109 | + return ''; |
|
110 | + } |
|
111 | + $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
112 | + return $finfo->file($this->getTmpFile()); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Gets the file's extension. |
|
117 | + * @since 4.9.80.p |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function getExtension() |
|
121 | + { |
|
122 | + if (!$this->extension) { |
|
123 | + $this->extension = $this->determineExtension(); |
|
124 | + } |
|
125 | + return $this->extension; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Determine's the file's extension given the temporary file. |
|
130 | + * @since 4.9.80.p |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + protected function determineExtension() |
|
134 | + { |
|
135 | + $position_of_period = strrpos($this->getName(), '.'); |
|
136 | + if ($position_of_period === false) { |
|
137 | + return ''; |
|
138 | + } |
|
139 | + return mb_substr( |
|
140 | + $this->getName(), |
|
141 | + $position_of_period + 1 |
|
142 | + ); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Gets the size of the file |
|
147 | + * @return int |
|
148 | + */ |
|
149 | + public function getSize() |
|
150 | + { |
|
151 | + return $this->size; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Gets the path to the temporary file which was uploaded. |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function getTmpFile() |
|
159 | + { |
|
160 | + return $this->tmp_file; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @since 4.9.80.p |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + public function __toString() |
|
168 | + { |
|
169 | + return $this->getName(); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Gets the error code PHP reported for the file upload. |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public function getErrorCode() |
|
177 | + { |
|
178 | + return $this->error_code; |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | // End of file FileSubmission.php |
182 | 182 | // Location: EventEspresso\core\services\request\files/FileSubmission.php |
@@ -10,11 +10,11 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_File_Input_Display_Strategy extends EE_Text_Input_Display_Strategy |
12 | 12 | { |
13 | - /** |
|
14 | - * Override's parent to just set the type. May someday support other arguments. |
|
15 | - */ |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - parent::__construct('file'); |
|
19 | - } |
|
13 | + /** |
|
14 | + * Override's parent to just set the type. May someday support other arguments. |
|
15 | + */ |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + parent::__construct('file'); |
|
19 | + } |
|
20 | 20 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'), |
56 | 56 | implode(', ', $this->allowed_file_extensions) |
57 | 57 | ), |
58 | - '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~' |
|
58 | + '~.*\.('.implode('|', $this->allowed_file_extensions).')$~' |
|
59 | 59 | ) |
60 | 60 | ); |
61 | 61 | parent::__construct($options); |
@@ -19,89 +19,89 @@ |
||
19 | 19 | */ |
20 | 20 | class EE_File_Input extends EE_Form_Input_Base |
21 | 21 | { |
22 | - /** |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected $allowed_file_extensions; |
|
22 | + /** |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected $allowed_file_extensions; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $allowed_mime_types; |
|
27 | + /** |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $allowed_mime_types; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param array $options |
|
34 | - * @throws InvalidArgumentException |
|
35 | - */ |
|
36 | - public function __construct($options = array()) |
|
37 | - { |
|
38 | - if (isset($options['allowed_file_extensions'])) { |
|
39 | - $this->allowed_file_extensions = (array) $options['allowed_file_extensions']; |
|
40 | - } else { |
|
41 | - $this->allowed_file_extensions = ['csv']; |
|
42 | - } |
|
43 | - if (isset($options['allowed_mime_types'])) { |
|
44 | - $this->allowed_mime_types = (array) $options['allowed_file_extensions']; |
|
45 | - } else { |
|
46 | - $this->allowed_mime_types = ['text/csv']; |
|
47 | - } |
|
32 | + /** |
|
33 | + * @param array $options |
|
34 | + * @throws InvalidArgumentException |
|
35 | + */ |
|
36 | + public function __construct($options = array()) |
|
37 | + { |
|
38 | + if (isset($options['allowed_file_extensions'])) { |
|
39 | + $this->allowed_file_extensions = (array) $options['allowed_file_extensions']; |
|
40 | + } else { |
|
41 | + $this->allowed_file_extensions = ['csv']; |
|
42 | + } |
|
43 | + if (isset($options['allowed_mime_types'])) { |
|
44 | + $this->allowed_mime_types = (array) $options['allowed_file_extensions']; |
|
45 | + } else { |
|
46 | + $this->allowed_mime_types = ['text/csv']; |
|
47 | + } |
|
48 | 48 | |
49 | - $this->_set_display_strategy(new EE_File_Input_Display_Strategy()); |
|
50 | - $this->_set_normalization_strategy(new EE_File_Normalization()); |
|
51 | - $this->add_validation_strategy( |
|
52 | - new EE_Text_Validation_Strategy( |
|
53 | - sprintf( |
|
54 | - // translators: %1$s is a list of allowed file extensions. |
|
55 | - esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'), |
|
56 | - implode(', ', $this->allowed_file_extensions) |
|
57 | - ), |
|
58 | - '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~' |
|
59 | - ) |
|
60 | - ); |
|
61 | - parent::__construct($options); |
|
49 | + $this->_set_display_strategy(new EE_File_Input_Display_Strategy()); |
|
50 | + $this->_set_normalization_strategy(new EE_File_Normalization()); |
|
51 | + $this->add_validation_strategy( |
|
52 | + new EE_Text_Validation_Strategy( |
|
53 | + sprintf( |
|
54 | + // translators: %1$s is a list of allowed file extensions. |
|
55 | + esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'), |
|
56 | + implode(', ', $this->allowed_file_extensions) |
|
57 | + ), |
|
58 | + '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~' |
|
59 | + ) |
|
60 | + ); |
|
61 | + parent::__construct($options); |
|
62 | 62 | |
63 | 63 | // It would be great to add this HTML attribute, but jQuery validate chokes on it. |
64 | - $this->set_other_html_attributes( |
|
65 | - $this->other_html_attributes() |
|
66 | - . ' extension="' |
|
67 | - . implode( |
|
68 | - ',', |
|
69 | - $this->allowed_file_extensions |
|
70 | - ) |
|
71 | - . '"' |
|
72 | - ); |
|
73 | - } |
|
64 | + $this->set_other_html_attributes( |
|
65 | + $this->other_html_attributes() |
|
66 | + . ' extension="' |
|
67 | + . implode( |
|
68 | + ',', |
|
69 | + $this->allowed_file_extensions |
|
70 | + ) |
|
71 | + . '"' |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * $_FILES has a really weird structure. So we let `FilesDataHandler` take care of finding the file info for |
|
78 | - * this input. |
|
79 | - * |
|
80 | - * @param array $req_data |
|
81 | - * @return FileSubmissionInterface |
|
82 | - * @throws InvalidArgumentException |
|
83 | - * @throws InvalidDataTypeException |
|
84 | - * @throws InvalidInterfaceException |
|
85 | - * @throws EE_Error |
|
86 | - * @since 4.9.80.p |
|
87 | - */ |
|
88 | - public function find_form_data_for_this_section($req_data) |
|
89 | - { |
|
90 | - // ignore $req_data. Files are in the files data handler. |
|
91 | - $fileDataHandler = LoaderFactory::getLoader()->getShared( |
|
92 | - 'EventEspresso\core\services\request\files\FilesDataHandler' |
|
93 | - ); |
|
94 | - return $fileDataHandler->getFileObject($this->html_name()); |
|
95 | - } |
|
76 | + /** |
|
77 | + * $_FILES has a really weird structure. So we let `FilesDataHandler` take care of finding the file info for |
|
78 | + * this input. |
|
79 | + * |
|
80 | + * @param array $req_data |
|
81 | + * @return FileSubmissionInterface |
|
82 | + * @throws InvalidArgumentException |
|
83 | + * @throws InvalidDataTypeException |
|
84 | + * @throws InvalidInterfaceException |
|
85 | + * @throws EE_Error |
|
86 | + * @since 4.9.80.p |
|
87 | + */ |
|
88 | + public function find_form_data_for_this_section($req_data) |
|
89 | + { |
|
90 | + // ignore $req_data. Files are in the files data handler. |
|
91 | + $fileDataHandler = LoaderFactory::getLoader()->getShared( |
|
92 | + 'EventEspresso\core\services\request\files\FilesDataHandler' |
|
93 | + ); |
|
94 | + return $fileDataHandler->getFileObject($this->html_name()); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Don't transform the file submission object into a string, thanks. |
|
99 | - * |
|
100 | - * @param string $value |
|
101 | - * @return null|string |
|
102 | - */ |
|
103 | - protected function _sanitize($value) |
|
104 | - { |
|
105 | - return $value; |
|
106 | - } |
|
97 | + /** |
|
98 | + * Don't transform the file submission object into a string, thanks. |
|
99 | + * |
|
100 | + * @param string $value |
|
101 | + * @return null|string |
|
102 | + */ |
|
103 | + protected function _sanitize($value) |
|
104 | + { |
|
105 | + return $value; |
|
106 | + } |
|
107 | 107 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | { |
71 | 71 | global $wpdb; |
72 | 72 | $start_at_record = $this->count_records_migrated(); |
73 | - $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare( |
|
73 | + $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} ".$wpdb->prepare( |
|
74 | 74 | "LIMIT %d, %d", |
75 | 75 | $start_at_record, |
76 | 76 | $limit |
@@ -15,86 +15,86 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class EE_Data_Migration_Script_Stage_Table extends EE_Data_Migration_Script_Stage |
17 | 17 | { |
18 | - /** |
|
19 | - * @var string The columns to select. May be overridden for children. |
|
20 | - */ |
|
21 | - protected string $select_expression = '*'; |
|
18 | + /** |
|
19 | + * @var string The columns to select. May be overridden for children. |
|
20 | + */ |
|
21 | + protected string $select_expression = '*'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Set in the constructor to add this sql to both the counting query in |
|
25 | - * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and |
|
26 | - * EE_Data_Migration_Script_Stage_Table::_get_rows(). |
|
27 | - * Eg "where column_name like '%some_value%'" |
|
28 | - * |
|
29 | - * @var string|null |
|
30 | - */ |
|
31 | - protected ?string $_extra_where_sql = ''; |
|
23 | + /** |
|
24 | + * Set in the constructor to add this sql to both the counting query in |
|
25 | + * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and |
|
26 | + * EE_Data_Migration_Script_Stage_Table::_get_rows(). |
|
27 | + * Eg "where column_name like '%some_value%'" |
|
28 | + * |
|
29 | + * @var string|null |
|
30 | + */ |
|
31 | + protected ?string $_extra_where_sql = ''; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
36 | - * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
37 | - * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
38 | - * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
39 | - * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
40 | - * very least we MUST report/return 50 items migrated) |
|
41 | - * |
|
42 | - * @param int $num_items_to_migrate |
|
43 | - * @return int number of items ACTUALLY migrated |
|
44 | - */ |
|
45 | - public function _migration_step($num_items_to_migrate = 50) |
|
46 | - { |
|
47 | - $rows = $this->_get_rows($num_items_to_migrate); |
|
48 | - $items_actually_migrated = 0; |
|
49 | - foreach ($rows as $old_row) { |
|
50 | - $this->_migrate_old_row($old_row); |
|
51 | - $items_actually_migrated++; |
|
52 | - } |
|
53 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
54 | - $this->set_completed(); |
|
55 | - } |
|
56 | - return $items_actually_migrated; |
|
57 | - } |
|
34 | + /** |
|
35 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
36 | + * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
37 | + * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
38 | + * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
39 | + * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
40 | + * very least we MUST report/return 50 items migrated) |
|
41 | + * |
|
42 | + * @param int $num_items_to_migrate |
|
43 | + * @return int number of items ACTUALLY migrated |
|
44 | + */ |
|
45 | + public function _migration_step($num_items_to_migrate = 50) |
|
46 | + { |
|
47 | + $rows = $this->_get_rows($num_items_to_migrate); |
|
48 | + $items_actually_migrated = 0; |
|
49 | + foreach ($rows as $old_row) { |
|
50 | + $this->_migrate_old_row($old_row); |
|
51 | + $items_actually_migrated++; |
|
52 | + } |
|
53 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
54 | + $this->set_completed(); |
|
55 | + } |
|
56 | + return $items_actually_migrated; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Gets the rows for each migration stage from the old table |
|
61 | - * |
|
62 | - * @global wpdb $wpdb |
|
63 | - * @param int $limit |
|
64 | - * @return array of arrays like $wpdb->get_results($sql, ARRAY_A) |
|
65 | - */ |
|
66 | - protected function _get_rows($limit) |
|
67 | - { |
|
68 | - global $wpdb; |
|
69 | - $start_at_record = $this->count_records_migrated(); |
|
70 | - $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare( |
|
71 | - "LIMIT %d, %d", |
|
72 | - $start_at_record, |
|
73 | - $limit |
|
74 | - ); |
|
75 | - return $wpdb->get_results($query, ARRAY_A); |
|
76 | - } |
|
59 | + /** |
|
60 | + * Gets the rows for each migration stage from the old table |
|
61 | + * |
|
62 | + * @global wpdb $wpdb |
|
63 | + * @param int $limit |
|
64 | + * @return array of arrays like $wpdb->get_results($sql, ARRAY_A) |
|
65 | + */ |
|
66 | + protected function _get_rows($limit) |
|
67 | + { |
|
68 | + global $wpdb; |
|
69 | + $start_at_record = $this->count_records_migrated(); |
|
70 | + $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare( |
|
71 | + "LIMIT %d, %d", |
|
72 | + $start_at_record, |
|
73 | + $limit |
|
74 | + ); |
|
75 | + return $wpdb->get_results($query, ARRAY_A); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * Counts the records to migrate; the public version may cache it |
|
81 | - * |
|
82 | - * @return int |
|
83 | - */ |
|
84 | - public function _count_records_to_migrate() |
|
85 | - { |
|
86 | - global $wpdb; |
|
87 | - $query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}"; |
|
88 | - return (int) $wpdb->get_var($query); |
|
89 | - } |
|
79 | + /** |
|
80 | + * Counts the records to migrate; the public version may cache it |
|
81 | + * |
|
82 | + * @return int |
|
83 | + */ |
|
84 | + public function _count_records_to_migrate() |
|
85 | + { |
|
86 | + global $wpdb; |
|
87 | + $query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}"; |
|
88 | + return (int) $wpdb->get_var($query); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * takes care of migrating this particular row from the OLD table to whatever its |
|
93 | - * representation is in the new database. If there are errors, use $this->add_error to log them. If there is a |
|
94 | - * fatal error which prevents all future migrations, throw an exception describing it |
|
95 | - * |
|
96 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
97 | - * @return void |
|
98 | - */ |
|
99 | - abstract protected function _migrate_old_row($old_row); |
|
91 | + /** |
|
92 | + * takes care of migrating this particular row from the OLD table to whatever its |
|
93 | + * representation is in the new database. If there are errors, use $this->add_error to log them. If there is a |
|
94 | + * fatal error which prevents all future migrations, throw an exception describing it |
|
95 | + * |
|
96 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
97 | + * @return void |
|
98 | + */ |
|
99 | + abstract protected function _migrate_old_row($old_row); |
|
100 | 100 | } |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | static $previous_recaptcha_response = array(); |
136 | 136 | $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
137 | 137 | // if this token has already been verified, then return previous response |
138 | - if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
139 | - return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
138 | + if (isset($previous_recaptcha_response[$grecaptcha_response])) { |
|
139 | + return $previous_recaptcha_response[$grecaptcha_response]; |
|
140 | 140 | } |
141 | 141 | // still here but no g-recaptcha-response ? - verification failed |
142 | - if (! $grecaptcha_response) { |
|
142 | + if ( ! $grecaptcha_response) { |
|
143 | 143 | EE_Error::add_error( |
144 | 144 | sprintf( |
145 | 145 | /* translators: 1: missing parameter */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | // will update to true if everything passes |
161 | - $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
161 | + $previous_recaptcha_response[$grecaptcha_response] = false; |
|
162 | 162 | $response = wp_safe_remote_post( |
163 | 163 | InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
164 | 164 | array( |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | } |
176 | 176 | $results = json_decode(wp_remote_retrieve_body($response), true); |
177 | 177 | if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
178 | - $errors = array_map( |
|
178 | + $errors = array_map( |
|
179 | 179 | array($this, 'getErrorCode'), |
180 | 180 | $results['error-codes'] |
181 | 181 | ); |
182 | 182 | if (isset($results['challenge_ts'])) { |
183 | - $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
183 | + $errors[] = 'challenge timestamp: '.$results['challenge_ts'].'.'; |
|
184 | 184 | } |
185 | 185 | $this->generateError(implode(' ', $errors), true); |
186 | 186 | } |
187 | - $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
187 | + $previous_recaptcha_response[$grecaptcha_response] = true; |
|
188 | 188 | add_action('shutdown', array($this, 'setSessionData')); |
189 | 189 | return true; |
190 | 190 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'bad-request' => 'The request is invalid or malformed.', |
226 | 226 | 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
227 | 227 | ); |
228 | - return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
228 | + return isset($error_codes[$error_code]) ? $error_codes[$error_code] : ''; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 |
@@ -26,272 +26,272 @@ |
||
26 | 26 | */ |
27 | 27 | class InvisibleRecaptcha |
28 | 28 | { |
29 | - const URL_GOOGLE_RECAPTCHA_API = 'https://www.google.com/recaptcha/api/siteverify'; |
|
29 | + const URL_GOOGLE_RECAPTCHA_API = 'https://www.google.com/recaptcha/api/siteverify'; |
|
30 | 30 | |
31 | - const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed'; |
|
31 | + const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed'; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var EE_Registration_Config $config |
|
35 | - */ |
|
36 | - private $config; |
|
33 | + /** |
|
34 | + * @var EE_Registration_Config $config |
|
35 | + */ |
|
36 | + private $config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var EE_Session $session |
|
40 | - */ |
|
41 | - private $session; |
|
38 | + /** |
|
39 | + * @var EE_Session $session |
|
40 | + */ |
|
41 | + private $session; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var boolean $recaptcha_passed |
|
45 | - */ |
|
46 | - private $recaptcha_passed; |
|
43 | + /** |
|
44 | + * @var boolean $recaptcha_passed |
|
45 | + */ |
|
46 | + private $recaptcha_passed; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * InvisibleRecaptcha constructor. |
|
51 | - * |
|
52 | - * @param EE_Registration_Config $registration_config |
|
53 | - * @param EE_Session $session |
|
54 | - */ |
|
55 | - public function __construct(EE_Registration_Config $registration_config, EE_Session $session = null) |
|
56 | - { |
|
57 | - $this->config = $registration_config; |
|
58 | - $this->session = $session; |
|
59 | - } |
|
49 | + /** |
|
50 | + * InvisibleRecaptcha constructor. |
|
51 | + * |
|
52 | + * @param EE_Registration_Config $registration_config |
|
53 | + * @param EE_Session $session |
|
54 | + */ |
|
55 | + public function __construct(EE_Registration_Config $registration_config, EE_Session $session = null) |
|
56 | + { |
|
57 | + $this->config = $registration_config; |
|
58 | + $this->session = $session; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @return boolean |
|
64 | - */ |
|
65 | - public function useInvisibleRecaptcha() |
|
66 | - { |
|
67 | - return $this->session instanceof EE_Session |
|
68 | - && $this->config->use_captcha |
|
69 | - && $this->config->recaptcha_theme === 'invisible'; |
|
70 | - } |
|
62 | + /** |
|
63 | + * @return boolean |
|
64 | + */ |
|
65 | + public function useInvisibleRecaptcha() |
|
66 | + { |
|
67 | + return $this->session instanceof EE_Session |
|
68 | + && $this->config->use_captcha |
|
69 | + && $this->config->recaptcha_theme === 'invisible'; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * @param array $input_settings |
|
75 | - * @return EE_Invisible_Recaptcha_Input |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - * @throws InvalidInterfaceException |
|
78 | - * @throws InvalidArgumentException |
|
79 | - * @throws DomainException |
|
80 | - */ |
|
81 | - public function getInput(array $input_settings = array()) |
|
82 | - { |
|
83 | - return new EE_Invisible_Recaptcha_Input( |
|
84 | - $input_settings, |
|
85 | - $this->config |
|
86 | - ); |
|
87 | - } |
|
73 | + /** |
|
74 | + * @param array $input_settings |
|
75 | + * @return EE_Invisible_Recaptcha_Input |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + * @throws InvalidInterfaceException |
|
78 | + * @throws InvalidArgumentException |
|
79 | + * @throws DomainException |
|
80 | + */ |
|
81 | + public function getInput(array $input_settings = array()) |
|
82 | + { |
|
83 | + return new EE_Invisible_Recaptcha_Input( |
|
84 | + $input_settings, |
|
85 | + $this->config |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * @param array $input_settings |
|
92 | - * @return string |
|
93 | - * @throws EE_Error |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - * @throws InvalidArgumentException |
|
97 | - * @throws DomainException |
|
98 | - */ |
|
99 | - public function getInputHtml(array $input_settings = array()) |
|
100 | - { |
|
101 | - return $this->getInput($input_settings)->get_html_for_input(); |
|
102 | - } |
|
90 | + /** |
|
91 | + * @param array $input_settings |
|
92 | + * @return string |
|
93 | + * @throws EE_Error |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + * @throws InvalidArgumentException |
|
97 | + * @throws DomainException |
|
98 | + */ |
|
99 | + public function getInputHtml(array $input_settings = array()) |
|
100 | + { |
|
101 | + return $this->getInput($input_settings)->get_html_for_input(); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @param EE_Form_Section_Proper $form |
|
107 | - * @param array $input_settings |
|
108 | - * @throws EE_Error |
|
109 | - * @throws InvalidArgumentException |
|
110 | - * @throws InvalidDataTypeException |
|
111 | - * @throws InvalidInterfaceException |
|
112 | - * @throws DomainException |
|
113 | - */ |
|
114 | - public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
115 | - { |
|
116 | - $form->add_subsections( |
|
117 | - array( |
|
118 | - 'espresso_recaptcha' => $this->getInput($input_settings), |
|
119 | - ), |
|
120 | - null, |
|
121 | - false |
|
122 | - ); |
|
123 | - } |
|
105 | + /** |
|
106 | + * @param EE_Form_Section_Proper $form |
|
107 | + * @param array $input_settings |
|
108 | + * @throws EE_Error |
|
109 | + * @throws InvalidArgumentException |
|
110 | + * @throws InvalidDataTypeException |
|
111 | + * @throws InvalidInterfaceException |
|
112 | + * @throws DomainException |
|
113 | + */ |
|
114 | + public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
115 | + { |
|
116 | + $form->add_subsections( |
|
117 | + array( |
|
118 | + 'espresso_recaptcha' => $this->getInput($input_settings), |
|
119 | + ), |
|
120 | + null, |
|
121 | + false |
|
122 | + ); |
|
123 | + } |
|
124 | 124 | |
125 | 125 | |
126 | - /** |
|
127 | - * @param RequestInterface $request |
|
128 | - * @return boolean |
|
129 | - * @throws InvalidArgumentException |
|
130 | - * @throws InvalidDataTypeException |
|
131 | - * @throws InvalidInterfaceException |
|
132 | - * @throws RuntimeException |
|
133 | - */ |
|
134 | - public function verifyToken(RequestInterface $request) |
|
135 | - { |
|
136 | - static $previous_recaptcha_response = array(); |
|
137 | - $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
|
138 | - // if this token has already been verified, then return previous response |
|
139 | - if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
140 | - return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
141 | - } |
|
142 | - // still here but no g-recaptcha-response ? - verification failed |
|
143 | - if (! $grecaptcha_response) { |
|
144 | - EE_Error::add_error( |
|
145 | - sprintf( |
|
146 | - /* translators: 1: missing parameter */ |
|
147 | - esc_html__( |
|
148 | - // @codingStandardsIgnoreStart |
|
149 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.', |
|
150 | - // @codingStandardsIgnoreEnd |
|
151 | - 'event_espresso' |
|
152 | - ), |
|
153 | - 'g-recaptcha-response' |
|
154 | - ), |
|
155 | - __FILE__, |
|
156 | - __FUNCTION__, |
|
157 | - __LINE__ |
|
158 | - ); |
|
159 | - return false; |
|
160 | - } |
|
161 | - // will update to true if everything passes |
|
162 | - $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
163 | - $response = wp_safe_remote_post( |
|
164 | - InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
165 | - array( |
|
166 | - 'body' => array( |
|
167 | - 'secret' => $this->config->recaptcha_privatekey, |
|
168 | - 'response' => $grecaptcha_response, |
|
169 | - 'remoteip' => $request->ipAddress(), |
|
170 | - ), |
|
171 | - ) |
|
172 | - ); |
|
173 | - if ($response instanceof WP_Error) { |
|
174 | - $this->generateError($response->get_error_messages()); |
|
175 | - return false; |
|
176 | - } |
|
177 | - $results = json_decode(wp_remote_retrieve_body($response), true); |
|
178 | - if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
179 | - $errors = array_map( |
|
180 | - array($this, 'getErrorCode'), |
|
181 | - $results['error-codes'] |
|
182 | - ); |
|
183 | - if (isset($results['challenge_ts'])) { |
|
184 | - $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
185 | - } |
|
186 | - $this->generateError(implode(' ', $errors), true); |
|
187 | - } |
|
188 | - $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
189 | - add_action('shutdown', array($this, 'setSessionData')); |
|
190 | - return true; |
|
191 | - } |
|
126 | + /** |
|
127 | + * @param RequestInterface $request |
|
128 | + * @return boolean |
|
129 | + * @throws InvalidArgumentException |
|
130 | + * @throws InvalidDataTypeException |
|
131 | + * @throws InvalidInterfaceException |
|
132 | + * @throws RuntimeException |
|
133 | + */ |
|
134 | + public function verifyToken(RequestInterface $request) |
|
135 | + { |
|
136 | + static $previous_recaptcha_response = array(); |
|
137 | + $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
|
138 | + // if this token has already been verified, then return previous response |
|
139 | + if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
140 | + return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
141 | + } |
|
142 | + // still here but no g-recaptcha-response ? - verification failed |
|
143 | + if (! $grecaptcha_response) { |
|
144 | + EE_Error::add_error( |
|
145 | + sprintf( |
|
146 | + /* translators: 1: missing parameter */ |
|
147 | + esc_html__( |
|
148 | + // @codingStandardsIgnoreStart |
|
149 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.', |
|
150 | + // @codingStandardsIgnoreEnd |
|
151 | + 'event_espresso' |
|
152 | + ), |
|
153 | + 'g-recaptcha-response' |
|
154 | + ), |
|
155 | + __FILE__, |
|
156 | + __FUNCTION__, |
|
157 | + __LINE__ |
|
158 | + ); |
|
159 | + return false; |
|
160 | + } |
|
161 | + // will update to true if everything passes |
|
162 | + $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
163 | + $response = wp_safe_remote_post( |
|
164 | + InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
165 | + array( |
|
166 | + 'body' => array( |
|
167 | + 'secret' => $this->config->recaptcha_privatekey, |
|
168 | + 'response' => $grecaptcha_response, |
|
169 | + 'remoteip' => $request->ipAddress(), |
|
170 | + ), |
|
171 | + ) |
|
172 | + ); |
|
173 | + if ($response instanceof WP_Error) { |
|
174 | + $this->generateError($response->get_error_messages()); |
|
175 | + return false; |
|
176 | + } |
|
177 | + $results = json_decode(wp_remote_retrieve_body($response), true); |
|
178 | + if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
179 | + $errors = array_map( |
|
180 | + array($this, 'getErrorCode'), |
|
181 | + $results['error-codes'] |
|
182 | + ); |
|
183 | + if (isset($results['challenge_ts'])) { |
|
184 | + $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
185 | + } |
|
186 | + $this->generateError(implode(' ', $errors), true); |
|
187 | + } |
|
188 | + $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
189 | + add_action('shutdown', array($this, 'setSessionData')); |
|
190 | + return true; |
|
191 | + } |
|
192 | 192 | |
193 | 193 | |
194 | - /** |
|
195 | - * @param string $error_response |
|
196 | - * @param bool $show_errors |
|
197 | - * @return void |
|
198 | - * @throws RuntimeException |
|
199 | - */ |
|
200 | - public function generateError($error_response = '', $show_errors = false) |
|
201 | - { |
|
202 | - throw new RuntimeException( |
|
203 | - sprintf( |
|
204 | - esc_html__( |
|
205 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
206 | - 'event_espresso' |
|
207 | - ), |
|
208 | - '<br />', |
|
209 | - $show_errors || current_user_can('manage_options') ? $error_response : '' |
|
210 | - ) |
|
211 | - ); |
|
212 | - } |
|
194 | + /** |
|
195 | + * @param string $error_response |
|
196 | + * @param bool $show_errors |
|
197 | + * @return void |
|
198 | + * @throws RuntimeException |
|
199 | + */ |
|
200 | + public function generateError($error_response = '', $show_errors = false) |
|
201 | + { |
|
202 | + throw new RuntimeException( |
|
203 | + sprintf( |
|
204 | + esc_html__( |
|
205 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
206 | + 'event_espresso' |
|
207 | + ), |
|
208 | + '<br />', |
|
209 | + $show_errors || current_user_can('manage_options') ? $error_response : '' |
|
210 | + ) |
|
211 | + ); |
|
212 | + } |
|
213 | 213 | |
214 | 214 | |
215 | - /** |
|
216 | - * @param string $error_code |
|
217 | - * @return string |
|
218 | - */ |
|
219 | - public function getErrorCode(&$error_code) |
|
220 | - { |
|
221 | - $error_codes = array( |
|
222 | - 'missing-input-secret' => 'The secret parameter is missing.', |
|
223 | - 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
224 | - 'missing-input-response' => 'The response parameter is missing.', |
|
225 | - 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
226 | - 'bad-request' => 'The request is invalid or malformed.', |
|
227 | - 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
228 | - ); |
|
229 | - return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
230 | - } |
|
215 | + /** |
|
216 | + * @param string $error_code |
|
217 | + * @return string |
|
218 | + */ |
|
219 | + public function getErrorCode(&$error_code) |
|
220 | + { |
|
221 | + $error_codes = array( |
|
222 | + 'missing-input-secret' => 'The secret parameter is missing.', |
|
223 | + 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
224 | + 'missing-input-response' => 'The response parameter is missing.', |
|
225 | + 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
226 | + 'bad-request' => 'The request is invalid or malformed.', |
|
227 | + 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
228 | + ); |
|
229 | + return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
230 | + } |
|
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * @return array |
|
235 | - * @throws InvalidInterfaceException |
|
236 | - * @throws InvalidDataTypeException |
|
237 | - * @throws InvalidArgumentException |
|
238 | - */ |
|
239 | - public function getLocalizedVars() |
|
240 | - { |
|
241 | - return (array) apply_filters( |
|
242 | - 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
243 | - array( |
|
244 | - 'siteKey' => $this->config->recaptcha_publickey, |
|
245 | - 'recaptcha_passed' => $this->recaptchaPassed(), |
|
246 | - 'wp_debug' => WP_DEBUG, |
|
247 | - 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
248 | - 'failed_message' => wp_strip_all_tags( |
|
249 | - __( |
|
250 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.', |
|
251 | - 'event_espresso' |
|
252 | - ) |
|
253 | - ) |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
233 | + /** |
|
234 | + * @return array |
|
235 | + * @throws InvalidInterfaceException |
|
236 | + * @throws InvalidDataTypeException |
|
237 | + * @throws InvalidArgumentException |
|
238 | + */ |
|
239 | + public function getLocalizedVars() |
|
240 | + { |
|
241 | + return (array) apply_filters( |
|
242 | + 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
243 | + array( |
|
244 | + 'siteKey' => $this->config->recaptcha_publickey, |
|
245 | + 'recaptcha_passed' => $this->recaptchaPassed(), |
|
246 | + 'wp_debug' => WP_DEBUG, |
|
247 | + 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
248 | + 'failed_message' => wp_strip_all_tags( |
|
249 | + __( |
|
250 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.', |
|
251 | + 'event_espresso' |
|
252 | + ) |
|
253 | + ) |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | 257 | |
258 | 258 | |
259 | - /** |
|
260 | - * @return boolean |
|
261 | - * @throws InvalidInterfaceException |
|
262 | - * @throws InvalidDataTypeException |
|
263 | - * @throws InvalidArgumentException |
|
264 | - */ |
|
265 | - public function recaptchaPassed() |
|
266 | - { |
|
267 | - if ($this->recaptcha_passed !== null) { |
|
268 | - return $this->recaptcha_passed; |
|
269 | - } |
|
270 | - // logged in means you have already passed a turing test of sorts |
|
271 | - if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) { |
|
272 | - $this->recaptcha_passed = true; |
|
273 | - return $this->recaptcha_passed; |
|
274 | - } |
|
275 | - // was test already passed? |
|
276 | - $this->recaptcha_passed = filter_var( |
|
277 | - $this->session->get_session_data( |
|
278 | - InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED |
|
279 | - ), |
|
280 | - FILTER_VALIDATE_BOOLEAN |
|
281 | - ); |
|
282 | - return $this->recaptcha_passed; |
|
283 | - } |
|
259 | + /** |
|
260 | + * @return boolean |
|
261 | + * @throws InvalidInterfaceException |
|
262 | + * @throws InvalidDataTypeException |
|
263 | + * @throws InvalidArgumentException |
|
264 | + */ |
|
265 | + public function recaptchaPassed() |
|
266 | + { |
|
267 | + if ($this->recaptcha_passed !== null) { |
|
268 | + return $this->recaptcha_passed; |
|
269 | + } |
|
270 | + // logged in means you have already passed a turing test of sorts |
|
271 | + if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) { |
|
272 | + $this->recaptcha_passed = true; |
|
273 | + return $this->recaptcha_passed; |
|
274 | + } |
|
275 | + // was test already passed? |
|
276 | + $this->recaptcha_passed = filter_var( |
|
277 | + $this->session->get_session_data( |
|
278 | + InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED |
|
279 | + ), |
|
280 | + FILTER_VALIDATE_BOOLEAN |
|
281 | + ); |
|
282 | + return $this->recaptcha_passed; |
|
283 | + } |
|
284 | 284 | |
285 | 285 | |
286 | - /** |
|
287 | - * @throws InvalidArgumentException |
|
288 | - * @throws InvalidDataTypeException |
|
289 | - * @throws InvalidInterfaceException |
|
290 | - */ |
|
291 | - public function setSessionData() |
|
292 | - { |
|
293 | - if ($this->session instanceof EE_Session) { |
|
294 | - $this->session->set_session_data([InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true]); |
|
295 | - } |
|
296 | - } |
|
286 | + /** |
|
287 | + * @throws InvalidArgumentException |
|
288 | + * @throws InvalidDataTypeException |
|
289 | + * @throws InvalidInterfaceException |
|
290 | + */ |
|
291 | + public function setSessionData() |
|
292 | + { |
|
293 | + if ($this->session instanceof EE_Session) { |
|
294 | + $this->session->set_session_data([InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true]); |
|
295 | + } |
|
296 | + } |
|
297 | 297 | } |
@@ -15,21 +15,21 @@ |
||
15 | 15 | */ |
16 | 16 | interface JsonSerializableAndUnserializable |
17 | 17 | { |
18 | - /** |
|
19 | - * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using |
|
20 | - * wp_json_serialize(). |
|
21 | - * @since 4.9.80.p |
|
22 | - * @return mixed |
|
23 | - */ |
|
24 | - public function toJsonSerializableData(); |
|
18 | + /** |
|
19 | + * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using |
|
20 | + * wp_json_serialize(). |
|
21 | + * @since 4.9.80.p |
|
22 | + * @return mixed |
|
23 | + */ |
|
24 | + public function toJsonSerializableData(); |
|
25 | 25 | |
26 | - /** |
|
27 | - * Initializes this object from data |
|
28 | - * @since 4.9.80.p |
|
29 | - * @param mixed $data |
|
30 | - * @return boolean success |
|
31 | - */ |
|
32 | - public function fromJsonSerializedData($data); |
|
26 | + /** |
|
27 | + * Initializes this object from data |
|
28 | + * @since 4.9.80.p |
|
29 | + * @param mixed $data |
|
30 | + * @return boolean success |
|
31 | + */ |
|
32 | + public function fromJsonSerializedData($data); |
|
33 | 33 | } |
34 | 34 | // End of file JsonSerializableAndUnserializable.php |
35 | 35 | // Location: EventEspresso\core\services\json/JsonSerializableAndUnserializable.php |
@@ -17,13 +17,13 @@ |
||
17 | 17 | */ |
18 | 18 | interface JsonWpOptionSerializableInterface extends JsonSerializableAndUnserializable |
19 | 19 | { |
20 | - /** |
|
21 | - * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to |
|
22 | - * determine what option name to use. |
|
23 | - * @since 4.9.80.p |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function getWpOptionName(); |
|
20 | + /** |
|
21 | + * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to |
|
22 | + * determine what option name to use. |
|
23 | + * @since 4.9.80.p |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function getWpOptionName(); |
|
27 | 27 | } |
28 | 28 | // End of file JsonWpOptionSerializableInterface.php |
29 | 29 | // Location: EventEspresso\core\services\options/JsonWpOptionSerializableInterface.php |