PluginProbe
QuadMenu – Mega Menu / trunk
QuadMenu – Mega Menu vtrunk
3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 87 releases
quadmenu / lib / class-locations.php

class-locations.php in QuadMenu – Mega Menu trunk, at lib/class-locations.php

86 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace QuadLayers\QuadMenu;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 die( '-1' );
7 }
8 /**
9 * Locations Class ex QuadMenu_Locations
10 */
11 class Locations {
12
13 private static $instance;
14
15 public function __construct() {
16
17 $this->locations();
18
19 $this->dev();
20
21 add_action( 'init', array( $this, 'active' ), -10 );
22
23 add_action( 'admin_init', array( $this, 'save' ), 999 );
24 }
25
26 function dev() {
27
28 register_nav_menus(
29 array(
30 'quadmenu_dev' => 'QuadMenu Dev',
31 )
32 );
33
34 unset( $GLOBALS['quadmenu_locations']['quadmenu_dev'] );
35 }
36
37 function locations() {
38
39 global $quadmenu_locations;
40
41 $quadmenu_locations = get_option( QUADMENU_DB_LOCATIONS, array() );
42 }
43
44 function active() {
45
46 global $quadmenu, $quadmenu_locations, $quadmenu_active_locations;
47
48 $quadmenu_active_locations = array( 'quadmenu_dev' => true );
49
50 if ( ! empty( $quadmenu ) && is_array( $quadmenu_locations ) && count( $quadmenu_locations ) ) {
51
52 foreach ( $quadmenu_locations as $id => $location ) {
53 if ( ! empty( $quadmenu[ $id . '_integration' ] ) && ! empty( $quadmenu[ $id . '_theme' ] ) ) {
54 $quadmenu_active_locations[ $id ] = $quadmenu[ $id . '_theme' ];
55 }
56 }
57 }
58 }
59
60 public function save() {
61
62 global $_wp_registered_nav_menus, $quadmenu, $quadmenu_locations;
63
64 if ( ! empty( $quadmenu ) && is_array( $_wp_registered_nav_menus ) && count( $_wp_registered_nav_menus ) ) {
65
66 $quadmenu_locations = array();
67
68 foreach ( $_wp_registered_nav_menus as $location => $name ) {
69
70 $quadmenu_locations[ $location ] = array(
71 'name' => $name,
72 );
73 }
74
75 update_option( QUADMENU_DB_LOCATIONS, $quadmenu_locations );
76 }
77 }
78
79 public static function instance() {
80 if ( ! isset( self::$instance ) ) {
81 self::$instance = new self();
82 }
83 return self::$instance;
84 }
85 }
86