| Server IP : 159.203.156.69 / Your IP : 216.73.216.37 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/php/green-estate-prod/wp-content/themes/spaciaz/inc/megamenu/ |
Upload File : |
<?php
defined('ABSPATH') || exit();
class Spaciaz_Megamenu {
private $menu_items = [];
public function __construct() {
$this->includes_core();
$this->check_megamenu();
$this->includes();
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
add_filter('spaciaz_nav_menu_args', [$this, 'set_menu_args'], 99999);
}
public function set_menu_args($args) {
$args['walker'] = new Spaciaz_Megamenu_Walker();
return $args;
}
private function check_megamenu() {
$all_locations = get_nav_menu_locations();
$main = $vertical = false;
if (isset(get_nav_menu_locations()['vertical'])) {
$vertical = wp_get_nav_menu_items(get_term($all_locations['vertical'], 'nav_menu')->term_id);
}
if (isset(get_nav_menu_locations()['primary'])) {
$main = wp_get_nav_menu_items(get_term($all_locations['primary'], 'nav_menu')->term_id);
}
$all = wp_parse_args($main, $vertical);
foreach ($all as $menu_item) {
$elementor_id = spaciaz_megamenu_get_post_related_menu($menu_item->ID);
if ($elementor_id) {
$this->menu_items[] = $elementor_id;
}
}
}
private function includes_core() {
if (is_admin()) {
include_once get_template_directory() . '/inc/megamenu/includes/admin/class-admin.php';
include_once get_template_directory() . '/inc/megamenu/includes/hook-functions.php';
}
include_once get_template_directory() . '/inc/megamenu/includes/core-functions.php';
}
private function includes() {
include_once get_template_directory() . '/inc/megamenu/includes/class-menu-walker.php';
}
public function enqueue_scripts() {
wp_enqueue_script('spaciaz-megamenu-frontend', get_template_directory_uri() . '/inc/megamenu/assets/js/frontend.js', array('jquery'), SPACIAZ_VERSION, true);
foreach ($this->menu_items as $id) {
Elementor\Core\Files\CSS\Post::create($id)->enqueue();
}
}
}
return new Spaciaz_Megamenu();