> $settings The form settings. * @return array> */ public function filter_ninja_forms_form_display_settings( array $settings ) : array { if ( isset( $settings['custom_messages']['settings'] ) ) { $settings['custom_messages']['settings'] = array_merge( $settings['custom_messages']['settings'], $this->get_messages_form_settings() ); } return $settings; } /** * Adds any custom labels to form settings in Ninja Forms. * * @listens filter:ninja_forms_display_form_settings * * @param array> $settings The form settings. * @param int|string $form_id The form ID. * @return array> */ public function filter_ninja_forms_display_form_settings( array $settings, $form_id ) : array { foreach ( $this->get_messages() as $name => $label ) { if ( empty( $settings[ $name ] ) ) { $settings[ $name ] = $label; } } return $settings; } /** * Returns an associative array of error/messages. * * @return array */ public function get_messages() : array { $messages = [ 'recaptchaProcessing' => _x( 'Please wait, processing CAPTCHA field.', 'recaptcha field', 'nf-custom-recaptcha' ), 'recaptchaRequired' => _x( 'Please complete the CAPTCHA field.', 'recaptcha field', 'nf-custom-recaptcha' ), 'recaptchaMismatch' => _x( 'Please enter the correct value in the CAPTCHA field.', 'recaptcha field', 'nf-custom-recaptcha' ), ]; return $messages; } /** * Retrieves custom validation form settings to Ninja Forms. * * @return array> */ public function get_messages_form_settings() : array { $settings = []; foreach ( $this->get_messages() as $name => $label ) { $setting = [ 'name' => $name, 'type' => 'textbox', 'label' => esc_html( $label ), 'width' => 'full', ]; $settings[] = $setting; } return $settings; } }