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.general.php

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

239 lines 9.2 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_GENERAL Class
4 *
5 * @package WPPIZZA
6 * @subpackage WPPIZZA_MODULE_LAYOUT_GENERAL
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_GENERAL{
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 = 'general';/* 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'), 10, 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] = __('General', 'wppizza-admin');
86 }
87 /*fields*/
88 if($fields){
89 $field = 'items_per_loop';
90 $settings['fields'][$this->section_key][$field] = array( __('Menu Items per page', 'wppizza-admin') , array(
91 'value_key'=>$field,
92 'option_key'=>$this->settings_page,
93 'label'=> __('how many menu items per category page (displays pagination, if there are more menu items for the selected category)[options: -1=all, >1=items per page]', 'wppizza-admin'),
94 'description'=>array(
95 '<span class="wppizza-highlight">'.__('if not set to -1, it must be >= wordpress settings->reading->Blog pages show at most', 'wppizza-admin').'</span>'
96 )
97 ));
98 $field = 'apply_menu_items_content_filter';
99 $settings['fields'][$this->section_key][$field] = array( __('Shortodes in menu items content', 'wppizza-admin') , array(
100 'value_key'=>$field,
101 'option_key'=>$this->settings_page,
102 'label'=> __('Allow shortcodes / content filters to be processed in menu item content fields', 'wppizza-admin'),
103 'description'=>array(
104 __('This will also change the wrapping "p" element to a "div" instead ', 'wppizza-admin')
105 )
106 ));
107 $field = 'allow_read_more_link';
108 $settings['fields'][$this->section_key][$field] = array( __('Enable "Read More" tag in menu items content', 'wppizza-admin') , array(
109 'value_key'=>$field,
110 'option_key'=>$this->settings_page,
111 'label'=> __('Allow insertion of "Read More" tag in menu item content fields', 'wppizza-admin'),
112 'description'=>array(
113 /* Translators: 1: Url/Link to documentation */
114 '<span class="wppizza-highlight">'.sprintf(__('In most cases, this will link to the single menu item, so you probably also want to set up the single item pages as <a href="%s">described here</a> if you insert this link into the content.', 'wppizza-admin'), 'https://docs.wp-pizza.com/developers/?section=wppizza-markup-single-single-php').'</span>'
115 )
116 ));
117 $field = 'disable_online_order';
118 $settings['fields'][$this->section_key][$field] = array( __('Completely disable online orders', 'wppizza-admin'), array(
119 'value_key'=>$field,
120 'option_key'=>$this->settings_page,
121 'label'=>__('Useful if you want to display your menu and prices but without offering online orders.', 'wppizza-admin'),
122 'description'=>array(
123 '<span class="wppizza-highlight">'.__('this will still display prices (unless set to be hidden), but will disable shoppingcart and orderpage', 'wppizza-admin').'</span>',
124 )
125 ));
126 }
127
128
129 return $settings;
130 }
131 /*------------------------------------------------------------------------------
132 # [output option fields - setting page]
133 # @since 3.0
134 # @return array()
135 ------------------------------------------------------------------------------*/
136 function admin_options_fields_settings($wppizza_options, $options_key, $field, $label, $description){
137
138 if($field=='items_per_loop'){
139 print'<label>';
140 print "<input name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' size='2' type='text' value='".$wppizza_options[$options_key][$field]."' />";
141 print'' . $label . '';
142 print'</label>';
143 print'' . $description . '';
144 }
145
146 if($field=='disable_online_order'){
147 print'<label>';
148 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
149 print'' . $label . '';
150 print'</label>';
151 print'' . $description . '';
152 }
153
154 if($field=='apply_menu_items_content_filter'){
155 print'<label>';
156 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
157 print'' . $label . '';
158 print'</label>';
159 print'' . $description . '';
160 }
161
162 if($field=='allow_read_more_link'){
163 print'<label>';
164 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
165 print'' . $label . '';
166 print'</label>';
167 print'' . $description . '';
168 }
169
170 }
171
172 /****************************************************************
173 *
174 * [insert default option on install]
175 * $parameter $options array() | filter passing on filtered options
176 * @since 3.0
177 * @return array()
178 *
179 ****************************************************************/
180 function options_default($options){
181
182 $options[$this->settings_page]['items_per_loop'] = '-1';
183 $options[$this->settings_page]['disable_online_order'] = false;
184 $options[$this->settings_page]['apply_menu_items_content_filter'] = false;
185 $options[$this->settings_page]['allow_read_more_link'] = false;
186
187 return $options;
188 }
189
190 /*------------------------------------------------------------------------------
191 # [validate options on save/update]
192 #
193 # @since 3.0
194 # @return array()
195 ------------------------------------------------------------------------------*/
196 function options_validate($options, $input){
197 /**make sure we get the full array on install/update**/
198 if ( empty( $_POST['_wp_http_referer'] ) ) {
199 return $input;
200 }
201 /********************************
202 * [validate]
203 ********************************/
204 if(isset($_POST[''.WPPIZZA_SLUG.'_'.$this->settings_page.''])){
205
206 /*set number of items per loop. must be >= get_option('posts_per_page ')*/
207 /*if minus=>set to -1**/
208 if(substr($input[$this->settings_page]['items_per_loop'],0,1)=='-'){
209 $set='-1';
210 }else{/*else mk int**/
211
212 $ppp = get_option('posts_per_page ');
213
214 if((int)$input[$this->settings_page]['items_per_loop'] >= $ppp){
215 $set= (int)$input[$this->settings_page]['items_per_loop'];
216 }else{
217 $set= $ppp;
218 }
219 }
220 $options[$this->settings_page]['items_per_loop'] = $set;
221
222 $options[$this->settings_page]['disable_online_order'] = !empty($input[$this->settings_page]['disable_online_order']) ? true : false;
223
224 $options[$this->settings_page]['apply_menu_items_content_filter'] = !empty($input[$this->settings_page]['apply_menu_items_content_filter']) ? true : false;
225
226 $options[$this->settings_page]['allow_read_more_link'] = !empty($input[$this->settings_page]['allow_read_more_link']) ? true : false;
227
228 }
229
230 return $options;
231 }
232 }
233 /***************************************************************
234 *
235 * [ini]
236 *
237 ***************************************************************/
238 $WPPIZZA_MODULE_LAYOUT_GENERAL = new WPPIZZA_MODULE_LAYOUT_GENERAL();
239 ?>