CleanTalk.php
109 lines
| 1 | <?php |
| 2 | /** |
| 3 | * CleanTalk. |
| 4 | * |
| 5 | * @since 3.2.2 |
| 6 | * @package EverestForms\Addons\CleanTalk |
| 7 | */ |
| 8 | |
| 9 | namespace EverestForms\Addons\CleanTalk; |
| 10 | |
| 11 | use EverestForms\Addons\CleanTalk\Builder\Builder; |
| 12 | use EverestForms\Addons\CleanTalk\Settings\Settings; |
| 13 | use EverestForms\Traits\Singleton; |
| 14 | |
| 15 | /** |
| 16 | * CleanTalk. |
| 17 | * |
| 18 | * @since 3.2.2 |
| 19 | */ |
| 20 | class CleanTalk { |
| 21 | |
| 22 | use Singleton; |
| 23 | |
| 24 | /** |
| 25 | * Constructor. |
| 26 | * |
| 27 | * @since 3.2.2 |
| 28 | */ |
| 29 | public function __construct() { |
| 30 | $this->setup(); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Setup the CleanTalk. |
| 35 | * |
| 36 | * @since 3.2.2 |
| 37 | */ |
| 38 | public function setup() { |
| 39 | if ( ! is_admin() ) { |
| 40 | return; |
| 41 | } |
| 42 | new Builder(); |
| 43 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Admin Enqueue Scripts. |
| 48 | */ |
| 49 | public function admin_enqueue_scripts() { |
| 50 | $screen = get_current_screen(); |
| 51 | $screen_id = $screen ? $screen->id : ''; |
| 52 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 53 | |
| 54 | wp_register_script( 'everest-forms-clean-talk', plugins_url( "addons/CleanTalk/assets/js/admin/admin{$suffix}.js", EVF_PLUGIN_FILE ), array( 'jquery' ), EVF_VERSION, true ); |
| 55 | wp_register_style( 'everest-forms-clean-talk-backward', plugins_url( 'addons/CleanTalk/assets/css/admin/backward.css', EVF_PLUGIN_FILE ), array(), EVF_VERSION ); |
| 56 | wp_register_style( 'everest-forms-clean-talk-style', plugins_url( 'addons/CleanTalk/assets/css/admin/admin.css', EVF_PLUGIN_FILE ), array(), EVF_VERSION ); |
| 57 | |
| 58 | if ( 'everest-forms_page_evf-settings' === $screen_id || 'everest-forms_page_evf-builder' === $screen_id ) { |
| 59 | if ( ! defined( 'EFP_PLUGIN_FILE' ) ) { |
| 60 | wp_enqueue_style( 'everest-forms-clean-talk-backward' ); |
| 61 | } |
| 62 | |
| 63 | wp_enqueue_script( 'everest-forms-clean-talk' ); |
| 64 | wp_enqueue_style( 'everest-forms-clean-talk-style' ); |
| 65 | wp_localize_script( |
| 66 | 'everest-forms-clean-talk', |
| 67 | 'everest_forms_clean_talk', |
| 68 | array( |
| 69 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 70 | 'security' => wp_create_nonce( 'everest_forms_clean_talk_nonce' ), |
| 71 | 'output' => $this->evf_get_popup_output(), |
| 72 | ) |
| 73 | ); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Get the output for the CleanTalk popup. |
| 79 | * |
| 80 | * @since 3.2.3 |
| 81 | */ |
| 82 | public function evf_get_popup_output() { |
| 83 | $output = ''; |
| 84 | |
| 85 | $output .= '<form action="" class="everest-forms-clean-talk-form-container">'; |
| 86 | $output .= '<div class="clean-talk-form-group">'; |
| 87 | $output .= '<div class="everest-forms-clean-talk-error-message-container" style="display: none"></div>'; |
| 88 | $output .= '<div class="everest-forms-clean-talk-access-key-title">' . __( 'CleanTalk Access Key', 'everest-forms' ) . '</div>'; |
| 89 | $output .= '<input type="password" class="everest-forms-clean-talk-access-key" placeholder="Enter access key" required />'; |
| 90 | $output .= '<p style="margin-top: 8px; font-size: 14px; text-align: left; margin-bottom: 24px; font">'; |
| 91 | $output .= __( 'Enter your CleanTalk REST API key from your ', 'everest-forms' ); |
| 92 | $output .= '<a href="https://cleantalk.org/my" target="_blank">' . __( 'account dashboard here', 'everest-forms' ) . '</a>.'; |
| 93 | $output .= '</p>'; |
| 94 | |
| 95 | $output .= '<div class="everest-forms-clean-talk-note">'; |
| 96 | $output .= '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: text-bottom; margin-right: 5px;">'; |
| 97 | $output .= '<path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.45455C4.38505 1.45455 1.45455 4.38505 1.45455 8C1.45455 11.615 4.38505 14.5455 8 14.5455C11.615 14.5455 14.5455 11.615 14.5455 8C14.5455 4.38505 11.615 1.45455 8 1.45455ZM0 8C0 3.58172 3.58172 0 8 0C12.4183 0 16 3.58172 16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8ZM8 7.27273C8.40166 7.27273 8.72727 7.59834 8.72727 8V10.9091C8.72727 11.3108 8.40166 11.6364 8 11.6364C7.59834 11.6364 7.27273 11.3108 7.27273 10.9091V8C7.27273 7.59834 7.59834 7.27273 8 7.27273ZM8 4.36364C7.59834 4.36364 7.27273 4.68925 7.27273 5.09091C7.27273 5.49257 7.59834 5.81818 8 5.81818H8.00727C8.40894 5.81818 8.73455 5.49257 8.73455 5.09091C8.73455 4.68925 8.40894 4.36364 8.00727 4.36364H8Z" fill="#4584FF"/>'; |
| 98 | $output .= '</svg>'; |
| 99 | $output .= '<p><strong>Note : </strong>' . __( 'This will update the CleanTalk Access Key globally. You can check here on ', 'everest-forms' ); |
| 100 | $output .= '<a href="' . esc_url( admin_url( 'admin.php?page=evf-settings&tab=recaptcha§ion=integration' ) ) . '" target="__blank">' . __( 'Settings > Security > Integration > CleanTalk', 'everest-forms' ) . '</a>.</p>'; |
| 101 | $output .= '</div>'; |
| 102 | |
| 103 | $output .= '</div>'; |
| 104 | $output .= '</form>'; |
| 105 | |
| 106 | return $output; |
| 107 | } |
| 108 | } |
| 109 |