PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.0
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.0
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 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 3 weeks ago views 7 months ago api.php 3 weeks ago init.php 3 weeks ago options.php 4 years ago walker-nav-menu.php 3 weeks ago
options.php
120 lines
1 <?php
2 namespace ElementsKit_Lite\Modules\Megamenu;
3
4 use ElementsKit_Lite\Libs\Framework\Attr;
5
6 defined( 'ABSPATH' ) || exit;
7
8 class Options {
9 private $dir;
10 private $url;
11
12 protected $current_menu_id = null;
13
14 public function __construct() {
15 // get current directory path
16 $this->dir = dirname( __FILE__ ) . '/';
17
18 // get current module's url
19 $this->url = \ElementsKit_Lite::plugin_url() . 'modules/megamenu/';
20
21 add_action( 'admin_footer', array( $this, 'options_menu_item' ) );
22 add_action( 'admin_footer', array( $this, 'options_megamenu' ) );
23 add_action( 'admin_head', array( $this, 'save_megamenu_options' ) );
24 }
25
26 public function current_menu_id() {
27
28 if ( null !== $this->current_menu_id ) {
29 return $this->current_menu_id;
30 }
31
32 $nav_menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
33 $menu_count = count( $nav_menus );
34
35 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are taking menu id from the URL. The method only can access admin. So nonce verification is not required.
36 $nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
37
38 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are taking menu id from the URL. The method only can access admin. So nonce verification is not required.
39 $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
40
41 $this->current_menu_id = $nav_menu_selected_id;
42
43 // If we have one theme location, and zero menus, we take them right into editing their first menu
44 $page_count = wp_count_posts( 'page' );
45 $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
46
47 // Get recently edited nav menu
48 $recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
49 if ( empty( $recently_edited ) && is_nav_menu( $this->current_menu_id ) ) {
50 $recently_edited = $this->current_menu_id;
51 }
52
53 // Use $recently_edited if none are selected
54 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are checking the menu id exist or not. The method only can access admin. So nonce verification is not required.
55 if ( empty( $this->current_menu_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) {
56 $this->current_menu_id = $recently_edited;
57 }
58
59 // On deletion of menu, if another menu exists, show it
60 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are checking the post action type. The method only can access admin. So nonce verification is not required.
61 if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) {
62 $this->current_menu_id = $nav_menus[0]->term_id;
63 }
64
65 // Set $this->current_menu_id to 0 if no menus
66 if ( $one_theme_location_no_menus ) {
67 $this->current_menu_id = 0;
68 } elseif ( empty( $this->current_menu_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
69 // if we have no selection yet, and we have menus, set to the first one in the list
70 $this->current_menu_id = $nav_menus[0]->term_id;
71 }
72
73 return $this->current_menu_id;
74 }
75
76 public static function get_icons() {
77 return include \ElementsKit_Lite::module_dir() . 'elementskit-icon-pack/icon-list.php';
78 }
79
80 function options_menu_item() {
81 $screen = get_current_screen();
82 if ( $screen->base != 'nav-menus' ) {
83 return;
84 }
85
86 include 'views/options-menu-item.php';
87 }
88
89 function options_megamenu() {
90 $screen = get_current_screen();
91 if ( $screen->base != 'nav-menus' ) {
92 return;
93 }
94
95 $menu_id = $this->current_menu_id();
96 $data = Attr::instance()->utils->get_option( Init::$megamenu_settings_key, array() );
97 $data = ( isset( $data[ 'menu_location_' . $menu_id ] ) ) ? $data[ 'menu_location_' . $menu_id ] : array();
98
99 include 'views/options-megamenu.php';
100 }
101
102 public function save_megamenu_options() {
103 $screen = get_current_screen();
104
105 if ( $screen->base != 'nav-menus' || ! isset( $_POST['update-nav-menu-nonce'] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['update-nav-menu-nonce'] ) ), 'update-nav_menu') ) {
106 return;
107 }
108
109 $menu_id = isset( $_POST['menu'] ) ? wp_unslash(intval($_POST['menu'])) : 0;
110 $is_enabled = isset( $_POST['is_enabled'] ) ? wp_unslash(intval($_POST['is_enabled'])) : 0;
111
112 $data = Attr::instance()->utils->get_option( Init::$megamenu_settings_key, array() );
113 $data[ 'menu_location_' . $menu_id ] = array(
114 'is_enabled' => $is_enabled,
115 );
116
117 Attr::instance()->utils->save_option( Init::$megamenu_settings_key, $data );
118 }
119 }
120