page-form.php
1227 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin page : dashboard |
| 4 | * |
| 5 | * @package SIB_Page_Form |
| 6 | */ |
| 7 | |
| 8 | if ( ! class_exists( 'SIB_Page_Form' ) ) { |
| 9 | /** |
| 10 | * Page class that handles backend page <i>dashboard ( for admin )</i> with form generation and processing |
| 11 | * |
| 12 | * @package SIB_Page_Form |
| 13 | */ |
| 14 | class SIB_Page_Form { |
| 15 | /** Page slug */ |
| 16 | const PAGE_ID = 'sib_page_form'; |
| 17 | |
| 18 | /** |
| 19 | * Page hook |
| 20 | * |
| 21 | * @var false|string |
| 22 | */ |
| 23 | protected $page_hook; |
| 24 | |
| 25 | /** |
| 26 | * Page tabs |
| 27 | * |
| 28 | * @var mixed |
| 29 | */ |
| 30 | protected $tabs; |
| 31 | |
| 32 | /** |
| 33 | * Form ID |
| 34 | * |
| 35 | * @var string |
| 36 | */ |
| 37 | public $formID; |
| 38 | |
| 39 | /** |
| 40 | * Default compliant Note |
| 41 | * |
| 42 | * @var string |
| 43 | */ |
| 44 | public $defaultComplianceNote; |
| 45 | |
| 46 | /** |
| 47 | * Forms list instance |
| 48 | * |
| 49 | * @var SIB_Forms_List |
| 50 | */ |
| 51 | public $forms; |
| 52 | |
| 53 | /** |
| 54 | * Constructs new page object and adds entry to WordPress admin menu |
| 55 | */ |
| 56 | function __construct() { |
| 57 | global $wp_roles; |
| 58 | $wp_roles->add_cap( 'administrator', 'view_custom_menu' ); |
| 59 | $wp_roles->add_cap( 'editor', 'view_custom_menu' ); |
| 60 | |
| 61 | $title = get_bloginfo('name'); |
| 62 | $this->defaultComplianceNote = sprintf( esc_attr('Your e-mail address is only used to send you our newsletter and information about the activities of %s. You can always use the unsubscribe link included in the newsletter.', 'mailin'), $title); |
| 63 | $this->page_hook = add_submenu_page( SIB_Page_Home::PAGE_ID, __( 'Forms', 'mailin' ), __( 'Forms', 'mailin' ), 'view_custom_menu', self::PAGE_ID, array( &$this, 'generate' ) ); |
| 64 | add_action( 'admin_print_scripts-' . $this->page_hook, array( $this, 'enqueue_scripts' ) ); |
| 65 | add_action( 'admin_print_styles-' . $this->page_hook, array( $this, 'enqueue_styles' ) ); |
| 66 | add_action( 'load-' . $this->page_hook, array( &$this, 'init' ) ); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Init Process |
| 71 | */ |
| 72 | function Init() { |
| 73 | SIB_Manager::is_done_validation(); |
| 74 | $this->forms = new SIB_Forms_List(); |
| 75 | $this->forms->prepare_items(); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Enqueue scripts of plugin |
| 80 | */ |
| 81 | function enqueue_scripts() { |
| 82 | wp_enqueue_script( 'sib-admin-js' ); |
| 83 | wp_enqueue_script( 'sib-bootstrap-js' ); |
| 84 | wp_enqueue_script( 'sib-chosen-js' ); |
| 85 | |
| 86 | wp_localize_script( |
| 87 | 'sib-admin-js', 'ajax_sib_object', |
| 88 | array( |
| 89 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 90 | 'ajax_nonce' => wp_create_nonce( 'ajax_sib_admin_nonce' ), |
| 91 | 'compliance_note' => $this->defaultComplianceNote |
| 92 | ) |
| 93 | ); |
| 94 | wp_localize_script( 'sib-admin-js', 'sib_img_url', array(SIB_Manager::$plugin_url.'/img/flags/') ); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Enqueue style sheets of plugin |
| 99 | */ |
| 100 | function enqueue_styles() { |
| 101 | wp_enqueue_style( 'sib-admin-css' ); |
| 102 | wp_enqueue_style( 'sib-bootstrap-css' ); |
| 103 | wp_enqueue_style( 'sib-chosen-css' ); |
| 104 | wp_enqueue_style( 'sib-fontawesome-css' ); |
| 105 | wp_enqueue_style( 'thickbox' ); |
| 106 | } |
| 107 | |
| 108 | /** Generate page script */ |
| 109 | function generate() { |
| 110 | ?> |
| 111 | <div id="wrap" class="wrap box-border-box container-fluid"> |
| 112 | <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor" viewBox="0 0 32 32"> |
| 113 | <circle cx="16" cy="16" r="16" fill="#0B996E"/> |
| 114 | <path fill="#fff" d="M21.002 14.54c.99-.97 1.453-2.089 1.453-3.45 0-2.814-2.07-4.69-5.19-4.69H9.6v20h6.18c4.698 0 8.22-2.874 8.22-6.686 0-2.089-1.081-3.964-2.998-5.174Zm-8.62-5.538h4.573c1.545 0 2.565.877 2.565 2.208 0 1.513-1.329 2.663-4.048 3.54-1.854.574-2.688 1.059-2.997 1.634l-.094.001V9.002Zm3.151 14.796h-3.152v-3.085c0-1.362 1.175-2.693 2.813-3.208 1.453-.484 2.657-.969 3.677-1.482 1.36.787 2.194 2.148 2.194 3.57 0 2.42-2.35 4.205-5.532 4.205Z"/> |
| 115 | </svg> |
| 116 | <svg xmlns="http://www.w3.org/2000/svg" width="80" height="25" fill="currentColor" viewBox="0 0 90 31"> |
| 117 | <path fill="#0B996E" d="M73.825 19.012c0-4.037 2.55-6.877 6.175-6.877 3.626 0 6.216 2.838 6.216 6.877s-2.59 6.715-6.216 6.715c-3.626 0-6.175-2.799-6.175-6.715Zm-3.785 0c0 5.957 4.144 10.155 9.96 10.155 5.816 0 10-4.198 10-10.155 0-5.957-4.143-10.314-10-10.314s-9.96 4.278-9.96 10.314ZM50.717 8.937l7.81 19.989h3.665l7.81-19.989h-3.945L60.399 24.37h-.08L54.662 8.937h-3.945Zm-15.18 9.354c.239-3.678 2.67-6.156 5.977-6.156 2.867 0 5.02 1.84 5.338 4.598h-6.614c-2.35 0-3.626.28-4.58 1.56h-.12v-.002Zm-3.784.6c0 5.957 4.183 10.274 9.96 10.274 3.904 0 7.33-1.998 8.804-5.158l-3.187-1.6c-1.115 2.08-3.267 3.319-5.618 3.319-2.83 0-5.379-2.16-5.379-4.238 0-1.08.718-1.56 1.753-1.56h12.63v-1.079c0-5.997-3.825-10.155-9.323-10.155-5.497 0-9.641 4.279-9.641 10.195M20.916 28.924h3.586V16.653c0-2.639 1.632-4.518 3.905-4.518.956 0 1.951.32 2.43.758.36-.96.917-1.918 1.753-2.878-.957-.799-2.59-1.32-4.184-1.32-4.382 0-7.49 3.279-7.49 7.956v12.274-.001Zm-17.33-13.23V5.937h5.896c1.992 0 3.307 1.16 3.307 2.919 0 1.998-1.713 3.518-5.218 4.677-2.39.759-3.466 1.399-3.865 2.16h-.12Zm0 9.794v-4.077c0-1.799 1.514-3.558 3.626-4.238 1.873-.64 3.425-1.28 4.74-1.958 1.754 1.04 2.829 2.837 2.829 4.717 0 3.198-3.028 5.556-7.132 5.556H3.586ZM0 28.926h7.968c6.057 0 10.597-3.798 10.597-8.835 0-2.759-1.393-5.237-3.864-6.836 1.275-1.28 1.873-2.76 1.873-4.559 0-3.717-2.67-6.196-6.693-6.196H0v26.426Z"/> |
| 118 | </svg> |
| 119 | <div class="row"> |
| 120 | <div id="wrap-left" class="box-border-box col-md-9 "> |
| 121 | <input type="hidden" class="sib-dateformat" value="<?php echo esc_attr( 'yyyy-mm-dd' ); ?>"> |
| 122 | <?php |
| 123 | if ( SIB_Manager::is_api_key_set() ) { |
| 124 | if ( ( isset( $_GET['action'] ) && 'edit' === sanitize_text_field($_GET['action'] )) || ( isset( $_GET['action'] ) && 'duplicate' === sanitize_text_field($_GET['action'] )) ) { |
| 125 | $this->formID = isset( $_GET['id'] ) ? sanitize_text_field( $_GET['id'] ) : 'new'; |
| 126 | $this->generate_form_edit(); |
| 127 | } else { |
| 128 | $this->generate_forms_page(); |
| 129 | } |
| 130 | } else { |
| 131 | $this->generate_welcome_page(); |
| 132 | } |
| 133 | ?> |
| 134 | </div> |
| 135 | <div id="wrap-right-side" class="box-border-box col-md-3"> |
| 136 | <?php |
| 137 | |
| 138 | SIB_Page_Home::generate_side_bar(); |
| 139 | ?> |
| 140 | </div> |
| 141 | </div> |
| 142 | </div> |
| 143 | <div id="sib_modal" class="modal fade" role="dialog"> |
| 144 | <div class="modal-dialog"> |
| 145 | <div class="modal-content"> |
| 146 | <div class="modal-header"> |
| 147 | <button type="button" class="close" data-dismiss="modal">×</button> |
| 148 | <h4><?php esc_attr_e( 'You are about to change the language', 'mailin' ); ?></h4> |
| 149 | </div> |
| 150 | <div class="modal-body"> |
| 151 | <p><?php esc_attr_e( "Please make sure that you've saved all the changes. We will have to reload the page.", 'mailin' ); ?></p> |
| 152 | <p><?php esc_attr_e( 'Do you want to continue?', 'mailin' ); ?></p> |
| 153 | </div> |
| 154 | <div class="modal-footer"> |
| 155 | <button type="button" class="btn btn-default" id="sib_modal_ok"><?php esc_attr_e( 'Ok', 'mailin' ); ?></button> |
| 156 | <button type="button" class="btn btn-default" id="sib_modal_cancel"><?php esc_attr_e( 'Cancel', 'mailin' ); ?></button> |
| 157 | </div> |
| 158 | </div> |
| 159 | </div> |
| 160 | </div> |
| 161 | <?php |
| 162 | } |
| 163 | /** Generate forms page */ |
| 164 | function generate_forms_page() { |
| 165 | ?> |
| 166 | <div id="main-content" class="sib-content"> |
| 167 | <div class="card sib-small-content"> |
| 168 | <div class="card-header"><strong><?php esc_attr_e( 'Forms', 'mailin' ); ?></strong></div> |
| 169 | |
| 170 | <form method="post" class="sib-forms-wrapper" style="padding:20px;min-height: 500px;"> |
| 171 | <i style="font-size: 13px;"><?php esc_attr_e( "Note: Forms created in Brevo plugin for WordPress won't be displayed in Forms section in Brevo application", 'mailin' ); ?></i> |
| 172 | <?php |
| 173 | $this->forms->display(); |
| 174 | ?> |
| 175 | </form> |
| 176 | </div> |
| 177 | </div> |
| 178 | <?php |
| 179 | } |
| 180 | /** Generate form edit page */ |
| 181 | function generate_form_edit() { |
| 182 | $is_activated_smtp = SIB_API_Manager::get_smtp_status() == 'disabled' ? 0 : 1; |
| 183 | $formData = SIB_Forms::getForm( $this->formID ); |
| 184 | $invisibleCaptcha = '1'; |
| 185 | if ( ! empty( $formData ) ) { |
| 186 | if ( isset( $_GET['action'] ) && 'duplicate' === sanitize_text_field($_GET['action']) ) { |
| 187 | $this->formID = 'new'; |
| 188 | $formData['title'] = ''; |
| 189 | } |
| 190 | if ( 'new' === $this->formID && isset( $_GET['pid'] ) ) { |
| 191 | $parent_formData = SIB_Forms::getForm( sanitize_text_field( $_GET['pid'] ) ); |
| 192 | $formData['title'] = $parent_formData['title']; |
| 193 | } |
| 194 | if ( ! isset( $formData['gCaptcha'] ) ) { |
| 195 | $gCaptcha = '0'; |
| 196 | } |
| 197 | else { |
| 198 | if( '0' == $formData['gCaptcha'] ) { |
| 199 | $gCaptcha = '0'; |
| 200 | } |
| 201 | else { |
| 202 | $gCaptcha = '1'; |
| 203 | } |
| 204 | if ( '3' == $formData['gCaptcha'] ) { |
| 205 | $invisibleCaptcha = '0'; |
| 206 | } |
| 207 | else { |
| 208 | $invisibleCaptcha = '1'; |
| 209 | } |
| 210 | } |
| 211 | if ( ! isset( $formData['termAccept'] ) ) { |
| 212 | $formData['termAccept'] = '0'; |
| 213 | } |
| 214 | |
| 215 | $selectCaptchaType = isset($formData['selectCaptchaType']) ? $formData['selectCaptchaType'] : ""; |
| 216 | if (!$selectCaptchaType) { |
| 217 | $gCaptchaVal = isset($formData['gCaptcha']) ? $formData['gCaptcha'] : 0; |
| 218 | if ($gCaptchaVal == 0) { |
| 219 | $selectCaptchaType = 1; |
| 220 | } else if ($gCaptchaVal == 2 || $gCaptchaVal == 3) { |
| 221 | $selectCaptchaType = 2; |
| 222 | } |
| 223 | } |
| 224 | $cCaptchaType = isset($formData['cCaptchaType']) ?? $formData['cCaptchaType']; |
| 225 | $cCaptchaStyle = isset($formData['cCaptchaStyle']) ? $formData['cCaptchaStyle'] : "auto"; |
| 226 | |
| 227 | ?> |
| 228 | <div id="main-content" class="sib-content"> |
| 229 | <form action="admin.php" class="" method="post" role="form"> |
| 230 | <input type="hidden" name="action" value="sib_setting_subscription"> |
| 231 | <input type="hidden" name="sib_form_id" value="<?php echo esc_attr( $this->formID ) ; ?>"> |
| 232 | <input type="hidden" id="is_smtp_activated" value="<?php echo esc_attr( $is_activated_smtp ) ; ?>"> |
| 233 | <?php |
| 234 | if ( isset( $_GET['pid'] ) ) { |
| 235 | ?> |
| 236 | <input type="hidden" name="pid" value="<?php echo esc_attr( $_GET['pid'] ); ?>"> |
| 237 | <?php |
| 238 | $lang = isset( $_GET['lang'] ) ? sanitize_text_field( $_GET['lang'] ) : ''; |
| 239 | if ( $lang ) { ?> |
| 240 | <input type="hidden" name="lang" value="<?php echo esc_attr( $lang ); ?>"> |
| 241 | <?php |
| 242 | } |
| 243 | } |
| 244 | ?> |
| 245 | <?php wp_nonce_field( 'sib_setting_subscription' ); ?> |
| 246 | <!-- Subscription form --> |
| 247 | <div class="card sib-small-content"> |
| 248 | <div class="card-header"> |
| 249 | <strong><?php esc_attr_e( 'Subscription form', 'mailin' ); ?></strong> <i |
| 250 | id="sib_setting_form_spin" class="fa fa-spinner fa-spin fa-fw fa-lg fa-2x"></i> |
| 251 | </div> |
| 252 | <div id="sib_setting_form_body" class="card-body"> |
| 253 | <div class="row <!--small-content-->"> |
| 254 | <div style="margin: 12px 0 34px 0px;"> |
| 255 | <b><?php esc_attr_e( 'Form Name : ', 'mailin' ); ?></b> <input type="text" |
| 256 | name="sib_form_name" |
| 257 | value="<?php echo esc_attr( $formData['title'] ); ?>" |
| 258 | style="width: 60%;" |
| 259 | required="required"/> |
| 260 | </div> |
| 261 | <div class="col-md-6"> |
| 262 | |
| 263 | <?php |
| 264 | if ( function_exists( 'wp_editor' ) ) { |
| 265 | // phpcs:ignore |
| 266 | wp_editor( |
| 267 | esc_html(stripcslashes($formData['html'])), 'sibformmarkup', array( |
| 268 | 'tinymce' => false, |
| 269 | 'media_buttons' => true, |
| 270 | 'textarea_name' => 'sib_form_html', |
| 271 | 'textarea_rows' => 15, |
| 272 | ) |
| 273 | ); |
| 274 | } else { |
| 275 | ?> |
| 276 | <textarea class="widefat" cols="160" rows="20" id="sibformmarkup" |
| 277 | name="sib_form_html"><?php |
| 278 | // phpcs:ignore |
| 279 | echo esc_html( $formData['html'] ); ?></textarea> |
| 280 | <?php |
| 281 | } |
| 282 | ?> |
| 283 | <br> |
| 284 | |
| 285 | <p> |
| 286 | <?php |
| 287 | esc_attr_e( 'Use the shortcode', 'mailin' ); |
| 288 | if ( isset( $_GET['pid'] ) ) { |
| 289 | $id = sanitize_text_field( $_GET['pid'] ); |
| 290 | } else { |
| 291 | $id = 'new' !== $this->formID ? $this->formID : ''; |
| 292 | } |
| 293 | ?> |
| 294 | <i style="background-color: #eee;padding: 3px;">[sibwp_form |
| 295 | id=<?php echo esc_attr( $id ); ?>]</i> |
| 296 | <?php |
| 297 | esc_attr_e( 'inside a post, page or text widget to display your sign-up form.', 'mailin' ); |
| 298 | ?> |
| 299 | <b><?php esc_attr_e( 'Do not copy and paste the above form mark up, that will not work', 'mailin' ); ?></b> |
| 300 | </p> |
| 301 | <div id="sib-field-form" class="card form-field" |
| 302 | style="padding-bottom: 20px;"> |
| 303 | |
| 304 | <div class="small-content2" |
| 305 | style="margin-top: 15px;"> |
| 306 | <b><?php esc_attr_e( 'Add a new Field', 'mailin' ); ?></b> |
| 307 | <?php SIB_Page_Home::get_narration_script( __( 'Add a New Field', 'mailin' ), __( 'Choose an attribute and add it to the subscription form of your Website', 'mailin' ) ); ?> |
| 308 | </div> |
| 309 | <div id="sib_sel_attribute_area" class="small-content2" |
| 310 | style="margin-top: 20px;"> |
| 311 | </div> |
| 312 | <div id="sib-field-content"> |
| 313 | <div style="margin-top: 30px;"> |
| 314 | <div class="sib-attr-normal sib-attr-category sib-attr-multiple-choice small-content2" |
| 315 | style="margin-top: 10px;" id="sib_field_label_area"> |
| 316 | <?php esc_attr_e( 'Label', 'mailin' ); ?> |
| 317 | <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)</small> |
| 318 | <input type="text" class="col-md-12 sib_field_changes" id="sib_field_label"> |
| 319 | </div> |
| 320 | <div class="sib-attr-normal small-content2" |
| 321 | style="margin-top: 10px;" id="sib_field_placeholder_area"> |
| 322 | <span><?php esc_attr_e( 'Place holder', 'mailin' ); ?> |
| 323 | <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>) |
| 324 | </small> </span> |
| 325 | <input type="text" class="col-md-12 sib_field_changes" id="sib_field_placeholder"> |
| 326 | </div> |
| 327 | <div class="sib-attr-normal small-content2" |
| 328 | style="margin-top: 10px;" id="sib_field_initial_area"> |
| 329 | <span><?php esc_attr_e( 'Initial value', 'mailin' ); ?> |
| 330 | <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>) |
| 331 | </small> </span> |
| 332 | <input type="text" class="col-md-12 sib_field_changes" id="sib_field_initial"> |
| 333 | </div> |
| 334 | <div class="sib-attr-other small-content2" |
| 335 | style="margin-top: 10px;" id="sib_field_button_text_area"> |
| 336 | <span><?php esc_attr_e( 'Button Text', 'mailin' ); ?></span> |
| 337 | <input type="text" class="col-md-12 sib_field_changes" id="sib_field_button_text"> |
| 338 | </div> |
| 339 | </div> |
| 340 | <div style="margin-top: 20px;"> |
| 341 | |
| 342 | <div class="sib-attr-normal sib-attr-category sib-attr-multiple-choice small-content2" style="margin-top: 5px;" id="sib_field_required_area"> |
| 343 | <label style="font-weight: normal;"><input type="checkbox" class="sib_field_changes" id="sib_field_required"> <?php esc_attr_e( 'Required field ?', 'mailin' ); ?> |
| 344 | </label> |
| 345 | </div> |
| 346 | <div class="sib-attr-category sib-attr-multiple-choice small-content2" |
| 347 | style="margin-top: 5px;" id="sib_field_type_area"> |
| 348 | <label style="font-weight: normal;"><input type="radio" class="sib_field_changes" name="sib_field_type" value="select" |
| 349 | checked> <?php esc_attr_e( 'Drop-down List', 'mailin' ); ?> |
| 350 | </label> |
| 351 | <label class="sib-attr-category" style="font-weight: normal;"><input type="radio" class="sib_field_changes" name="sib_field_type" |
| 352 | value="radio"> <?php esc_attr_e( 'Radio List', 'mailin' ); ?> |
| 353 | </label> |
| 354 | <label class="sib-attr-multiple-choice" style="font-weight: normal;"><input type="radio" class="sib_field_changes" name="sib_field_type" |
| 355 | value="radio"> <?php esc_attr_e( 'Checkboxes List', 'mailin' ); ?> |
| 356 | </label> |
| 357 | </div> |
| 358 | </div> |
| 359 | <div class="small-content2" style="margin-top: 20px;" |
| 360 | id="sib_field_add_area"> |
| 361 | <button type="button" id="sib_add_to_form_btn" |
| 362 | class="btn btn-success sib-add-to-form"><span |
| 363 | class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?> |
| 364 | </button> |
| 365 | <div style="display:none"> |
| 366 | <input id="getDomain" value="<?php |
| 367 | echo plugins_url('mailin/img/flags/') ?>"></input> |
| 368 | </div> |
| 369 | <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?> |
| 370 | </div> |
| 371 | <div class="small-content2" style="margin-top: 20px;" |
| 372 | id="sib_field_html_area"> |
| 373 | <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span> |
| 374 | <textarea class="col-md-12" style="height: 140px;" |
| 375 | id="sib_field_html"></textarea> |
| 376 | </div> |
| 377 | </div> |
| 378 | </div> |
| 379 | <!---- multi list per interest -----> |
| 380 | <div id="sib-multi-lists" class="card form-field" |
| 381 | style="padding-bottom: 20px;"> |
| 382 | |
| 383 | <div class="small-content2" |
| 384 | style="margin-top: 15px"> |
| 385 | <b><?php esc_attr_e( 'Add Multi-List Subscription', 'mailin' ); ?></b> |
| 386 | <?php SIB_Page_Home::get_narration_script( __( 'Add Multi-List Subscription', 'mailin' ), __( 'Enable your contacts to subscribe to content based on specific interests or preferences. Create a contact list for each interest and allow them to subscribe using this field', 'mailin' ) ); ?> |
| 387 | </div> |
| 388 | <div id="sib_sel_multi_list_area" class="small-content2" |
| 389 | style="margin-top: 20px;"> |
| 390 | <input type="hidden" id="sib_selected_multi_list_id" value=""> |
| 391 | <select data-placeholder="<?php esc_attr_e( 'Please select the lists', 'mailin' ); ?>" id="sib_select_multi_list" |
| 392 | class="col-md-12 chosen-select" name="multi_list_ids[]" multiple="" |
| 393 | tabindex="-1"></select> |
| 394 | </div> |
| 395 | <div id="sib_multi_list_field" style="display: none;"> |
| 396 | <div style="margin-top: 30px;"> |
| 397 | <div class="sib-attr-normal sib-attr-category sib-attr-multiple-choice small-content2" |
| 398 | style="margin-top: 10px;" id="sib_multi_field_label_area"> |
| 399 | <?php esc_attr_e( 'Label', 'mailin' ); ?> |
| 400 | <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)</small> |
| 401 | <input type="text" class="col-md-12 sib_field_changes" id="sib_multi_field_label"> |
| 402 | </div> |
| 403 | </div> |
| 404 | <div style="margin-top: 20px;"> |
| 405 | <div class="sib-attr-normal sib-attr-category sib-attr-multiple-choice small-content2" style="margin-top: 5px;" id="sib_multi_field_required_area"> |
| 406 | <label style="font-weight: normal;"><input type="checkbox" class="sib_field_changes" id="sib_multi_field_required"> <?php esc_attr_e( 'Required field ?', 'mailin' ); ?> |
| 407 | </label> |
| 408 | </div> |
| 409 | </div> |
| 410 | <div class="small-content2" style="margin-top: 20px;" |
| 411 | id="sib_multi_field_add_area"> |
| 412 | <button type="button" id="sib_multi_lists_add_form_btn" |
| 413 | class="btn btn-success sib-add-to-form"><span |
| 414 | class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?> |
| 415 | </button> |
| 416 | <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?> |
| 417 | </div> |
| 418 | <div class="small-content2" style="margin-top: 20px;" |
| 419 | id="sib_field_html_area"> |
| 420 | <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span> |
| 421 | <textarea class="col-md-12" style="height: 140px;" |
| 422 | id="sib_multi_field_html"></textarea> |
| 423 | </div> |
| 424 | </div> |
| 425 | </div> |
| 426 | |
| 427 | <div id="sib-gdpr-block" class="card form-field" style="padding-bottom: 20px;"> |
| 428 | <div class="small-content2" |
| 429 | style="margin-top: 15px;margin-bottom: 15px;"> |
| 430 | <b><?php esc_attr_e( 'Compliance Note', 'mailin' ); ?></b> |
| 431 | <?php SIB_Page_Home::get_narration_script( __( 'Add compliance note', 'mailin' ), __( 'Create GDPR-compliant subscription forms for collecting email addresses.', 'mailin' ) ); ?> |
| 432 | </div> |
| 433 | <div class="small-content2" style="margin-top: 0px;"> |
| 434 | <input type="radio" name="sib_add_compliant_note" class="sib-add-compliant-note" value="1" ><label class="sib-radio-label"> <?php esc_attr_e( 'Yes', 'mailin');?></label> |
| 435 | <input type="radio" name="sib_add_compliant_note" class="sib-add-compliant-note" value="0" checked><label class="sib-radio-label"> <?php esc_attr_e( 'No', 'mailin');?></label> |
| 436 | </div> |
| 437 | <div class="small-content2 sib-gdpr-block-area" style="display: none;"> |
| 438 | <textarea id="sib_gdpr_text" class="col-md-12" rows="5"><?php echo trim( $this->defaultComplianceNote ); ?></textarea> |
| 439 | <label id="set_gdpr_default"><?php esc_attr_e('Reset to Default', 'mailin');?> <i class="fa fa-refresh"></i></label> |
| 440 | </div> |
| 441 | <div class="small-content2 sib-gdpr-block-btn" style="display: none;"> |
| 442 | <button type="button" id="sib_add_compliance_note" |
| 443 | class="btn btn-success sib-add-to-form"><span |
| 444 | class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?> |
| 445 | </button> |
| 446 | <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?> |
| 447 | </div> |
| 448 | </div> |
| 449 | |
| 450 | <!---- end block ------> |
| 451 | <div id="sib_form_captcha" class="card form-field" |
| 452 | style="padding-bottom: 20px;"> |
| 453 | <div class="alert alert-danger" style="margin:5px;display: none;"></div> |
| 454 | <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;"> |
| 455 | <b><?php esc_attr_e( 'Add Captcha', 'mailin' ); ?></b> |
| 456 | <?php SIB_Page_Home::get_narration_script( __( 'Add Captcha', 'mailin' ), __( 'We are using Google reCaptcha for this form. To use Google reCaptcha on this form, you should input site key and secret key.' , 'mailin' ) ); ?> |
| 457 | </div> |
| 458 | <div class="small-content2" style="margin-top: 0px;"> |
| 459 | <input type="radio" name="sib_add_captcha" class="sib-add-captcha" value="1" <?php checked( $gCaptcha, '1' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'Yes', 'mailin' ); ?></label> |
| 460 | <input type="radio" name="sib_add_captcha" class="sib-add-captcha" value="0" <?php checked( $gCaptcha, '0' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'No', 'mailin' ); ?></label> |
| 461 | </div> |
| 462 | <!-- Captcha Select Box--> |
| 463 | <div id="sib_sel_captcha_area" class="small-content2" style="margin-top: 15px;" > |
| 464 | <select class="col-md-12 sib-captcha-select" name="sib-select-captcha-type"<?php |
| 465 | if ( '0' == $gCaptcha) { |
| 466 | echo("style='display: none;'");} |
| 467 | ?>> |
| 468 | <option value="1" disabled="true" selected>Select the Captcha that you would like to use</option> |
| 469 | <option value="2" <?php echo ('2' == $selectCaptchaType) ? "selected" : ""; ?>>Google Captcha</option> |
| 470 | <option value="3" <?php echo ('3' == $selectCaptchaType) ? "selected" : ""; ?>>Cloudflare Captcha</option> |
| 471 | </select> |
| 472 | </div> |
| 473 | <!-- Google Captcha Start--> |
| 474 | <div class="small-content2 sib-captcha-key" |
| 475 | <?php |
| 476 | if ( '1' !== $gCaptcha || $selectCaptchaType == 3) { |
| 477 | echo("style='display: none;'");} |
| 478 | ?> |
| 479 | > |
| 480 | <i><?php esc_attr_e( 'Site Key', 'mailin' ); ?></i> |
| 481 | <input type="text" class="col-md-12" id="sib_captcha_site" name="sib_captcha_site" value="<?php |
| 482 | if ( isset( $formData['gCaptcha_site'] ) && ! empty( $formData['gCaptcha_site'] ) ) { |
| 483 | echo esc_attr( $formData['gCaptcha_site'] ); |
| 484 | } else { |
| 485 | echo ''; |
| 486 | } |
| 487 | ?>"> |
| 488 | </div> |
| 489 | <div class="small-content2 sib-captcha-key" |
| 490 | <?php |
| 491 | if ( '1' !== $gCaptcha || $selectCaptchaType == 3 ) { |
| 492 | echo("style='display: none;'");} |
| 493 | ?> |
| 494 | > |
| 495 | <i><?php esc_attr_e( 'Secret Key', 'mailin' ); ?></i> |
| 496 | <input type="text" class="col-md-12" id="sib_captcha_secret" name="sib_captcha_secret" value="<?php |
| 497 | if ( isset( $formData['gCaptcha_secret'] ) && ! empty( $formData['gCaptcha_secret'] ) ) { |
| 498 | echo esc_attr( $formData['gCaptcha_secret'] ); |
| 499 | } else { |
| 500 | echo ''; |
| 501 | } |
| 502 | ?>"> |
| 503 | </div> |
| 504 | <div class="small-content2 sib-captcha-key" |
| 505 | <?php |
| 506 | if ( '1' !== $gCaptcha || $selectCaptchaType == 3) { |
| 507 | echo("style='display: none;'");} |
| 508 | |
| 509 | ?> |
| 510 | > |
| 511 | <input type="radio" name="sib_recaptcha_type" class="sib-captcha-type" value="0" <?php checked( $invisibleCaptcha, '0' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'Google Captcha', 'mailin');?></label> |
| 512 | <input type="radio" name="sib_recaptcha_type" class="sib-captcha-type" value="1" <?php checked( $invisibleCaptcha, '1' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'Google Invisible Captcha', 'mailin');?></label> |
| 513 | </div> |
| 514 | <div class="small-content2 sib-captcha-key" |
| 515 | <?php |
| 516 | if ( '1' !== $gCaptcha || $selectCaptchaType == 3) { |
| 517 | echo("style='display: none;'");} |
| 518 | ?> |
| 519 | > |
| 520 | <button type="button" id="sib_add_captcha_btn" |
| 521 | class="btn btn-success sib-add-to-form"><span |
| 522 | class="sib-large-icon"></span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?> |
| 523 | </button> |
| 524 | <?php SIB_Page_Home::get_narration_script( __( 'Add Captcha', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?> |
| 525 | </div> |
| 526 | <!-- Google Captcha End--> |
| 527 | <!-- Turnstile Start--> |
| 528 | <div class="sib-captcha-key-turnstile" |
| 529 | <?php |
| 530 | if ($selectCaptchaType != 3 || $gCaptcha == 0 ) { |
| 531 | echo("style='display: none;'");} |
| 532 | ?> |
| 533 | > |
| 534 | <div class="small-content2"> |
| 535 | <i><?php esc_attr_e( 'Site Key', 'mailin' ); ?></i> |
| 536 | <input type="text" class="col-md-12" id="sib_captcha_site_turnstile" name="sib_captcha_site_turnstile" value="<?php |
| 537 | if ( isset( $formData['cCaptcha_site'] ) && ! empty( $formData['cCaptcha_site'] ) ) { |
| 538 | echo esc_attr( $formData['cCaptcha_site'] ); |
| 539 | } else { |
| 540 | echo ''; |
| 541 | } |
| 542 | ?>"> |
| 543 | </div> |
| 544 | <div class="small-content2 sib-captcha-key-turnstile" style="margin-bottom: 15px !important;"> |
| 545 | <i><?php esc_attr_e( 'Secret Key', 'mailin' ); ?></i> |
| 546 | <input type="text" class="col-md-12" id="sib_captcha_secret_turnstile" name="sib_captcha_secret_turnstile" value="<?php |
| 547 | if ( isset( $formData['cCaptcha_secret'] ) && ! empty( $formData['cCaptcha_secret'] ) ) { |
| 548 | echo esc_attr( $formData['cCaptcha_secret'] ); |
| 549 | } else { |
| 550 | echo ''; |
| 551 | } |
| 552 | ?>"> |
| 553 | </div> |
| 554 | <div class="small-content2 sib-captcha-key-turnstile"> |
| 555 | <input type="radio" name="turnstile_captcha_theme" class="sib-captcha-type" value="auto" <?php checked( $cCaptchaStyle, 'auto' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'Auto', 'mailin');?></label> |
| 556 | <input type="radio" name="turnstile_captcha_theme" class="sib-captcha-type" value="dark" <?php checked( $cCaptchaStyle, 'dark' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'Dark Theme', 'mailin');?></label> |
| 557 | <input type="radio" name="turnstile_captcha_theme" class="sib-captcha-type" value="light" <?php checked( $cCaptchaStyle, 'light' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'Light Theme', 'mailin');?></label> |
| 558 | </div> |
| 559 | <div class="small-content2"> |
| 560 | <button type="button" id="sib_add_captcha_btn_turnstile" |
| 561 | class="btn btn-success sib-add-to-form"><span |
| 562 | class="sib-large-icon"></span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?> |
| 563 | </button> |
| 564 | <?php SIB_Page_Home::get_narration_script( __( 'Add Captcha', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?> |
| 565 | </div> |
| 566 | </div> |
| 567 | <!-- Turnstile End --> |
| 568 | </div> |
| 569 | <div id="sib_form_terms" class="card form-field" |
| 570 | style="padding-bottom: 20px;"> |
| 571 | <div class="alert alert-danger" style="margin:5px;display: none;"></div> |
| 572 | <!-- for terms --> |
| 573 | <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;"> |
| 574 | <b><?php esc_attr_e( 'Add a Term acceptance checkbox', 'mailin' ); ?></b> |
| 575 | <?php SIB_Page_Home::get_narration_script( __( 'Add a Term acceptance checkbox', 'mailin' ), __( 'If the terms and condition checkbox is added to the form, the field will be mandatory for subscription.' , 'mailin' ) ); ?> |
| 576 | </div> |
| 577 | <div class="small-content2" style="margin-top: 0px;"> |
| 578 | <input type="radio" name="sib_add_terms" class="sib-add-terms" value="1" <?php checked( $formData['termAccept'], '1' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'Yes', 'mailin');?></label> |
| 579 | <input type="radio" name="sib_add_terms" class="sib-add-terms" value="0" <?php checked( $formData['termAccept'], '0' ); ?>><label class="sib-radio-label"> <?php esc_attr_e( 'No', 'mailin');?></label> |
| 580 | </div> |
| 581 | <div class="small-content2 sib-terms-url" |
| 582 | <?php |
| 583 | if ( '1' !== $formData['termAccept'] ) { |
| 584 | echo("style='display: none;'");} |
| 585 | ?> |
| 586 | > |
| 587 | <i><?php esc_attr_e( 'URL to terms and conditions', 'mailin' ); ?></i> |
| 588 | <input type="text" class="col-md-12" id="sib_terms_url" name="sib_terms_url" value="<?php |
| 589 | if ( isset( $formData['termsURL'] ) && ! empty( $formData['termsURL'] ) ) { |
| 590 | echo esc_attr( $formData['termsURL'] ); |
| 591 | } else { |
| 592 | echo ''; |
| 593 | } |
| 594 | ?>"> |
| 595 | </div> |
| 596 | <div class="small-content2 sib-terms-url" |
| 597 | <?php |
| 598 | if ( '1' !== $formData['termAccept'] ) { |
| 599 | echo("style='display: none;'");} |
| 600 | ?> |
| 601 | > |
| 602 | <button type="button" id="sib_add_termsUrl_btn" |
| 603 | class="btn btn-success sib-add-to-form"><span |
| 604 | class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?> |
| 605 | </button> |
| 606 | <?php SIB_Page_Home::get_narration_script( __( 'Add Terms URL', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?> |
| 607 | </div> |
| 608 | |
| 609 | </div> |
| 610 | <!-- use css of custom or theme --> |
| 611 | <div class="card form-field"> |
| 612 | <div class="small-content2" style="margin-top: 15px;margin-bottom: 10px;"> |
| 613 | <b><?php esc_attr_e( 'Form Style', 'mailin' ); ?> </b> |
| 614 | <?php SIB_Page_Home::get_narration_script( __( 'Form Style', 'mailin' ), __( 'Select the style you favorite. Your custom css will be applied to form only.', 'mailin' ) ); ?> |
| 615 | </div> |
| 616 | <div id="sib_form_css_area" class="small-content2" style="margin-bottom: 15px;"> |
| 617 | <label style="font-weight: normal;"><input type="radio" name="sib_css_type" value="1" <?php checked( $formData['dependTheme'], '1' ); ?>> <?php esc_attr_e( 'Current Theme', 'mailin' ); ?> |
| 618 | </label> |
| 619 | <label style="font-weight: normal;"><input type="radio" name="sib_css_type" value="0" <?php checked( $formData['dependTheme'], '0' ); ?>> <?php esc_attr_e( 'Custom style', 'mailin' ); ?> |
| 620 | </label> |
| 621 | <textarea class="widefat" cols="60" rows="10" id="sibcssmarkup" style="margin-top: 10px; font-size: 13px; display: <?php echo '0' == $formData['dependTheme'] ? 'block' : 'none'; ?>;" |
| 622 | name="sib_form_css"><?php echo esc_textarea( $formData['css'] ); ?></textarea> |
| 623 | |
| 624 | </div> |
| 625 | |
| 626 | </div> |
| 627 | </div> |
| 628 | <div class="col-md-6"> |
| 629 | <!-- hidden fields for attributes --> |
| 630 | <input type="hidden" id="sib_hidden_email" data-type="email" data-name="email" |
| 631 | data-text="<?php esc_attr_e( 'Email Address', 'mailin' ); ?>"> |
| 632 | <input type="hidden" id="sib_hidden_submit" data-type="submit" |
| 633 | data-name="submit" data-text="<?php esc_attr_e( 'Subscribe', 'mailin' ); ?>"> |
| 634 | <input type="hidden" id="sib_hidden_message_1" |
| 635 | value="<?php esc_attr_e( 'Select Brevo Attribute', 'mailin' ); ?>"> |
| 636 | <input type="hidden" id="sib_hidden_message_2" |
| 637 | value="<?php esc_attr_e( 'Brevo merge fields : Normal', 'mailin' ); ?>"> |
| 638 | <input type="hidden" id="sib_hidden_message_3" |
| 639 | value="<?php esc_attr_e( 'Brevo merge fields : Category', 'mailin' ); ?>"> |
| 640 | <input type="hidden" id="sib_hidden_message_multichoice" |
| 641 | value="<?php esc_attr_e( 'Brevo merge fields : Multiple Choice', 'mailin' ); ?>"> |
| 642 | <input type="hidden" id="sib_hidden_message_4" |
| 643 | value="<?php esc_attr_e( 'Other', 'mailin' ); ?>"> |
| 644 | <input type="hidden" id="sib_hidden_message_5" |
| 645 | value="<?php esc_attr_e( 'Submit Button', 'mailin' ); ?>"> |
| 646 | |
| 647 | <!-- preview field --> |
| 648 | |
| 649 | <div class="card form-field"> |
| 650 | <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;"> |
| 651 | <b><?php esc_attr_e( 'Preview', 'mailin' ); ?> |
| 652 | <i id="sib-preview-form-refresh" class="fa fa-refresh" style="cursor:pointer;font-weight: bold;" aria-hidden="true"></i> |
| 653 | </b> |
| 654 | </div> |
| 655 | <iframe id="sib-preview-form" |
| 656 | src="<?php echo esc_url( site_url() . '/?sib_form=' . esc_attr( $this->formID ) ); ?>" |
| 657 | width="300px" height="428" title="SIB Preview Form"></iframe> |
| 658 | </div> |
| 659 | </div> |
| 660 | </div> |
| 661 | <div class="sib-small-content" style="margin-top: 30px;"> |
| 662 | <div class="col-md-3"> |
| 663 | <button class="btn btn-success"><?php esc_attr_e( 'Save', 'mailin' ); ?></button> |
| 664 | </div> |
| 665 | </div> |
| 666 | </div> |
| 667 | </div> <!-- End Subscription form--> |
| 668 | |
| 669 | <!-- Sign up Process --> |
| 670 | |
| 671 | <div class="card sib-small-content"> |
| 672 | |
| 673 | <!-- Adding security through hidden referrer field --> |
| 674 | <div class="card-header"> |
| 675 | <strong><?php esc_attr_e( 'Sign up process', 'mailin' ); ?></strong> <i |
| 676 | id="sib_setting_signup_spin" class="fa fa-spinner fa-spin fa-fw fa-lg fa-2x"></i> |
| 677 | </div> |
| 678 | <div id="sib_setting_signup_body" class="card-body"> |
| 679 | <div id="sib_form_alert_message" class="alert alert-danger alert-dismissable fade in" |
| 680 | role="alert" style="display: none;"> |
| 681 | <span id="sib_disclaim_smtp" |
| 682 | style="display: none;"><?php _e( 'Confirmation emails will be sent through your own email server, but you have no guarantees on their deliverability. <br/> <a href="https://app-smtp.brevo.com/" target="_blank" rel="noopener">Click here</a> to send your emails through Brevo in order to improve your deliverability and get statistics', 'mailin' ); ?></span> |
| 683 | <span id="sib_disclaim_do_template" |
| 684 | style="display: none;"><?php _e( 'The template you selected does not include a link {{DOUBLEOPTIN}} to allow subscribers to confirm their subscription. <br/> Please edit the template to include a link with {{DOUBLEOPTIN}} as URL.', 'mailin' ); ?></span> |
| 685 | <span id="sib_disclaim_confirm_template" |
| 686 | style="display: none;"><?php _e( 'You cannot select a template with the tag {{DOUBLEOPTIN}}', 'mailin' ); ?></span> |
| 687 | </div> |
| 688 | |
| 689 | <!-- Linked List --> |
| 690 | <div class="row sib-small-content"> |
| 691 | <span class="col-md-3"> |
| 692 | <?php esc_attr_e( 'Linked List', 'mailin' ); ?> |
| 693 | <?php SIB_Page_Home::get_narration_script( __( 'Linked List', 'mailin' ), __( 'Select the list where you want to add your new subscribers', 'mailin' ) ); ?> |
| 694 | </span> |
| 695 | <div id="sib_select_list_area" class="col-md-4"> |
| 696 | |
| 697 | <input type="hidden" id="sib_selected_list_id" value=""> |
| 698 | <select data-placeholder="Please select the list" id="sib_select_list" |
| 699 | class="col-md-12 chosen-select" name="list_id[]" multiple="" |
| 700 | tabindex="-1"></select> |
| 701 | </div> |
| 702 | <div class="col-md-5"> |
| 703 | <small |
| 704 | style="font-style: italic;"><?php esc_attr_e( 'You can use Marketing Automation to create specific workflow when a user is added to the list.', 'mailin' ); ?></small> |
| 705 | </div> |
| 706 | |
| 707 | </div> |
| 708 | <!-- confirmation email --> |
| 709 | <div class="row small-content"> |
| 710 | <span class="col-md-3"><?php esc_attr_e( 'Send a confirmation email', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Confirmation message', 'mailin' ), __( 'You can choose to send a confirmation email. You will be able to set up the template that will be sent to your new suscribers', 'mailin' ) ) ); ?></span> |
| 711 | |
| 712 | <div class="col-md-4"> |
| 713 | <label class="col-md-6" style="font-weight: normal;"><input type="radio" |
| 714 | id="is_confirm_email_yes" |
| 715 | name="is_confirm_email" |
| 716 | value="1" <?php checked( $formData['isOpt'], '1' ); ?>> <?php esc_attr_e( 'Yes', 'mailin' ); ?> |
| 717 | </label> |
| 718 | <label class="col-md-5" style="font-weight: normal;"><input type="radio" |
| 719 | id="is_confirm_email_no" |
| 720 | name="is_confirm_email" |
| 721 | value="0" <?php checked( $formData['isOpt'], '0' ); ?>> <?php esc_attr_e( 'No', 'mailin' ); ?> |
| 722 | </label> |
| 723 | </div> |
| 724 | <div class="col-md-5"> |
| 725 | <small |
| 726 | style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to receive a confirmation email', 'mailin' ); ?></small> |
| 727 | </div> |
| 728 | </div> |
| 729 | <!-- select template id for confirmation email --> |
| 730 | <div class="row" id="sib_confirm_template_area"> |
| 731 | <input type="hidden" id="sib_selected_template_id" |
| 732 | value="<?php echo esc_attr( $formData['templateID'] ); ?>"> |
| 733 | <input type="hidden" id="sib_default_template_name" |
| 734 | value="<?php esc_attr_e( 'Default', 'mailin' ); ?>"> |
| 735 | |
| 736 | <div class="col-md-3" id="sib_template_id_area"> |
| 737 | </div> |
| 738 | <div class="col-md-4"> |
| 739 | <a href="https://my.brevo.com/camp/lists/template" class="col-md-12" |
| 740 | target="_blank" rel="noopener"><i |
| 741 | class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?> |
| 742 | </a> |
| 743 | </div> |
| 744 | </div> |
| 745 | <!-- double optin confirmation email --> |
| 746 | <div class="row sib-small-content mt-3"> |
| 747 | <span |
| 748 | class="col-md-3"><?php esc_attr_e( 'Double Opt-In', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Double Opt-In', 'mailin' ), __( 'Your subscribers will receive an email inviting them to confirm their subscription. Be careful, your subscribers are not saved in your list before confirming their subscription.', 'mailin' ) ) ); ?></span> |
| 749 | |
| 750 | <div class="col-md-4"> |
| 751 | <label class="col-md-6" style="font-weight: normal;"><input type="radio" |
| 752 | id="is_double_optin_yes" |
| 753 | name="is_double_optin" |
| 754 | value="1" <?php checked( $formData['isDopt'], '1' ); ?>> <?php esc_attr_e( 'Yes', 'mailin' ); ?> |
| 755 | </label> |
| 756 | <label class="col-md-5" style="font-weight: normal;"><input type="radio" |
| 757 | id="is_double_optin_no" |
| 758 | name="is_double_optin" |
| 759 | value="0" <?php checked( $formData['isDopt'], '0' ); ?>> <?php esc_attr_e( 'No', 'mailin' ); ?> |
| 760 | </label> |
| 761 | </div> |
| 762 | <div class="col-md-5"> |
| 763 | <small |
| 764 | style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to confirm their email address', 'mailin' ); ?></small> |
| 765 | </div> |
| 766 | </div> |
| 767 | <!-- select template id for double optin confirmation email --> |
| 768 | <div class="row" id="sib_doubleoptin_template_area"> |
| 769 | <input type="hidden" id="sib_selected_do_template_id" value="<?php echo esc_attr( $formData['templateID'] ); ?>"> |
| 770 | <div class="col-md-3" id="sib_doubleoptin_template_id_area"> |
| 771 | </div> |
| 772 | <div class="col-md-4"> |
| 773 | <a href="https://my.brevo.com/camp/lists/template" |
| 774 | class="col-md-12" target="_blank" rel="noopener"><i |
| 775 | class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?> |
| 776 | </a> |
| 777 | </div> |
| 778 | </div> |
| 779 | <div class="row sib-small-content mt-3" id="sib_double_redirect_area"> |
| 780 | <span class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after clicking in the email', 'mailin' ); ?></span> |
| 781 | |
| 782 | <div class="col-md-8"> |
| 783 | <input type="url" class="col-md-11" name="redirect_url" value="<?php echo esc_attr( $formData['redirectInEmail'] ); ?>"> |
| 784 | </div> |
| 785 | </div> |
| 786 | <div class="row sib-small-content mt-3" id="sib_final_confirm_template_area"> |
| 787 | <span class="col-md-3"><?php esc_attr_e( 'Select final confirmation email template', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Final confirmation', 'mailin' ), __( 'This is the final confirmation email your contacts will receive once they click on the double opt-in confirmation link. You can select one of the default templates we have created for you, e.g. \'Default template - Final confirmation\'. |
| 788 | For your information, you cannot select a template with the tag {{DOUBLEOPTIN}}.', 'mailin' ) ) ); ?></span> |
| 789 | <div class="row col-md-8"> |
| 790 | <input type="hidden" id="sib_selected_confirm_template_id" value="<?php echo esc_attr( $formData['confirmID'] );?>"> |
| 791 | <div class="col-md-5" id="sib_final_confirm_template_id_area"> |
| 792 | </div> |
| 793 | <div class="col-md-4"> |
| 794 | <a href="https://my.brevo.com/camp/lists/template" |
| 795 | class="col-md-12" target="_blank" rel="noopener"><i |
| 796 | class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?> |
| 797 | </a> |
| 798 | </div> |
| 799 | </div> |
| 800 | </div> |
| 801 | |
| 802 | <div class="row sib-small-content mt-3"> |
| 803 | <span |
| 804 | class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after subscription', 'mailin' ); ?></span> |
| 805 | |
| 806 | <div class="col-md-4"> |
| 807 | <label class="col-md-6" style="font-weight: normal;"><input type="radio" |
| 808 | id="is_redirect_url_click_yes" |
| 809 | name="is_redirect_url_click" |
| 810 | value="1" checked> <?php esc_attr_e( 'Yes', 'mailin' ); ?> |
| 811 | </label> |
| 812 | <label class="col-md-5" style="font-weight: normal;"><input type="radio" |
| 813 | id="is_redirect_url_click_no" |
| 814 | name="is_redirect_url_click" |
| 815 | value="0" <?php checked( $formData['redirectInForm'], '' ); ?>> <?php esc_attr_e( 'No', 'mailin' ); ?> |
| 816 | </label> |
| 817 | |
| 818 | </div> |
| 819 | <div class="col-md-5"> |
| 820 | <small |
| 821 | style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want to redirect your subscribers to a specific page after they fullfill the form', 'mailin' ); ?></small> |
| 822 | </div> |
| 823 | </div> |
| 824 | <div class="row" style="margin-top: 10px; |
| 825 | <?php |
| 826 | if ( '' == $formData['redirectInForm'] ) { |
| 827 | echo 'display:none;'; |
| 828 | } |
| 829 | ?> |
| 830 | " id="sib_subscrition_redirect_area"> |
| 831 | <span class="col-md-3"></span> |
| 832 | |
| 833 | <div class="col-md-8"> |
| 834 | <input type="url" class="col-md-11" name="redirect_url_click" |
| 835 | value="<?php echo esc_attr( $formData['redirectInForm'] ); ?>"> |
| 836 | </div> |
| 837 | </div> |
| 838 | |
| 839 | <div class="row sib-small-content" style="margin-top: 30px;"> |
| 840 | <div class="col-md-3"> |
| 841 | <button class="btn btn-success"><?php esc_attr_e( 'Save', 'mailin' ); ?></button> |
| 842 | </div> |
| 843 | </div> |
| 844 | |
| 845 | </div> |
| 846 | </div><!-- End Sign up process form--> |
| 847 | |
| 848 | <!-- Confirmation message form --> |
| 849 | <div class="card sib-small-content"> |
| 850 | <div class="card-header"> |
| 851 | <strong><?php esc_attr_e( 'Confirmation message', 'mailin' ); ?></strong> |
| 852 | </div> |
| 853 | <div class="card-body"> |
| 854 | <div class="row sib-small-content mt-3"> |
| 855 | <!-- <span class="col-md-3"></span> --> |
| 856 | <label for="inputEmail3" class="col-md-3"><?php esc_attr_e( 'Success message', 'mailin' ); ?></label> |
| 857 | <div class="col-md-8"> |
| 858 | <input type="text" class="col-md-11" name="alert_success_message" |
| 859 | value="<?php echo esc_attr( $formData['successMsg'] ); ?>" required> |
| 860 | <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Success message', 'mailin' ), __( 'Set up the success message that will appear when one of your visitors surccessfully signs up', 'mailin' ) ) ); ?> |
| 861 | </div> |
| 862 | </div> |
| 863 | <div class="row sib-small-content mt-3"> |
| 864 | <span class="col-md-3"><?php esc_attr_e( 'General error message', 'mailin' ); ?></span> |
| 865 | |
| 866 | <div class="col-md-8"> |
| 867 | <input type="text" class="col-md-11" name="alert_error_message" |
| 868 | value="<?php echo esc_attr( $formData['errorMsg'] ); ?>" required> |
| 869 | <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'General message error', 'mailin' ), __( 'Set up the message that will appear when an error occurs during the subscritpion process', 'mailin' ) ) ); ?> |
| 870 | </div> |
| 871 | </div> |
| 872 | <!-- |
| 873 | <div class="row sib-small-content mt-3"> |
| 874 | <span class="col-md-3"><?php esc_attr_e( 'Existing subscribers', 'mailin' ); ?></span> |
| 875 | |
| 876 | <div class="col-md-8"> |
| 877 | <input type="text" class="col-md-11" name="alert_exist_subscriber" |
| 878 | value="<?php echo esc_attr( $formData['existMsg'] ); ?>" required> |
| 879 | <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Existing Suscribers', 'mailin' ), __( 'Set up the message that will appear when a suscriber is already in your database', 'mailin' ) ) ); ?> |
| 880 | </div> |
| 881 | </div> |
| 882 | --> |
| 883 | <div class="row sib-small-content mt-3"> |
| 884 | <span class="col-md-3"><?php esc_attr_e( 'Invalid email address', 'mailin' ); ?></span> |
| 885 | |
| 886 | <div class="col-md-8"> |
| 887 | <input type="text" class="col-md-11" name="alert_invalid_email" |
| 888 | value="<?php echo esc_attr( $formData['invalidMsg'] ); ?>" required> |
| 889 | <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Invalid email address', 'mailin' ), __( 'Set up the message that will appear when the email address used to sign up is not valid', 'mailin' ) ) ); ?> |
| 890 | </div> |
| 891 | </div> |
| 892 | <div class="row sib-small-content mt-3"> |
| 893 | <span class="col-md-3"><?php esc_attr_e( 'Required Field', 'mailin' ); ?></span> |
| 894 | |
| 895 | <div class="col-md-8"> |
| 896 | <input type="text" class="col-md-11" name="alert_required_message" |
| 897 | value="<?php echo esc_attr( $formData['requiredMsg'] ); ?>" required> |
| 898 | <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Required Field', 'mailin' ), __( 'Set up the message that will appear when the required field is empty', 'mailin' ) ) ); ?> |
| 899 | </div> |
| 900 | </div> |
| 901 | <div class="row sib-small-content" style="margin-top: 30px;"> |
| 902 | <div class="col-md-3"> |
| 903 | <button class="btn btn-success"><?php esc_attr_e( 'Save', 'mailin' ); ?></button> |
| 904 | </div> |
| 905 | </div> |
| 906 | </div> |
| 907 | </div> <!-- End Confirmation message form--> |
| 908 | </form> |
| 909 | </div> |
| 910 | <script> |
| 911 | jQuery(document).ready(function () { |
| 912 | jQuery('#sib_add_to_form_btn').click(function () { |
| 913 | //var field_html = jQuery('#sib_field_html').html(); |
| 914 | |
| 915 | // tinyMCE.activeEditor.selection.setContent(field_html); |
| 916 | |
| 917 | return false; |
| 918 | }); |
| 919 | }); |
| 920 | </script> |
| 921 | <?php |
| 922 | } else { |
| 923 | // If empty? |
| 924 | ?> |
| 925 | <div id="main-content" class="sib-content"> |
| 926 | <div class="card sib-small-content"> |
| 927 | <div class="card-header"> |
| 928 | <strong><?php esc_attr_e( 'Subscription form', 'mailin' ); ?></strong> |
| 929 | </div> |
| 930 | <div style="padding: 24px 32px; margin-bottom: 12px;"> |
| 931 | <?php esc_attr_e( 'Sorry, you selected invalid form ID. Please check again if the ID is right', 'mailin' ); ?> |
| 932 | </div> |
| 933 | </div> |
| 934 | </div> |
| 935 | <?php |
| 936 | } |
| 937 | } |
| 938 | |
| 939 | /** Generate welcome page */ |
| 940 | function generate_welcome_page() { |
| 941 | ?> |
| 942 | <div id="main-content" class="row"> |
| 943 | <img class="small-content" src="<?php echo esc_url( SIB_Manager::$plugin_url . '/img/background/setting.png' ); ?>" alt="Settings Image" style="width: 100%;"> |
| 944 | </div> |
| 945 | <?php |
| 946 | SIB_Page_Home::print_disable_popup(); |
| 947 | } |
| 948 | |
| 949 | /** Save subscription form setting */ |
| 950 | public static function save_setting_subscription() { |
| 951 | // Check user role. |
| 952 | if ( ! current_user_can( 'manage_options' ) ) { |
| 953 | wp_die( 'Not allowed' ); |
| 954 | } |
| 955 | |
| 956 | // Check secret through hidden referrer field. |
| 957 | check_admin_referer( 'sib_setting_subscription' ); |
| 958 | |
| 959 | //Handling of backslash added by WP because magic quotes are enabled by default |
| 960 | array_walk_recursive( $_POST, function(&$value) { |
| 961 | $value = stripslashes($value); |
| 962 | }); |
| 963 | |
| 964 | // Subscription form. |
| 965 | $formID = isset( $_POST['sib_form_id'] ) ? sanitize_text_field( $_POST['sib_form_id'] ) : ''; |
| 966 | $form_name = isset( $_POST['sib_form_name'] ) ? sanitize_text_field( $_POST['sib_form_name'] ) : ''; |
| 967 | // phpcs:disable |
| 968 | $form_html = isset( $_POST['sib_form_html'] ) ? wp_kses($_POST['sib_form_html'], SIB_Manager::wordpress_allowed_attributes()) : ''; |
| 969 | $list_ids = ''; |
| 970 | |
| 971 | if (!empty($_POST['list_id']) && is_array($_POST['list_id'])) { |
| 972 | $list_ids = array_filter($_POST['list_id'], 'intval'); |
| 973 | $list_ids = maybe_serialize($list_ids); |
| 974 | } |
| 975 | // phpcs:enable |
| 976 | $dependTheme = isset( $_POST['sib_css_type'] ) ? sanitize_text_field( $_POST['sib_css_type'] ) : ''; |
| 977 | $customCss = isset( $_POST['sib_form_css'] ) ? sanitize_text_field( $_POST['sib_form_css'] ) : ''; |
| 978 | $gCaptcha = isset( $_POST['sib_add_captcha'] ) ? sanitize_text_field( $_POST['sib_add_captcha'] ) : '0'; |
| 979 | $gCaptchaSecret = isset( $_POST['sib_captcha_secret'] ) ? sanitize_text_field( $_POST['sib_captcha_secret'] ) : ''; |
| 980 | $gCaptchaSite = isset( $_POST['sib_captcha_site'] ) ? sanitize_text_field( $_POST['sib_captcha_site'] ) : ''; |
| 981 | $termAccept = isset( $_POST['sib_add_terms'] ) ? sanitize_text_field( $_POST['sib_add_terms'] ) : '0'; |
| 982 | $termURL = isset( $_POST['sib_terms_url'] ) ? sanitize_text_field( $_POST['sib_terms_url'] ) : ''; |
| 983 | $gCaptchaType = isset( $_POST['sib_recaptcha_type'] ) ? sanitize_text_field( $_POST['sib_recaptcha_type'] ) : '0'; |
| 984 | $selectCaptchaType = isset( $_POST['sib-select-captcha-type'] ) ? sanitize_text_field( $_POST['sib-select-captcha-type'] ) : '1'; |
| 985 | $cCaptchaSecret = isset( $_POST['sib_captcha_secret_turnstile'] ) ? sanitize_text_field( $_POST['sib_captcha_secret_turnstile'] ) : ''; |
| 986 | $cCaptchaSite = isset( $_POST['sib_captcha_site_turnstile'] ) ? sanitize_text_field( $_POST['sib_captcha_site_turnstile'] ) : ''; |
| 987 | $cCaptchaType = isset( $_POST['sib_recaptcha_type_turnstile'] ) ? sanitize_text_field( $_POST['sib_recaptcha_type_turnstile'] ) : ''; |
| 988 | $cCaptchaStyle = isset( $_POST['turnstile_captcha_theme'] ) ? sanitize_text_field( $_POST['turnstile_captcha_theme'] ) : ''; |
| 989 | |
| 990 | if ( $gCaptcha != '0' ) { |
| 991 | if ( $gCaptchaType == '0' ) { |
| 992 | $gCaptcha = '3'; // google recaptcha. |
| 993 | } |
| 994 | elseif ( $gCaptchaType == '1' ) { |
| 995 | $gCaptcha = '2'; // google invisible recaptcha. |
| 996 | } |
| 997 | } |
| 998 | // for wpml plugins. |
| 999 | $pid = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : ''; |
| 1000 | $lang = isset( $_POST['lang'] ) ? sanitize_text_field( $_POST['lang'] ) : ''; |
| 1001 | // sign up process. |
| 1002 | $templateID = '-1'; |
| 1003 | $confirmID = '-1'; |
| 1004 | $redirectInForm = ''; |
| 1005 | |
| 1006 | $isOpt = isset( $_POST['is_confirm_email'] ) ? sanitize_text_field( $_POST['is_confirm_email'] ) : false; |
| 1007 | if ( $isOpt ) { |
| 1008 | $templateID = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : '-1'; |
| 1009 | } |
| 1010 | $isDopt = isset( $_POST['is_double_optin'] ) ? sanitize_text_field( $_POST['is_double_optin'] ) : false; |
| 1011 | if ( $isDopt ) { |
| 1012 | $templateID = isset( $_POST['doubleoptin_template_id'] ) ? sanitize_text_field( $_POST['doubleoptin_template_id'] ) : '-1'; |
| 1013 | $confirmID = isset( $_POST['confirm_template_id'] ) ? sanitize_text_field( $_POST['confirm_template_id'] ) : '-1'; |
| 1014 | } |
| 1015 | $redirectInEmail = isset( $_POST['redirect_url'] ) ? sanitize_text_field( $_POST['redirect_url'] ) : ''; |
| 1016 | $isRedirectInForm = isset( $_POST['is_redirect_url_click'] ) ? sanitize_text_field( $_POST['is_redirect_url_click'] ) : false; |
| 1017 | if ( $isRedirectInForm ) { |
| 1018 | $redirectInForm = isset( $_POST['redirect_url_click'] ) ? sanitize_text_field( $_POST['redirect_url_click'] ) : ''; |
| 1019 | } |
| 1020 | |
| 1021 | // get available attributes list. |
| 1022 | $attributes = SIB_API_Manager::get_attributes(); |
| 1023 | $attributes = array_merge( |
| 1024 | $attributes['attributes']['normal_attributes'], |
| 1025 | $attributes['attributes']['category_attributes'], |
| 1026 | $attributes['attributes']['multiple_choice_attributes'] |
| 1027 | ); |
| 1028 | $available_attrs = array( 'email' ); |
| 1029 | if ( isset( $attributes ) && is_array( $attributes ) ) { |
| 1030 | foreach ( $attributes as $attribute ) { |
| 1031 | $pos = strpos( $form_html, 'sib-' . $attribute['name'] . '-area' ); |
| 1032 | if ( false !== $pos ) { |
| 1033 | $available_attrs[] = $attribute['name']; |
| 1034 | } |
| 1035 | } |
| 1036 | } |
| 1037 | $successMsg = isset( $_POST['alert_success_message'] ) ? sanitize_text_field( esc_attr ($_POST['alert_success_message'] ) ) : ''; |
| 1038 | $errorMsg = isset( $_POST['alert_error_message'] ) ? sanitize_text_field( esc_attr( $_POST['alert_error_message'] ) ) : ''; |
| 1039 | $existMsg = isset( $_POST['alert_exist_subscriber'] ) ? sanitize_text_field( esc_attr( $_POST['alert_exist_subscriber'] ) ) : ''; |
| 1040 | $invalidMsg = isset( $_POST['alert_invalid_email'] ) ? sanitize_text_field( esc_attr( $_POST['alert_invalid_email'] ) ) : ''; |
| 1041 | $requiredMsg = isset( $_POST['alert_required_message']) ? sanitize_text_field( esc_attr($_POST['alert_required_message'])) : ''; |
| 1042 | $formData = array( |
| 1043 | 'title' => $form_name, |
| 1044 | 'html' => $form_html, |
| 1045 | 'css' => $customCss, |
| 1046 | 'listID' => $list_ids, |
| 1047 | 'dependTheme' => $dependTheme, |
| 1048 | 'isOpt' => $isOpt, |
| 1049 | 'isDopt' => $isDopt, |
| 1050 | 'templateID' => $templateID, |
| 1051 | 'confirmID' => $confirmID, |
| 1052 | 'redirectInEmail' => $redirectInEmail, |
| 1053 | 'redirectInForm' => $redirectInForm, |
| 1054 | 'successMsg' => $successMsg, |
| 1055 | 'errorMsg' => $errorMsg, |
| 1056 | 'existMsg' => $existMsg, |
| 1057 | 'invalidMsg' => $invalidMsg, |
| 1058 | 'requiredMsg' => $requiredMsg, |
| 1059 | 'attributes' => implode( ',', $available_attrs ), |
| 1060 | 'gcaptcha' => $gCaptcha, |
| 1061 | 'gcaptcha_secret' => $gCaptchaSecret, |
| 1062 | 'gcaptcha_site' => $gCaptchaSite, |
| 1063 | 'selectCaptchaType' => $selectCaptchaType, |
| 1064 | 'cCaptchaType' => $cCaptchaType, |
| 1065 | 'ccaptcha_secret' => $cCaptchaSecret, |
| 1066 | 'ccaptcha_site' => $cCaptchaSite, |
| 1067 | 'cCaptchaStyle' => $cCaptchaStyle, |
| 1068 | 'termAccept' => $termAccept, |
| 1069 | 'termsURL' => $termURL, |
| 1070 | ); |
| 1071 | |
| 1072 | if ( 'new' === $formID ) { |
| 1073 | $formID = SIB_Forms::addForm( $formData ); |
| 1074 | if ( '' !== $pid ) { |
| 1075 | $transID = SIB_Forms_Lang::add_form_ID( $formID, $pid, $lang ); |
| 1076 | } |
| 1077 | } else { |
| 1078 | SIB_Forms::updateForm( $formID, $formData ); |
| 1079 | } |
| 1080 | if ( '' !== $pid ) { |
| 1081 | wp_safe_redirect( |
| 1082 | add_query_arg( |
| 1083 | array( |
| 1084 | 'page' => self::PAGE_ID, |
| 1085 | 'action' => 'edit', |
| 1086 | 'id' => $formID, |
| 1087 | 'pid' => $pid, |
| 1088 | 'lang' => $lang, |
| 1089 | ), admin_url( 'admin.php' ) |
| 1090 | ) |
| 1091 | ); |
| 1092 | exit(); |
| 1093 | } else { |
| 1094 | wp_safe_redirect( |
| 1095 | add_query_arg( |
| 1096 | array( |
| 1097 | 'page' => self::PAGE_ID, |
| 1098 | 'action' => 'edit', |
| 1099 | 'id' => $formID, |
| 1100 | ), admin_url( 'admin.php' ) |
| 1101 | ) |
| 1102 | ); |
| 1103 | exit(); |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | /** Ajax process when change template id */ |
| 1108 | public static function ajax_change_template() { |
| 1109 | check_ajax_referer( 'ajax_sib_admin_nonce', 'security' ); |
| 1110 | if ( ! current_user_can( 'view_custom_menu' ) ) { |
| 1111 | wp_send_json_error( 'forbidden', 403 ); |
| 1112 | } |
| 1113 | $template_id = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : ''; |
| 1114 | $mailin = new SendinblueApiClient( ); |
| 1115 | $data = array( |
| 1116 | 'id' => $template_id, |
| 1117 | ); |
| 1118 | $response = $mailin->getEmailTemplate( $data["id"] ); |
| 1119 | |
| 1120 | $ret_email = '-1'; |
| 1121 | if ( $mailin->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK) { |
| 1122 | $from_email = $response[0]['sender']['email']; |
| 1123 | if ( '[DEFAULT_FROM_EMAIL]' == $from_email ) { |
| 1124 | $ret_email = '-1'; |
| 1125 | } else { |
| 1126 | $ret_email = $from_email; |
| 1127 | } |
| 1128 | } |
| 1129 | wp_send_json( $ret_email ); |
| 1130 | } |
| 1131 | |
| 1132 | /** |
| 1133 | * Ajax module to get all lists. |
| 1134 | */ |
| 1135 | public static function ajax_get_lists() { |
| 1136 | check_ajax_referer( 'ajax_sib_admin_nonce', 'security' ); |
| 1137 | if ( ! current_user_can( 'view_custom_menu' ) ) { |
| 1138 | wp_send_json_error( 'forbidden', 403 ); |
| 1139 | } |
| 1140 | $lists = SIB_API_Manager::get_lists(); |
| 1141 | $frmID = isset( $_POST['frmid'] ) ? sanitize_text_field( $_POST['frmid'] ) : ''; |
| 1142 | $formData = SIB_Forms::getForm( $frmID ); |
| 1143 | $result = array( |
| 1144 | 'lists' => $lists, |
| 1145 | 'selected' => $formData['listID'], |
| 1146 | ); |
| 1147 | wp_send_json( $result ); |
| 1148 | } |
| 1149 | |
| 1150 | /** |
| 1151 | * Ajax module to get all templates. |
| 1152 | */ |
| 1153 | public static function ajax_get_templates() { |
| 1154 | check_ajax_referer( 'ajax_sib_admin_nonce', 'security' ); |
| 1155 | if ( ! current_user_can( 'view_custom_menu' ) ) { |
| 1156 | wp_send_json_error( 'forbidden', 403 ); |
| 1157 | } |
| 1158 | $templates = SIB_API_Manager::get_templates(); |
| 1159 | $result = array( |
| 1160 | 'templates' => $templates, |
| 1161 | ); |
| 1162 | wp_send_json( $result ); |
| 1163 | } |
| 1164 | |
| 1165 | /** |
| 1166 | * Ajax module to get all attributes. |
| 1167 | */ |
| 1168 | public static function ajax_get_attributes() { |
| 1169 | check_ajax_referer( 'ajax_sib_admin_nonce', 'security' ); |
| 1170 | if ( ! current_user_can( 'view_custom_menu' ) ) { |
| 1171 | wp_send_json_error( 'forbidden', 403 ); |
| 1172 | } |
| 1173 | $attrs = SIB_API_Manager::get_attributes(); |
| 1174 | $result = array( |
| 1175 | 'attrs' => $attrs, |
| 1176 | ); |
| 1177 | wp_send_json( $result ); |
| 1178 | } |
| 1179 | |
| 1180 | /** |
| 1181 | * Ajax module to update form html for preview |
| 1182 | */ |
| 1183 | public static function ajax_update_html() { |
| 1184 | check_ajax_referer( 'ajax_sib_admin_nonce', 'security' ); |
| 1185 | if ( ! current_user_can( 'view_custom_menu' ) ) { |
| 1186 | wp_send_json_error( 'forbidden', 403 ); |
| 1187 | } |
| 1188 | $gCaptchaType = isset( $_POST['gCaptchaType']) ? sanitize_text_field($_POST['gCaptchaType']) : '1'; |
| 1189 | $gCaptcha = isset( $_POST['gCaptcha'] ) ? sanitize_text_field($_POST['gCaptcha']) : '0'; |
| 1190 | if ( $gCaptcha != '0' ) { |
| 1191 | if( $gCaptchaType == '1' ) { |
| 1192 | $gCaptcha = '2'; |
| 1193 | } |
| 1194 | elseif ( $gCaptchaType == '0' ) { |
| 1195 | $gCaptcha = '3'; |
| 1196 | } |
| 1197 | } |
| 1198 | $formData = array( |
| 1199 | 'html' => isset( $_POST['frmData'] ) ? wp_kses($_POST['frmData'], SIB_Manager::wordpress_allowed_attributes()) : '',// phpcs:ignore |
| 1200 | 'css' => isset( $_POST['frmCss'] ) ? sanitize_text_field($_POST['frmCss']) : '', |
| 1201 | 'dependTheme' => isset( $_POST['isDepend'] ) ? sanitize_text_field($_POST['isDepend']) : '', |
| 1202 | 'gCaptcha' => $gCaptcha, |
| 1203 | 'gCaptcha_site' => isset( $_POST['gCaptchaSite'] ) ? sanitize_text_field($_POST['gCaptchaSite']) : '', |
| 1204 | 'selectCaptchaType' => isset( $_POST['selectCaptchaType'] ) ? sanitize_text_field($_POST['selectCaptchaType']) : '', |
| 1205 | ); |
| 1206 | |
| 1207 | update_option( SIB_Manager::PREVIEW_OPTION_NAME, $formData ); |
| 1208 | die; |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * Ajax module to copy content from origin form for translation |
| 1213 | */ |
| 1214 | public static function ajax_copy_origin_form() { |
| 1215 | check_ajax_referer( 'ajax_sib_admin_nonce', 'security' ); |
| 1216 | if ( ! current_user_can( 'view_custom_menu' ) ) { |
| 1217 | wp_send_json_error( 'forbidden', 403 ); |
| 1218 | } |
| 1219 | $pID = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : 1; |
| 1220 | $formData = SIB_Forms::getForm( $pID ); |
| 1221 | // phpcs:ignore |
| 1222 | $html = $formData['html']; |
| 1223 | |
| 1224 | wp_send_json( $html ); |
| 1225 | } |
| 1226 | } |
| 1227 | } |