-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiMenu.php
156 lines (120 loc) · 5.22 KB
/
multiMenu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
$thisfile = basename(__FILE__, ".php");
# register plugin
register_plugin(
$thisfile, //Plugin id
'MultiMenu', //Plugin name
'3.0', //Plugin version
'Multicolor', //Plugin author
'https://www.paypal.com/paypalme/multicol0r', //author website
'Plugin to create multiple menus', //Plugin description
'pages', //page type - on which admin tab to display
'showMultiMenu' //main function (administration)
);
i18n_merge('multiMenu') || i18n_merge('multiMenu', 'en_US');
# add a link in the admin tab 'theme'
add_action('pages-sidebar', 'createSideMenu', array($thisfile, 'MultiMenu 🚩'));
function showMultiMenu()
{
global $SITEURL;
global $GSADMIN;
if (isset($_GET['addMultiMenu'])) {
include(GSPLUGINPATH . 'multiMenu/addNew.php');
} else {
include(GSPLUGINPATH . 'multiMenu/settings.php');
}
echo '<form style="background:#fafafa; border:solid 1px #ddd; text-align:center; padding:10px;" action="https://www.paypal.com/cgi-bin/webscr" class="moneyshot" method="post" target="_top" style="display:block;text-align:center;">
<p style="margin:0;padding:0;margin-bottom:10px;">' . i18n_r('multiMenu/PAYPAL') . '</p>
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="KFZ9MCBUKB7GL" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
<img alt="" border="0" src="https://www.paypal.com/en_PL/i/scr/pixel.gif" width="1" height="1" />
</form>
<small style="text-align:center;width:100%;display:block;margin-top:10px;">
<a href="https://www.jqueryscript.net/menu/Drag-Drop-Menu-Builder-For-Bootstrap.html">' . i18n_r('multiMenu/INFO') . '</a>
</small>
';
}
add_action('footer', 'hideMenu');
function hideMenu()
{
echo '<style> #metadata_window p.post-menu{display:none}
#menu-items{display:none !important}
#sb_menumanager{display:none !important}
</style>';
};
function multiMenu($name)
{
global $SITEURL;
$files = file_get_contents(GSDATAOTHERPATH . 'multiMenu/' . $name . '.json');
$class = file_get_contents(GSDATAOTHERPATH . 'multiMenu/folderClass/' . $name . '-class.json');
$jsClass = json_decode($class);
$reJsonFiles = json_decode($files);
echo '<ul class="' . $jsClass->classul . '">';
global $SITEURL;
foreach ($reJsonFiles as $item) {
if (strpos($item->href, '://') !== false) {
$check = GSDATAPAGESPATH . 'index.xml';
} else {
$check = GSDATAPAGESPATH . $item->href . '.xml';
};
$xml = @simplexml_load_file($check);
if (file_exists($check)) {
echo '
<li class="' . ($jsClass->active == 'li' ? (return_page_slug() == $item->href ? 'active current' : '') : "") . ' ' . $jsClass->classulli . ' ' . (isset($item->children) ? 'parent' : '') . '">
<a href="'
. (strpos($item->href, '://') ? $item->href : find_url($item->href, (string)$xml->parent)) .
'" target="' . $item->target . '" class="' . ($jsClass->active == 'a' ? (return_page_slug() == $item->href ? 'active current' : '') : "") . ' ' . $jsClass->classullia . '">' . $item->text . '</a>';
if (isset($item->children)) {
echo '
<ul class="' . $jsClass->classulliul . '">';
foreach ($item->children as $subitem) {
if (strpos($subitem->href, 'http') !== false) {
$checkSub = GSDATAPAGESPATH . 'index.xml';
} else {
$checkSub = GSDATAPAGESPATH . $subitem->href . '.xml';
};
$xmlSub = @simplexml_load_file($checkSub);
if (file_exists($checkSub)) {
echo '
<li class="' . $jsClass->classulliulli . ' ' . ($jsClass->active == 'li' ? (return_page_slug() == $subitem->href ? 'active current' : '') : "") . '">
<a class="' . ($jsClass->active == 'a' ? (return_page_slug() == $subitem->href ? 'active current' : '') : "") . ' ' . $jsClass->classulliullia . '"
href="' . (strpos($subitem->href, '://') ? $subitem->href : find_url($subitem->href, (string)$xmlSub->parent)) . '" target="' . $subitem->target . '">' . $subitem->text . '</a>';
};
//sub-sub
if (isset($subitem->children)) {
echo '
<ul class="' . $jsClass->classulliul . '">';
foreach ($subitem->children as $subsubitem) {
if (strpos($subsubitem->href, '://') !== false) {
$checkSubSub = GSDATAPAGESPATH . 'index.xml';
} else {
$checkSubSub = GSDATAPAGESPATH . $subsubitem->href . '.xml';
};
$xmlSubSub = @simplexml_load_file($checkSubSub);
if (file_exists($checkSubSub)) {
echo '
<li class="' . $jsClass->classulliulli . ' ' . ($jsClass->active == 'li' ? (return_page_slug() == $subsubitem->href ? 'active current' : '') : "") . '">
<a href="' . (strpos($subsubitem->href, '://') ? $subsubitem->href : find_url($subsubitem->href, (string)$xmlSubSub))
. '"
class="' . ($jsClass->active == 'a' ? (return_page_slug() == $subsub->href ? 'active current' : '') : "") . ' ' . $jsClass->classulliullia . '"
target="' . $subsubitem->target . '">' . $subsubitem->text . '</a>
</li>';
};
};
echo '
</ul>';
};
echo '
</li>';
};
echo '
</ul>';
};
echo '
</li>';
};
};
echo '
</ul>';
};