PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
← All changes | includes/class-convertkit-recaptcha.php +51 -2 3.3.23.4.3 View file →
@@ -71,9 +71,9 @@
71 71 * @param string $recaptcha_response The reCAPTCHA response.
72 72 * @param string $plugin_action The action to verify the reCAPTCHA response for.
73 73 * @return bool|WP_Error
74 74 */
75 - public function verify_recaptcha( $recaptcha_response, $plugin_action ) {
75 + public function verify( $recaptcha_response, $plugin_action ) {
76 76
77 77 // Don't run if the reCAPTCHA or scripts are disabled.
78 78 if ( ! $this->settings->has_recaptcha_site_and_secret_keys() || $this->settings->scripts_disabled() ) {
79 79 return true;
@@ -90,9 +90,9 @@
90 90 ),
91 91 )
92 92 );
93 93
94 - // Bail if an error occured.
94 + // Bail if an error occurred.
95 95 if ( is_wp_error( $response ) ) {
96 96 return $response;
97 97 }
98 98
@@ -126,8 +126,57 @@
126 126 }
127 127
128 128 // If here, the submission looks genuine. Continue the request.
129 129 return true;
130 +
131 + }
132 +
133 + /**
134 + * Attaches the reCAPTCHA v3 invisible-badge attributes to the given submit
135 + * button element within an existing DOM tree, so that the challenge is
136 + * executed when the button is clicked and the form is submitted via the
137 + * `convertKitRecaptchaFormSubmit` callback.
138 + *
139 + * @since 3.3.7
140 + *
141 + * @param ConvertKit_HTML_Parser $parser Parser wrapping the DOM (unused).
142 + * @param DOMElement $button <button> element to attach attributes to.
143 + * @param string $plugin_action Plugin action string.
144 + */
145 + public function attach_to_form_button_dom( $parser, $button, $plugin_action ) {
146 +
147 + unset( $parser );
148 +
149 + $button->setAttribute( 'data-sitekey', esc_attr( $this->settings->recaptcha_site_key() ) );
150 + $button->setAttribute( 'data-callback', 'convertKitRecaptchaFormSubmit' );
151 + $button->setAttribute( 'data-action', $plugin_action );
152 + $button->setAttribute( 'class', trim( $button->getAttribute( 'class' ) . ' g-recaptcha' ) );
153 +
154 + }
155 +
156 + /**
157 + * Returns the HTML for a submit button with reCAPTCHA v3 invisible-badge
158 + * attributes attached, used by templates that don't have a DOM parser
159 + * available (e.g. the Restrict Content tag view).
160 + *
161 + * @since 3.3.7
162 + *
163 + * @param string $label Button's visible label.
164 + * @param string $plugin_action Plugin action string.
165 + * @param string[] $css_classes CSS classes for the button.
166 + * @return string
167 + */
168 + public function get_submit_button_html( $label, $plugin_action, $css_classes = array() ) {
169 +
170 + $css_classes[] = 'g-recaptcha';
171 +
172 + return sprintf(
173 + '<input type="submit" class="%1$s" value="%2$s" data-sitekey="%3$s" data-callback="convertKitRecaptchaFormSubmit" data-action="%4$s" />',
174 + esc_attr( implode( ' ', $css_classes ) ),
175 + esc_attr( $label ),
176 + esc_attr( $this->settings->recaptcha_site_key() ),
177 + esc_attr( $plugin_action )
178 + );
130 179
131 180 }
132 181
133 182 }