-
Notifications
You must be signed in to change notification settings - Fork 2
/
restaurant-menu.php
186 lines (159 loc) · 4.9 KB
/
restaurant-menu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
/**
* Plugin Name: Restaurant Menu
* Plugin URI: https://motopress.com/products/restaurant-menu/
* Description: This plugin gives you the power to effectively create, maintain and display online menus for almost any kind of restaurant, cafes and other typical food establishments.
* Version: 2.4.4
* Author: MotoPress
* Author URI: https://motopress.com
* License: GPLv2 or later
* Text Domain: mp-restaurant-menu
* Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use mp_restaurant_menu\classes\Core;
use mp_restaurant_menu\classes\Media;
use mp_restaurant_menu\classes\upgrade\Install;
if ( ! defined( 'MP_RM_PLUGIN_FILE' ) ) {
define( 'MP_RM_PLUGIN_FILE', __FILE__ );
}
define('MP_RM_PLUGIN_PATH', plugin_dir_path(__FILE__));
define('MP_RM_MEDIA_URL', plugins_url(plugin_basename(__DIR__) . '/media/'));
define('MP_RM_JS_URL', MP_RM_MEDIA_URL . 'js/');
define('MP_RM_CSS_URL', MP_RM_MEDIA_URL . 'css/');
define('MP_RM_PLUGIN_NAME', str_replace('-', '_', dirname(plugin_basename(__FILE__))));
define('MP_RM_LANG_PATH', MP_RM_PLUGIN_PATH . 'languages/');
define('MP_RM_TEMPLATES_PATH', MP_RM_PLUGIN_PATH . 'templates/');
define('MP_RM_CLASSES_PATH', MP_RM_PLUGIN_PATH . 'classes/');
define('MP_RM_PREPROCESSORS_PATH', MP_RM_CLASSES_PATH . 'preprocessors/');
define('MP_RM_CONTROLLERS_PATH', MP_RM_CLASSES_PATH . 'controllers/');
define('MP_RM_WIDGETS_PATH', MP_RM_CLASSES_PATH . 'widgets/');
define('MP_RM_MODELS_PATH', MP_RM_CLASSES_PATH . 'models/');
define('MP_RM_MODULES_PATH', MP_RM_CLASSES_PATH . 'modules/');
define('MP_RM_LIBS_PATH', MP_RM_CLASSES_PATH . 'libs/');
define('MP_RM_CONFIGS_PATH', MP_RM_PLUGIN_PATH . 'configs/');
define('MP_RM_TEMPLATES_ACTIONS', MP_RM_PLUGIN_PATH . 'templates-actions/');
define('MP_RM_TEMPLATES_FUNCTIONS', MP_RM_PLUGIN_PATH . 'templates-functions/');
if ( ! defined( 'MP_RM_DEBUG' ) ) {
define('MP_RM_DEBUG', FALSE);
}
register_activation_hook(__FILE__, array(MP_Restaurant_Menu_Setup_Plugin::init(), 'on_activation'));
register_deactivation_hook(__FILE__, array('MP_Restaurant_Menu_Setup_Plugin', 'on_deactivation'));
add_action( 'plugins_loaded', array('MP_Restaurant_Menu_Setup_Plugin', 'init') );
/**
* Class MP_Restaurant_Menu_Setup_Plugin
*/
class MP_Restaurant_Menu_Setup_Plugin {
protected static $instance;
/**
* MP_Restaurant_Menu_Setup_Plugin constructor.
*/
public function __construct() {
MP_Restaurant_Menu_Setup_Plugin::include_all();
Core::get_instance()->init_plugin(MP_RM_PLUGIN_NAME);
if (!defined('MP_RM_TEMPLATE_PATH')) {
define('MP_RM_TEMPLATE_PATH', $this->template_path());
}
}
/**
* Include files
*/
static function include_all() {
/**
* Include WP Parser
*/
require_once 'functions.php';
/**
* Include WP Parser
*/
require_once MP_RM_LIBS_PATH . 'parsers.php';
/**
* Include WP Parser
*/
require_once MP_RM_LIBS_PATH . 'gateways/ipnlistener.php';
/**
* Include state
*/
require_once MP_RM_CLASSES_PATH . 'class-state-factory.php';
/**
* Include Core class
*/
require_once MP_RM_CLASSES_PATH . 'class-core.php';
/**
* Include Core class
*/
require_once MP_RM_CLASSES_PATH . 'class-capability.php';
/**
* Include Model
*/
require_once MP_RM_CLASSES_PATH . 'class-model.php';
/**
* Include Controller
*/
require_once MP_RM_CLASSES_PATH . 'class-controller.php';
/**
* Include Preprocessor
*/
require_once MP_RM_CLASSES_PATH . 'class-preprocessor.php';
/**
* Include Module
*/
require_once MP_RM_CLASSES_PATH . 'class-module.php';
/**
* Include view
*/
require_once MP_RM_CLASSES_PATH . 'class-view.php';
/**
* Include media
*/
require_once MP_RM_CLASSES_PATH . 'class-media.php';
/**
* Include hooks
*/
require_once MP_RM_CLASSES_PATH . 'class-hooks.php';
/**
* Include hooks
*/
require_once MP_RM_CLASSES_PATH . 'class-shortcodes.php';
require_once MP_RM_CLASSES_PATH . 'upgrade/class-upgrade.php';
require_once MP_RM_CLASSES_PATH . 'upgrade/class-install.php';
}
/**
* Get the template path.
* @return string
*/
public function template_path() {
return apply_filters('mprm_template_path', 'mp-restaurant-menu/');
}
/**
* @return MP_Restaurant_Menu_Setup_Plugin
*/
public static function init() {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
/**
* On activation plugin
*/
public static function on_activation() {
//Register all custom post type, taxonomy and rewrite rule
Media::get_instance()->register_all_post_type();
Media::get_instance()->register_all_taxonomies();
// User capability
Install::get_instance()->setup_roles_capabilities();
// Create table/tables
Install::get_instance()->create_structure();
flush_rewrite_rules();
}
/**
* On deactivation plugin
*/
public static function on_deactivation() {
update_option('mprm_capabilities_version', '0.0.0');
flush_rewrite_rules();
}
}