css
1 year ago
img
1 year ago
js
1 year ago
partials
1 year ago
class-eqw-advance.php
1 year ago
class-eqw-cart.php
1 year ago
class-eqw-email.php
1 year ago
class-eqw-enquiry.php
1 year ago
class-eqw-form-control.php
1 year ago
class-eqw-menu.php
1 year ago
class-eqw-option.php
1 year ago
class-eqw-product-options.php
1 year ago
class-pisol-enquiry-quotation-woocommerce-admin.php
1 year ago
index.php
1 year ago
plugins.php
1 year ago
class-eqw-email.php
147 lines
| 1 | <?php |
| 2 | |
| 3 | class Class_Pi_Eqw_Email{ |
| 4 | |
| 5 | public $plugin_name; |
| 6 | |
| 7 | private $settings = array(); |
| 8 | |
| 9 | private $active_tab; |
| 10 | |
| 11 | private $this_tab = 'email'; |
| 12 | |
| 13 | private $tab_name = "Email setting"; |
| 14 | |
| 15 | private $setting_key = 'pi_eqw_email_setting'; |
| 16 | |
| 17 | public $tab; |
| 18 | |
| 19 | |
| 20 | function __construct($plugin_name){ |
| 21 | $this->plugin_name = $plugin_name; |
| 22 | |
| 23 | $this->settings = array( |
| 24 | |
| 25 | |
| 26 | 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 coma like this text@email.com, text2@email.com </strong>','pisol-enquiry-quotation-woocommerce'),'default'=> get_option('admin_email')), |
| 27 | |
| 28 | array('field'=>'pi_eqw_email_subject', 'label'=>__('Subject of the email','pisol-enquiry-quotation-woocommerce'),'type'=>'text', 'default'=>__('New enquiry received'), 'desc'=>__('subject of the email', 'pisol-enquiry-quotation-woocommerce')), |
| 29 | |
| 30 | 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')), |
| 31 | |
| 32 | 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')), |
| 33 | |
| 34 | 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')), |
| 35 | |
| 36 | |
| 37 | 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), |
| 38 | |
| 39 | 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'), 'desc'=>__('Subject of the enquiry email send to customer', 'pisol-enquiry-quotation-woocommerce'), 'pro'=>true), |
| 40 | 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, sed to you and the customer', 'pisol-enquiry-quotation-woocommerce'),'pro'=>true), |
| 41 | |
| 42 | array('field'=>'title', 'class'=> 'bg-primary text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__("Spam protection",'pisol-enquiry-quotation-woocommerce'), 'type'=>"setting_category"), |
| 43 | |
| 44 | 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')), |
| 45 | |
| 46 | 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'))), |
| 47 | |
| 48 | 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')), |
| 49 | |
| 50 | 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)), |
| 51 | |
| 52 | array('field'=>'pi_eqw_captcha_placeholder','desc'=>'', 'label'=>__('Captcha field placeholder','pisol-enquiry-quotation-woocommerce'),'type'=>'text', 'default'=>'Enter the CAPTCHA'), |
| 53 | |
| 54 | array('field'=>'title', 'class'=> 'hide-pro bg-primary text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__('Custom message for customer email', 'pisol-enquiry-quotation-woocommerce'), 'type'=>'setting_category'), |
| 55 | |
| 56 | 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), |
| 57 | |
| 58 | 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), |
| 59 | |
| 60 | 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), |
| 61 | |
| 62 | array('field'=>'title', 'class'=> 'hide-pro bg-primary text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__('Custom message for admin email', 'pisol-enquiry-quotation-woocommerce'), 'type'=>'setting_category'), |
| 63 | |
| 64 | 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), |
| 65 | |
| 66 | 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), |
| 67 | |
| 68 | 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) |
| 69 | |
| 70 | |
| 71 | ); |
| 72 | |
| 73 | $this->tab = sanitize_text_field(filter_input( INPUT_GET, 'tab')); |
| 74 | $this->active_tab = $this->tab != "" ? $this->tab : 'default'; |
| 75 | |
| 76 | if($this->this_tab == $this->active_tab){ |
| 77 | add_action($this->plugin_name.'_tab_content', array($this,'tab_content')); |
| 78 | } |
| 79 | |
| 80 | |
| 81 | add_action($this->plugin_name.'_tab', array($this,'tab'),3); |
| 82 | |
| 83 | |
| 84 | $this->register_settings(); |
| 85 | |
| 86 | if(PI_EQW_DELETE_SETTING){ |
| 87 | $this->delete_settings(); |
| 88 | } |
| 89 | |
| 90 | add_action( 'admin_notices', [$this, 'library_warning'] ); |
| 91 | } |
| 92 | |
| 93 | function library_warning(){ |
| 94 | $captcha = get_option('pi_eqw_captcha'); |
| 95 | if(!\PISOL_ENQ_CaptchaGenerator::image_library_available() && $captcha == 'captcha'){ |
| 96 | ?> |
| 97 | <div class="notice notice-error is-dismissible"> |
| 98 | <h3>Enquiry form Captcha issue</h3> |
| 99 | <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> |
| 100 | |
| 101 | </div> |
| 102 | <?php |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | |
| 107 | function delete_settings(){ |
| 108 | foreach($this->settings as $setting){ |
| 109 | delete_option( $setting['field'] ); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | function register_settings(){ |
| 114 | |
| 115 | foreach($this->settings as $setting){ |
| 116 | register_setting( $this->setting_key, $setting['field']); |
| 117 | } |
| 118 | |
| 119 | } |
| 120 | |
| 121 | function tab(){ |
| 122 | $page = sanitize_text_field(filter_input( INPUT_GET, 'page')); |
| 123 | $this->tab_name = __('Email setting','pisol-enquiry-quotation-woocommerce'); |
| 124 | ?> |
| 125 | <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 ) ); ?>"> |
| 126 | <?php echo esc_html( $this->tab_name); ?> |
| 127 | </a> |
| 128 | <?php |
| 129 | } |
| 130 | |
| 131 | function tab_content(){ |
| 132 | ?> |
| 133 | <form method="post" action="options.php" class="pisol-setting-form"> |
| 134 | <?php settings_fields( $this->setting_key ); ?> |
| 135 | <?php |
| 136 | foreach($this->settings as $setting){ |
| 137 | new pisol_class_form_eqw($setting, $this->setting_key); |
| 138 | } |
| 139 | ?> |
| 140 | <input type="submit" class="mt-3 btn btn-primary btn-sm" value="Save Option" /> |
| 141 | </form> |
| 142 | <?php |
| 143 | } |
| 144 | |
| 145 | } |
| 146 | |
| 147 |