PluginProbe
WPPizza – A Restaurant Plugin / 3.19
WPPizza – A Restaurant Plugin v3.19
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 / wppizza.php

wppizza.php in WPPizza – A Restaurant Plugin 3.19, at wppizza.php

337 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 #* Plugin Name: WPPizza
4 #* Plugin URI: https://wordpress.org/extend/plugins/wppizza/
5 #* Description: A Restaurant Plugin (not only for Pizza)
6 #* Version: 3.19
7 #* Requires PHP: 5.3+
8 #* Author: ollybach
9 #* Author URI: https://www.wp-pizza.com
10 #* License: GPL2
11 #* Text Domain: wppizza
12 #* Domain Path: lang
13 #*
14 #* License:
15 #*
16 #* Copyright 2012 ollybach (dev@wp-pizza.com)
17 #*
18 #* This program is free software; you can redistribute it and/or modify
19 #* it under the terms of the GNU General Public License, version 2, as
20 #* published by the Free Software Foundation.
21 #*
22 #* This program is distributed in the hope that it will be useful,
23 #* but WITHOUT ANY WARRANTY; without even the implied warranty of
24 #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 #* GNU General Public License for more details.
26 #*
27 #* You should have received a copy of the GNU General Public License
28 #* along with this program; if not, write to the Free Software
29 #* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #* or see <http://www.gnu.org/licenses/>.
31 #*
32 #* @package WPPizza
33 #* @category Core
34 #* @author ollybach
35 #*
36 #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
37
38 /***************************************************************
39 *
40 * Simply exit if accessed directly
41 *
42 ***************************************************************/
43 if ( ! defined( 'ABSPATH' ) ) {exit();}
44
45 /***************************************************************
46 *
47 * for simplicities sake lets put this here at the top
48 * MUST ALWAYS BE SET IN LINE WITH PLUGIN VERSION NUMBER ABOVE
49 *
50 * @since v3
51 *
52 * @since v3.10
53 * major version number of plugin
54 * [for convenience in plugin/theme development]
55 *
56 ***************************************************************/
57 define('WPPIZZA_VERSION', '3.19');
58 define('WPPIZZA_VERSION_MAJOR', '3');
59
60 /***************************************************************
61 *
62 *
63 * [CLASS]
64 * @since v3
65 *
66 *
67 ***************************************************************/
68 if (!class_exists( 'WPPIZZA' )){
69 class WPPIZZA {
70
71 /*
72 * @var WPPIZZA
73 * @since 3.0
74 */
75 private static $instance;
76
77 /*
78 setting properties
79 to make php 8.2+ / 9.0 happy...
80 */
81 public $dbcookie;
82 public $categories;
83 public $helpers;
84 public $gateways;
85 public $email;
86 public $admin_helper;
87 public $markup_orderinfo;
88 public $markup_openingtimes;
89 public $markup_minicart;
90 public $markup_maincart;
91 public $markup_navigation;
92 public $markup_search;
93 public $markup_additives;
94 public $markup_foodtype;
95 public $markup_options;
96 public $markup_pickup_choice;
97 public $markup_totals;
98 public $markup_pages;
99 public $templates_menu_items;
100 public $templates_email_print;
101 public $admin_dashboard_widgets;
102 public $sales_data;
103 public $user;
104 public $db;
105 public $order;
106 public $cron;
107 public $register_gateways;
108 public $user_caps;
109
110
111 /*
112 * @var session
113 * @since 3.0
114 */
115 public $session;
116
117
118
119 function __construct() {
120
121 /*
122 some - somewhat inconsequentiial - setup actions to provide some useful links perhaps
123 in the WP admin plugin page (wp-admin/plugins.php) for this plugin
124 @since 3.16
125 */
126 //add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);// FOR REFERENCE CURRENTLY NOT IMPLEMENTED
127 add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2);
128 }
129
130 /***************************************************************
131 * Main WPPIZZA
132 *
133 * To insures only one instance of WPPIZZA exists in memory
134 *
135 * @since 3.0
136 * @static
137 * @staticvar array $instance
138 * @uses WPPIZZA::setup_constants() setup constants
139 * @uses WPPIZZA::requires() Include all required files
140 * @uses WPPIZZA::load_textdomain() load the language files
141 *
142 * @return WPPIZZA
143 ****************************************************************/
144 public static function instance() {
145
146 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPPIZZA ) ) {
147
148 self::$instance = new WPPIZZA;
149
150 /**load text domain**/
151 add_action( 'init', array( self::$instance, 'load_plugin_textdomain'));
152 /**load custom functions.php - if exists**/
153 add_action( 'after_setup_theme', array( self::$instance, 'load_custom_functions'));
154
155 /*setting up some constants*/
156 self::$instance->wppizza_constants(__FILE__);
157 /**include all required files **/
158 self::$instance->requires();
159 /**cookies**/
160 self::$instance->dbcookie = new WPPIZZA_DBCOOKIE();
161 /**sessions**/
162 self::$instance->session = new WPPIZZA_SESSIONS();
163 /**categories**/
164 self::$instance->categories = new WPPIZZA_CATEGORIES_SORTED();
165 /**global helper functions**/
166 self::$instance->helpers = new WPPIZZA_HELPERS();
167 /**gateways**/
168 self::$instance->gateways = new WPPIZZA_GATEWAYS();
169 /**emails**/
170 self::$instance->email = new WPPIZZA_EMAIL();
171 /**admin only**/
172 if (is_admin()) {
173 /**register gateways**/
174 self::$instance->register_gateways = new WPPIZZA_REGISTER_GATEWAYS();
175 /**admin user caps**/
176 self::$instance->user_caps = new WPPIZZA_USER_CAPS();
177 }
178
179 /**
180 admin helper functions (order history mainly) - these might also be used outside admin area
181 (so moved outside is_admin() conditional since v3.5) !
182 **/
183 self::$instance->admin_helper = new WPPIZZA_ADMIN_HELPERS();
184
185 /**
186 templates | shortcodes | widget markup | sales data
187 **/
188 self::$instance->markup_orderinfo = new WPPIZZA_MARKUP_ORDERINFO(); /* shortcode or enabled in cart widget */
189 self::$instance->markup_openingtimes = new WPPIZZA_MARKUP_OPENINGTIMES(); /* shortcode or enabled in cart widget */
190 self::$instance->markup_minicart = new WPPIZZA_MARKUP_MINICART(); /* shortcode or enabled in cart widget */
191 self::$instance->markup_maincart = new WPPIZZA_MARKUP_MAINCART(); /* shortcode or cart widget */
192 self::$instance->markup_navigation = new WPPIZZA_MARKUP_NAVIGATION(); /* shortcode or navigation widget */
193 self::$instance->markup_search = new WPPIZZA_MARKUP_SEARCH(); /* shortcode or search widget */
194 self::$instance->markup_additives = new WPPIZZA_MARKUP_ADDITIVES(); /* shortcode or in menu items, menu items loop */
195 self::$instance->markup_foodtype = new WPPIZZA_MARKUP_FOODTYPE(); /* shortcode or in menu items, menu items loop */
196 self::$instance->markup_options = new WPPIZZA_MARKUP_OPTIONS(); /* shortcode to output some wppizza options */
197 self::$instance->markup_pickup_choice = new WPPIZZA_MARKUP_PICKUP_CHOICE(); /* shortcode and called in cart|orderpage templates */
198 self::$instance->markup_totals = new WPPIZZA_MARKUP_TOTALS(); /* shortcode only */
199 self::$instance->markup_pages = new WPPIZZA_MARKUP_PAGES(); /* auto (orderpage|confirmationpage|thankyoupage) and "orderhistory" shortcode */
200 self::$instance->templates_menu_items = new WPPIZZA_MARKUP_MENU_ITEMS(); /* single item, categories loop, add to cart button, bestsellers*/
201 self::$instance->templates_email_print = new WPPIZZA_MARKUP_EMAIL_PRINT(); /* email / print templates */
202 self::$instance->admin_dashboard_widgets = new WPPIZZA_DASHBOARD_WIDGETS(); /* auto dashboard widgets */
203 self::$instance->sales_data = new WPPIZZA_SALES_DATA(); /* auto sales data results */
204
205
206 /**
207 user login / out/ register forms
208 upadate details form
209 registration emails / redirects
210 etc
211 **/
212 self::$instance->user = new WPPIZZA_USER();/* login form, registration, emails etc */
213 self::$instance->db = new WPPIZZA_DB();/* query insert update delete etc */
214 self::$instance->order = new WPPIZZA_ORDER();/* */
215 self::$instance->cron = new WPPIZZA_CRON();/* wppizza wp cronjobs */
216
217 }
218
219 return self::$instance;
220 }
221
222
223 /*************************************************************************************
224 * wppizza constants
225 *
226 * @access private
227 * @since 3.0
228 * @return void
229 *************************************************************************************/
230 private function wppizza_constants($PLUGIN_FILE_ABS_PATH) {
231 require_once(dirname($PLUGIN_FILE_ABS_PATH) .'/includes/global.constants.inc.php');
232 }
233
234 /*************************************************************************************
235 * load wppizzas functions.php
236 * - if exists in theme/childtheme directory as ./wppizza/functions.php
237 * @since 3.0
238 * @return void
239 *************************************************************************************/
240 function load_custom_functions(){
241 if(WPPIZZA_LOCATE_DIR !='' && file_exists(WPPIZZA_TEMPLATE_DIR . '/functions.php')){
242 include_once( WPPIZZA_TEMPLATE_DIR . '/functions.php');
243 }
244 }
245
246 /*************************************************************************************
247 * load text domain on init.
248 * @since 3.0
249 * @return void
250 *************************************************************************************/
251 public function load_plugin_textdomain(){
252 /*
253 NOTE: BOTH only required on admin as frontend strings get added to wppizza->localization (options table) on intall
254 and are subsequently used from there.
255 localization is split for convenience to enable frontend localization into more languages
256 without having to translate the whole backend too (although that would be ideal of course)
257 */
258 if(is_admin()){
259 // admin localization strings
260 load_plugin_textdomain('wppizza-admin', false, dirname(plugin_basename( __FILE__ ) ) . '/lang' );
261 // load after admin to insert default localization strings
262 load_plugin_textdomain('wppizza', false, dirname(plugin_basename( __FILE__ ) ) . '/lang' );
263 }else{
264 // frontend dev constants - not loaded by default (but can be enabled by constant) as it's kind of overkill loading these for very little benefit,
265 if(WPPIZZA_DEV_LOAD_TEXTDOMAIN){
266 load_plugin_textdomain('wppizza_dev', false, dirname(plugin_basename( __FILE__ ) ) . '/lang' );
267 }
268 }
269 }
270
271 /*************************************************************************************
272 * Include our required files / classes
273 *
274 * @access private
275 * @since 3.0
276 * @return void
277 *************************************************************************************/
278 private function requires(){
279 require_once(WPPIZZA_PATH .'includes/setup/required.files.inc.php');
280 }
281 /*************************************************************************************
282 * Set some plugin settings links in the admin plugin page (next to deactivate link)
283 * CURRENTLY NOT IMPLEMENTED
284 * @access private
285 * @since 3.16
286 * @return array
287 *************************************************************************************/
288 function plugin_action_links($links, $file) {
289
290 if (($file === plugin_basename(__FILE__) ) && (current_user_can('manage_options'))) {
291 $settings = '<a href="'. admin_url('edit.php?post_type=wppizza&page=order_settings') .'">'. esc_html__('Order Settings', 'disable-gutenberg') .'</a>';
292 array_unshift($links, $settings);
293 }
294
295 return $links;
296 }
297
298 /*************************************************************************************
299 * Set plugin settings links
300 *
301 * @access private
302 * @since 3.16
303 * @return array
304 *************************************************************************************/
305 function plugin_meta_links($links, $file) {
306
307 if ($file === plugin_basename(__FILE__)) {
308 $links[] = '<a target="_blank" rel="noopener noreferrer" href="https://docs.wp-pizza.com/getting-started/?section=setup" title="'. esc_attr__('Getting started', 'wppizza-admin') .'">'. esc_html__('Getting started', 'wppizza-admin') .'</a>';
309 $links[] = '<a target="_blank" rel="noopener noreferrer" href="https://docs.wp-pizza.com" title="'. esc_attr__('Documentation', 'wppizza-admin') .'">'. esc_html__('Documentation', 'wppizza-admin') .'</a>';
310 $links[] = '<a target="_blank" rel="noopener noreferrer" href="https://www.wp-pizza.com" title="'. esc_attr__('Homepage', 'wppizza-admin') .'">'. esc_html__('Homepage', 'wppizza-admin') .'</a>';
311 $links[] = '<a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/plugins/wppizza/#developers" title="'. esc_attr__('Changelog', 'wppizza-admin') .'">'. esc_html__('Changelog', 'wppizza-admin') .'</a>';
312 $links[] = '<a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/support/plugin/wppizza/reviews/?rate=5#new-post" title="'. esc_attr__('Click here to rate and review this plugin on WordPress.org', 'wppizza-admin') .'">'. esc_html__('Rate this plugin', 'wppizza-admin') .'&nbsp;&raquo;</a>';
313 }
314
315 return $links;
316 }
317
318 }
319 }
320
321
322 /*************************************************************************************
323 * The main function responsible for returning WPPIZZA to functions everywhere.
324 *
325 * Example: $wppizza = WPPIZZA();
326 *
327 * @since 3.0
328 * @return object WPPIZZA Instance
329 *************************************************************************************/
330 function WPPIZZA() {
331 return WPPIZZA::instance();
332 }
333 function wppizza_ini() {
334 WPPIZZA();
335 }
336 add_action( 'plugins_loaded', 'wppizza_ini');
337 ?>