css
3 days ago
img
3 days ago
js
3 days ago
partials
3 days ago
class-analytics.php
3 days ago
class-eqw-advance.php
3 days ago
class-eqw-cart.php
3 days ago
class-eqw-email.php
3 days ago
class-eqw-enquiry.php
3 days ago
class-eqw-form-control.php
3 days ago
class-eqw-menu.php
3 days ago
class-eqw-option.php
3 days ago
class-eqw-product-options.php
3 days ago
class-pisol-enquiry-quotation-woocommerce-admin.php
3 days ago
class-telegram-options.php
3 days ago
index.php
3 days ago
plugins.php
3 days ago
class-eqw-email.php
150 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | |
| 4 | class Class_Pi_Eqw_Email{ |
| 5 | |
| 6 | public $plugin_name; |
| 7 | |
| 8 | private $settings = array(); |
| 9 | |
| 10 | private $active_tab; |
| 11 | |
| 12 | private $this_tab = 'email'; |
| 13 | |
| 14 | private $tab_name = "Email setting"; |
| 15 | |
| 16 | private $setting_key = 'pi_eqw_email_setting'; |
| 17 | |
| 18 | public $tab; |
| 19 | |
| 20 | |
| 21 | function __construct($plugin_name){ |
| 22 | $this->plugin_name = $plugin_name; |
| 23 | |
| 24 | add_action('init', array($this,'init')); |
| 25 | |
| 26 | $this->tab = sanitize_text_field(filter_input( INPUT_GET, 'tab')); |
| 27 | $this->active_tab = $this->tab != "" ? $this->tab : 'default'; |
| 28 | |
| 29 | if($this->this_tab == $this->active_tab){ |
| 30 | add_action($this->plugin_name.'_tab_content', array($this,'tab_content')); |
| 31 | } |
| 32 | |
| 33 | add_action($this->plugin_name.'_tab', array($this,'tab'),3); |
| 34 | |
| 35 | if(PI_EQW_DELETE_SETTING){ |
| 36 | $this->delete_settings(); |
| 37 | } |
| 38 | |
| 39 | add_action( 'admin_notices', [$this, 'library_warning'] ); |
| 40 | } |
| 41 | |
| 42 | function init(){ |
| 43 | $this->settings = array( |
| 44 | |
| 45 | array('field'=>'title', 'class'=> 'hide-pro bg-dark opacity-75 text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>'Email settings', 'type'=>'setting_category'), |
| 46 | |
| 47 | array('field'=>'pi_eqw_email', 'label'=>__('Email id','pisol-enquiry-quotation-woocommerce'),'type'=>'text', 'desc'=>__('Email id that will receive the enquiry, <strong class="text-danger">In PRO version you can add multiple email separated with comma like this text@email.com, text2@email.com </strong>','pisol-enquiry-quotation-woocommerce'),'default'=> get_option('admin_email')), |
| 48 | |
| 49 | array('field'=>'pi_eqw_email_subject', 'label'=>__('Subject of the email','pisol-enquiry-quotation-woocommerce'),'type'=>'text', 'default'=>__('New enquiry received', 'pisol-enquiry-quotation-woocommerce'), 'desc'=>__('subject of the email', 'pisol-enquiry-quotation-woocommerce')), |
| 50 | |
| 51 | array('field'=>'pi_eqw_show_message_as_row', 'label'=>__('Show product message as row in email','pisol-enquiry-quotation-woocommerce'),'type'=>'switch','default'=> 1, 'desc'=>__('Show message as row in the email else it will be shown as a columns in the product row','pisol-enquiry-quotation-woocommerce')), |
| 52 | |
| 53 | array('field'=>'pi_eqw_email_template', 'label'=>__('Use WooCommerce email template','pisol-enquiry-quotation-woocommerce'),'type'=>'switch','default'=> 1, 'desc'=>__('Use Woocommerce email template all the colors will be as per woocommerce email template ','pisol-enquiry-quotation-woocommerce')), |
| 54 | |
| 55 | array('field'=>'pi_enq_add_img_url', 'label'=>__('Enable this option If product and logo image are not shown in the email or You dont want image attached in email','pisol-enquiry-quotation-woocommerce'),'type'=>'switch','default'=>0, 'desc'=>__('Enable this option only if you are having issue in seeing image inside the enquiry email or You dont want image to be send as attachment in the email','pisol-enquiry-quotation-woocommerce')), |
| 56 | |
| 57 | |
| 58 | array('field'=>'pi_eqw_email_to_customer', 'label'=>__('Send enquiry email to customer as well','pisol-enquiry-quotation-woocommerce'),'type'=>'switch','default'=>1, 'desc'=>__('Will send the enquiry email copy to customer as well','pisol-enquiry-quotation-woocommerce'), 'pro'=>true), |
| 59 | |
| 60 | array('field'=>'pi_eqw_customer_email_subject', 'label'=>__('Subject of the email to customer','pisol-enquiry-quotation-woocommerce'),'type'=>'text', 'default'=>__('Your enquiry is submitted', 'pisol-enquiry-quotation-woocommerce'), 'desc'=>__('Subject of the enquiry email send to customer', 'pisol-enquiry-quotation-woocommerce'), 'pro'=>true), |
| 61 | array('field'=>'pi_eqw_company_logo', 'label'=>__('Logo added in the email','pisol-enquiry-quotation-woocommerce'),'type'=>'image', 'desc'=>__('This is the image that will be added inside the email copy, sent to you and the customer', 'pisol-enquiry-quotation-woocommerce'),'pro'=>true), |
| 62 | |
| 63 | array('field'=>'title', 'class'=> 'bg-dark opacity-75 text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__("Spam protection",'pisol-enquiry-quotation-woocommerce'), 'type'=>"setting_category"), |
| 64 | |
| 65 | array('field'=>'pi_eqw_enable_honeypot', 'label'=>__('Use honeypot for spam protection','pisol-enquiry-quotation-woocommerce'),'type'=>'switch','default'=> 1, 'desc'=>__('This will add an hidden field which user will not fill but spam bot will fill and so the form will not be submitted','pisol-enquiry-quotation-woocommerce')), |
| 66 | |
| 67 | array('field'=>'pi_eqw_captcha', 'label'=>__('Use captcha','pisol-enquiry-quotation-woocommerce'),'type'=>'select','default'=> '', 'desc'=>__('Select the type of captcha to add','pisol-enquiry-quotation-woocommerce'), 'value'=> array(''=>'None','captcha'=>__('Captcha','pisol-enquiry-quotation-woocommerce'))), |
| 68 | |
| 69 | array('field'=>'pi_eqw_captcha_characters','desc'=>'Type of string used in captcha', 'label'=>__('Select type of string to use in the captcha','pisol-enquiry-quotation-woocommerce'),'type'=>'select', 'default'=>'mix', 'value'=>array('capital_letter'=>'Capital letter','small_letter'=>'Small letter','numbers'=>'Numbers','mix'=>'Mix')), |
| 70 | |
| 71 | array('field'=>'pi_eqw_captcha_length','desc'=>'', 'label'=>__('Captcha string length','pisol-enquiry-quotation-woocommerce'),'type'=>'select', 'default'=>'6', 'value'=>array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6)), |
| 72 | |
| 73 | array('field'=>'pi_eqw_captcha_placeholder','desc'=>'', 'label'=>__('Captcha field placeholder','pisol-enquiry-quotation-woocommerce'),'type'=>'text', 'default'=>'Enter the CAPTCHA'), |
| 74 | |
| 75 | array('field'=>'title', 'class'=> 'hide-pro bg-dark opacity-75 text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__('Custom message for customer email', 'pisol-enquiry-quotation-woocommerce'), 'type'=>'setting_category'), |
| 76 | |
| 77 | array('field'=>'pi_eqw_customer_email_above_product_table', 'label'=>__('Above product table','pisol-enquiry-quotation-woocommerce'),'type'=>'textarea', 'default'=>"", 'desc'=>__('This message will appear above the product table','pisol-enquiry-quotation-woocommerce'),'pro'=>true), |
| 78 | |
| 79 | array('field'=>'pi_eqw_customer_email_below_product_table', 'label'=>__('Below product table','pisol-enquiry-quotation-woocommerce'),'type'=>'textarea', 'default'=>"", 'desc'=>__('This message will appear below the product table','pisol-enquiry-quotation-woocommerce'),'pro'=>true), |
| 80 | |
| 81 | array('field'=>'pi_eqw_customer_email_below_customer_detail', 'label'=>__('Below customer detail','pisol-enquiry-quotation-woocommerce'),'type'=>'textarea', 'default'=>"", 'desc'=>__('This message will appear below the customer detail table','pisol-enquiry-quotation-woocommerce'),'pro'=>true), |
| 82 | |
| 83 | array('field'=>'title', 'class'=> 'hide-pro bg-dark opacity-75 text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__('Custom message for admin email', 'pisol-enquiry-quotation-woocommerce'), 'type'=>'setting_category'), |
| 84 | |
| 85 | array('field'=>'pi_eqw_admin_email_above_product_table', 'label'=>__('Above product table','pisol-enquiry-quotation-woocommerce'),'type'=>'textarea', 'default'=>"", 'desc'=>__('This message will appear above the product table','pisol-enquiry-quotation-woocommerce'),'pro'=>true), |
| 86 | |
| 87 | array('field'=>'pi_eqw_admin_email_below_product_table', 'label'=>__('Below product table','pisol-enquiry-quotation-woocommerce'),'type'=>'textarea', 'default'=>"", 'desc'=>__('This message will appear below the product table','pisol-enquiry-quotation-woocommerce'),'pro'=>true), |
| 88 | |
| 89 | array('field'=>'pi_eqw_admin_email_below_customer_detail', 'label'=>__('Below customer detail','pisol-enquiry-quotation-woocommerce'),'type'=>'textarea', 'default'=>"", 'desc'=>__('This message will appear below the customer detail table','pisol-enquiry-quotation-woocommerce'),'pro'=>true) |
| 90 | |
| 91 | |
| 92 | ); |
| 93 | $this->register_settings(); |
| 94 | } |
| 95 | |
| 96 | function library_warning(){ |
| 97 | $captcha = get_option('pi_eqw_captcha'); |
| 98 | if(!\PISOL_ENQ_CaptchaGenerator::image_library_available() && $captcha == 'captcha'){ |
| 99 | ?> |
| 100 | <div class="notice notice-error is-dismissible"> |
| 101 | <h3>Enquiry form Captcha issue</h3> |
| 102 | <p>Captcha requires an image generation module, but neither GD nor Imagick is installed on your server. Please install one of these PHP libraries for Captcha to work, or disable the Captcha setting by visiting the settings page <a href="<?php echo esc_url(admin_url('admin.php?page=pisol-enquiry-quote&tab=email#row_pi_eqw_captcha')); ?>" target="_blank">here</a></p> |
| 103 | |
| 104 | </div> |
| 105 | <?php |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | |
| 110 | function delete_settings(){ |
| 111 | foreach($this->settings as $setting){ |
| 112 | delete_option( $setting['field'] ); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | function register_settings(){ |
| 117 | |
| 118 | foreach($this->settings as $setting){ |
| 119 | register_setting( $this->setting_key, $setting['field']); |
| 120 | } |
| 121 | |
| 122 | } |
| 123 | |
| 124 | function tab(){ |
| 125 | $page = sanitize_text_field(filter_input( INPUT_GET, 'page')); |
| 126 | $this->tab_name = __('Email','pisol-enquiry-quotation-woocommerce'); |
| 127 | ?> |
| 128 | <a class=" px-3 text-light d-flex align-items-center border-left border-right <?php echo ($this->active_tab == $this->this_tab ? 'bg-primary' : 'bg-secondary'); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page='.$page.'&tab='.$this->this_tab ) ); ?>"> |
| 129 | <span class="dashicons dashicons-email-alt"></span> <?php echo esc_html( $this->tab_name); ?> |
| 130 | </a> |
| 131 | <?php |
| 132 | } |
| 133 | |
| 134 | function tab_content(){ |
| 135 | ?> |
| 136 | <form method="post" action="options.php" class="pisol-setting-form"> |
| 137 | <?php settings_fields( $this->setting_key ); ?> |
| 138 | <?php |
| 139 | foreach($this->settings as $setting){ |
| 140 | new pisol_class_form_eqw($setting, $this->setting_key); |
| 141 | } |
| 142 | ?> |
| 143 | <input type="submit" class="my-3 btn btn-primary btn-md" value="<?php echo esc_attr__('Save Option', 'pisol-enquiry-quotation-woocommerce'); ?>" /> |
| 144 | </form> |
| 145 | <?php |
| 146 | } |
| 147 | |
| 148 | } |
| 149 | |
| 150 |