PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 1.4.0
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v1.4.0
3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / modules / megamenu / options.php
elementskit-lite / modules / megamenu Last commit date
assets 6 years ago views 6 years ago api.php 6 years ago init.php 6 years ago options.php 6 years ago walker-nav-menu.php 6 years ago
options.php
112 lines
1 <?php
2 namespace ElementsKit\Modules\Megamenu;
3 use ElementsKit\Libs\Framework\Attr;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class Options{
8 private $dir;
9 private $url;
10
11 protected $current_menu_id = null;
12
13 public function __construct() {
14 // get current directory path
15 $this->dir = dirname(__FILE__) . '/';
16
17 // get current module's url
18 $this->url = \ElementsKit::plugin_url() . 'modules/megamenu/';
19
20 add_action( 'admin_footer', [ $this, 'options_menu_item'] );
21 add_action( 'admin_footer', [ $this, 'options_megamenu'] );
22 add_action( 'admin_head', [ $this, 'save_megamenu_options'] );
23 }
24
25 public function current_menu_id() {
26
27 if ( null !== $this->current_menu_id ) {
28 return $this->current_menu_id;
29 }
30
31 $nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
32 $menu_count = count( $nav_menus );
33 $nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) sanitize_key($_REQUEST['menu']) : 0;
34 $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
35
36 $this->current_menu_id = $nav_menu_selected_id;
37
38 // If we have one theme location, and zero menus, we take them right into editing their first menu
39 $page_count = wp_count_posts( 'page' );
40 $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
41
42 // Get recently edited nav menu
43 $recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
44 if ( empty( $recently_edited ) && is_nav_menu( $this->current_menu_id ) ) {
45 $recently_edited = $this->current_menu_id;
46 }
47
48 // Use $recently_edited if none are selected
49 if ( empty( $this->current_menu_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) {
50 $this->current_menu_id = $recently_edited;
51 }
52
53 // On deletion of menu, if another menu exists, show it
54 if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) {
55 $this->current_menu_id = $nav_menus[0]->term_id;
56 }
57
58 // Set $this->current_menu_id to 0 if no menus
59 if ( $one_theme_location_no_menus ) {
60 $this->current_menu_id = 0;
61 } elseif ( empty( $this->current_menu_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
62 // if we have no selection yet, and we have menus, set to the first one in the list
63 $this->current_menu_id = $nav_menus[0]->term_id;
64 }
65
66 return $this->current_menu_id;
67
68 }
69
70 public static function get_icons() {
71 return include \ElementsKit::module_dir() . 'controls/icon-list.php';
72 }
73
74 function options_menu_item() {
75 $screen = get_current_screen();
76 if($screen->base != 'nav-menus'){
77 return;
78 }
79
80 include 'views/options-menu-item.php';
81 }
82
83 function options_megamenu() {
84 $screen = get_current_screen();
85 if($screen->base != 'nav-menus'){
86 return;
87 }
88
89 $menu_id = $this->current_menu_id();
90 $data = Attr::instance()->utils->get_option(Init::$megamenu_settings_key, []);
91 $data = (isset($data['menu_location_' . $menu_id])) ? $data['menu_location_' . $menu_id] : [];
92
93 include 'views/options-megamenu.php';
94 }
95
96 public function save_megamenu_options(){
97 $screen = get_current_screen();
98 if($screen->base != 'nav-menus' || !isset($_POST['update-nav-menu-nonce']) ){
99 return;
100 }
101 $menu_id = isset($_POST['menu']) ? sanitize_key($_POST['menu']) : 0;
102 $is_enabled = isset($_POST['is_enabled']) ? sanitize_key($_POST['is_enabled']) : 0;
103
104 $data = Attr::instance()->utils->get_option(Init::$megamenu_settings_key, []);
105 $data['menu_location_' . $menu_id] = [
106 'is_enabled' => $is_enabled,
107 ];
108
109 Attr::instance()->utils->save_sanitized(Init::$megamenu_settings_key, $data);
110
111 }
112 }