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

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

258 lines 10.1 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_IMAGES Class
4 *
5 * @package WPPIZZA
6 * @subpackage WPPIZZA_MODULE_LAYOUT_IMAGES
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_IMAGES{
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 = 'images';/* 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'), 60, 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] = __('Menu Item Images', 'wppizza-admin');
86 }
87
88 /*help*/
89 if($help){
90 $settings['help'][$this->section_key][] = array(
91 'label'=>__('Menu Item Images', 'wppizza-admin'),
92 'description'=>array(
93 __('Set menu item image options according to the settings available', 'wppizza-admin')
94 )
95 );
96 }
97
98 /*fields*/
99 if($fields){
100
101 $field = 'placeholder_img';
102 $settings['fields'][$this->section_key][$field] = array( __('Display placeholder image', 'wppizza-admin') , array(
103 'value_key'=>$field,
104 'option_key'=>$this->settings_page,
105 'label'=>__('Display a placeholder image when no featured image has been associated with a meal item', 'wppizza-admin'),
106 'description'=>array()
107 ));
108 $field = 'prettyPhoto';
109 $settings['fields'][$this->section_key][$field] = array( __('Enable prettyPhoto', 'wppizza-admin') , array(
110 'value_key'=>$field,
111 'option_key'=>$this->settings_page,
112 'label'=>__('Enable prettyPhoto (Lightbox Clone) on menu item images', 'wppizza-admin'),
113 'description'=>array()
114 ));
115
116 $field = 'prettyPhotoStyle';
117 $settings['fields'][$this->section_key][$field] = array( __('Set prettyPhoto Style', 'wppizza-admin') , array(
118 'value_key'=>$field,
119 'option_key'=>$this->settings_page,
120 'label'=>__('see prettyPhoto.custom.js if you would like to adjust prettyPhoto options', 'wppizza-admin'),
121 'description'=>array()
122 ));
123
124 $field = 'cart_image';
125 $settings['fields'][$this->section_key][$field] = array( __('Thumbnail on checkout', 'wppizza-admin') , array(
126 'value_key'=>$field,
127 'option_key'=>$this->settings_page,
128 'label'=>__('Display a small thumbnail of any featured image set next to each item in cart on checkout pages', 'wppizza-admin'),
129 'description'=>array()
130 ));
131
132 $field = 'featured_image_size';
133 $settings['fields'][$this->section_key][$field] = array( __('Featured image size', 'wppizza-admin') , array(
134 'value_key'=>$field,
135 'option_key'=>$this->settings_page,
136 'label'=>__('Menu item image size used (actual display may vary depending on your theme\'s image css declarations and Wordpress->Media->Image Sizes when added to the Media Library)', 'wppizza-admin'),
137 'description'=>array()
138 ));
139
140 }
141
142 return $settings;
143 }
144 /*------------------------------------------------------------------------------
145 # [output option fields - setting page]
146 # @since 3.0
147 # @return array()
148 ------------------------------------------------------------------------------*/
149 function admin_options_fields_settings($wppizza_options, $options_key, $field, $label, $description){
150
151
152 if($field=='placeholder_img'){
153 print'<label>';
154 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
155 print'' . $label . '';
156 print'</label>';
157 print'' . $description . '';
158 }
159 if($field=='cart_image'){
160 print'<label>';
161 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
162 print'' . $label . '';
163 print'</label>';
164 print'' . $description . '';
165 }
166 if($field=='prettyPhoto' ){
167 print'<label>';
168 echo "<input id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]' type='checkbox' ". checked($wppizza_options[$options_key][$field],true,false)." value='1' />";
169 print'' . $label . '';
170 print'</label>';
171 print'' . $description . '';
172 }
173 if($field=='prettyPhotoStyle'){
174 print'<label>';
175 echo "<select id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]'>";
176 echo "<option value='pp_default' ".selected($wppizza_options[$options_key][$field],"pp_default",false).">Default</option>";
177 echo "<option value='light_rounded' ".selected($wppizza_options[$options_key][$field],"light_rounded",false).">Light rounded</option>";
178 echo "<option value='dark_rounded' ".selected($wppizza_options[$options_key][$field],"dark_rounded",false).">Dark rounded</option>";
179 echo "<option value='light_square' ".selected($wppizza_options[$options_key][$field],"light_square",false).">Light square</option>";
180 echo "<option value='dark_square' ".selected($wppizza_options[$options_key][$field],"dark_square",false).">Dark square</option>";
181 echo "<option value='facebook' ".selected($wppizza_options[$options_key][$field],"facebook",false).">Facebook</option>";
182 echo "</select>";
183 print'' . $label . '';
184 print'</label>';
185 print'' . $description . '';
186 }
187 if($field=='featured_image_size'){
188
189 $available_media_sizes = wppizza_get_wordpress_image_sizes();
190
191 print'<label>';
192 echo "<select id='".$field."' name='".WPPIZZA_SLUG."[".$options_key."][".$field."]'>";
193 /*
194 as its the default make sure "thumbnail is always there
195 even if it should not exist in the media sizes for some unknown reason
196 */
197 if(!isset($available_media_sizes['thumbnail'])){
198 echo "<option value='thumbnail' ".selected($wppizza_options[$options_key][$field],"thumbnail",false).">Thumbnail</option>";
199 }
200 foreach($available_media_sizes as $key => $val){
201 echo "<option value='".$key."' ".selected($wppizza_options[$options_key][$field],$key,false).">".$val['label']."</option>";
202 }
203 echo "</select>";
204 print'' . $label . '';
205 print'</label>';
206 print'' . $description . '';
207 }
208
209 }
210
211 /****************************************************************
212 *
213 * [insert default option on install]
214 * $parameter $options array() | filter passing on filtered options
215 * @since 3.0
216 * @return array()
217 *
218 ****************************************************************/
219 function options_default($options){
220
221 $options[$this->settings_page]['placeholder_img'] = true;
222 $options[$this->settings_page]['cart_image'] = false;
223 $options[$this->settings_page]['prettyPhoto'] = false;
224 $options[$this->settings_page]['prettyPhotoStyle'] = 'pp_default';
225 $options[$this->settings_page]['featured_image_size'] = 'thumbnail';
226
227 return $options;
228 }
229
230 /*------------------------------------------------------------------------------
231 # [validate options on save/update]
232 #
233 # @since 3.0
234 # @return array()
235 ------------------------------------------------------------------------------*/
236 function options_validate($options, $input){
237 /**make sure we get the full array on install/update**/
238 if ( empty( $_POST['_wp_http_referer'] ) ) {
239 return $input;
240 }
241 if(isset($_POST[''.WPPIZZA_SLUG.'_'.$this->settings_page.''])){
242 $options[$this->settings_page]['placeholder_img'] = !empty($input[$this->settings_page]['placeholder_img']) ? true : false;
243 $options[$this->settings_page]['cart_image'] = !empty($input[$this->settings_page]['cart_image']) ? true : false;
244 $options[$this->settings_page]['prettyPhoto'] = !empty($input[$this->settings_page]['prettyPhoto']) ? true : false;
245 $options[$this->settings_page]['prettyPhotoStyle']=wppizza_validate_string($input[$this->settings_page]['prettyPhotoStyle']);
246 $options[$this->settings_page]['featured_image_size']=wppizza_validate_string($input[$this->settings_page]['featured_image_size']);
247 }
248
249 return $options;
250 }
251 }
252 /***************************************************************
253 *
254 * [ini]
255 *
256 ***************************************************************/
257 $WPPIZZA_MODULE_LAYOUT_IMAGES = new WPPIZZA_MODULE_LAYOUT_IMAGES();
258 ?>