PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/fields/FrmFieldCaptcha.php +17 -6 6.29 → trunk View file →
@@ -71,10 +71,14 @@
71 71 );
72 72 }
73 73
74 74 /**
75 - * Replace the "for" attribute for captcha field so it matches the response ID.
75 + * Modify the captcha field label so it is not orphaned.
76 76 *
77 + * The label is omitted when the label position is set to "none".
78 + * When the label is visible it is rendered as a <span> instead of a <label>,
79 + * since the captcha response input is inside an iframe and cannot be referenced.
80 + *
77 81 * @param array $args
78 82 * @param string $html
79 83 *
80 84 * @return string
@@ -79,10 +83,19 @@
79 83 *
80 84 * @return string
81 85 */
82 86 protected function before_replace_html_shortcodes( $args, $html ) {
83 - $settings = FrmCaptchaFactory::get_settings_object();
84 - return str_replace( ' for="field_[key]"', ' for="' . esc_attr( $settings->token_field ) . '"', $html );
87 + if ( 'none' === FrmField::get_option( $this->field, 'label' ) ) {
88 + // Fully strip the label for a CAPTCHA if it is set to hidden.
89 + return preg_replace( '~\s*<label\b[^>]*for="field_\[key\]"[^>]*>.*?</label>\s*~s', '', $html );
90 + }
91 +
92 + // Convert a CAPTCHA label to a span to prevent an orphaned label issue in WAVE.
93 + return preg_replace(
94 + '~<label\b([^>]*?)\s*for="field_\[key\]"([^>]*?)>(.*?)</label>~s',
95 + '<span$1$2>$3</span>',
96 + $html
97 + );
85 98 }
86 99
87 100 /**
88 101 * @param array $args
@@ -140,11 +153,9 @@
140 153 *
141 154 * @return void
142 155 */
143 156 protected function load_field_scripts( $args ) {
144 - $api_js_url = $this->api_url();
145 -
146 - wp_register_script( 'captcha-api', $api_js_url, array( 'formidable' ), '3', true );
157 + wp_register_script( 'captcha-api', $this->api_url(), array( 'formidable' ), '3', true );
147 158 wp_enqueue_script( 'captcha-api' );
148 159 }
149 160
150 161 /**