PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.7
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.7
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
← All changes | Inc/functions.php +99 -127 4.2.134.0.7 View file →
@@ -1,23 +1,85 @@
1 1 <?php
2 2
3 -// no direct access allowed
4 -if (!defined('ABSPATH')) {
5 - exit;
3 +/**
4 + * Check given value empty or not
5 + *
6 + * @param [type] $value
7 + *
8 + * @return void
9 + */
10 +function check_is_empty($value, $default = '')
11 +{
12 + $value = !empty(esc_attr($value)) ? $value : $default;
13 + return $value;
6 14 }
7 15
8 16
9 17 // WP Adminify function for get an option
10 -function pxlbsadminify_get_option($option = '', $default = null) {
11 - $options = [];
12 - // if (is_multisite() && is_site_wide('wp-adminify/wp-adminify.php')) {
13 - $options = (array) \PXLBSAdminify\Inc\Admin\AdminSettings::get_instance()->get();
14 - // }
15 - return (isset($options[$option])) ? $options[$option] : $default;
18 +if (!function_exists('jltwp_adminify_get_option')) {
19 + function jltwp_adminify_get_option($option = '', $default = null)
20 + {
21 + $options = [];
22 + // if (is_multisite() && is_site_wide('wp-adminify/wp-adminify.php')) {
23 + $options = (array) \WPAdminify\Inc\Admin\AdminSettings::get_instance()->get();
24 + // }
25 + return (isset($options[$option])) ? $options[$option] : $default;
26 + }
16 27 }
17 28
29 +function is_site_wide($plugin)
30 +{
31 + if (!is_multisite()) {
32 + return false;
33 + }
18 34
35 + $plugins = get_site_option('active_sitewide_plugins');
36 + if (isset($plugins[$plugin])) {
37 + return true;
38 + }
39 +
40 + return false;
41 +}
42 +
43 +
44 +
45 +
19 46 /**
47 + * Check if the request is coming from an iframe.
48 + *
49 + * @param None
50 + * @throws None
51 + * @return bool
52 + */
53 +function is_iframe()
54 +{
55 + return isset($_SERVER["HTTP_SEC_FETCH_DEST"]) && strtolower($_SERVER["HTTP_SEC_FETCH_DEST"]) === "iframe";
56 + // $isIframe = isset($_SERVER["HTTP_SEC_FETCH_DEST"]) && strtolower($_SERVER["HTTP_SEC_FETCH_DEST"]) === "iframe";
57 + // if ( $isIframe ) return true;
58 + // if ( isset($_GET['adminify-iframe']) ) return true;
59 + // return false;
60 +}
61 +
62 +/**
63 + * Load a template file.
64 + *
65 + * @param string $template_name The name of the template file to load.
66 + * @throws None
67 + * @return void
68 + */
69 +function adminify_load_template($template_name)
70 +{
71 + require_once WP_ADMINIFY_PATH . 'Inc/Admin/Frames/Templates/' . $template_name;
72 +}
73 +
74 +function maybe_network_admin_url($url) {
75 + if ( is_network_admin() ) {
76 + return network_admin_url($url);
77 + }
78 + return admin_url($url);
79 +}
80 +
81 +/**
20 82 * User Roles Slug from Names
21 83 *
22 84 * @param [type] $user_roles
23 85 *
@@ -22,9 +84,9 @@
22 84 * @param [type] $user_roles
23 85 *
24 86 * @return void
25 87 */
26 -function pxlbsadminify_menu_roles($user_roles = [])
88 +function jltwp_adminify_menu_roles($user_roles = [])
27 89 {
28 90 $disabled_for_roles = [];
29 91 if (!empty( $user_roles)) {
30 92 foreach ($user_roles as $usr_key) {
@@ -43,11 +105,11 @@
43 105 * @param array $menu_options Menu options array.
44 106 *
45 107 * @return array Admin menu array.
46 108 */
47 -function pxlbsadminify_build_menu($menu, $submenu, $menu_options) {
109 +function jltwp_adminify_build_menu($menu, $submenu, $menu_options) {
48 110 $admin_menu = [];
49 - $menu_options = apply_filters('pxlbsadminify_menu_option_compatibility_filter', $menu_options, $menu);
111 + $menu_options = apply_filters('jltwp_adminify_menu_option_compatibility_filter', $menu_options, $menu);
50 112
51 113 foreach ($menu as $key => $item) {
52 114 if (is_array($menu_options)) {
53 115 if (isset($menu_options[$item[2]])) {
@@ -52,10 +114,10 @@
52 114 if (is_array($menu_options)) {
53 115 if (isset($menu_options[$item[2]])) {
54 116 $optiongroup = $menu_options[$item[2]];
55 117 if (!empty($optiongroup['hidden_for'])) {
56 - $disabled_for = pxlbsadminify_menu_roles($optiongroup['hidden_for']);
57 - if (\PXLBSAdminify\Inc\Utils::restrict_for($disabled_for)) {
118 + $disabled_for = jltwp_adminify_menu_roles($optiongroup['hidden_for']);
119 + if (\WPAdminify\Inc\Utils::restrict_for($disabled_for)) {
58 120 continue;
59 121 }
60 122 }
61 123 }
@@ -63,10 +125,8 @@
63 125
64 126 $menu_slug = $item[2];
65 127 $menu_title = $item[0];
66 128 $menu_name = isset($item[5]) ? $item[5] : '';
67 - // Use unique key for custom menu items instead of link URL
68 - $menu_key_id = (!empty($menu_name) && strpos($menu_name, 'adminify-custom-menu-') !== false) ? $menu_name : $menu_slug;
69 129 $menu_icon = isset($item[6]) ? $item[6] : '';
70 130 $external_link = (isset($item['external_link']) && $item['external_link'] == 1 ) ? true: false;
71 131
72 132 $menu_hook = get_plugin_page_hook($menu_slug, 'admin.php');
@@ -78,9 +138,9 @@
78 138 }
79 139
80 140 $url = '';
81 141
82 - $arrParsedUrl = wp_parse_url($menu_slug);
142 + $arrParsedUrl = parse_url($menu_slug);
83 143 if (!empty($arrParsedUrl['scheme'])) {
84 144 if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") {
85 145 $url = $menu_slug;
86 146 }
@@ -85,14 +145,14 @@
85 145 $url = $menu_slug;
86 146 }
87 147 } else {
88 148 $url = ( ! empty($menu_hook) || ( ( 'index.php' !== $menu_slug ) && file_exists(WP_PLUGIN_DIR . "/$menu_file") && ! file_exists(ABSPATH . "/wp-admin/$menu_file") ) )
89 - ? \PXLBSAdminify\Inc\Utils::maybe_network_admin_url('admin.php?page=' . $menu_slug)
90 - : \PXLBSAdminify\Inc\Utils::maybe_network_admin_url($menu_slug);
149 + ? maybe_network_admin_url('admin.php?page=' . $menu_slug)
150 + : maybe_network_admin_url($menu_slug);
91 151 }
92 152
93 - $admin_menu[$menu_key_id] = [
94 - 'key' => $menu_key_id,
153 + $admin_menu[$menu_slug] = [
154 + 'key' => $menu_slug,
95 155 'title' => $menu_title,
96 156 'url' => $url,
97 157 'name' => $menu_name,
98 158 'icon' => $menu_icon,
@@ -102,18 +162,13 @@
102 162 ];
103 163
104 164 if (!empty($submenu[$menu_slug])) {
105 165 foreach ($submenu[$menu_slug] as $sub_key => $sub_item) {
106 - $sub_slug = $sub_item[2];
107 - // Use unique key for custom submenu items instead of link URL
108 - $sub_key_id = isset($sub_item['key']) ? $sub_item['key'] : $sub_slug;
109 166 $external_link = false;
110 - // Look up external_link setting using unique key first, then fall back to slug
111 - if( isset($optiongroup['submenu'][$sub_key_id])){
112 - $external_link = ($optiongroup['submenu'][$sub_key_id]['external_link'] == 1) ? true : false;
113 - } elseif( isset($optiongroup['submenu'][$sub_slug])){
114 - $external_link = ($optiongroup['submenu'][$sub_slug]['external_link'] == 1) ? true : false;
167 + if( isset($optiongroup['submenu'][$sub_item[2]])){
168 + $external_link = ($optiongroup['submenu'][$sub_item[2]]['external_link'] == 1)? true : false ;
115 169 }
170 + $sub_slug = $sub_item[2];
116 171 $sub_title = $sub_item[0];
117 172 $sub_name = isset($sub_item[5]) ? $sub_item[5] : '';
118 173 $sub_icon = isset($sub_item[6]) ? $sub_item[6] : '';
119 174
@@ -127,9 +182,9 @@
127 182
128 183
129 184 $sub_url = '';
130 185
131 - $arrParsedUrl = wp_parse_url($sub_slug);
186 + $arrParsedUrl = parse_url($sub_slug);
132 187 if (!empty($arrParsedUrl['scheme'])) {
133 188 if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") {
134 189 $sub_url = $sub_slug;
135 190 }
@@ -134,10 +189,10 @@
134 189 $sub_url = $sub_slug;
135 190 }
136 191 } else {
137 192 $sub_url = ( ! empty($sub_menu_hook) || ( ( 'index.php' !== $sub_slug ) && file_exists(WP_PLUGIN_DIR . "/$sub_file") && ! file_exists(ABSPATH . "/wp-admin/$sub_file") ) )
138 - ? \PXLBSAdminify\Inc\Utils::maybe_network_admin_url('admin.php?page=' . $sub_slug)
139 - : \PXLBSAdminify\Inc\Utils::maybe_network_admin_url($sub_slug);
193 + ? maybe_network_admin_url('admin.php?page=' . $sub_slug)
194 + : maybe_network_admin_url($sub_slug);
140 195 }
141 196
142 197 // Wrong Menu/Submenu Links
143 198
@@ -153,22 +208,11 @@
153 208 if ('jfb-addons' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-addons'); }
154 209 if ('jfb-payments' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-payments'); }
155 210 if ('jfb-records' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-records'); }
156 211
157 - // WP Adminify Support - open in new tab
158 - if ('adminify-support' === $sub_slug) {
159 - $sub_url = \PXLBSAdminify\Inc\Admin\AdminSettings::support_url();
160 - $external_link = true;
161 - }
162 212
163 - // WP Adminify Pricing/Upgrade - open in new tab
164 - if ('wp-adminify-settings-pricing' === $sub_slug) {
165 - $sub_url = 'https://wpadminify.com/pricing';
166 - $external_link = true;
167 - }
168 -
169 - $admin_menu[$menu_key_id]['children'][$sub_key_id] = [
170 - 'key' => $sub_key_id,
213 + $admin_menu[$menu_slug]['children'][$sub_slug] = [
214 + 'key' => $sub_slug,
171 215 'title' => $sub_title,
172 216 'url' => $sub_url,
173 217 'name' => $sub_name,
174 218 'icon' => $sub_icon,
@@ -176,88 +220,9 @@
176 220 ];
177 221 }
178 222 }
179 223 }
180 -
181 - // Elementor 3rd-level flyout menu integration
182 - // Grabs Quick Start, Settings, Tools, Role Manager, etc. from Elementor's sidebar navigation
183 - // Wrapped in Throwable catch so any Elementor API change degrades gracefully
184 - try {
185 - $elementor_flyout_class = '\Elementor\Modules\EditorOne\Classes\Menu_Data_Provider';
186 -
187 - if (class_exists($elementor_flyout_class)) {
188 - $elementor_menu_key = isset($admin_menu['elementor-home']) ? 'elementor-home' :
189 - (isset($admin_menu['elementor']) ? 'elementor' : null);
190 -
191 - if ($elementor_menu_key && isset($admin_menu[$elementor_menu_key]['children']['elementor'])
192 - && method_exists($elementor_flyout_class, 'instance')
193 - ) {
194 - $menu_data_provider = $elementor_flyout_class::instance();
195 -
196 - // Try known method names in order: current API → known alternates
197 - $flyout_items = [];
198 - $method_candidates = [
199 - 'get_third_level_data' => ['editor_flyout'], // Current Elementor API
200 - 'get_editor_flyout_data' => [], // Legacy / alternate
201 - 'get_level3_items' => [], // Fallback
202 - ];
203 -
204 - foreach ($method_candidates as $method => $args) {
205 - if (!method_exists($menu_data_provider, $method)) {
206 - continue;
207 - }
208 -
209 - $result = call_user_func_array([$menu_data_provider, $method], $args);
210 -
211 - if (is_array($result)) {
212 - // Normalize: result might wrap items under an 'items' key or be the array itself
213 - $flyout_items = isset($result['items']) && is_array($result['items'])
214 - ? $result['items']
215 - : $result;
216 - }
217 - break;
218 - }
219 -
220 - if (!empty($flyout_items)) {
221 - $flyout_children = [];
222 -
223 - foreach ($flyout_items as $item) {
224 - if (!is_array($item)) {
225 - continue;
226 - }
227 -
228 - // Flexible key mapping — tolerate renamed fields
229 - $slug = $item['slug'] ?? ($item['id'] ?? '');
230 - $label = $item['label'] ?? ($item['title'] ?? '');
231 - $url = $item['url'] ?? ($item['link'] ?? '');
232 -
233 - if (empty($slug) || empty($label)) {
234 - continue;
235 - }
236 -
237 - $flyout_children[$slug] = [
238 - 'key' => $slug,
239 - 'title' => $label,
240 - 'url' => $url,
241 - 'icon' => $item['icon'] ?? '',
242 - 'name' => '',
243 - 'is_flyout_child' => true,
244 - 'external_link' => false,
245 - ];
246 - }
247 -
248 - if (!empty($flyout_children)) {
249 - $admin_menu[$elementor_menu_key]['children']['elementor']['children'] = $flyout_children;
250 - $admin_menu[$elementor_menu_key]['children']['elementor']['has_flyout_children'] = true;
251 - }
252 - }
253 - }
254 - }
255 - } catch (\Throwable $e) {
256 - // Silently degrade — menu renders without flyout items
257 - }
258 -
259 - $admin_menu = pxlbsadminify_replaceAmpersandInHref($admin_menu, 'url');
224 + $admin_menu = jlt_adminify_replaceAmpersandInHref($admin_menu, 'url');
260 225 return $admin_menu;
261 226 }
262 227
263 228 /**
@@ -266,14 +231,14 @@
266 231 * @see https://wordpress.org/support/topic/automatically-adding-amp-in-url/
267 232 * @param array $array The input array to process.
268 233 * @return array The updated array with replacements.
269 234 */
270 -function pxlbsadminify_replaceAmpersandInHref($array, $indicator='href') {
235 +function jlt_adminify_replaceAmpersandInHref($array, $indicator='href') {
271 236
272 237 foreach ($array as $key => $value) {
273 238 if (is_array($value)) {
274 239 // Recursively process child arrays
275 - $array[$key] = pxlbsadminify_replaceAmpersandInHref($value, $indicator);
240 + $array[$key] = jlt_adminify_replaceAmpersandInHref($value, $indicator);
276 241 } elseif ($key === $indicator && is_string($value)) {
277 242 // Replace &amp; with & in $indicator keys
278 243 $array[$key] = str_replace('&amp;', '&', $value);
279 244 }
@@ -278,5 +243,12 @@
278 243 $array[$key] = str_replace('&amp;', '&', $value);
279 244 }
280 245 }
281 246 return $array;
247 +}
248 +
249 +function jlt_adminify_sluggify_with_underscores($string) {
250 + $slug = sanitize_title($string);
251 + $slug = str_replace('-', '_', $slug);
252 +
253 + return $slug;
282 254 }