Builder.php
87 lines
| 1 | <?php |
| 2 | /** |
| 3 | * CleanTalk. |
| 4 | * |
| 5 | * @since 3.2.2 |
| 6 | * @package EverestForms\Addons\CleanTalk\Builder |
| 7 | */ |
| 8 | |
| 9 | namespace EverestForms\Addons\CleanTalk\Builder; |
| 10 | |
| 11 | /** |
| 12 | * CleanTalk. |
| 13 | * |
| 14 | * @since 3.2.2 |
| 15 | */ |
| 16 | class Builder { |
| 17 | |
| 18 | /** |
| 19 | * Constructor. |
| 20 | * |
| 21 | * @since 3.2.2 |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | add_action( 'everest_forms_inline_cleantalk_settings', array( $this, 'add_inline_clean_talk_settings' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Inline settings. |
| 29 | * |
| 30 | * @param [type] $obj |
| 31 | */ |
| 32 | public function add_inline_clean_talk_settings( $obj ) { |
| 33 | $settings = isset( $this->form_data['settings'] ) ? $this->form_data['settings'] : array(); |
| 34 | $clean_talk_method = get_option( 'everest_forms_clean_talk_methods', 'rest_api' ); |
| 35 | $access_key = get_option( 'everest_forms_recaptcha_cleantalk_access_key', '' ); |
| 36 | |
| 37 | echo '<div class="everest-forms-border-container">'; |
| 38 | echo '<div class="everest-forms-clean-talk-setting-container"><h4 class="everest-forms-border-container-title">' . esc_html__( 'CleanTalk', 'everest-forms' ) . '</h4>'; |
| 39 | echo '<div>'; |
| 40 | echo '<button class="everest-forms-update-clean-talk-key-button ' . ( empty( $access_key ) ? 'everest-forms-hidden' : '' ) . '" data-access-key="' . esc_attr( $access_key ) . '">'; |
| 41 | echo esc_html__( 'Update Key', 'everest-forms' ); |
| 42 | echo '</button>'; |
| 43 | echo '<a href="https://docs.everestforms.net/docs/cleantalk/" target="_blank" class="everest-forms-learn-more-link-cleantalk">' . esc_html__( 'View Docs', 'everest-forms' ) . '</a>'; |
| 44 | echo '</div></div>'; |
| 45 | everest_forms_panel_field( |
| 46 | 'toggle', |
| 47 | 'settings', |
| 48 | 'cleantalk', |
| 49 | $obj->form_data, |
| 50 | esc_html__( 'Enable CleanTalk anti-spam protection', 'everest-forms' ), |
| 51 | array( |
| 52 | 'default' => '0', |
| 53 | ) |
| 54 | ); |
| 55 | |
| 56 | if ( empty( $access_key ) ) { |
| 57 | echo '<div class="everest-forms-warning-container">'; |
| 58 | echo '<img src="' . esc_url( plugins_url( 'addons/CleanTalk/assets/images/warning.png', EVF_PLUGIN_FILE ) ) . '" alt="' . esc_attr__( 'CleanTalk', 'everest-forms' ) . '" class="everest-forms-warning-icon" />'; |
| 59 | echo '<p class="everest-forms-warning-text">'; |
| 60 | echo esc_html__( 'No CleanTalk access key found ', 'everest-forms' ); |
| 61 | echo '<span class="everest-forms-warning-text-link">Add Key</span>'; |
| 62 | echo '</p>'; |
| 63 | echo '</div>'; |
| 64 | } |
| 65 | echo '<div class="everest-forms-border-container everest-forms-cleantalk-protection-type">'; |
| 66 | everest_forms_panel_field( |
| 67 | 'select', |
| 68 | 'settings', |
| 69 | 'cleantalk_protection_type', |
| 70 | $obj->form_data, |
| 71 | esc_html__( 'Protection type', 'everest-forms' ), |
| 72 | array( |
| 73 | 'default' => 'mark_as_spam', |
| 74 | 'tooltip' => esc_html__( "Please select the protection type. Choosing 'Mark as Spam' allows the submission but marks the entry as spam, while selecting 'Reject Submission' will prevent the form submission.", 'everest-forms' ), |
| 75 | 'options' => array( |
| 76 | 'mark_as_spam' => esc_html__( 'Mark as Spam', 'everest-forms' ), |
| 77 | 'validation_failed' => esc_html__( 'Reject Submission', 'everest-forms' ), |
| 78 | ), |
| 79 | ) |
| 80 | ); |
| 81 | |
| 82 | echo '</div>'; |
| 83 | echo '</div>'; |
| 84 | |
| 85 | } |
| 86 | } |
| 87 |