WP init
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace ElementsKit_Lite;
|
||||
|
||||
use ElementsKit_Lite\Libs\Framework\Attr;
|
||||
use ElementsKit_Lite\Modules\Megamenu\Init;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Megamenu_Api extends Core\Handler_Api {
|
||||
|
||||
public function config() {
|
||||
$this->prefix = 'megamenu';
|
||||
}
|
||||
|
||||
public function get_save_menuitem_settings() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
$menu_item_id = $this->request['settings']['menu_id'];
|
||||
$menu_item_settings = wp_json_encode( $this->request['settings'], JSON_UNESCAPED_UNICODE );
|
||||
update_post_meta( $menu_item_id, Init::$menuitem_settings_key, $menu_item_settings );
|
||||
|
||||
return array(
|
||||
'saved' => 1,
|
||||
'message' => esc_html__( 'Saved', 'elementskit-lite' ),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_get_menuitem_settings() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
$menu_item_id = $this->request['menu_id'];
|
||||
|
||||
$data = get_post_meta( $menu_item_id, Init::$menuitem_settings_key, true );
|
||||
return (array) json_decode( $data );
|
||||
}
|
||||
|
||||
public function get_megamenu_content() {
|
||||
$menu_item_id = intval($this->request['id']);
|
||||
|
||||
if ('publish' !== get_post_status ($menu_item_id) || post_password_required($menu_item_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$elementor = \Elementor\Plugin::instance();
|
||||
$output = $elementor->frontend->get_builder_content_for_display($menu_item_id);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
new Megamenu_Api();
|
||||
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
.icons-selector *{margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline}.icons-selector,.icons-selector *,.icons-selector :after,.icons-selector :before,.icons-selector:after,.icons-selector:before{-webkit-box-sizing:content-box;box-sizing:content-box}.icons-selector{display:inline-block;vertical-align:middle;text-align:left}.icons-selector .selector{width:100px;height:40px}.icons-selector .selector-button{width:39px;height:100%;display:block;text-align:center;cursor:pointer;float:left}.icons-selector .selector-button i{line-height:38px;text-align:center}.icons-selector .selected-icon{display:block;width:60px;height:100%;float:left;text-align:center}.icons-selector .selected-icon i{line-height:40px;font-size:18px;cursor:default}.icons-selector .selector-popup{position:absolute;z-index:10000;background-color:#fefefe;padding:5px;height:auto;width:342px;margin-top:-1px}.icons-selector .selector-category select,.icons-selector .selector-search input[type=text]{border:0;line-height:20px;padding:10px 2.5%;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;margin-bottom:5px;font-size:12px;display:block}.icons-selector .selector-category select{height:40px}.icons-selector .selector-category select option{padding:10px}.icons-selector input::-webkit-input-placeholder{text-transform:uppercase}.icons-selector input:-moz-placeholder{text-transform:uppercase}.icons-selector input::-moz-placeholder{text-transform:uppercase}.icons-selector input:-ms-input-placeholder{text-transform:uppercase}.icons-selector .selector-search{position:relative}.icons-selector .selector-search i{position:absolute;right:10px;top:7px}.icons-selector .fip-icons-container{width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;padding:5px}.icons-selector .fip-icons-container .loading{font-size:24px;margin:0 auto;padding:20px 0;text-align:center;width:100%}.icons-selector .fip-box{display:inline-block;margin:2px;width:60px;line-height:42px;text-align:center;cursor:pointer;vertical-align:top;height:40px}.icons-selector .selector-footer{line-height:12px;padding:5px 5px 0 5px;text-align:center}.icons-selector .selector-footer,.icons-selector .selector-footer i{font-size:14px}.icons-selector .selector-arrows{float:right}.icons-selector .selector-pages{font-size:11px;float:left}.icons-selector .selector-arrows i{cursor:pointer}.icons-selector .selector-footer em{font-style:italic}.icons-selector .icons-picker-error i:before{color:#eee}@font-face{font-family:iconpicker;src:url(../fonts/iconpicker.eot?90190138);src:url(../fonts/iconpicker.eot?90190138#iefix) format('embedded-opentype'),url(../fonts/iconpicker.woff?90190138) format('woff'),url(../fonts/iconpicker.ttf?90190138) format('truetype'),url(../fonts/iconpicker.svg?90190138#iconpicker) format('svg');font-weight:400;font-style:normal}.icons-selector [class*=" fip-icon-"]:before,.icons-selector [class^=fip-icon-]:before{font-family:iconpicker;font-style:normal;font-weight:400;speak:none;display:inline-block;text-decoration:inherit;width:1em;margin-right:.2em;text-align:center;font-variant:normal;text-transform:none;line-height:1em;margin-left:.2em}.icons-selector .fip-icon-search:before{content:'\e812';cursor:default}.icons-selector .fip-icon-cancel:before{content:'\e814';cursor:pointer}.icons-selector .fip-icon-block:before{content:'\e84e';color:#fed0d0}.icons-selector .fip-icon-down-dir:before{content:'\e800'}.icons-selector .fip-icon-up-dir:before{content:'\e813'}.icons-selector .fip-icon-left-dir:before{content:'\e801'}.icons-selector .fip-icon-right-dir:before{content:'\e802'}.icons-selector .fip-icon-spin3:before{content:'\e815'}.icons-selector .fip-icon-spin3{-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear;display:inline-block}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Copyright (C) 2014 by original authors @ fontello.com</metadata>
|
||||
<defs>
|
||||
<font id="iconpicker" horiz-adv-x="1000" >
|
||||
<font-face font-family="iconpicker" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
|
||||
<missing-glyph horiz-adv-x="1000" />
|
||||
<glyph glyph-name="spin3" unicode="" d="m494 850c-266 0-483-210-494-472c-1-19 13-20 13-20l84 0c16 0 19 10 19 18c10 199 176 358 378 358c107 0 205-45 273-118l-58-57c-11-12-11-27 5-31l247-50c21-5 46 11 37 44l-58 227c-2 9-16 22-29 13l-65-60c-89 91-214 148-352 148z m409-508c-16 0-19-10-19-18c-10-199-176-358-377-358c-108 0-205 45-274 118l59 57c10 12 10 27-5 31l-248 50c-21 5-46-11-37-44l58-227c2-9 16-22 30-13l64 60c89-91 214-148 353-148c265 0 482 210 493 473c1 18-13 19-13 19l-84 0z" horiz-adv-x="1000" />
|
||||
<glyph glyph-name="search" unicode="" d="m643 386q0 103-74 176t-176 74t-177-74t-73-176t73-177t177-73t176 73t74 177z m286-465q0-29-22-50t-50-21q-30 0-50 21l-191 191q-100-69-223-69q-80 0-153 31t-125 84t-84 125t-31 153t31 152t84 126t125 84t153 31t152-31t126-84t84-126t31-152q0-123-69-223l191-191q21-21 21-51z" horiz-adv-x="928.6" />
|
||||
<glyph glyph-name="cancel" unicode="" d="m724 112q0-22-15-38l-76-76q-16-15-38-15t-38 15l-164 165l-164-165q-16-15-38-15t-38 15l-76 76q-16 16-16 38t16 38l164 164l-164 164q-16 16-16 38t16 38l76 76q16 16 38 16t38-16l164-164l164 164q16 16 38 16t38-16l76-76q15-15 15-38t-15-38l-164-164l164-164q15-15 15-38z" horiz-adv-x="785.7" />
|
||||
<glyph glyph-name="block" unicode="" d="m732 352q0 90-48 164l-421-420q76-50 166-50q62 0 118 25t96 65t65 97t24 119z m-557-167l421 421q-75 50-167 50q-83 0-153-40t-110-112t-41-152q0-91 50-167z m682 167q0-88-34-168t-91-137t-137-92t-166-34t-167 34t-137 92t-91 137t-34 168t34 167t91 137t137 91t167 34t166-34t137-91t91-137t34-167z" horiz-adv-x="857.1" />
|
||||
<glyph glyph-name="down-dir" unicode="" d="m571 457q0-14-10-25l-250-250q-11-11-25-11t-25 11l-250 250q-11 11-11 25t11 25t25 11h500q14 0 25-11t10-25z" horiz-adv-x="571.4" />
|
||||
<glyph glyph-name="up-dir" unicode="" d="m571 171q0-14-10-25t-25-10h-500q-15 0-25 10t-11 25t11 26l250 250q10 10 25 10t25-10l250-250q10-11 10-26z" horiz-adv-x="571.4" />
|
||||
<glyph glyph-name="left-dir" unicode="" d="m357 600v-500q0-14-10-25t-26-11t-25 11l-250 250q-10 11-10 25t10 25l250 250q11 11 25 11t26-11t10-25z" horiz-adv-x="357.1" />
|
||||
<glyph glyph-name="right-dir" unicode="" d="m321 350q0-14-10-25l-250-250q-11-11-25-11t-25 11t-11 25v500q0 15 11 25t25 11t25-11l250-250q10-10 10-25z" horiz-adv-x="357.1" />
|
||||
</font>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace ElementsKit_Lite\Modules\Megamenu;
|
||||
|
||||
use ElementsKit_Lite;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Init {
|
||||
|
||||
public $dir;
|
||||
|
||||
public $url;
|
||||
|
||||
public static $menuitem_settings_key = 'elementskit_menuitem_settings';
|
||||
public static $megamenu_settings_key = 'megamenu_settings';
|
||||
|
||||
public function __construct() {
|
||||
|
||||
// get current directory path
|
||||
$this->dir = dirname( __FILE__ ) . '/';
|
||||
|
||||
// get current module's url
|
||||
$this->url = \ElementsKit_Lite::plugin_url() . 'modules/megamenu/';
|
||||
|
||||
// enqueue scripts
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
|
||||
// include all necessary files
|
||||
$this->include_files();
|
||||
|
||||
new Options();
|
||||
}
|
||||
|
||||
public function include_files() {
|
||||
include $this->dir . 'api.php';
|
||||
include $this->dir . 'walker-nav-menu.php';
|
||||
|
||||
$backward_class_file = ElementsKit_Lite::plugin_dir() . 'compatibility/backward/walker-nav-menu-backward-compatiblity.php';
|
||||
if ( file_exists( $backward_class_file ) ) {
|
||||
include $backward_class_file;
|
||||
}
|
||||
}
|
||||
|
||||
public function enqueue_styles() {
|
||||
$screen = get_current_screen();
|
||||
if ( $screen->base == 'nav-menus' ) {
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_style( 'fonticonpicker', $this->url . 'assets/css/jquery.fonticonpicker.css', false, \ElementsKit_Lite::version() );
|
||||
wp_enqueue_style( 'elementskit-menu-admin-style', $this->url . 'assets/css/admin-style.css', false, \ElementsKit_Lite::version() );
|
||||
}
|
||||
}
|
||||
|
||||
public function enqueue_scripts() {
|
||||
$screen = get_current_screen();
|
||||
if ( $screen->base == 'nav-menus' ) {
|
||||
wp_enqueue_script( 'fonticonpicker', $this->url . 'assets/js/jquery.fonticonpicker.min.js', array( 'jquery' ), \ElementsKit_Lite::version(), true );
|
||||
wp_enqueue_script( 'elementskit-menu-admin-script', $this->url . 'assets/js/admin-script.js', array( 'jquery', 'wp-color-picker' ), \ElementsKit_Lite::version(), true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace ElementsKit_Lite\Modules\Megamenu;
|
||||
|
||||
use ElementsKit_Lite\Libs\Framework\Attr;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Options {
|
||||
private $dir;
|
||||
private $url;
|
||||
|
||||
protected $current_menu_id = null;
|
||||
|
||||
public function __construct() {
|
||||
// get current directory path
|
||||
$this->dir = dirname( __FILE__ ) . '/';
|
||||
|
||||
// get current module's url
|
||||
$this->url = \ElementsKit_Lite::plugin_url() . 'modules/megamenu/';
|
||||
|
||||
add_action( 'admin_footer', array( $this, 'options_menu_item' ) );
|
||||
add_action( 'admin_footer', array( $this, 'options_megamenu' ) );
|
||||
add_action( 'admin_head', array( $this, 'save_megamenu_options' ) );
|
||||
}
|
||||
|
||||
public function current_menu_id() {
|
||||
|
||||
if ( null !== $this->current_menu_id ) {
|
||||
return $this->current_menu_id;
|
||||
}
|
||||
|
||||
$nav_menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
|
||||
$menu_count = count( $nav_menus );
|
||||
|
||||
// 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.
|
||||
$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
|
||||
|
||||
// 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.
|
||||
$add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
|
||||
|
||||
$this->current_menu_id = $nav_menu_selected_id;
|
||||
|
||||
// If we have one theme location, and zero menus, we take them right into editing their first menu
|
||||
$page_count = wp_count_posts( 'page' );
|
||||
$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
|
||||
|
||||
// Get recently edited nav menu
|
||||
$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
|
||||
if ( empty( $recently_edited ) && is_nav_menu( $this->current_menu_id ) ) {
|
||||
$recently_edited = $this->current_menu_id;
|
||||
}
|
||||
|
||||
// Use $recently_edited if none are selected
|
||||
// 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.
|
||||
if ( empty( $this->current_menu_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) {
|
||||
$this->current_menu_id = $recently_edited;
|
||||
}
|
||||
|
||||
// On deletion of menu, if another menu exists, show it
|
||||
// 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.
|
||||
if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) {
|
||||
$this->current_menu_id = $nav_menus[0]->term_id;
|
||||
}
|
||||
|
||||
// Set $this->current_menu_id to 0 if no menus
|
||||
if ( $one_theme_location_no_menus ) {
|
||||
$this->current_menu_id = 0;
|
||||
} elseif ( empty( $this->current_menu_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
|
||||
// if we have no selection yet, and we have menus, set to the first one in the list
|
||||
$this->current_menu_id = $nav_menus[0]->term_id;
|
||||
}
|
||||
|
||||
return $this->current_menu_id;
|
||||
}
|
||||
|
||||
public static function get_icons() {
|
||||
return include \ElementsKit_Lite::module_dir() . 'elementskit-icon-pack/icon-list.php';
|
||||
}
|
||||
|
||||
function options_menu_item() {
|
||||
$screen = get_current_screen();
|
||||
if ( $screen->base != 'nav-menus' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
include 'views/options-menu-item.php';
|
||||
}
|
||||
|
||||
function options_megamenu() {
|
||||
$screen = get_current_screen();
|
||||
if ( $screen->base != 'nav-menus' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$menu_id = $this->current_menu_id();
|
||||
$data = Attr::instance()->utils->get_option( Init::$megamenu_settings_key, array() );
|
||||
$data = ( isset( $data[ 'menu_location_' . $menu_id ] ) ) ? $data[ 'menu_location_' . $menu_id ] : array();
|
||||
|
||||
include 'views/options-megamenu.php';
|
||||
}
|
||||
|
||||
public function save_megamenu_options() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
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') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$menu_id = isset( $_POST['menu'] ) ? wp_unslash(intval($_POST['menu'])) : 0;
|
||||
$is_enabled = isset( $_POST['is_enabled'] ) ? wp_unslash(intval($_POST['is_enabled'])) : 0;
|
||||
|
||||
$data = Attr::instance()->utils->get_option( Init::$megamenu_settings_key, array() );
|
||||
$data[ 'menu_location_' . $menu_id ] = array(
|
||||
'is_enabled' => $is_enabled,
|
||||
);
|
||||
|
||||
Attr::instance()->utils->save_option( Init::$megamenu_settings_key, $data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<script>
|
||||
var elementskit_options_megamenu_markup = `
|
||||
<fieldset class="menu-settings-group elementskit-options-megamenu" id="elementskit-options-megamenu">
|
||||
<legend class="menu-settings-group-name attr-text-bold"><?php esc_html_e( 'ElementsKit Megamenu', 'elementskit-lite' ); ?></legend>
|
||||
<div class="menu-settings-input checkbox-input">
|
||||
<input name="is_enabled" type="checkbox" <?php checked( ( isset( $data['is_enabled'] ) ? $data['is_enabled'] : '' ), '1' ); ?> id="elementskit-menu-metabox-input-is-enabled" class="elementskit-menu-is-enabled" value="1">
|
||||
<label for="elementskit-menu-metabox-input-is-enabled"><?php esc_html_e( 'Enable this menu for Megamenu content', 'elementskit-lite' ); ?></label><br>
|
||||
<p class="notice notice-warning" style="margin-top: 10px;padding-top: 10px;padding-bottom: 10px;background:#f3f3f3;">After enabling this, you need to use ElementsKit's header-footer module with <b>elementskit nav-menu</b> widget to show the mega menu. <a href="https://help.wpmet.com/docs/mega-menu-module/" target="_blank">See here how to do it.</a></p>
|
||||
</div>
|
||||
</fieldset>
|
||||
`;
|
||||
|
||||
var elementskit_megamenu_nonce = `<?php echo esc_attr( wp_create_nonce( 'wp_rest' ) ); ?>`;
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,191 @@
|
||||
<div class="attr-modal attr-fade" id="attr_menu_control_panel_modal" tabindex="-1" role="dialog">
|
||||
<div class="attr-modal-dialog attr-modal-dialog-centered" role="document">
|
||||
<div class="attr-modal-content ekit_menu_modal_content">
|
||||
<div class="attr-modal-header">
|
||||
<ul class="tb-nav tb-nav-tabs ekit_menu_control_nav" role="tablist">
|
||||
<li role="presentation" id="attr_content_nav" class="attr-active"><a class="attr-nav-link" href="#attr_content_tab" aria-controls="attr_content_tab"
|
||||
role="tab" data-attr-toggle="tab"><?php esc_html_e( 'Content', 'elementskit-lite' ); ?></a></li>
|
||||
<li role="presentation" id="attr_icon_nav"><a class="attr-nav-link ekit-<?php echo esc_attr(ElementsKit_Lite::package_type()); ?>-labal" href="#attr_icon_tab" aria-controls="attr_icon_tab" role="tab"
|
||||
data-attr-toggle="tab"><?php esc_html_e( 'Icon', 'elementskit-lite' ); ?></a></li>
|
||||
<li role="presentation" id="attr_badge_nav"><a class="attr-nav-link ekit-<?php echo esc_attr(ElementsKit_Lite::package_type()); ?>-labal" href="#attr_badge_tab" aria-controls="attr_badge_tab"
|
||||
role="tab" data-attr-toggle="tab"><?php esc_html_e( 'Badge', 'elementskit-lite' ); ?></a></li>
|
||||
<li role="presentation" id="attr_badge_nav"><a class="attr-nav-link" href="#attr_vertical_menu_setting_tab" aria-controls="attr_vertical_menu_setting_tab"
|
||||
role="tab" data-attr-toggle="tab"><?php esc_html_e( 'Settings', 'elementskit-lite' ); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="attr-modal-body ekit-wid-con">
|
||||
<div class="attr-tab-content">
|
||||
<div role="tabpanel" class="attr-tab-pane attr-active" id="attr_content_tab">
|
||||
<?php if ( defined( 'ELEMENTOR_VERSION' ) ) : ?>
|
||||
<div class="switch-wrapper">
|
||||
<input type="checkbox" value="1" id="elementskit-menu-item-enable" />
|
||||
<label for="elementskit-menu-item-enable"><span><em></em></span></label>
|
||||
</div>
|
||||
<div id="elementskit-menu-builder-warper">
|
||||
<small
|
||||
class="elementskit-menu-mega-submenu enabled_item"><?php esc_html_e( 'Megamenu enabled', 'elementskit-lite' ); ?></small>
|
||||
<small
|
||||
class="elementskit-menu-mega-submenu disabled_item"><?php esc_html_e( 'Megamenu disabled', 'elementskit-lite' ); ?></small>
|
||||
|
||||
<button disabled type="button" id="elementskit-menu-builder-trigger"
|
||||
class="elementskit-menu-elementor-button button" data-attr-toggle="modal"
|
||||
data-target="#elementskit-menu-builder-modal">
|
||||
<img src="<?php echo esc_url( $this->url ); ?>/assets/images/elementor-icon.png"
|
||||
alt="<?php esc_attr_e( 'elementskit megamenu', 'elementskit-lite' ); ?>" />
|
||||
<?php esc_html_e( 'Edit megamenu content', 'elementskit-lite' ); ?>
|
||||
</button>
|
||||
|
||||
<div id="mobile_submenu_content_type" class="ekit-<?php echo esc_attr(ElementsKit_Lite::package_type()); ?>-labal ekit-<?php echo esc_attr(ElementsKit_Lite::package_type()); ?>-labal-container">
|
||||
<strong><?php esc_html_e( 'Use mobile submenu as:', 'elementskit-lite' ); ?></strong>
|
||||
<span><input type="radio" name="content_type" checked value="builder_content"> <?php esc_html_e( 'builder content', 'elementskit-lite' ); ?></span>
|
||||
<span><input type="radio" name="content_type" value="submenu_list"> <?php esc_html_e( 'wp submenu list', 'elementskit-lite' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p class="no-elementor-notice">
|
||||
<?php esc_html_e( 'This plugin requires Elementor page builder to edt megamenu items content', 'elementskit-lite' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div role="tabpanel" class="attr-tab-pane" id="attr_icon_tab">
|
||||
<table class="option-table ekit-<?php echo esc_attr(ElementsKit_Lite::package_type()); ?>-labal-container">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong><?php esc_html_e( 'Choose icon color', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright">
|
||||
<input type="text" value="#bada55" class="elementskit-menu-wpcolor-picker"
|
||||
id="elementskit-menu-icon-color-field" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?php esc_html_e( 'Select icon', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright">
|
||||
<select id="elementskit-menu-icon-field" class="elementskit-menu-icon-picker">
|
||||
<option value=""><?php esc_html_e( 'No icon', 'elementskit-lite' ); ?></option>
|
||||
<?php
|
||||
foreach ( self::get_icons() as $icon_class ) {
|
||||
echo "<option value='" . esc_attr( $icon_class ) . "'>'" . esc_html( $icon_class ) . "'</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div role="tabpanel" class="attr-tab-pane" id="attr_badge_tab">
|
||||
<table class="option-table ekit-<?php echo esc_attr(ElementsKit_Lite::package_type()); ?>-labal ekit-<?php echo esc_attr(ElementsKit_Lite::package_type()); ?>-labal-container">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong><?php esc_html_e( 'Badge text', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright">
|
||||
<input type="text"
|
||||
placeholder="<?php esc_html_e( 'Badge Text', 'elementskit-lite' ); ?>"
|
||||
id="elementskit-menu-badge-text-field" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><strong><?php esc_html_e( 'Choose badge color', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright">
|
||||
<input type="text" class="elementskit-menu-wpcolor-picker" value="#ffffff"
|
||||
id="elementskit-menu-badge-color-field" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><strong><?php esc_html_e( 'Choose badge background', 'elementskit-lite' ); ?></strong>
|
||||
</td>
|
||||
<td class="alignright">
|
||||
<input type="text" class="elementskit-menu-wpcolor-picker" value="#bada55"
|
||||
id="elementskit-menu-badge-background-field" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div role="tabpanel" class="attr-tab-pane" id="attr_vertical_menu_setting_tab">
|
||||
<table class="option-table">
|
||||
<tbody class="xs_menu_settings_panel">
|
||||
<tr id="xs_megamenu_width_type">
|
||||
<td><strong><?php esc_html_e( 'Mega Menu Width as:', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright ekit_width_lists">
|
||||
<input type="radio" name="width_type" id="width_type_default" value="default_width" checked>
|
||||
<label for="width_type_default"><?php esc_html_e( 'Default Width', 'elementskit-lite' ); ?></label>
|
||||
<input type="radio" id="width_type_full" name="width_type" value="full_width">
|
||||
<label for="width_type_full"><?php esc_html_e( 'Full Width', 'elementskit-lite' ); ?></label>
|
||||
<input type="radio" id="width_type_custom" name="width_type" value="custom_width">
|
||||
<label for="width_type_custom"><?php esc_html_e( 'Custom Width', 'elementskit-lite' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="menu-width-container">
|
||||
<td><strong><?php esc_html_e( 'Menu Width', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright">
|
||||
<input type="text" placeholder="<?php esc_html_e( '750px', 'elementskit-lite' ); ?>" id="elementskit-menu-vertical-menu-width-field" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="vertical_megamenu_position_type">
|
||||
<td><strong><?php esc_html_e( 'Mega Menu Position as:', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright">
|
||||
<input type="radio" id="position_type_top" name="position_type" value="top_position">
|
||||
<label for="position_type_top"><?php esc_html_e( 'Default', 'elementskit-lite' ); ?></label>
|
||||
<input type="radio" name="position_type" id="position_type_relative" checked value="relative_position">
|
||||
<label for="position_type_relative"><?php esc_html_e( 'Relative', 'elementskit-lite' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="enable_ajax_load">
|
||||
<td><strong><?php esc_html_e( 'Enable Ajax Load:', 'elementskit-lite' ); ?></strong></td>
|
||||
<td class="alignright">
|
||||
<input type="radio" id="ajax_load_yes" name="megamenu_ajax_load" value="yes">
|
||||
<label for="ajax_load_yes"><?php esc_html_e( 'Yes', 'elementskit-lite' ); ?></label>
|
||||
<input type="radio" id="ajax_load_no" name="megamenu_ajax_load" checked value="no">
|
||||
<label for="ajax_load_no"><?php esc_html_e( 'No', 'elementskit-lite' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="attr-modal-footer">
|
||||
<input type="hidden" id="elementskit-menu-modal-menu-id">
|
||||
<input type="hidden" id="elementskit-menu-modal-menu-has-child">
|
||||
<div class="clearfix ekit-modal-controls">
|
||||
<div class="left-content">
|
||||
<button class="btn-modal-close" type="button" data-dismiss="modal">
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" xmlns="https://www.w3.org/2000/svg">
|
||||
<line fill="none" stroke="#000" stroke-width="1.1" x1="1" y1="1" x2="13" y2="13"></line>
|
||||
<line fill="none" stroke="#000" stroke-width="1.1" x1="13" y1="1" x2="1" y2="13"></line>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<div class="right-content">
|
||||
<a class="button button-default alignleft" href="https://help.wpmet.com/docs/mega-menu-module/" target="_blank" >Megamenu Turorial</a>
|
||||
|
||||
<span class='spinner'></span>
|
||||
<?php echo wp_kses( get_submit_button( esc_html__( 'Save', 'elementskit-lite' ), 'elementskit-menu-item-save button-primary alignright', '', false ), ['input'=>['class'=>[], 'type'=>[], 'value'=>[]]] ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span id="elementskit-menu-modal-spinner" class='spinner'></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="attr-modal attr-fade" id="elementskit-menu-builder-modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
|
||||
<div class="attr-modal-dialog attr-modal-dialog-centered" role="document">
|
||||
<div class="attr-modal-content">
|
||||
<div class="attr-modal-body">
|
||||
<button class="ekit_close" type="button" data-dismiss="modal"><svg width="20" height="20"
|
||||
viewBox="0 0 20 20" xmlns="https://www.w3.org/2000/svg">
|
||||
<line fill="none" stroke="#fff" stroke-width="1.4" x1="1" y1="1" x2="19" y2="19"></line>
|
||||
<line fill="none" stroke="#fff" stroke-width="1.4" x1="19" y1="1" x2="1" y2="19"></line>
|
||||
</svg></button>
|
||||
<iframe id="elementskit-menu-builder-iframe" src="" frameborder="0"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
namespace ElementsKit_Lite;
|
||||
|
||||
use \ElementsKit_Lite\Modules\Megamenu\Init;
|
||||
use \ElementsKit_Lite\Libs\Framework\Attr;
|
||||
|
||||
class ElementsKit_Menu_Walker extends \Walker_Nav_Menu {
|
||||
|
||||
public $menu_Settings;
|
||||
|
||||
// custom methods
|
||||
public function get_item_meta( $menu_item_id ) {
|
||||
$meta_key = Init::$menuitem_settings_key;
|
||||
$data = get_post_meta( $menu_item_id, $meta_key, true );
|
||||
$data = (array) json_decode( $data );
|
||||
|
||||
$default = array(
|
||||
'menu_id' => null,
|
||||
'menu_has_child' => '',
|
||||
'menu_enable' => 0,
|
||||
'menu_icon' => '',
|
||||
'menu_icon_color' => '',
|
||||
'menu_badge_text' => '',
|
||||
'menu_badge_color' => '',
|
||||
'menu_badge_background' => '',
|
||||
'mobile_submenu_content_type' => 'builder_content',
|
||||
'vertical_megamenu_position_type' => 'relative_position',
|
||||
'vertical_menu_width' => '',
|
||||
'megamenu_width_type' => 'default_width',
|
||||
'megamenu_ajax_load' => 'no',
|
||||
);
|
||||
return array_merge( $default, $data );
|
||||
}
|
||||
|
||||
public function is_megamenu( $menu_slug ) {
|
||||
$menu_obj = wp_get_nav_menu_object($menu_slug);
|
||||
$menu_slug = ( ( ( gettype( $menu_obj ) == 'object' ) && ( isset( $menu_obj->slug ) ) ) ? $menu_obj->slug : $menu_slug );
|
||||
|
||||
$cache_key = 'elementskit_megamenu_data_' . $menu_slug;
|
||||
$cached = wp_cache_get( $cache_key );
|
||||
if ( false !== $cached ) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
$return = 0;
|
||||
|
||||
$modules_all = \ElementsKit_Lite\Config\Module_List::instance()->get_list();
|
||||
$modules_active = \ElementsKit_Lite\Libs\Framework\Classes\Utils::instance()->get_option( 'module_list', $modules_all );
|
||||
$modules_active = ( ! isset( $modules_active[0] ) ? array_keys( $modules_active ) : $modules_active );
|
||||
|
||||
$settings = Attr::instance()->utils->get_option( Init::$megamenu_settings_key, array() );
|
||||
$term = get_term_by( 'slug', $menu_slug, 'nav_menu' );
|
||||
|
||||
if ( in_array( 'megamenu', $modules_active )
|
||||
&& isset( $term->term_id )
|
||||
&& isset( $settings[ 'menu_location_' . $term->term_id ] )
|
||||
&& $settings[ 'menu_location_' . $term->term_id ]['is_enabled'] == '1' ) {
|
||||
|
||||
$return = 1;
|
||||
}
|
||||
|
||||
wp_cache_set( $cache_key, $return );
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function is_megamenu_item( $item_meta, $menu ) {
|
||||
if ( $this->is_megamenu( $menu ) == 1 && $item_meta['menu_enable'] == 1 && class_exists( 'Elementor\Plugin' ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the list before the elements are added.
|
||||
*
|
||||
* @see Walker::start_lvl()
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param array $args An array of arguments. @see wp_nav_menu()
|
||||
*/
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "\n$indent<ul class=\"elementskit-dropdown elementskit-submenu-panel\">\n";
|
||||
}
|
||||
/**
|
||||
* Ends the list of after the elements are added.
|
||||
*
|
||||
* @see Walker::end_lvl()
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param array $args An array of arguments. @see wp_nav_menu()
|
||||
*/
|
||||
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "$indent</ul>\n";
|
||||
}
|
||||
/**
|
||||
* Start the element output.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $item Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param array $args An array of arguments. @see wp_nav_menu()
|
||||
* @param int $id Current item ID.
|
||||
*/
|
||||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
$classes[] = 'menu-item-' . $item->ID;
|
||||
|
||||
/**
|
||||
* Filter the CSS class(es) applied to a menu item's list item element.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @since 4.1.0 The `$depth` parameter was added.
|
||||
*
|
||||
* @param array $classes The CSS classes that are applied to the menu item's `<li>` element.
|
||||
* @param object $item The current menu item.
|
||||
* @param array $args An array of {@see wp_nav_menu()} arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
|
||||
// New
|
||||
$class_names .= ' nav-item';
|
||||
$item_meta = $this->get_item_meta( $item->ID );
|
||||
$is_megamenu_item = $this->is_megamenu_item( $item_meta, $args->menu );
|
||||
|
||||
if ( in_array( 'menu-item-has-children', $classes ) || $is_megamenu_item == true ) {
|
||||
$class_names .= ' elementskit-dropdown-has ' . $item_meta['vertical_megamenu_position_type'] . ' elementskit-dropdown-menu-' . $item_meta['megamenu_width_type'] . '';
|
||||
}
|
||||
|
||||
if ( $is_megamenu_item == true ) {
|
||||
$class_names .= ' elementskit-megamenu-has';
|
||||
}
|
||||
|
||||
if ( $item_meta['mobile_submenu_content_type'] == 'builder_content' ) {
|
||||
$class_names .= ' elementskit-mobile-builder-content';
|
||||
}
|
||||
|
||||
if ( in_array( 'current-menu-item', $classes ) ) {
|
||||
$class_names .= ' active';
|
||||
}
|
||||
|
||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||
|
||||
/**
|
||||
* Filter the ID applied to a menu item's list item element.
|
||||
*
|
||||
* @since 3.0.1
|
||||
* @since 4.1.0 The `$depth` parameter was added.
|
||||
*
|
||||
* @param string $menu_id The ID that is applied to the menu item's `<li>` element.
|
||||
* @param object $item The current menu item.
|
||||
* @param array $args An array of {@see wp_nav_menu()} arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
|
||||
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||
// New
|
||||
$data_attr = '';
|
||||
switch ( $item_meta['megamenu_width_type'] ) {
|
||||
case 'default_width':
|
||||
$data_attr = esc_attr( ' data-vertical-menu=750px' );
|
||||
break;
|
||||
|
||||
case 'full_width':
|
||||
$data_attr = ' data-vertical-menu=""';
|
||||
break;
|
||||
|
||||
case 'custom_width':
|
||||
$data_attr = $item_meta['vertical_menu_width'] === '' ? esc_attr( ' data-vertical-menu=750px' ) : esc_attr( ' data-vertical-menu=' . $item_meta['vertical_menu_width'] . '' );
|
||||
break;
|
||||
|
||||
default:
|
||||
$data_attr = esc_attr( ' data-vertical-menu=750px' );
|
||||
break;
|
||||
}
|
||||
//
|
||||
$output .= $indent . '<li' . $id . $class_names . $data_attr . '>';
|
||||
$atts = array();
|
||||
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
|
||||
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
||||
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
|
||||
$submenu_indicator = '';
|
||||
|
||||
// New
|
||||
if ( $depth === 0 ) {
|
||||
$atts['class'] = 'ekit-menu-nav-link';
|
||||
}
|
||||
if ( $depth === 0 && in_array( 'menu-item-has-children', $classes ) ) {
|
||||
$atts['class'] .= ' ekit-menu-dropdown-toggle';
|
||||
}
|
||||
if ( in_array( 'menu-item-has-children', $classes ) || $is_megamenu_item == true ) {
|
||||
// Use an if statement to conditionally display the submenu indicator icon
|
||||
if(!empty($args->submenu_indicator_icon)) {
|
||||
$submenu_indicator .= $args->submenu_indicator_icon;
|
||||
} else {
|
||||
$submenu_indicator .= '<i class="icon icon-down-arrow1 elementskit-submenu-indicator"></i>';
|
||||
}
|
||||
}
|
||||
if ( $depth > 0 ) {
|
||||
$manual_class = array_values( $classes )[0] . ' ' . 'dropdown-item';
|
||||
$atts ['class'] = $manual_class;
|
||||
}
|
||||
if ( in_array( 'current-menu-item', $item->classes ) ) {
|
||||
$atts['class'] .= ' active';
|
||||
}
|
||||
|
||||
//
|
||||
/**
|
||||
* Filter the HTML attributes applied to a menu item's anchor element.
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @since 4.1.0 The `$depth` parameter was added.
|
||||
*
|
||||
* @param array $atts {
|
||||
* The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
|
||||
*
|
||||
* @type string $title Title attribute.
|
||||
* @type string $target Target attribute.
|
||||
* @type string $rel The rel attribute.
|
||||
* @type string $href The href attribute.
|
||||
* }
|
||||
* @param object $item The current menu item.
|
||||
* @param array $args An array of {@see wp_nav_menu()} arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
|
||||
$attributes = '';
|
||||
foreach ( $atts as $attr => $value ) {
|
||||
if ( ! empty( $value ) ) {
|
||||
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
|
||||
$attributes .= ' ' . $attr . '="' . $value . '"';
|
||||
}
|
||||
}
|
||||
$item_output = $args->before;
|
||||
// New
|
||||
|
||||
//
|
||||
$item_output .= '<a' . $attributes . '>';
|
||||
|
||||
if ( $this->is_megamenu( $args->menu ) == 1 ) {
|
||||
// add badge text
|
||||
if ( $item_meta['menu_badge_text'] != '' ) {
|
||||
$badge_style = 'background:' . $item_meta['menu_badge_background'] . '; color:' . $item_meta['menu_badge_color'];
|
||||
$badge_carret_style = 'border-top-color:' . $item_meta['menu_badge_background'];
|
||||
$item_output .= '<span style="' . $badge_style . '" class="ekit-menu-badge">' . $item_meta['menu_badge_text'] . '<i style="' . $badge_carret_style . '" class="ekit-menu-badge-arrow"></i></span>';
|
||||
}
|
||||
|
||||
// add menu icon & style
|
||||
if ( $item_meta['menu_icon'] != '' ) {
|
||||
$icon_style = 'color:' . $item_meta['menu_icon_color'];
|
||||
$item_output .= '<i class="ekit-menu-icon ' . $item_meta['menu_icon'] . '" style="' . $icon_style . '" ></i>';
|
||||
}
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
||||
$item_output .= $submenu_indicator . '</a>';
|
||||
$item_output .= $args->after;
|
||||
/**
|
||||
* Filter a menu item's starting output.
|
||||
*
|
||||
* The menu item's starting output only includes `$args->before`, the opening `<a>`,
|
||||
* the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
|
||||
* no filter for modifying the opening and closing `<li>` for a menu item.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $item_output The menu item's starting HTML output.
|
||||
* @param object $item Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param array $args An array of {@see wp_nav_menu()} arguments.
|
||||
*/
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||
}
|
||||
/**
|
||||
* Ends the element output, if needed.
|
||||
*
|
||||
* @see Walker::end_el()
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $item Page data object. Not used.
|
||||
* @param int $depth Depth of page. Not Used.
|
||||
* @param array $args An array of arguments. @see wp_nav_menu()
|
||||
*/
|
||||
public function end_el( &$output, $item, $depth = 0, $args = array() ) {
|
||||
if ( $depth === 0 ) {
|
||||
if ( $this->is_megamenu( $args->menu ) == 1 ) {
|
||||
$item_meta = $this->get_item_meta( $item->ID );
|
||||
if ( $item_meta['menu_enable'] == 1 && class_exists( 'Elementor\Plugin' ) ) {
|
||||
$builder_post_title = 'dynamic-content-megamenu-menuitem' . $item->ID;
|
||||
$builder_post = Utils::get_page_by_title( $builder_post_title, 'elementskit_content' );
|
||||
$output .= '<div class="elementskit-megamenu-panel">';
|
||||
if ( $builder_post != null ) {
|
||||
$elementor = \Elementor\Plugin::instance();
|
||||
$mega_menu_output = $elementor->frontend->get_builder_content_for_display( $builder_post->ID );
|
||||
|
||||
// if ajax load is enable and not elementor editor mode
|
||||
if(!empty($item_meta['megamenu_ajax_load']) && $item_meta['megamenu_ajax_load'] == 'yes') {
|
||||
$mega_menu_output = sprintf('<div class="megamenu-ajax-load" data-id="%1$s"></div>', $builder_post->ID);
|
||||
}
|
||||
|
||||
$output .= $mega_menu_output;
|
||||
} else {
|
||||
$output .= esc_html__( 'No content found', 'elementskit-lite' );
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
}
|
||||
}
|
||||
$output .= "</li>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user