PluginProbe
WPPizza – A Restaurant Plugin / 3.20
WPPizza – A Restaurant Plugin v3.20
trunk 2.16.11.28 3.19 3.19.1 3.19.2 3.19.3 3.19.4 3.19.5 3.19.6 3.19.7 3.19.7.1 3.19.7.2 3.19.7.3 3.19.7.4 3.19.8 3.19.8.1 3.19.8.2 3.19.8.3 3.19.9 3.20 3.20.1
wppizza / classes / modules / mod.order_settings.emails.php

mod.order_settings.emails.php in WPPizza – A Restaurant Plugin 3.20, at classes/modules/mod.order_settings.emails.php

262 lines 11.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPPIZZA_MODULE_ORDERSETTINGS_EMAILS Class
4 *
5 * @package WPPIZZA
6 * @subpackage WPPIZZA_MODULE_ORDERSETTINGS_EMAILS
7 * @copyright Copyright (c) 2015, Oliver Bach
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 3.0
10 *
11 */
12 if ( ! defined( 'ABSPATH' ) ) exit;/*Exit if accessed directly*/
13
14
15 /************************************************************************************************************************
16 *
17 *
18 *
19 *
20 *
21 *
22 ************************************************************************************************************************/
23 class WPPIZZA_MODULE_ORDERSETTINGS_EMAILS{
24
25 private $settings_page = 'order_settings';/* which admin subpage (identified there by this->class_key) are we adding this to */
26
27 private $section_key = 'emails';/* must be unique */
28
29
30 function __construct() {
31 /**********************************************************
32 [add settings to admin]
33 ***********************************************************/
34 if(is_admin()){
35 /* add admin options settings page*/
36 add_filter('wppizza_filter_settings_sections_'.$this->settings_page.'', array($this, 'admin_options_settings'), 80, 5);
37 /* add admin options settings page fields */
38 add_action('wppizza_admin_settings_section_fields_'.$this->settings_page.'', array($this, 'admin_options_fields_settings'), 10, 5);
39 /**add default options **/
40 add_filter('wppizza_filter_setup_default_options', array( $this, 'options_default'));
41 /**validate options**/
42 add_filter('wppizza_filter_options_validate', array( $this, 'options_validate'), 10, 2 );
43 }
44
45 }
46
47 /*******************************************************************************************************************************************************
48 *
49 *
50 *
51 * [frontend filters]
52 *
53 *
54 *
55 ********************************************************************************************************************************************************/
56 /*******************************************************************************************************************************************************
57 *
58 *
59 *
60 * [add admin page options]
61 *
62 *
63 *
64 ********************************************************************************************************************************************************/
65
66 /*------------------------------------------------------------------------------
67 #
68 #
69 # [settings page]
70 #
71 #
72 ------------------------------------------------------------------------------*/
73
74 /*------------------------------------------------------------------------------
75 # [settings section - setting page]
76 # @since 3.0
77 # @return array()
78 ------------------------------------------------------------------------------*/
79 function admin_options_settings($settings, $sections, $fields, $inputs, $help){
80
81 /*section*/
82 if($sections){
83 $settings['sections'][$this->section_key] = __('Emails', 'wppizza-admin');
84 }
85 /*help*/
86 if($help){
87 $settings['help'][$this->section_key][] = array(
88 'label'=>__('"From" email address:', 'wppizza-admin'),
89 'description'=>array(
90 __('All emails will appear to have been sent from this address. (Some fax gateways for example require a distinct FROM email address). However, the customers email address will still be stored in the db/order history if entered', 'wppizza-admin')
91 )
92 );
93 $settings['help'][$this->section_key][] = array(
94 'label'=>__('Attachments', 'wppizza-admin'),
95 'description'=>array(
96 __('If you wish to add an attachment to the order emails add the FULL ABSOLUTE PATH to the file(s) you wish to attach to the emails', 'wppizza-admin')
97 )
98 );
99 $settings['help'][$this->section_key][] = array(
100 'label'=>__('DMARC', 'wppizza-admin'),
101 'description'=>array(
102 __('If a DMARC notice/warning is displayed at the top of the page and you are certain you are happy with your email settings as they are, you can enable and save this option to forcefully hide/disable this notice.', 'wppizza-admin')
103 )
104 );
105 }
106 /*fields*/
107 if($fields){
108 $field = 'order_email_to';
109 $settings['fields'][$this->section_key][$field] = array( __('Order Email Recipient(s)', 'wppizza-admin'), array(
110 'value_key'=>$field,
111 'option_key'=>$this->settings_page,
112 'label'=> __('Which email address should any orders be sent to [separated by comma if multiple]', 'wppizza-admin'),
113 'description'=>array()
114 ));
115 $field = 'order_email_bcc';
116 $settings['fields'][$this->section_key][$field] = array( __('Order Email Bcc\'s', 'wppizza-admin'), array(
117 'value_key'=>$field,
118 'option_key'=>$this->settings_page,
119 'label'=>__('If you would like to BCC order emails add these here [separated by comma if multiple]', 'wppizza-admin'),
120 'description'=>array()
121 ));
122 $field = 'order_email_from';
123 $settings['fields'][$this->section_key][$field] = array( __('"From" email address', 'wppizza-admin'), array(
124 'value_key'=>$field,
125 'option_key'=>$this->settings_page,
126 'label'=>__('All emails will appear to have been sent from this address.', 'wppizza-admin'),
127 'description'=>array(
128 '<span class="wppizza-highlight">'.__('You are strongly advised to set an email here that exists and corresponds to the domain of this server', 'wppizza-admin').'</span>'
129 )
130 ));
131 $field = 'order_email_from_name';
132 $settings['fields'][$this->section_key][$field] = array( __('"From" email name', 'wppizza-admin'), array(
133 'value_key'=>$field,
134 'option_key'=>$this->settings_page,
135 'label'=>__('You can set a static "name" here (in conjunction with any "From" email address set above). If left empty, the email address will be used.', 'wppizza-admin').'',
136 'description'=>array()
137 ));
138 $field = 'order_email_attachments';
139 $settings['fields'][$this->section_key][$field] = array( __('Email Attachments', 'wppizza-admin'), array(
140 'value_key'=>$field,
141 'option_key'=>$this->settings_page,
142 'label'=>__('Email Attachments [separated by comma if multiple]:', 'wppizza-admin').'',
143 'description'=>array(
144 ''.__('Your absolute WP Path', 'wppizza-admin').': '. substr(ABSPATH,0,-1) .''
145 )
146 ));
147 $field = 'dmarc_nag_off';
148 $settings['fields'][$this->section_key][$field] = array( __('Turn Off DMARC Notice', 'wppizza-admin'), array(
149 'value_key'=>$field,
150 'option_key'=>$this->settings_page,
151 'label'=>__('Disable DMARC notice', 'wppizza-admin').'',
152 'description'=>array()
153 ));
154 }
155
156
157 return $settings;
158 }
159 /*------------------------------------------------------------------------------
160 # [output option fields - setting page]
161 # @since 3.0
162 # @return array()
163 ------------------------------------------------------------------------------*/
164 function admin_options_fields_settings($wppizza_options, $options_key, $field, $label, $description){
165
166 /********************************
167 * [Emails / Attachments]
168 ********************************/
169 if($field=='order_email_to' || $field=='order_email_bcc' ){//$field==order_sms => not implemented
170 echo "<label>";
171 if(is_array($wppizza_options[$options_key][$field])){$val=implode(",",$wppizza_options[$options_key][$field]);}else{$val='';}
172 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' size='30' type='text' value='".$val."' />";
173 echo "".$label."";
174 echo "</label>";
175 echo"".$description."";
176 }
177 if($field=='order_email_attachments'){
178 echo "<label>";
179 if(isset($wppizza_options[$options_key][$field]) && is_array($wppizza_options[$options_key][$field])){$val=implode(",",$wppizza_options[$options_key][$field]);}else{$val='';}
180 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' size='30' type='text' value='".$val."' placeholder='/absolute/path/to/your/file'/>";
181 echo "".$label."";
182 echo "</label>";
183 echo"".$description."";
184 }
185 if($field=='order_email_from'){
186 echo "<label>";
187 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' size='30' type='text' value='".$wppizza_options[$options_key][$field]."' />";
188 echo "".$label."";
189 echo "</label>";
190 echo"".$description."";
191 }
192 if($field=='order_email_from_name'){
193 echo "<label>";
194 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' size='30' type='text' value='".$wppizza_options[$options_key][$field]."' />";
195 echo "".$label."";
196 echo "</label>";
197 echo"".$description."";
198 }
199 if($field=='dmarc_nag_off'){
200 echo "<label>";
201 echo" <input name='".WPPIZZA_SLUG."[".$options_key."][dmarc_nag_off]' type='checkbox' ". checked($wppizza_options[$options_key]['dmarc_nag_off'],true,false)." value='1' /> ";
202 echo "".$label."";
203 echo "</label>";
204 echo"".$description."";
205 }
206
207 }
208
209 /*------------------------------------------------------------------------------
210 # [insert default option on install]
211 # $parameter $options array() | filter passing on filtered options
212 # @since 3.0
213 # @return array()
214 ------------------------------------------------------------------------------*/
215 function options_default($options){
216
217 $options[$this->settings_page]['order_email_to'] = array(''.get_option('admin_email').'');
218 $options[$this->settings_page]['order_email_bcc'] = array();
219 $options[$this->settings_page]['order_email_attachments'] = array();
220 $options[$this->settings_page]['order_email_from'] = get_option('admin_email');
221 $options[$this->settings_page]['order_email_from_name'] = get_option('blogname');
222 $options[$this->settings_page]['dmarc_nag_off'] = false;
223
224
225 return $options;
226 }
227
228 /*------------------------------------------------------------------------------
229 # [validate options on save/update]
230 #
231 # @since 3.0
232 # @return array()
233 ------------------------------------------------------------------------------*/
234 function options_validate($options, $input){
235 /**make sure we get the full array on install/update**/
236 if ( empty( $_POST['_wp_http_referer'] ) ) {
237 return $input;
238 }
239 /*
240 settings
241 */
242 if(isset($_POST[''.WPPIZZA_SLUG.'_'.$this->settings_page.''])){
243 $options[$this->settings_page]['order_email_to'] = wppizza_validate_email_array($input[$this->settings_page]['order_email_to']);
244 $options[$this->settings_page]['order_email_bcc'] = wppizza_validate_email_array($input[$this->settings_page]['order_email_bcc']);
245 $options[$this->settings_page]['order_email_attachments'] = wppizza_strtoarray($input[$this->settings_page]['order_email_attachments']);
246 $emailFrom=wppizza_validate_email_array($input[$this->settings_page]['order_email_from']);/*validated as array but we only store the first value as string*/
247 $options[$this->settings_page]['order_email_from'] = !empty($emailFrom[0]) ? ''.$emailFrom[0].'' : '' ;
248 $options[$this->settings_page]['order_email_from_name'] = wppizza_validate_string($input[$this->settings_page]['order_email_from_name']);
249 /**dmarc nag**/
250 $options[$this->settings_page]['dmarc_nag_off']= !empty($input[$this->settings_page]['dmarc_nag_off']) ? true : false;
251 }
252
253 return $options;
254 }
255 }
256 /***************************************************************
257 *
258 * [ini]
259 *
260 ***************************************************************/
261 $WPPIZZA_MODULE_ORDERSETTINGS_EMAILS = new WPPIZZA_MODULE_ORDERSETTINGS_EMAILS();
262 ?>