PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.1.7
Adminify – White Label, Admin Menu Editor, Login Customizer v3.1.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 +28 -264 4.2.213.1.7 View file →
@@ -1,282 +1,46 @@
1 1 <?php
2 2
3 -// no direct access allowed
4 -if (!defined('ABSPATH')) {
5 - exit;
6 -}
3 +use WPAdminify\Inc\Modules\ActivityLogs\ActivityLogs;
7 4
8 -
9 -// 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;
16 -}
17 -
18 -
19 5 /**
20 - * User Roles Slug from Names
6 + * Check given value empty or not
21 7 *
22 - * @param [type] $user_roles
8 + * @param [type] $value
23 9 *
24 10 * @return void
25 11 */
26 -function pxlbsadminify_menu_roles($user_roles = [])
27 -{
28 - $disabled_for_roles = [];
29 - if (!empty( $user_roles)) {
30 - foreach ($user_roles as $usr_key) {
31 - $disabled_for_roles[] = strtolower(str_replace(' ', '_', $usr_key));
32 - }
33 - }
34 - return $disabled_for_roles;
12 +function check_is_empty( $value, $default = '' ) {
13 + $value = ! empty( esc_attr( $value ) ) ? $value : $default;
14 + return $value;
35 15 }
36 16
37 17
38 -/**
39 - * Build admin menu array.
40 - *
41 - * @param array $menu Menu array.
42 - * @param array $submenu Submenu array.
43 - * @param array $menu_options Menu options array.
44 - *
45 - * @return array Admin menu array.
46 - */
47 -function pxlbsadminify_build_menu($menu, $submenu, $menu_options) {
48 - $admin_menu = [];
49 - $menu_options = apply_filters('pxlbsadminify_menu_option_compatibility_filter', $menu_options, $menu);
18 +// WP Adminify function for get an option
19 +if ( ! function_exists( 'jltwp_adminify_get_option' ) ) {
20 + function jltwp_adminify_get_option( $option = '', $default = null ) {
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 + }
27 +}
50 28
51 - foreach ($menu as $key => $item) {
52 - if (is_array($menu_options)) {
53 - if (isset($menu_options[$item[2]])) {
54 - $optiongroup = $menu_options[$item[2]];
55 - if (!empty($optiongroup['hidden_for'])) {
56 - $disabled_for = pxlbsadminify_menu_roles($optiongroup['hidden_for']);
57 - if (\PXLBSAdminify\Inc\Utils::restrict_for($disabled_for)) {
58 - continue;
59 - }
60 - }
61 - }
62 - }
29 +function is_site_wide( $plugin ) {
30 + if ( ! is_multisite() ) {
31 + return false;
32 + }
63 33
64 - $menu_slug = $item[2];
65 - $menu_title = $item[0];
66 - $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 - $menu_icon = isset($item[6]) ? $item[6] : '';
70 - $external_link = (isset($item['external_link']) && $item['external_link'] == 1 ) ? true: false;
34 + $plugins = get_site_option( 'active_sitewide_plugins' );
35 + if ( isset( $plugins[ $plugin ] ) ) {
36 + return true;
37 + }
71 38
72 - $menu_hook = get_plugin_page_hook($menu_slug, 'admin.php');
73 - $menu_file = $menu_slug;
74 - $pos = strpos($menu_file, '?');
75 -
76 - if (false !== $pos) {
77 - $menu_file = substr($menu_file, 0, $pos);
78 - }
79 -
80 - $url = '';
81 -
82 - $arrParsedUrl = wp_parse_url($menu_slug);
83 - if (!empty($arrParsedUrl['scheme'])) {
84 - if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") {
85 - $url = $menu_slug;
86 - }
87 - } else {
88 - $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);
91 - }
92 -
93 - $admin_menu[$menu_key_id] = [
94 - 'key' => $menu_key_id,
95 - 'title' => $menu_title,
96 - 'url' => $url,
97 - 'name' => $menu_name,
98 - 'icon' => $menu_icon,
99 - 'children' => [],
100 - 'separator' => !empty( $item['separator'] ) ? $item['separator'] : '',
101 - 'external_link' => $external_link ,
102 - ];
103 -
104 - if (!empty($submenu[$menu_slug])) {
105 - 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 - $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]) && is_array($optiongroup['submenu'][$sub_key_id])){
112 - $external_link = (!empty($optiongroup['submenu'][$sub_key_id]['external_link']) && $optiongroup['submenu'][$sub_key_id]['external_link'] == 1) ? true : false;
113 - } elseif( isset($optiongroup['submenu'][$sub_slug]) && is_array($optiongroup['submenu'][$sub_slug])){
114 - $external_link = (!empty($optiongroup['submenu'][$sub_slug]['external_link']) && $optiongroup['submenu'][$sub_slug]['external_link'] == 1) ? true : false;
115 - }
116 - $sub_title = $sub_item[0];
117 - $sub_name = isset($sub_item[5]) ? $sub_item[5] : '';
118 - $sub_icon = isset($sub_item[6]) ? $sub_item[6] : '';
119 -
120 - $sub_menu_hook = get_plugin_page_hook($sub_slug, $menu_slug);
121 - $sub_file = $sub_slug;
122 - $pos = strpos($sub_file, '?');
123 -
124 - if (false !== $pos) {
125 - $sub_file = substr($sub_file, 0, $pos);
126 - }
127 -
128 -
129 - $sub_url = '';
130 -
131 - $arrParsedUrl = wp_parse_url($sub_slug);
132 - if (!empty($arrParsedUrl['scheme'])) {
133 - if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") {
134 - $sub_url = $sub_slug;
135 - }
136 - } else {
137 - $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);
140 - }
141 -
142 - // Wrong Menu/Submenu Links
143 -
144 - // Support for White Label Plugin Url
145 - if ('white-label' === $sub_slug) {
146 - $sub_url = admin_url('options-general.php?page=white-label');
147 - }
148 -
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,
176 - ];
177 - }
178 - }
179 - }
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');
260 - return $admin_menu;
39 + return false;
261 40 }
262 41
263 -/**
264 -* Recursively replace all occurrences of &amp; with & in an array.
265 -*
266 -* @see https://wordpress.org/support/topic/automatically-adding-amp-in-url/
267 -* @param array $array The input array to process.
268 -* @return array The updated array with replacements.
269 -*/
270 -function pxlbsadminify_replaceAmpersandInHref($array, $indicator='href') {
271 42
272 - foreach ($array as $key => $value) {
273 - if (is_array($value)) {
274 - // Recursively process child arrays
275 - $array[$key] = pxlbsadminify_replaceAmpersandInHref($value, $indicator);
276 - } elseif ($key === $indicator && is_string($value)) {
277 - // Replace &amp; with & in $indicator keys
278 - $array[$key] = str_replace('&amp;', '&', $value);
279 - }
280 - }
281 - return $array;
43 +function adminify_activity_logs( $args = [] ) {
44 + $adminify_activity_logs = ActivityLogs::get_instance();
45 + $adminify_activity_logs->api->insert( $args );
282 46 }