Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/bdthemes-element-pack/modules/iconnav/module.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + namespace ElementPack\Modules\Iconnav;
3 +
4 + use ElementPack\Base\Element_Pack_Module_Base;
5 +
6 + if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
7 +
8 + class Module extends Element_Pack_Module_Base {
9 +
10 + public function get_name() {
11 + return 'iconnav';
12 + }
13 +
14 + public function get_widgets() {
15 +
16 + $widgets = [
17 + 'Iconnav',
18 + ];
19 +
20 + return $widgets;
21 + }
22 + }
23 +
24 + class ep_offcanvas_walker extends \Walker_Nav_Menu {
25 + var $has_child = false;
26 + public function start_lvl(&$output, $depth = 0, $args = array()) {
27 + $output .= '<ul class="bdt-nav-sub">';
28 + }
29 +
30 + public function end_lvl(&$output, $depth = 0, $args = array()) {
31 + $output .= '</ul>';
32 + }
33 +
34 + public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
35 + $data = array();
36 + $class = '';
37 + $classes = empty($item->classes) ? array() : (array) $item->classes;
38 + if($classes) {
39 + $class = trim(preg_replace('/menu-item(.+)/', '', implode(' ', $classes)));
40 + }
41 + //new class
42 + $classes = array();
43 + $data['style'] = '';
44 +
45 + if($args->walker->has_children){
46 + $classes[] ='bdt-parent';
47 + }
48 +
49 + if($item->current || $item->current_item_parent || $item->current_item_ancestor) {
50 + $classes[] = ' bdt-active';
51 + }
52 + if($item->dropdown_child && $depth > 0) {
53 + $classes[] = ' sub-dropdown';
54 + }
55 + // set id
56 + $data['data-id'] = $item->ID;
57 +
58 + // is current item ?
59 + if (in_array('current-menu-item', $classes) || in_array('current_page_item', $classes)) {
60 + $data['data-menu-active'] = 2;
61 +
62 + // home/frontpage item
63 + } elseif (preg_replace('/#(.+)$/', '', $item->url) == 'index.php' && (is_home() || is_front_page())) {
64 + $data['data-menu-active'] = 2;
65 + }
66 + if($item->full_width){
67 + $data['full_width'] = $item->full_width;
68 + } elseif($item->style_position) {
69 + if ($item->style_position == 'bottom-left') {
70 + $data_uk_dropdown = (is_rtl()) ? 'bottom-right' : 'bottom-left';
71 + } elseif ($item->style_position == 'bottom-right') {
72 + $data_uk_dropdown = (is_rtl()) ? 'bottom-left' : 'bottom-right';
73 + } else {
74 + $data_uk_dropdown = $item->style_position;
75 + }
76 + $data['dropdown_style'] = ($data_uk_dropdown);
77 + }
78 + $attributes = '';
79 + foreach ($data as $name => $value) {
80 + $attributes .= sprintf(' %s="%s"', $name, $value);
81 + }
82 +
83 + // create item output
84 + $id = apply_filters('nav_menu_item_id', '', $item, $args);
85 +
86 + if($classes) {
87 + $class .= implode(' ', $classes);
88 + }
89 + if($class) {
90 + $class = ' class="'.$class.'"';
91 + } else {
92 + $class = '';
93 + }
94 +
95 + $output .= '<li'.(strlen($id) ? sprintf(' id="%s"', esc_attr($id)) : '').$attributes . $class.'>';
96 +
97 + // set link attributes
98 + $attributes = '';
99 + foreach (array('attr_title' => 'title', 'target' => 'target', 'xfn' => 'rel', 'url' => 'href') as $var => $attr) {
100 + if (!empty($item->$var)) {
101 + $attributes .= sprintf(' %s="%s"', $attr, $item->$var);
102 + }
103 + }
104 +
105 + // escape link title
106 + $item->title = $item->title; //htmlspecialchars($item->title, ENT_COMPAT, "UTF-8");
107 + $classes = trim(preg_replace('/menu-item(.+)/', '', implode(' ', $classes)));
108 +
109 + // is separator ?
110 + if ($item->url == '#') {
111 + $isline = preg_match("/^\s*\-+\s*$/", $item->title);
112 +
113 + $type = "header";
114 + if ($isline) {
115 + $type = 'separator-line';
116 + } elseif ($item->hasChildren) {
117 + $type = 'separator-text';
118 + }
119 +
120 + $format = '%s<a href="#" %s>%s</a>%s';
121 + $classes = ' seperator';
122 + $attributes = ' class="'.$classes.'" data-type="'.$type.'"';
123 + } else {
124 + $format = '%s<a%s>%s</a>%s';
125 + }
126 +
127 + // create link output
128 + $item_output = sprintf($format, $args->before, $attributes, $args->link_before.apply_filters('the_title', $item->title, $item->ID).$args->link_after, $args->after);
129 +
130 + $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
131 + }
132 +
133 + public function end_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
134 + $output .= '</li>';
135 + }
136 +
137 + function display_element ($element, &$children_elements, $max_depth, $depth, $args, &$output) {
138 + // attach to element so that it's available in start_el()
139 + $element->hasChildren = isset($children_elements[$element->ID]) && !empty($children_elements[$element->ID]);
140 + return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
141 + }
142 + }