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.settings.multisite.php

mod.settings.multisite.php in WPPizza – A Restaurant Plugin 3.20, at classes/modules/mod.settings.multisite.php

659 lines 26.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPPIZZA_MODULE_SETTINGS_MULTISITE Class
4 *
5 * @package WPPIZZA
6 * @subpackage WPPIZZA_MODULE_SETTINGS_MULTISITE
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_SETTINGS_MULTISITE{
24
25 private $settings_page = 'settings';/* which admin subpage (identified there by this->class_key) are we adding this to */
26 private $layout_page = 'layout';/* which admin subpage (identified there by this->class_key) are we adding this to */
27
28 private $layout_section = 'layout-itemsorting-categories';/* splicing it into a specific section adding fields */
29
30
31 private $section_key = 'multisite';/* must be unique */
32
33 private $items_keys_blog_details = array(); /* keys of menu items that should have the blogname name added before them */
34
35
36 function __construct() {
37 /**********************************************************
38 [add settings to admin]
39 ***********************************************************/
40 if(is_admin()){
41
42 if(is_multisite()){
43
44 /* add admin options settings page*/
45 add_filter('wppizza_filter_settings_sections_'.$this->settings_page.'', array($this, 'admin_options_settings'), 30, 5);
46 /* add admin options settings page fields */
47 add_action('wppizza_admin_settings_section_fields_'.$this->settings_page.'', array($this, 'admin_options_fields_settings'), 10, 5);
48
49 /* add admin options layout page*/
50 add_filter('wppizza_filter_settings_sections_'.$this->layout_page.'', array($this, 'admin_options_layout'), 1000, 5);/* priority must be same or higher than cat items display (at 50) */
51 /* add admin options layout page fields */
52 add_action('wppizza_admin_settings_section_fields_'.$this->layout_page.'', array($this, 'admin_options_fields_layout'), 10, 5);
53 }
54
55 /**add default options, regardless of if it's a multisite setup or not **/
56 add_filter('wppizza_filter_setup_default_options', array( $this, 'options_default'));
57 /**validate options**/
58 add_filter('wppizza_filter_options_validate', array( $this, 'options_validate'), 10, 2 );
59 }
60 /**********************************************************
61 [filter/actions depending on settings]
62 ***********************************************************/
63 if(is_multisite()){
64 /* sessions per site ? default true */
65 add_filter( 'wppizza_filter_session_per_site', array( $this, 'sessions_per_site' ));
66 /* order history all sites (parent only)? default false */
67 add_filter( 'wppizza_filter_order_history_all_sites', array( $this, 'order_history_all_sites' ));
68 /* reports all sites (parent only) ? default false */
69 add_filter( 'wppizza_filter_reports_all_sites', array( $this, 'reports_all_sites' ));
70
71
72 /* add parameters blog name for cart/session and order variables*/
73 add_filter('wppizza_filter_cart_items_from_session', array( $this, 'get_blogname_for_cart_email_order'));
74 add_filter('wppizza_filter_order_items_markup', array( $this, 'get_blogname_for_cart_email_order'));
75 add_filter('wppizza_filter_email_items_markup', array( $this, 'get_blogname_for_cart_email_order'));
76
77
78 /* add blog name in cart */
79 add_filter('wppizza_filter_cart_item_markup', array( $this, 'show_blogname_in_cart'), 10, 3 );
80 /* add blog name in order */
81 add_filter('wppizza_filter_order_item_markup', array( $this, 'show_blogname_in_order'), 10, 5 );
82 /* add blog name in html emails */
83 add_filter('wppizza_filter_templates_item_markup_html', array( $this, 'show_blogname_in_html_templates'), 10, 5 );
84 /* add blog name in plaintext emails */
85 add_filter('wppizza_filter_templates_item_markup_plaintext', array( $this, 'show_blogname_in_plaintext_templates'), 10, 3 );
86
87 /* add variables for print/email templates */
88 add_filter('wppizza_filter_site_details_formatted', array( $this, 'parent_site_details_formatted'), 10, 3 );
89
90 }
91 }
92
93 /*******************************************************************************************************************************************************
94 *
95 *
96 *
97 * [ filters]
98 *
99 *
100 *
101 ********************************************************************************************************************************************************/
102 /*
103 add parent site vars to formatted details
104 only runs when multisite
105 */
106 function parent_site_details_formatted($site_parameters , $order, $tpl_args = false){
107
108 /* skip if there's nothing to do in the first place */
109 if(empty($order['blog_info']) && empty($tpl_args)){
110 return $site_parameters;
111 }
112 /*
113 if we have a multisite setup , check if blog id of order is
114 multisite parent site . i.e the same.
115 If it is NOT get parent sites details
116 */
117 if(empty($tpl_args) && $order['blog_info']['blog_id'] != BLOG_ID_CURRENT_SITE){
118 $has_parent_blog = true;
119 $parent_blog = (array) get_blog_details(BLOG_ID_CURRENT_SITE);
120 }
121
122 if(!empty($has_parent_blog) || !empty($tpl_args)){
123
124 /*
125 parent site name
126 */
127 if(!empty($tpl_args)){
128 $site_parameters['parent_site_name']['template_default_sort']= 10;
129 $site_parameters['parent_site_name']['template_default_enabled']= false;
130 $site_parameters['parent_site_name']['template_parameter'] = true;
131 $site_parameters['parent_site_name']['template_row_default_css'] = '';
132 }else{
133 $site_parameters['parent_site_name']['class_ident'] = 'parent-site-name';
134 $site_parameters['parent_site_name']['value'] = $parent_blog['blogname'];
135 $site_parameters['parent_site_name']['value_formatted'] = $parent_blog['blogname'];
136 }
137 $site_parameters['parent_site_name']['label'] = __('parent site name (if different)','wppizza-admin');
138 /*
139 parent site url
140 */
141 if(!empty($tpl_args)){
142 $site_parameters['parent_site_url']['template_default_sort']= 20;
143 $site_parameters['parent_site_url']['template_default_enabled']= false;
144 $site_parameters['parent_site_url']['template_parameter'] = true;
145 $site_parameters['parent_site_url']['template_row_default_css'] = '';
146 }else{
147 $site_parameters['parent_site_url']['class_ident'] = 'parent-site-url';
148 $site_parameters['parent_site_url']['value'] = $parent_blog['siteurl'];
149 $site_parameters['parent_site_url']['value_formatted'] = $parent_blog['siteurl'];
150 }
151 $site_parameters['parent_site_url']['label'] = __('parent site url (if different)','wppizza-admin');
152 /*
153 parent site id - commented as most likely unnecessary
154 */
155 //if(!empty($tpl_args)){
156 // $site_parameters['site_id']['template_default_sort']= 30;
157 // $site_parameters['site_id']['template_default_enabled']= false;
158 // $site_parameters['site_id']['template_parameter'] = true;
159 // $site_parameters['site_id']['template_row_default_css'] = '';
160 //}else{
161 // $site_parameters['site_id']['class_ident'] = 'site-id';
162 // $site_parameters['site_id']['value'] = $parent_blog -> site_id;
163 // $site_parameters['site_id']['value_formatted'] = $parent_blog -> site_id;
164 //}
165 //$site_parameters['site_id']['label'] = __('parent site id','wppizza-admin');
166 /*
167 blog id - commented as most likely unnecessary
168 */
169 //if(!empty($tpl_args)){
170 // $site_parameters['blog_id']['template_default_sort']= 40;
171 // $site_parameters['blog_id']['template_default_enabled']= false;
172 // $site_parameters['blog_id']['template_parameter'] = true;
173 // $site_parameters['blog_id']['template_row_default_css'] = '';
174 //}else{
175 // $site_parameters['blog_id']['class_ident'] = 'blog-id';
176 // $site_parameters['blog_id']['value'] = $parent_blog -> blog_id;
177 // $site_parameters['blog_id']['value_formatted'] = $parent_blog -> blog_id;
178 //}
179 //$site_parameters['blog_id']['label'] = __('parent blog id','wppizza-admin');
180 }
181
182 return $site_parameters;
183 }
184 /*********************************************************************
185 *
186 * [markup]
187 *
188 **********************************************************************/
189 /*
190 add blogname to plaintext email markup
191 */
192 function show_blogname_in_plaintext_templates($markup_item, $key, $item){
193 global $wppizza_options;
194 /* skip if not enabled */
195 if(empty($wppizza_options[$this->layout_page]['items_group_sort_print_by_category'])){
196 return $markup_item;
197 }
198
199 if(!empty($wppizza_options[$this->layout_page]['items_blog_hierarchy'])){
200 if(isset($this -> items_keys_blog_details[$key])){
201 $prepend_blog_name = apply_filters('wppizza_filter_plaintext_line', $this -> items_keys_blog_details[$key]['blogname'], ' ', true) ;
202 $markup_item = PHP_EOL . $prepend_blog_name . $markup_item ;
203 }}
204
205 return $markup_item;
206 }
207
208
209 /*
210 add blogname to html email markup
211 */
212 function show_blogname_in_html_templates($markup_item, $key, $item, $items, $colspan){
213 global $wppizza_options;
214 /* skip if not enabled */
215 if(empty($wppizza_options[$this->layout_page]['items_group_sort_print_by_category'])){
216 return $markup_item;
217 }
218
219 if(!empty($wppizza_options[$this->layout_page]['items_blog_hierarchy'])){
220 if(isset($this -> items_keys_blog_details[$key])){
221 $style = $wppizza_options[$this->layout_page]['items_blog_hierarchy_email_style'];
222 $prepend_blog_name = '<tr class="'.WPPIZZA_SLUG.'-item-blog-'.$this -> items_keys_blog_details[$key]['blog_id'].'" class="'.WPPIZZA_SLUG.'-item-blogname"><td colspan="'.$colspan.'" style="'.$style.'">'.$this -> items_keys_blog_details[$key]['blogname'].'</td></tr>';
223 array_unshift($markup_item, $prepend_blog_name);
224 }}
225
226 return $markup_item;
227 }
228
229
230 /*
231 add blogname to order markup (checkout page, confirmation page, thank you page, users order history)
232 */
233 function show_blogname_in_order($markup_item, $key, $item, $cart, $colspan ){
234 global $wppizza_options;
235 /* skip if not enabled */
236 if(empty($wppizza_options[$this->layout_page]['items_group_sort_print_by_category'])){
237 return $markup_item;
238 }
239
240 if(!empty($wppizza_options[$this->layout_page]['items_blog_hierarchy'])){
241 if(isset($this -> items_keys_blog_details[$key])){
242 $prepend_blog_name = '<tr><td id="'.WPPIZZA_SLUG.'-item-blog-'.$this -> items_keys_blog_details[$key]['blog_id'].'" class="'.WPPIZZA_SLUG.'-item-blogname" colspan="'.$colspan.'">'.$this -> items_keys_blog_details[$key]['blogname'].'</td></tr>';
243 array_unshift($markup_item, $prepend_blog_name);
244 }}
245
246 return $markup_item;
247 }
248
249
250 /*
251 add blogname to cart markup
252 */
253 function show_blogname_in_cart($markup_item, $key, $item){
254 global $wppizza_options;
255
256 /* skip if not enabled */
257 if(empty($wppizza_options[$this->layout_page]['items_group_sort_print_by_category'])){
258 return $markup_item;
259 }
260
261 if(!empty($wppizza_options[$this->layout_page]['items_blog_hierarchy_cart'])){
262 if(isset($this -> items_keys_blog_details[$key])){
263 $prepend_blog_name = '<li class="'.WPPIZZA_SLUG.'-item-blog-'.$this -> items_keys_blog_details[$key]['blog_id'].'" class="'.WPPIZZA_SLUG.'-item-blogname">'.$this -> items_keys_blog_details[$key]['blogname'].'</li>';
264 array_unshift($markup_item, $prepend_blog_name);
265 }}
266
267 return $markup_item;
268 }
269
270
271
272 /*********************************************************************
273 *
274 * [add get item keys that should have blogname added before them (will automatically be before category too if displayed)]
275 *
276 **********************************************************************/
277 function get_blogname_for_cart_email_order($items){
278 static $run_once = 0; $run_once++;
279 if($run_once>1){return $items;}
280
281 global $wppizza_options;
282 /* skip if not enabled */
283 if(empty($wppizza_options[$this->layout_page]['items_group_sort_print_by_category'])){
284 return $items;
285 }
286
287 $add_blog_details = array();
288 foreach($items as $key => $item){
289 $item_blog_id = $item['blog_id'];
290 if(!isset($do_blog_name[$item_blog_id])){
291 $do_blog_name[$item_blog_id] = true;
292 $add_blog_details[$key] = WPPIZZA() -> helpers -> wppizza_blog_details($item_blog_id);
293 //$add_blog_name[$key] = array('blog_id' => $item_blog_id, 'blog_name' => $blog_details->blogname );
294 }
295 }
296
297 /* all menu item keys as keys that need blog name displayed */
298 $this -> items_keys_blog_details = $add_blog_details;
299
300 return $items;
301 }
302
303
304
305 /*
306 sessions per site ? default true. i.e WPPIZZA_SLUG_'.$blog_id.'
307 */
308 function sessions_per_site($session_key){
309 global $blog_id, $wppizza_options;
310
311 if(!is_multisite()){
312 return $session_key;
313 }
314 /**
315 always get settings from parent blog for this if it's not already parent anyway
316 **/
317 if($blog_id != BLOG_ID_CURRENT_SITE){
318 switch_to_blog(BLOG_ID_CURRENT_SITE);
319 /* get option from main parent blog */
320 $blog_options = get_option(WPPIZZA_SLUG);
321
322 /*
323 if wppizza not activated in parent / master site to start off with, use default
324 */
325
326 /*
327 is_plugin_active only exists in admin, so lets simply recreate it, checking if plugin is active in master site
328 */
329 $wppizza_master_active = in_array( WPPIZZA_PLUGIN_INDEX, (array) get_option( 'active_plugins', array() ) );
330 if(!isset($blog_options[$this->settings_page]['wp_multisite_session_per_site']) || !$wppizza_master_active){
331 $session_key = $session_key ;
332 }else{
333 if(empty($blog_options[$this->settings_page]['wp_multisite_session_per_site'])){
334 $session_key = WPPIZZA_SLUG;
335 }
336 }
337 restore_current_blog();
338 }else{
339 if(empty($wppizza_options[$this->settings_page]['wp_multisite_session_per_site'])){
340 $session_key = WPPIZZA_SLUG;
341 }
342 }
343 return $session_key;
344 }
345
346 /*************************************
347
348 query db - admin history - from all sites (parent sie only)
349
350 **************************************/
351 function order_history_all_sites($bool){
352 global $wppizza_options, $blog_id;
353 $bool = ( is_multisite() && $blog_id==BLOG_ID_CURRENT_SITE && !empty($wppizza_options[$this->settings_page]['wp_multisite_order_history_all_sites'])) ? true : false;
354 return $bool;
355 }
356 /*************************************
357
358 query db - admin history from all sites (parent sie only)
359
360 **************************************/
361 function reports_all_sites($bool){
362 global $wppizza_options, $blog_id;
363 $bool = ( is_multisite() && $blog_id==BLOG_ID_CURRENT_SITE && !empty($wppizza_options[$this->settings_page]['wp_multisite_reports_all_sites'])) ? true : false;
364 return $bool;
365 }
366
367
368 /*******************************************************************************************************************************************************
369 *
370 *
371 *
372 * [add admin page options]
373 *
374 *
375 *
376 ********************************************************************************************************************************************************/
377
378 /*------------------------------------------------------------------------------
379 #
380 #
381 # [settings page]
382 #
383 #
384 ------------------------------------------------------------------------------*/
385
386 /*------------------------------------------------------------------------------
387 # [settings section - setting page]
388 # @since 3.0
389 # @return array()
390 ------------------------------------------------------------------------------*/
391 function admin_options_settings($settings, $sections, $fields, $inputs, $help){
392 global $blog_id;
393 /* in multisite setup and parentsite only */
394 if(is_multisite() && $blog_id==BLOG_ID_CURRENT_SITE){
395 /*section*/
396 if($sections){
397 $settings['sections'][$this->section_key] = __('Multisite', 'wppizza-admin');
398 }
399 /*help*/
400 if($help){
401 $settings['help'][$this->section_key][] = array(
402 'label'=>__('Multisite environment', 'wppizza-admin'),
403 'description'=>array(
404 __('Several options are available in a multisite environment that will allow you to - for example - administer and/or view certain aspects of all sites in the parent site.', 'wppizza-admin'),
405 __('Please adjust settings as appropriate according to the information provided next to each individual option.', 'wppizza-admin')
406 )
407 );
408 }
409
410 /*fields*/
411 if($fields){
412
413 $field = 'wp_multisite_session_per_site';
414 $settings['fields'][$this->section_key][$field] = array( __('Cart - per (sub)site', 'wppizza-admin'), array(
415 'value_key'=>$field,
416 'option_key'=>$this->settings_page,
417 'label'=>__('Sets cart contents / order on a per site basis when using subdirectories. Turning this off has no effect/relevance when using different domains per site on the network (it will alwasy be per site in that case). You probably want this *on* when you have a multisite/network install.', 'wppizza-admin'),
418 'description'=>array(
419 '<span class="wppizza-highlight">'.__('THERE ARE ONLY VERY FEW SECENARIOS WHERE YOU MIGHT WANT THIS OFF', 'wppizza-admin').'</span>'
420 )
421 ));
422
423 $field = 'wp_multisite_order_history_all_sites';
424 $settings['fields'][$this->section_key][$field] = array( __('Orders/Customers (Admin) - all subsites', 'wppizza-admin'), array(
425 'value_key'=>$field,
426 'option_key'=>$this->settings_page,
427 /* Translators: 1,2: WPPizza Name as defined by constant */
428 'label'=>sprintf(__('check to have order history/customers to use all orders/customers of all child sites (%1$s -> Order History / %2$s -> Customers ) ', 'wppizza-admin'), WPPIZZA_NAME, WPPIZZA_NAME),
429 'description'=>array(
430 '<span class="wppizza-highlight">'.__('NOTE: THIS MIGHT SLOW THINGS DOWN IN THE ADMIN ORDER HISTORY PAGE OF YOUR MAIN/PARENT SITE CONSIDERABLY', 'wppizza-admin').'</span>'
431 )
432 ));
433
434 $field = 'wp_multisite_reports_all_sites';
435 $settings['fields'][$this->section_key][$field] = array( __('Reports (Admin) - all subsites', 'wppizza-admin'), array(
436 'value_key'=>$field,
437 'option_key'=>$this->settings_page,
438 /* Translators: 1: WPPizza Name as defined by constant */
439 'label'=>sprintf(__('check to have reporting - including dashboard widget - to use all orders of all child sites (%s -> Reports)', 'wppizza-admin'), WPPIZZA_NAME),
440 'description'=>array(
441 '<span class="wppizza-highlight">'.__('NOTE: THIS MIGHT SLOW THINGS DOWN IN THE ADMIN ORDER HISTORY PAGE OF YOUR MAIN/PARENT SITE CONSIDERABLY', 'wppizza-admin').'</span>'
442 )
443 ));
444
445 }
446 }
447
448 return $settings;
449 }
450 /*------------------------------------------------------------------------------
451 # [output option fields - setting page]
452 # @since 3.0
453 # @return array()
454 ------------------------------------------------------------------------------*/
455 function admin_options_fields_settings($wppizza_options, $options_key, $field, $label, $description){
456
457 if($field=='wp_multisite_session_per_site'){
458 echo "<label>";
459 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
460 echo "" . $label . "";
461 echo "</label>";
462 echo"".$description."";
463 }
464
465 if($field=='wp_multisite_reports_all_sites'){
466 echo "<label>";
467 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
468 echo "" . $label . "";
469 echo "</label>";
470 echo"".$description."";
471 }
472
473 if($field=='wp_multisite_order_history_all_sites'){
474 echo "<label>";
475 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
476 echo "" . $label . "";
477 echo "</label>";
478 echo"".$description."";
479 }
480 }
481
482 /*------------------------------------------------------------------------------
483 #
484 #
485 # [layout page]
486 #
487 #
488 ------------------------------------------------------------------------------*/
489 /****************************************************************
490 * [settigs section - layout page]
491 * @since 3.0
492 * @return array()
493 ****************************************************************/
494 function admin_options_layout($settings, $sections, $fields, $inputs, $help){
495 global $wppizza_options;
496
497 /*skip section as we are adding to the "Items Sorting and Category Display" */
498
499 /*fields*/
500 if($fields){
501 $add_settings = array();
502
503 $field = 'items_blog_hierarchy';
504 $add_settings['fields'][$this->layout_section][$field] = array( __('Blogname display in order pages and emails', 'wppizza-admin'), array(
505 'value_key'=>$field,
506 'option_key'=>$this->layout_page,
507 'label'=>__('Enable to also sort by and show blogname additionally to categories in order pages and emails', 'wppizza-admin'),
508 'description'=>array()
509 ));
510
511 $field = 'items_blog_hierarchy_cart';
512 $add_settings['fields'][$this->layout_section][$field] = array( __('Blogname display in cart', 'wppizza-admin'), array(
513 'value_key'=>$field,
514 'option_key'=>$this->layout_page,
515 'label'=>__('Enable to also sort by and show blogname additionally to categories in cart', 'wppizza-admin'),
516 'description'=>array()
517 ));
518
519 $field = 'items_blog_hierarchy_email_style';
520 $add_settings['fields'][$this->layout_section][$field] = array( __('Blogname style in html emails', 'wppizza-admin'), array(
521 'value_key'=>$field,
522 'option_key'=>$this->layout_page,
523 'label'=>__('Some email services do not understand (or delete) css declarations, therefore please enter the distinct style declarations here', 'wppizza-admin'),
524 'description'=>array()
525 ));
526
527 }
528
529 /*
530 splice fields into the required position on admin layout page
531 */
532 if(!empty($add_settings)){
533 if($fields){
534 $settings['fields'][$this->layout_section] = wppizza_array_splice(
535 $settings['fields'][$this->layout_section],
536 $add_settings['fields'][$this->layout_section],
537 /* array keys here are the keys after which the above settings will be inserted - there must be as many keys as there are $add_settings*/
538 array('items_category_hierarchy','items_category_hierarchy_cart','items_category_hierarchy_email_style'),
539 true
540 );
541 }
542 }
543
544 return $settings;
545 }
546 /****************************************************************
547 * [output option fields - layout page]
548 * @since 3.0
549 * @return array()
550 ****************************************************************/
551 function admin_options_fields_layout($wppizza_options, $options_key, $field, $label, $description){
552
553 if($field=='items_blog_hierarchy'){
554 print'<label>';
555 print "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
556 print'' . $label . '';
557 print'</label>';
558 print'' . $description . '';
559 }
560
561 if($field=='items_blog_hierarchy_cart'){
562 print'<label>';
563 print "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
564 print'' . $label . '';
565 print'</label>';
566 print'' . $description . '';
567 }
568
569 if($field=='items_blog_hierarchy_email_style'){
570 print'<label>';
571 echo "<input name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' size='75' type='text' value='".$wppizza_options[$options_key][$field]."' />";
572 print'' . $label . '';
573 print'</label>';
574 print'' . $description . '';
575
576 }
577
578 }
579
580
581
582
583 /*------------------------------------------------------------------------------
584 # [insert default option on install]
585 # $parameter $options array() | filter passing on filtered options
586 # @since 3.0
587 # @return array()
588 ------------------------------------------------------------------------------*/
589 function options_default($options){
590 /* settings page */
591 $options[$this->settings_page]['wp_multisite_session_per_site'] = true;
592 $options[$this->settings_page]['wp_multisite_reports_all_sites'] = false;
593 $options[$this->settings_page]['wp_multisite_order_history_all_sites'] = false;
594 /* layout page */
595 $options[$this->layout_page]['items_blog_hierarchy'] = false;
596 $options[$this->layout_page]['items_blog_hierarchy_cart'] = false;
597 $options[$this->layout_page]['items_blog_hierarchy_email_style'] = 'text-align:center;padding:12px 2px 7px 2px;font-size:110%; font-weight:bold';
598 return $options;
599 }
600
601 /*------------------------------------------------------------------------------
602 # [validate options on save/update]
603 #
604 # @since 3.0
605 # @return array()
606 ------------------------------------------------------------------------------*/
607 function options_validate($options, $input){
608
609 /**make sure we get the full array on install/update**/
610 if ( empty( $_POST['_wp_http_referer'] ) ) {
611 return $input;
612 }
613
614
615 /*
616 settings
617 */
618 if(isset($_POST[''.WPPIZZA_SLUG.'_'.$this->settings_page.''])){
619 global $blog_id;
620
621 /*if not multisite or not parent site save/use defaults*/
622 if(!is_multisite() || $blog_id != BLOG_ID_CURRENT_SITE){
623 $options[$this->settings_page]['wp_multisite_session_per_site'] = true;
624 $options[$this->settings_page]['wp_multisite_reports_all_sites'] =false;
625 $options[$this->settings_page]['wp_multisite_order_history_all_sites'] =false;
626 //$options[$this->settings_page]['wp_multisite_order_history_print'] = array('header_from_child'=>false,'multisite_info'=>false);
627 }else{
628 $options[$this->settings_page]['wp_multisite_session_per_site'] = !empty($input[$this->settings_page]['wp_multisite_session_per_site']) ? true : false;
629 $options[$this->settings_page]['wp_multisite_reports_all_sites'] = !empty($input[$this->settings_page]['wp_multisite_reports_all_sites']) ? true : false;
630 $options[$this->settings_page]['wp_multisite_order_history_all_sites'] = !empty($input[$this->settings_page]['wp_multisite_order_history_all_sites']) ? true : false;
631
632 /**as we might have enabled or disabled wp_multisite_reports_all_sites , clear transient*/
633 delete_transient( WPPIZZA_TRANSIENT_REPORTS_NAME.'_'.WPPIZZA_ADMIN_DASHBOARD_TRANSIENT_REPORTS_EXPIRY.'' );
634 }
635 }
636
637 /*
638 layout
639 */
640 if(isset($_POST[''.WPPIZZA_SLUG.'_'.$this->layout_page.''])){
641
642 $options[$this->layout_page]['items_blog_hierarchy'] = ( !empty($input[$this->layout_page]['items_blog_hierarchy']) && is_multisite() ) ? true : false;
643 $options[$this->layout_page]['items_blog_hierarchy_cart'] = ( !empty($input[$this->layout_page]['items_blog_hierarchy_cart']) && is_multisite() ) ? true : false;
644 /* only actually overwrite if multisite otherwise keep what we have as the input will not exist in non ms environments*/
645 if(is_multisite()){
646 $options[$this->layout_page]['items_blog_hierarchy_email_style']= wppizza_validate_string($input[$this->layout_page]['items_blog_hierarchy_email_style']);
647 }
648 }
649
650 return $options;
651 }
652 }
653 /***************************************************************
654 *
655 * [ini]
656 *
657 ***************************************************************/
658 $WPPIZZA_MODULE_SETTINGS_MULTISITE = new WPPIZZA_MODULE_SETTINGS_MULTISITE();
659 ?>