forked from boywondercreative/maera-restaurant
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaera-restaurant.php
335 lines (281 loc) · 8.52 KB
/
maera-restaurant.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<?php
/**
* Plugin Name: Maera Restaurant Shell
* Plugin URI: https://press.codes
* Description: Restaurant shell for the Maera theme.
* Version: 0.1.0
* Author: Brian C. Welch
* Author URI: http://briancwelch.com
* Requires at least: 4.0
* Tested up to: 4.0
* License: MIT
*
* Text Domain: maera-restaurant
* Domain Path: /languages/
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define Globals.
define( 'MAERA_RES_VER', '0.1.0' );
define( 'MAERA_RES_SHELL_URL', plugins_url( '', __FILE__ ) );
define( 'MAERA_RES_SHELL_PATH', dirname( __FILE__ ) );
/**
* Include the restaurant shell in the list of available shells.
* @param [type] $shells [description].
* @return [type] [description]
*/
function maera_include_restaurant_shell( $shells ) {
$shells[] = array(
'value' => 'restaurant',
'label' => 'Restaurant',
'class' => 'Maera_Restaurant',
);
return $shells;
}
add_filter( 'maera/shells/available', 'maera_include_restaurant_shell' );
/**
* Plugin textdomains
*/
function maera_restaurant_texdomain() {
$lang_dir = get_template_directory() . '/languages';
$custom_path = WP_LANG_DIR . '/maera-' . get_locale() . '.mo';
if ( file_exists( $custom_path ) ) {
load_plugin_textdomain( 'maera-restaurant', $custom_path );
} else {
load_plugin_textdomain( 'maera-restaurant', false, $lang_dir );
}
}
add_action( 'plugins_loaded', 'maera_restaurant_texdomain' );
/**
* Maera Restaurant Main Class
*
* @category Plugin
* @package Maera Shell
* @author Brian C. Welch <[email protected]>
* @copyright 2015 Brian C. Welch, Press.Codes, Maera
* @license http://opensource.org/licenses/MIT MIT License
* @version Development: @MAERA_RES_VER@
* @link http://press.codes
* @see Maera_Restaurant(), Maera_Restaurant::method()
* @since Class available since Release 1.0.0
*/
if ( ! class_exists( 'Maera_Restaurant' ) ) {
/**
* Main Maera Restaurant class.
*/
class Maera_Restaurant {
/**
* [$instance description]
* @var [type]
*/
private static $instance;
/**
* [$customizer description]
* @var [type]
*/
public $customizer;
/**
* [$scripts description]
* @var [type]
*/
public $scripts;
/**
* [$structure description]
* @var [type]
*/
public $structure;
/**
* [$data description]
* @var [type]
*/
public $data;
/**
* [$styles description]
* @var [type]
*/
public $styles;
/**
* [$posttype description]
* @var [type]
*/
public $posttype;
/**
* [$widgetareas description]
* @var [type]
*/
public $widgetareas;
/**
* [$taxonomies description]
* @var [type]
*/
public $taxonomies;
/**
* Main Class Constructor
*/
public function __construct() {
if ( ! defined( 'MAERA_SHELL_PATH' ) ) {
define( 'MAERA_SHELL_PATH', dirname( __FILE__ ) );
}
// Require or include any additional files that may be needed.
require_once( __DIR__ . '/includes/class-maera-restaurant-customizer.php');
require_once( __DIR__ . '/includes/class-maera-restaurant-scripts.php');
require_once( __DIR__ . '/includes/class-maera-restaurant-structure.php');
require_once( __DIR__ . '/includes/class-maera-restaurant-data.php');
require_once( __DIR__ . '/includes/class-maera-restaurant-styles.php');
require_once( __DIR__ . '/includes/class-maera-restaurant-posttypes.php');
require_once( __DIR__ . '/includes/class-maera-restaurant-widget-areas.php');
require_once( __DIR__ . '/includes/class-maera-restaurant-taxonomies.php');
// Instantiate additional classes.
$this->customizer = new Maera_Restaurant_Customizer();
$this->scripts = new Maera_Restaurant_Scripts();
$this->structure = new Maera_Restaurant_Structure();
$this->data = new Maera_Restaurant_Data();
$this->styles = new Maera_Restaurant_Styles();
$this->posttype = new Maera_Restaurant_PostTypes();
$this->widgetareas = new Maera_Restaurant_Widget_Areas();
$this->taxonomies = new Maera_Restaurant_Taxonomies();
// Add Actions.
add_action( 'after_setup_theme', array( $this, 'required_plugins' ) );
add_action( 'do_meta_boxes', array( $this, 'slides_image_box' ) );
// Add Filters.
add_filter( 'kirki/config', array( $this, 'customizer_config' ) );
// Theme Supports.
add_theme_support( 'kirki' );
add_theme_support( 'restaurant' );
add_theme_support( 'tonesque' );
add_theme_support( 'site-logo' );
if ( '1' === get_theme_mod( 'enable_breadcrumbs' , '1' ) ) {
add_theme_support( 'breadcrumbs' );
}
}
/**
* Singleton
* @return self::$instance
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Customize Kirki.
* @return [type] [description]
*/
function customizer_config( $config ) {
$colors = Maera_Restaurant_Styles::palette_colors();
$config['logo_image'] = MAERA_RES_SHELL_URL . '/assets/img/maera_restaurant_logo.png';
$config['description'] = __( 'The Maera restaurant shell allows you to easily create restaurant sites with ease and includes a wealth of customization options.', 'maera-restaurant' );
$config['color_accent'] = $colors[4];
$config['color_back'] = $colors[5];
$config['width'] = '20%';
return $config;
}
/**
* Build the array of required plugins
* You can use the 'maera/required_plugins' filter to add or remove plugins.
* @param array $plugins [description].
*/
function required_plugins( $plugins = array() ) {
if ( ! $plugins || empty( $plugins ) ) {
$plugins = array();
}
$plugins[] = array(
'name' => 'Restaurant',
'file' => 'restaurant.php',
'slug' => 'restaurant',
);
// Check to see if the user has ACF Pro installed, if not, require the free version.
if ( ! class_exists( 'acf_pro' ) ) {
$plugins[] = array(
'name' => 'Advanced Custom Fields',
'file' => 'acf.php',
'slug' => 'advanced-custom-fields',
);
}
$plugins = new Maera_Required_Plugins( $plugins );
}
/**
* Move the featured image box from the side to the main area when editing slides.
*/
function slides_image_box() {
$screen = get_current_screen();
if ( 'slide' === $screen->post_type ) {
remove_meta_box( 'postimagediv', 'slide', 'side' );
add_meta_box( 'postimagediv', __( 'Slide - Background Image' ), 'post_thumbnail_meta_box', 'slide', 'normal', 'high' );
}
}
} // End Class
} // End if
/**
* Licensing handler.
*/
function maera_restaurant_licensing() {
if ( is_admin() && class_exists( 'Maera_Updater' ) ) {
$maera_res_license = new Maera_Updater( 'plugin', __FILE__, 'Maera Restaurant Shell', MAERA_RES_VER, '@brianwelch' );
}
}
add_action( 'init', 'maera_restaurant_licensing' );
/**
* Load Maera Restaurant widgets.
*/
include_once( __DIR__ . '/includes/widgets/class-maera-restaurant-slider-widget.php');
include_once( __DIR__ . '/includes/widgets/class-maera-restaurant-menu-widget.php');
/**
* Register the slider widget.
*/
function maera_res_slider_widgets() {
register_widget( 'Maera_Restaurant_Slider_Widget' );
}
add_action( 'widgets_init', 'maera_res_slider_widgets' );
/**
* Register the menu widget.
*/
function maera_res_menu_widgets() {
register_widget( 'Maera_Restaurant_Menu_Widget' );
}
add_action( 'widgets_init', 'maera_res_menu_widgets' );
/**
* Add the secondary slider image to Advanced Custom Fields
*/
if ( function_exists( 'register_field_group' ) ) {
register_field_group( array(
'id' => 'acf_slider-second-image-1',
'title' => 'Slider - Second Image',
'fields' => array(
array(
'key' => 'field_54ff77a3c04fb',
'label' => 'Slider - Second Image',
'name' => 'slider_-_second_image',
'type' => 'image',
'instructions' => 'Enter the secondary image for the slider. This is the image that is displayed over the background.',
'required' => 1,
'save_format' => 'url',
'preview_size' => 'medium',
'library' => 'all',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'slide',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array(
'position' => 'normal',
'layout' => 'default',
'hide_on_screen' => array(
0 => 'comments',
1 => 'send-trackbacks',
),
),
'menu_order' => 0,
));
}