name = __( 'reCaptcha', 'weforms' ); $this->input_type = 'recaptcha'; $this->icon = 'qrcode'; } /** * Render the text field * * @param array $field_settings * @param int $form_id * * @return void */ public function render( $field_settings, $form_id ) { $settings = weforms_get_settings( 'recaptcha' ); $is_invisible = false; $public_key = isset( $settings->key ) ? $settings->key : ''; $type = isset( $settings->type ) ? $settings->type : ''; $theme = isset( $field_settings['recaptcha_theme'] ) ? $field_settings['recaptcha_theme'] : 'light'; $use_theme_css = isset( $form_settings['use_theme_css'] ) ? $form_settings['use_theme_css'] : 'wpuf-style'; /** Recaptcha V3 start */ if( 'v3' == $type ) { ?>
  • print_list_attributes( $field_settings ); ?> >
  • print_list_attributes( $field_settings ); ?> >
  • print_list_attributes( $field_settings ); echo esc_attr( $invisible_css ); ?>> print_label( $field_settings ); } if ( ! $public_key ) { esc_html_e( 'reCaptcha API key is missing.', 'weforms'); } else { ?>
  • 'has_recaptcha_api_keys', 'button_class' => 'button-faded', 'msg_title' => __( 'Site key and Secret key', 'weforms' ), 'msg' => sprintf( __( 'You need to set Site key and Secret key in Settings in order to use "Recaptcha" field. Click here to get the these key.', 'weforms' ), admin_url( 'admin.php?page=weforms#/settings' ), 'https://www.google.com/recaptcha/' ), ]; } /** * Get field options setting * * @return array */ public function get_options_settings() { $settings = [ [ 'name' => 'label', 'title' => __( 'Title', 'weforms' ), 'type' => 'text', 'section' => 'basic', 'priority' => 10, 'help_text' => __( 'Title of the section', 'weforms' ), ], [ 'name' => 'recaptcha_type', 'title' => 'reCaptcha type', 'type' => 'radio', 'options' => [ 'enable_no_captcha' => __( 'Enable noCaptcha', 'weforms' ), 'invisible_recaptcha' => __( 'Enable Invisible reCaptcha', 'weforms' ), ], 'default' => 'enable_no_captcha', 'section' => 'basic', 'priority' => 11, 'help_text' => __( 'Select reCaptcha type', 'weforms' ), 'show_if' => 'is_recaptcha_v2' ], [ 'name' => 'recaptcha_theme', 'title' => 'reCaptcha Theme', 'type' => 'radio', 'options' => [ 'light' => __( 'Light', 'weforms' ), 'dark' => __( 'Dark', 'weforms' ), ], 'default' => 'light', 'section' => 'advanced', 'priority' => 12, 'help_text' => __( 'Select reCaptcha Theme', 'weforms' ), 'show_if' => 'is_recaptcha_v2' ], ]; return $settings; } /** * Get the field props * * @return array */ public function get_field_props() { $props = [ 'template' => $this->get_type(), 'label' => '', 'recaptcha_type' => 'enable_no_captcha', 'is_meta' => 'yes', 'id' => 0, 'is_new' => true, 'wpuf_cond' => null, 'recaptcha_theme' => 'light', ]; return $props; } }