This repository was archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmegamenu.php
More file actions
780 lines (562 loc) · 20.4 KB
/
megamenu.php
File metadata and controls
780 lines (562 loc) · 20.4 KB
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
<?php
/*
* Plugin Name: Max Mega Menu
* Plugin URI: http://www.maxmegamenu.com
* Description: Mega Menu for WordPress.
* Version: 1.8.3.2
* Author: Tom Hemsley
* Author URI: http://www.maxmegamenu.com
* License: GPL-2.0+
* Copyright: 2015 Tom Hemsley (http://www.maxmegamenu.com)
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // disable direct access
}
if ( ! class_exists( 'Mega_Menu' ) ) :
/**
* Main plugin class
*/
final class Mega_Menu {
/**
* @var string
*/
public $version = '1.8.3.2';
/**
* Init
*
* @since 1.0
*/
public static function init() {
$plugin = new self();
}
/**
* Constructor
*
* @since 1.0
*/
public function __construct() {
$this->define_constants();
$this->includes();
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
add_action( 'admin_init', array( $this, 'install_upgrade_check' ) );
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'widgets_init', array( $this, 'register_widget' ) );
add_action( 'after_setup_theme', array( $this, 'register_nav_menus' ) );
add_filter( 'wp_nav_menu_args', array( $this, 'modify_nav_menu_args' ), 9999 );
add_filter( 'wp_nav_menu', array( $this, 'add_responsive_toggle' ), 10, 2 );
add_filter( 'wp_nav_menu_objects', array( $this, 'add_widgets_to_menu' ), 10, 2 );
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'apply_depth_to_menu_items' ), 5, 2 );
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'apply_megamenu_settings_to_menu_items' ), 6, 2 );
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'apply_megamenu_classes_to_menu_items' ), 7, 2 );
add_filter( 'megamenu_nav_menu_css_class', array( $this, 'prefix_menu_classes' ) );
add_filter( 'black_studio_tinymce_enable_pages' , array($this, 'megamenu_blackstudio_tinymce' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts'), 9 );
// add 'go pro' link to plugin options
$plugin = plugin_basename( __FILE__ );
add_filter( "plugin_action_links_{$plugin}", array( $this, 'upgrade_to_pro_link' ) );
register_deactivation_hook( __FILE__, array( $this, 'delete_version_number') );
add_shortcode( 'maxmenu', array( $this, 'register_shortcode' ) );
add_shortcode( 'maxmegamenu', array( $this, 'register_shortcode' ) );
if ( is_admin() ) {
new Mega_Menu_Nav_Menus();
new Mega_Menu_Widget_Manager();
new Mega_Menu_Menu_Item_Manager();
new Mega_Menu_Settings();
}
$mega_menu_style_manager = new Mega_Menu_Style_Manager();
$mega_menu_style_manager->setup_actions();
}
/**
* Add custom actions to allow enqueuing scripts on specific pages
*
* @since 1.8.3
*/
public function admin_enqueue_scripts( $hook ) {
wp_enqueue_style( 'maxmegamenu-global', MEGAMENU_BASE_URL . 'css/global.css', array(), MEGAMENU_VERSION );
if ( 'nav-menus.php' == $hook ) {
do_action("megamenu_nav_menus_scripts", $hook );
}
if ( 'toplevel_page_maxmegamenu' == $hook ) {
do_action("megamenu_admin_scripts", $hook );
}
}
/**
* Register menu locations created within Max Mega Menu.
*
* @since 1.8
*/
public function register_nav_menus() {
$locations = get_option('megamenu_locations');
if ( is_array( $locations ) && count( $locations ) ) {
foreach ( $locations as $key => $val ) {
register_nav_menu( $key, $val );
}
}
}
/**
* Add go pro link on plugin page
*
* @since 1.8.3
*/
public function upgrade_to_pro_link( $links ) {
if ( function_exists( 'is_plugin_active' ) && ! is_plugin_active( 'megamenu-pro/megamenu-pro.php' ) ) {
$links[] = '<a href="http://www.maxmegamenu.com/upgrade/?utm_source=free&utm_medium=link&utm_campaign=pro" target="_blank"><b>' . __( "Go Pro", "megamenu" ) . '</b></a>';
}
return $links;
}
/**
* Black Studio TinyMCE Compatibility.
* Load TinyMCE assets on nav-menus.php page.
*
* @since 1.8
* @param array $pages
* @return array $pages
*/
public function megamenu_blackstudio_tinymce( $pages ) {
$pages[] = 'nav-menus.php';
return $pages;
}
/**
* Detect new or updated installations and run actions accordingly.
*
* @since 1.3
*/
public function install_upgrade_check() {
if ( $version = get_option( "megamenu_version" ) ) {
if ( version_compare( $this->version, $version, '!=' ) ) {
update_option( "megamenu_version", $this->version );
do_action( "megamenu_after_update" );
}
} else {
add_option( "megamenu_version", $this->version );
do_action( "megamenu_after_install" );
}
}
/**
* Delete the current version number
*
* @since 1.3
*/
public function delete_version_number() {
delete_option( "megamenu_version", $this->version );
}
/**
* Register widget
*
* @since 1.7.4
*/
public function register_widget() {
register_widget( 'Mega_Menu_Widget' );
}
/**
* Shortcode used to display a menu
*
* @since 1.3
* @return string
*/
public function register_shortcode( $atts ) {
if ( ! isset( $atts['location'] ) ) {
return false;
}
if ( has_nav_menu( $atts['location'] ) ) {
return wp_nav_menu( array( 'theme_location' => $atts['location'], 'echo' => false ) );
}
return "<!-- menu not found [maxmegamenu location={$atts['location']}] -->";
}
/**
* Initialise translations
*
* @since 1.0
*/
public function load_plugin_textdomain() {
load_plugin_textdomain( 'megamenu', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Define Mega Menu constants
*
* @since 1.0
*/
private function define_constants() {
define( 'MEGAMENU_VERSION', $this->version );
define( 'MEGAMENU_BASE_URL', trailingslashit( plugins_url( 'megamenu' ) ) );
define( 'MEGAMENU_PATH', plugin_dir_path( __FILE__ ) );
}
/**
* All Mega Menu classes
*
* @since 1.0
*/
private function plugin_classes() {
return array(
'mega_menu_walker' => MEGAMENU_PATH . 'classes/walker.class.php',
'mega_menu_widget_manager' => MEGAMENU_PATH . 'classes/widget-manager.class.php',
'mega_menu_menu_item_manager' => MEGAMENU_PATH . 'classes/menu-item-manager.class.php',
'mega_menu_nav_menus' => MEGAMENU_PATH . 'classes/nav-menus.class.php',
'mega_menu_style_manager' => MEGAMENU_PATH . 'classes/style-manager.class.php',
'mega_menu_settings' => MEGAMENU_PATH . 'classes/settings.class.php',
'mega_menu_widget' => MEGAMENU_PATH . 'classes/widget.class.php',
'scssc' => MEGAMENU_PATH . 'classes/scssc.inc.php',
);
}
/**
* Load required classes
*
* @since 1.0
*/
private function includes() {
$autoload_is_disabled = defined( 'MEGAMENU_AUTOLOAD_CLASSES' ) && MEGAMENU_AUTOLOAD_CLASSES === false;
if ( function_exists( "spl_autoload_register" ) && ! $autoload_is_disabled ) {
// >= PHP 5.2 - Use auto loading
if ( function_exists( "__autoload" ) ) {
spl_autoload_register( "__autoload" );
}
spl_autoload_register( array( $this, 'autoload' ) );
} else {
// < PHP5.2 - Require all classes
foreach ( $this->plugin_classes() as $id => $path ) {
if ( is_readable( $path ) && ! class_exists( $id ) ) {
require_once $path;
}
}
}
}
/**
* Autoload classes to reduce memory consumption
*
* @since 1.0
* @param string $class
*/
public function autoload( $class ) {
$classes = $this->plugin_classes();
$class_name = strtolower( $class );
if ( isset( $classes[ $class_name ] ) && is_readable( $classes[ $class_name ] ) ) {
require_once $classes[ $class_name ];
}
}
/**
* Appends "mega-" to all menu classes.
* This is to help avoid theme CSS conflicts.
*
* @since 1.0
* @param array $classes
* @return array
*/
public function prefix_menu_classes( $classes ) {
$return = array();
foreach ( $classes as $class ) {
$return[] = 'mega-' . $class;
}
return $return;
}
/**
* Add the html for the responsive toggle box to the menu
*
* @param string $nav_menu
* @param object $args
* @return string
* @since 1.3
*/
public function add_responsive_toggle( $nav_menu, $args ) {
// make sure we're working with a Mega Menu
if ( ! is_a( $args->walker, 'Mega_Menu_Walker' ) )
return $nav_menu;
$toggle_id = apply_filters("megamenu_toggle_id", "mega-menu-toggle-{$args->theme_location}", $args->menu, $args->theme_location );
$toggle_class = 'mega-menu-toggle';
$find = 'class="' . $args->container_class . '">';
$replace = $find . '<div class="' . $toggle_class . '"></div>';
return str_replace( $find, $replace, $nav_menu );
}
/**
* Apply a depth to each item in the menu
*
* @since 1.8.2
* @param array $items - All menu item objects
* @param object $args
* @return array - Menu objects including widgets
*/
public function apply_depth_to_menu_items( $items, $args ) {
// We can't assume the menu items are in any particular order.
// (for example, the "Add Descendants as sub menu items" adds all items to the 'bottom' of the menu)
// We only need to know about top level menu items and their immediate children
$parents = array();
foreach ( $items as $key => $item ) {
if ( $item->menu_item_parent == 0 ) {
$parents[] = $item->ID;
$item->depth = 0;
}
}
if ( count( $parents ) ) {
foreach ( $items as $key => $item ) {
if ( in_array( $item->menu_item_parent, $parents ) ) {
$item->depth = 1;
}
}
}
return $items;
}
/**
* Store the mega menu settings for each menu item
*
* @since 1.8.2
* @param array $items - All menu item objects
* @param object $args
* @return array - Menu objects including widgets
*/
public function apply_megamenu_settings_to_menu_items( $items, $args ) {
// apply saved metadata to each menu item
foreach ( $items as $item ) {
$saved_settings = array_filter( (array) get_post_meta( $item->ID, '_megamenu', true ) );
$item->megamenu_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
}
return $items;
}
/**
* Apply classes to nav menu items
*
* @since 1.8.2
* @param array $items - All menu item objects
* @param object $args
* @return array - Menu objects including widgets
*/
public function apply_megamenu_classes_to_menu_items( $items, $args ) {
$parents = array();
foreach ( $items as $item ) {
if ( $item->depth == 0 ) {
$item->classes[] = 'align-' . $item->megamenu_settings['align'];
$item->classes[] = 'menu-' . $item->megamenu_settings['type'];
}
if ( $item->megamenu_settings['hide_arrow'] == 'true') {
$item->classes[] = 'hide-arrow';
}
if ( $item->megamenu_settings['hide_text'] == 'true' && $item->depth == 0 ) {
$item->classes[] = 'hide-text';
}
if ( $item->megamenu_settings['item_align'] != 'left' && $item->depth == 0 ) {
$item->classes[] = 'item-align-' . $item->megamenu_settings['item_align'];
}
if ( $item->megamenu_settings['disable_link'] == 'true') {
$item->classes[] = 'disable-link';
}
// add column classes for second level menu items displayed in mega menus
if ( $item->depth == 1 ) {
$parent_settings = array_filter( (array) get_post_meta( $item->menu_item_parent, '_megamenu', true ) );
if ( isset( $parent_settings['type'] ) && $parent_settings['type'] == 'megamenu' ) {
$parent_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $parent_settings );
$span = $item->megamenu_settings['mega_menu_columns'];
$total_columns = $parent_settings['panel_columns'];
if ( $total_columns >= $span ) {
$item->classes[] = "menu-columns-{$span}-of-{$total_columns}";
$column_count = $span;
} else {
$item->classes[] = "menu-columns-{$total_columns}-of-{$total_columns}";
$column_count = $total_columns;
}
if ( ! isset( $parents[ $item->menu_item_parent ] ) ) {
$parents[ $item->menu_item_parent ] = $column_count;
} else {
$parents[ $item->menu_item_parent ] = $parents[ $item->menu_item_parent ] + $column_count;
if ( $parents[ $item->menu_item_parent ] > $total_columns ) {
$parents[ $item->menu_item_parent ] = $column_count;
$item->classes[] = 'menu-clear';
}
}
}
}
}
return $items;
}
/**
* Append the widget objects to the menu array before the
* menu is processed by the walker.
*
* @since 1.0
* @param array $items - All menu item objects
* @param object $args
* @return array - Menu objects including widgets
*/
public function add_widgets_to_menu( $items, $args ) {
// make sure we're working with a Mega Menu
if ( ! is_a( $args->walker, 'Mega_Menu_Walker' ) )
return $items;
$items = apply_filters( "megamenu_nav_menu_objects_before", $items, $args );
$widget_manager = new Mega_Menu_Widget_Manager();
$default_columns = apply_filters("megamenu_default_columns", 1);
foreach ( $items as $item ) {
// only look for widgets on top level items
if ( $item->depth == 0 && $item->megamenu_settings['type'] == 'megamenu' ) {
$panel_widgets = $widget_manager->get_widgets_for_menu_id( $item->ID );
if ( count( $panel_widgets) ) {
if ( ! in_array( 'menu-item-has-children', $item->classes ) ) {
$item->classes[] = 'menu-item-has-children';
}
$cols = 0;
foreach ( $panel_widgets as $widget ) {
$menu_item = array(
'type' => 'widget',
'title' => '',
'content' => $widget_manager->show_widget( $widget['widget_id'] ),
'menu_item_parent' => $item->ID,
'db_id' => 0, // This menu item does not have any childen
'ID' => $widget['widget_id'],
'menu_order' => $item->menu_order + 1,
'classes' => array(
"menu-item",
"menu-item-type-widget",
"menu-columns-{$widget['mega_columns']}-of-{$item->megamenu_settings['panel_columns']}",
"menu-widget-class-" . $widget_manager->get_widget_class( $widget['widget_id'] )
)
);
if ( $cols == 0 ) {
$menu_item['classes'][] = "menu-clear";
}
$cols = $cols + $widget['mega_columns'];
if ( $cols > $item->megamenu_settings['panel_columns'] ) {
$menu_item['classes'][] = "menu-clear";
$cols = $widget['mega_columns'];
}
$items[] = (object) $menu_item;
}
}
}
}
$items = apply_filters( "megamenu_nav_menu_objects_after", $items, $args );
return $items;
}
/**
* Use the Mega Menu walker to output the menu
* Resets all parameters used in the wp_nav_menu call
* Wraps the menu in mega-menu IDs and classes
*
* @since 1.0
* @param $args array
* @return array
*/
public function modify_nav_menu_args( $args ) {
$settings = get_option( 'megamenu_settings' );
$current_theme_location = $args['theme_location'];
$locations = get_nav_menu_locations();
if ( isset ( $settings[ $current_theme_location ]['enabled'] ) && $settings[ $current_theme_location ]['enabled'] == true ) {
if ( ! isset( $locations[ $current_theme_location ] ) ) {
return $args;
}
$menu_id = $locations[ $current_theme_location ];
if ( ! $menu_id ) {
return $args;
}
$style_manager = new Mega_Menu_Style_Manager();
$themes = $style_manager->get_themes();
$menu_theme = isset( $themes[ $settings[ $current_theme_location ]['theme'] ] ) ? $themes[ $settings[ $current_theme_location ]['theme'] ] : $themes['default'];
$menu_settings = $settings[ $current_theme_location ];
$wrap_attributes = apply_filters("megamenu_wrap_attributes", array(
"id" => '%1$s',
"class" => '%2$s mega-no-js',
"data-event" => isset( $menu_settings['event'] ) ? $menu_settings['event'] : 'hover',
"data-effect" => isset( $menu_settings['effect'] ) ? $menu_settings['effect'] : 'disabled',
"data-panel-width" => preg_match('/^\d/', $menu_theme['panel_width']) !== 1 ? $menu_theme['panel_width'] : '',
"data-second-click" => isset( $settings['second_click'] ) ? $settings['second_click'] : 'close',
"data-mobile-behaviour" => isset( $settings['mobile_behaviour'] ) ? $settings['mobile_behaviour'] : 'standard',
"data-breakpoint" => absint( $menu_theme['responsive_breakpoint'] )
), $menu_id, $menu_settings, $settings, $current_theme_location );
$attributes = "";
foreach( $wrap_attributes as $attribute => $value ) {
if ( strlen( $value ) ) {
$attributes .= " " . $attribute . '="' . $value . '"';
}
}
$sanitized_location = str_replace( apply_filters("megamenu_location_replacements", array("-", " ") ), "-", $current_theme_location );
$defaults = array(
'menu' => $menu_id,
'container' => 'div',
'container_class' => 'mega-menu-wrap',
'container_id' => 'mega-menu-wrap-' . $sanitized_location,
'menu_class' => 'mega-menu mega-menu-horizontal',
'menu_id' => 'mega-menu-' . $sanitized_location,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul' . $attributes . '>%3$s</ul>',
'depth' => 0,
'walker' => new Mega_Menu_Walker()
);
$args = array_merge( $args, apply_filters( "megamenu_nav_menu_args", $defaults, $menu_id, $current_theme_location ) );
}
return $args;
}
/**
* Display admin notices.
*/
public function admin_notices() {
if ( ! $this->is_compatible_wordpress_version() ) :
?>
<div class="error">
<p><?php _e( 'Max Mega Menu is not compatible with your version of WordPress. Please upgrade WordPress to the latest version or disable Max Mega Menu.', 'megamenu' ); ?></p>
</div>
<?php
endif;
if ( is_plugin_active('ubermenu/ubermenu.php') ) :
?>
<div class="error">
<p><?php _e( 'Max Mega Menu is not compatible with Uber Menu. Please disable Uber Menu.', 'megamenu' ); ?></p>
</div>
<?php
endif;
if ( did_action('megamenu_after_install') === 1 ) :
?>
<div class="updated">
<?php
$link = "<a href='" . admin_url("admin.php?page=maxmegamenu") . "'>" . __( "click here", 'megamenu' ) . "</a>";
?>
<p><?php echo sprintf( __( 'Thanks for installing Max Mega Menu! Please %s to get started.', 'megamenu' ), $link); ?></p>
</div>
<?php
endif;
$css_version = get_transient("megamenu_css_version");
$css = get_transient("megamenu_css");
if ( $css && version_compare( $this->version, $css_version, '!=' ) ) :
?>
<div class="updated">
<?php
$link = "<a href='" . admin_url("admin.php?page=maxmegamenu&tab=tools") . "'>" . __( "regenerate the CSS", 'megamenu' ) . "</a>";
?>
<p><?php echo sprintf( __( 'Max Mega Menu has been updated. Please %s to ensure maximum compatibility with the latest version.', 'megamenu' ), $link); ?></p>
</div>
<?php
endif;
}
/**
* Checks this WordPress installation is v3.8 or above.
* 3.8 is needed for dashicons.
*/
public function is_compatible_wordpress_version() {
global $wp_version;
return $wp_version >= 3.8;
}
}
add_action( 'plugins_loaded', array( 'Mega_Menu', 'init' ), 10 );
endif;
if ( ! function_exists( 'max_mega_menu_is_enabled' ) ) {
/**
* Determines if Max Mega Menu has been enabled for a given menu location.
*
* Usage:
*
* Max Mega Menu is enabled:
* function_exists( 'max_mega_menu_is_enabled' )
*
* Max Mega Menu has been enabled for a theme location:
* function_exists( 'max_mega_menu_is_enabled' ) && max_mega_menu_is_enabled( $location )
*
* @since 1.8
* @param string $location - theme location identifier
*/
function max_mega_menu_is_enabled( $location = false ) {
if ( ! $location ) {
return true; // the plugin is enabled
}
// if a location has been passed, check to see if MMM has been enabled for the location
$settings = get_option( 'megamenu_settings' );
return is_array( $settings ) && isset( $settings[ $location ]['enabled'] ) && $settings[ $location ]['enabled'] == true;
}
}