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.layout.style.php

mod.layout.style.php in WPPizza – A Restaurant Plugin 3.20, at classes/modules/mod.layout.style.php

248 lines 10.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPPIZZA_MODULE_LAYOUT_STYLE Class
4 *
5 * @package WPPIZZA
6 * @subpackage WPPIZZA_MODULE_LAYOUT_STYLE
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_LAYOUT_STYLE{
24
25 private $settings_page = 'layout';/* which admin subpage (identified there by this->class_key) are we adding this to */
26
27 private $section_key = 'style';/* 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'), 20, 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 * [frontend filters]
51 *
52 *
53 *
54 ********************************************************************************************************************************************************/
55
56
57
58 /*******************************************************************************************************************************************************
59 *
60 *
61 *
62 * [add admin page options]
63 *
64 *
65 *
66 ********************************************************************************************************************************************************/
67
68 /*------------------------------------------------------------------------------
69 #
70 #
71 # [settings page]
72 #
73 #
74 ------------------------------------------------------------------------------*/
75
76 /*------------------------------------------------------------------------------
77 # [settings section - setting page]
78 # @since 3.0
79 # @return array()
80 ------------------------------------------------------------------------------*/
81 function admin_options_settings($settings, $sections, $fields, $inputs, $help){
82
83 /*section*/
84 if($sections){
85 $settings['sections'][$this->section_key] = __('Style', 'wppizza-admin');
86 }
87 /*fields*/
88 if($fields){
89
90 $field = 'include_css';
91 $settings['fields'][$this->section_key][$field] = array( __('Include CSS / Stylesheet', 'wppizza-admin') , array(
92 'value_key'=>$field,
93 'option_key'=>$this->settings_page,
94 'label'=>__('Include frontend css that came with this plugin (untick if you want to provide your own styles somewhere else)', 'wppizza-admin'),
95 'description'=>array()
96 ));
97
98 $field = 'style';
99 $settings['fields'][$this->section_key][$field] = array( __('Which style to use (if enabled above)', 'wppizza-admin'), array(
100 'value_key'=>$field,
101 'option_key'=>$this->settings_page,
102 'label'=>'',
103 'description'=>array()
104 ));
105
106 $field = 'load_additional_styles';
107 $settings['fields'][$this->section_key][$field] = array( __('Load additional styles', 'wppizza-admin') , array(
108 'value_key'=>$field,
109 'option_key'=>$this->settings_page,
110 'label'=>'',
111 'description'=>array(__('If you are using more than just the one style selected above in your shortcodes, enable the additional stylesheets here', 'wppizza-admin'))
112 ));
113
114 $field = 'css_priority';
115 $settings['fields'][$this->section_key][$field] = array( __('Stylesheet Priority', 'wppizza-admin') , array(
116 'value_key'=>$field,
117 'option_key'=>$this->settings_page,
118 'label'=>__('By default, the stylesheet will be loaded AFTER the main theme stylesheet (which should have a priority of "10"). If you experience strange behaviour or layout issues (in conjunction with other plugins for example), you can try adjusting this priority here (the bigger the number, the later it gets loaded).', 'wppizza-admin'),
119 'description'=>array()
120 ));
121 }
122
123 /*help*/
124 if($help){
125 $settings['help'][$this->section_key][] = array(
126 'label'=>__('Style', 'wppizza-admin'),
127 'description'=>array(
128 __('Choose from one of the styles for your layout of menu items in the frontend. Make sure "Include CSS / Stylesheet" is enabled.', 'wppizza-admin'),
129 __('If you choose a grid layout, some more layout options will become available.', 'wppizza-admin')
130 )
131 );
132 }
133
134
135 return $settings;
136 }
137 /*------------------------------------------------------------------------------
138 # [output option fields - setting page]
139 # @since 3.0
140 # @return array()
141 ------------------------------------------------------------------------------*/
142 function admin_options_fields_settings($wppizza_options, $options_key, $field, $label, $description){
143
144 if($field=='style'){
145 print'<label>';
146 echo "<select id='".WPPIZZA_SLUG."_".$options_key."_".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' />";
147 foreach(wppizza_public_styles($wppizza_options[$options_key][$field]) as $k=>$v){
148 echo"<option value='".$v['id']."' ".$v['selected'].">".$v['value']."</option>";
149 }
150 echo "</select>";
151 print'' . $label . '';
152 print'</label>';
153 print'' . $description . '';
154
155 /**grid options**/
156 $gridOptionsShow=($wppizza_options[$options_key][$field]=='grid') ? 'block' : 'none' ;
157
158 echo"<div id='".WPPIZZA_SLUG."-".$field."-grid' style='display:".$gridOptionsShow."'>";
159 echo "<input id='' name='".WPPIZZA_SLUG."[".$options_key."][style_grid_columns]' size='4' type='text' value='".$wppizza_options[$options_key]['style_grid_columns']."' />";
160 echo" ".__('How many columns per row [minimum 1]', 'wppizza-admin')."";
161 echo"<br />";
162 echo "<input id='' name='".WPPIZZA_SLUG."[".$options_key."][style_grid_margins]' size='4' type='text' value='".$wppizza_options[$options_key]['style_grid_margins']."' />";
163 echo" ".__('margins between columns [in %]', 'wppizza-admin')."";
164 echo"<br />";
165 echo "<input id='' name='".WPPIZZA_SLUG."[".$options_key."][style_grid_full_width]' size='4' type='text' value='".$wppizza_options[$options_key]['style_grid_full_width']."' />";
166 echo" ".__('maximum browser width for layout to revert to 1 column per row [in px] - (for mobile / small screen devices)', 'wppizza-admin')."";
167 echo"<br /><br />";
168 echo" <span class='description' >".__('you will probably have to tweak the above to work with your theme and/or add some custom css. make sure to check things with different browsers', 'wppizza-admin')."</span>";
169 echo"</div>";
170 }
171
172 if($field=='include_css'){
173 print'<label>';
174 print "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
175 print'' . $label . '';
176 print'</label>';
177 print'' . $description . '';
178 }
179 if($field=='load_additional_styles'){
180 print'<label>';
181 foreach(wppizza_public_styles() as $style){
182 print "<label><input id='".$field."".$style['id']."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."][".$style['id']."]' type='checkbox' ". checked(isset($wppizza_options[$options_key][$field][$style['id']]),true,false)." value='1' />".$style['value']."</label>";
183 }
184 print'' . $label . '';
185 print'</label>';
186 print'' . $description . '';
187 }
188 if($field=='css_priority'){
189 print'<label>';
190 print "<input name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' size='2' type='text' value='".$wppizza_options[$options_key][$field]."' />";
191 print'' . $label . '';
192 print'</label>';
193 print'' . $description . '';
194 }
195 }
196
197 /****************************************************************
198 *
199 * [insert default option on install]
200 * $parameter $options array() | filter passing on filtered options
201 * @since 3.0
202 * @return array()
203 *
204 ****************************************************************/
205 function options_default($options){
206
207 $options[$this->settings_page]['style'] = 'default';
208 $options[$this->settings_page]['style_grid_columns'] = 3;
209 $options[$this->settings_page]['style_grid_margins'] = 1.5;
210 $options[$this->settings_page]['style_grid_full_width'] = 480;
211 $options[$this->settings_page]['include_css'] = true;
212 $options[$this->settings_page]['load_additional_styles'] = array();
213 $options[$this->settings_page]['css_priority'] = 11;
214
215 return $options;
216 }
217
218 /*------------------------------------------------------------------------------
219 # [validate options on save/update]
220 #
221 # @since 3.0
222 # @return array()
223 ------------------------------------------------------------------------------*/
224 function options_validate($options, $input){
225 /**make sure we get the full array on install/update**/
226 if ( empty( $_POST['_wp_http_referer'] ) ) {
227 return $input;
228 }
229 if(isset($_POST[''.WPPIZZA_SLUG.'_'.$this->settings_page.''])){
230 $options[$this->settings_page]['style'] = wppizza_validate_alpha_only($input[$this->settings_page]['style']);
231 $options[$this->settings_page]['style_grid_columns'] = ((int)$input[$this->settings_page]['style_grid_columns']>0) ? (int)$input[$this->settings_page]['style_grid_columns'] : 1;
232 $options[$this->settings_page]['style_grid_margins'] = (float)$input[$this->settings_page]['style_grid_margins'];
233 $options[$this->settings_page]['style_grid_full_width'] = ((int)$input[$this->settings_page]['style_grid_full_width']>0) ? (int)$input[$this->settings_page]['style_grid_full_width'] : 480;
234 $options[$this->settings_page]['include_css'] = !empty($input[$this->settings_page]['include_css']) ? true : false;
235 $options[$this->settings_page]['load_additional_styles'] = !empty($input[$this->settings_page]['load_additional_styles']) ? wppizza_validate_array($input[$this->settings_page]['load_additional_styles']) : array();
236 $options[$this->settings_page]['css_priority'] = wppizza_validate_int_only($input[$this->settings_page]['css_priority']);
237 }
238
239 return $options;
240 }
241 }
242 /***************************************************************
243 *
244 * [ini]
245 *
246 ***************************************************************/
247 $WPPIZZA_MODULE_LAYOUT_STYLE = new WPPIZZA_MODULE_LAYOUT_STYLE();
248 ?>