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.access_rights.access.php

mod.access_rights.access.php in WPPizza – A Restaurant Plugin 3.20, at classes/modules/mod.access_rights.access.php

157 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPPIZZA_MODULE_ACCESSRIGHTS_ACCESS Class
4 *
5 * @package WPPIZZA
6 * @subpackage WPPIZZA_MODULE_ACCESSRIGHTS_ACCESS
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_ACCESSRIGHTS_ACCESS{
24
25 private $settings_page = 'access_rights';/* which admin subpage (identified there by this->class_key) are we adding this to */
26 private $section_key = 'access';/* must be unique */
27 private $module_priority = 10;/* display order (priority) of settings in subpage */
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'), $this->module_priority, 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 /**validate options**/
40 add_filter('wppizza_filter_options_validate', array( $this, 'options_validate'), 10, 2 );
41 }
42 }
43
44 /*******************************************************************************************************************************************************
45 *
46 *
47 *
48 * [frontend filters]
49 *
50 *
51 *
52 ********************************************************************************************************************************************************/
53
54 /*******************************************************************************************************************************************************
55 *
56 *
57 *
58 * [add admin page options]
59 *
60 *
61 *
62 ********************************************************************************************************************************************************/
63
64 /*------------------------------------------------------------------------------
65 #
66 #
67 # [settings page]
68 #
69 #
70 ------------------------------------------------------------------------------*/
71
72 /*------------------------------------------------------------------------------
73 # [settings section - setting page]
74 # @since 3.0
75 # @return array()
76 ------------------------------------------------------------------------------*/
77 function admin_options_settings($settings, $sections, $fields, $inputs, $help){
78
79 /*section*/
80 if($sections){
81 $settings['sections'][$this->section_key] = __('Access Permissions', 'wppizza-admin');
82 }
83 /*help*/
84 if($help){
85 $settings['help'][$this->section_key][] = array(
86 'label'=>__('Access Permissions', 'wppizza-admin'),
87 'description'=>array(
88 __('Enable user roles that are allowed to access the available plugin pages', 'wppizza-admin')
89 )
90 );
91 }
92 /*fields*/
93 if($fields){
94 $field = 'show_admin_access_capabilities';
95 $settings['fields'][$this->section_key][$field] = array( '', array(
96 'value_key'=>$field,
97 'option_key'=>$this->settings_page,
98 'label'=>'',
99 'description'=>array()
100 ));
101 }
102
103 return $settings;
104 }
105 /*------------------------------------------------------------------------------
106 # [output option fields - setting page]
107 # @since 3.0
108 # @return array()
109 ------------------------------------------------------------------------------*/
110 function admin_options_fields_settings($wppizza_options, $options_key, $field, $label, $description){
111 if($field=='show_admin_access_capabilities'){
112 /* echo access capabilities */
113 WPPIZZA()-> user_caps -> user_echo_admin_caps($field, WPPIZZA_SLUG, false, $this->section_key);
114 }
115 }
116 /*------------------------------------------------------------------------------
117 # [insert default option on install]
118 # $parameter $options array() | filter passing on filtered options
119 # @since 3.0
120 # @return array()
121 ------------------------------------------------------------------------------*/
122 // function options_default($options){
123 //
124 // //$options[$this->settings_page]['close_shop_now']=false;
125 //
126 // return $options;
127 // }
128
129 /*------------------------------------------------------------------------------
130 # [validate options on save/update]
131 #
132 # @since 3.0
133 # @return array()
134 ------------------------------------------------------------------------------*/
135 function options_validate($options, $input){
136 /**make sure we get the full array on install/update**/
137 if ( empty( $_POST['_wp_http_referer'] ) ) {
138 return $input;
139 }
140 /********************************
141 * [validate]
142 ********************************/
143 if(isset($_POST[''.WPPIZZA_SLUG.'_'.$this->settings_page.''])){
144 /* update available page capabilties */
145 $caps = WPPIZZA() -> user_caps -> user_caps_update($input[$this->section_key]);
146 $options[key($caps)] = $caps[key($caps)];
147 }
148 return $options;
149 }
150 }
151 /***************************************************************
152 *
153 * [ini]
154 *
155 ***************************************************************/
156 $WPPIZZA_MODULE_ACCESSRIGHTS_ACCESS = new WPPIZZA_MODULE_ACCESSRIGHTS_ACCESS();
157 ?>