PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.3.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.3.2
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 +105 -150 4.2.64.0.3.2 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,19 +105,19 @@
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);
50 -
51 - foreach ($menu as $key => $item) {
111 + $menu_options = apply_filters('jltwp_adminify_menu_option_compatibility_filter', $menu_options, $menu);
112 +
113 + foreach ($menu as $key => $item) {
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,12 +125,9 @@
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 - $external_link = (isset($item['external_link']) && $item['external_link'] == 1 ) ? true: false;
71 130
72 131 $menu_hook = get_plugin_page_hook($menu_slug, 'admin.php');
73 132 $menu_file = $menu_slug;
74 133 $pos = strpos($menu_file, '?');
@@ -77,10 +136,10 @@
77 136 $menu_file = substr($menu_file, 0, $pos);
78 137 }
79 138
80 139 $url = '';
81 -
82 - $arrParsedUrl = wp_parse_url($menu_slug);
140 +
141 + $arrParsedUrl = parse_url($menu_slug);
83 142 if (!empty($arrParsedUrl['scheme'])) {
84 143 if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") {
85 144 $url = $menu_slug;
86 145 }
@@ -85,35 +144,25 @@
85 144 $url = $menu_slug;
86 145 }
87 146 } else {
88 147 $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);
148 + ? maybe_network_admin_url('admin.php?page=' . $menu_slug)
149 + : maybe_network_admin_url($menu_slug);
91 150 }
92 151
93 - $admin_menu[$menu_key_id] = [
94 - 'key' => $menu_key_id,
152 + $admin_menu[$menu_slug] = [
153 + 'key' => $menu_slug,
95 154 'title' => $menu_title,
96 155 'url' => $url,
97 156 'name' => $menu_name,
98 157 'icon' => $menu_icon,
99 158 'children' => [],
100 - 'separator' => !empty( $item['separator'] ) ? $item['separator'] : '',
101 - 'external_link' => $external_link ,
159 + 'separator' => !empty( $item['separator'] ) ? $item['separator'] : ''
102 160 ];
103 161
104 162 if (!empty($submenu[$menu_slug])) {
105 163 foreach ($submenu[$menu_slug] as $sub_key => $sub_item) {
106 164 $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 - $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;
115 - }
116 165 $sub_title = $sub_item[0];
117 166 $sub_name = isset($sub_item[5]) ? $sub_item[5] : '';
118 167 $sub_icon = isset($sub_item[6]) ? $sub_item[6] : '';
119 168
@@ -127,9 +176,9 @@
127 176
128 177
129 178 $sub_url = '';
130 179
131 - $arrParsedUrl = wp_parse_url($sub_slug);
180 + $arrParsedUrl = parse_url($sub_slug);
132 181 if (!empty($arrParsedUrl['scheme'])) {
133 182 if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") {
134 183 $sub_url = $sub_slug;
135 184 }
@@ -134,130 +183,29 @@
134 183 $sub_url = $sub_slug;
135 184 }
136 185 } else {
137 186 $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);
187 + ? maybe_network_admin_url('admin.php?page=' . $sub_slug)
188 + : maybe_network_admin_url($sub_slug);
140 189 }
141 190
142 191 // Wrong Menu/Submenu Links
143 -
144 192 // Support for White Label Plugin Url
145 193 if ('white-label' === $sub_slug) {
146 194 $sub_url = admin_url('options-general.php?page=white-label');
147 195 }
148 196
149 - // JetFormBuilder
150 - if ('jet-form-builder' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder'); }
151 - if ('jet-form-builder' === $sub_slug) { $sub_url = admin_url('post-new.php?post_type=jet-form-builder'); }
152 - if ('jfb-settings' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-settings'); }
153 - if ('jfb-addons' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-addons'); }
154 - if ('jfb-payments' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-payments'); }
155 - if ('jfb-records' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-records'); }
156 -
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 -
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,
171 - 'title' => $sub_title,
172 - 'url' => $sub_url,
173 - 'name' => $sub_name,
174 - 'icon' => $sub_icon,
175 - 'external_link' => $external_link,
197 + $admin_menu[$menu_slug]['children'][$sub_slug] = [
198 + 'key' => $sub_slug,
199 + 'title' => $sub_title,
200 + 'url' => $sub_url,
201 + 'name' => $sub_name,
202 + 'icon' => $sub_icon,
176 203 ];
177 204 }
178 205 }
179 206 }
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');
207 + $admin_menu = jlt_adminify_replaceAmpersandInHref($admin_menu, 'url');
260 208 return $admin_menu;
261 209 }
262 210
263 211 /**
@@ -262,18 +210,18 @@
262 210
263 211 /**
264 212 * Recursively replace all occurrences of &amp; with & in an array.
265 213 *
266 -* @see https://wordpress.org/support/topic/automatically-adding-amp-in-url/
214 +* @see https://wordpress.org/support/topic/automatically-adding-amp-in-url/
267 215 * @param array $array The input array to process.
268 216 * @return array The updated array with replacements.
269 217 */
270 -function pxlbsadminify_replaceAmpersandInHref($array, $indicator='href') {
218 +function jlt_adminify_replaceAmpersandInHref($array, $indicator='href') {
271 219
272 220 foreach ($array as $key => $value) {
273 221 if (is_array($value)) {
274 222 // Recursively process child arrays
275 - $array[$key] = pxlbsadminify_replaceAmpersandInHref($value, $indicator);
223 + $array[$key] = jlt_adminify_replaceAmpersandInHref($value, $indicator);
276 224 } elseif ($key === $indicator && is_string($value)) {
277 225 // Replace &amp; with & in $indicator keys
278 226 $array[$key] = str_replace('&amp;', '&', $value);
279 227 }
@@ -279,4 +227,11 @@
279 227 }
280 228 }
281 229 return $array;
282 230 }
231 +
232 +function jlt_adminify_sluggify_with_underscores($string) {
233 + $slug = sanitize_title($string);
234 + $slug = str_replace('-', '_', $slug);
235 +
236 + return $slug;
237 +}