PluginProbe
Adminimize / 1.9.1
Adminimize v1.9.1
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
adminimize / inc-setup / dashboard.php

dashboard.php in Adminimize 1.9.1, at inc-setup/dashboard.php

89 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Adminimize
4 * @subpackage Dashboard Setup
5 * @author Frank Bültge
6 */
7 if ( ! function_exists( 'add_action' ) ) {
8 echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
9 exit;
10 }
11
12 if ( ! is_admin() ) {
13 return NULL;
14 }
15
16 // Return registered widgets; only on page index/dashboard :(
17 add_action( 'wp_dashboard_setup', '_mw_adminimize_dashboard_setup', 99 );
18
19 function _mw_adminimize_dashboard_setup() {
20
21 $adminimizeoptions = _mw_adminimize_get_option_value();
22
23 $widgets = _mw_adminimize_get_dashboard_widgets();
24 $adminimizeoptions[ 'mw_adminimize_dashboard_widgets' ] = $widgets;
25
26 _mw_adminimize_update_option( $adminimizeoptions );
27
28 // exclude super admin
29 if ( _mw_adminimize_exclude_super_admin() ) {
30 return NULL;
31 }
32
33 $user_roles = _mw_adminimize_get_all_user_roles();
34
35 foreach ( $user_roles as $role ) {
36 $disabled_dashboard_option_[ $role ] = _mw_adminimize_get_option_value(
37 'mw_adminimize_disabled_dashboard_option_' . $role . '_items'
38 );
39 }
40
41 foreach ( $user_roles as $role ) {
42 if ( ! isset( $disabled_dashboard_option_[ $role ][ '0' ] ) ) {
43 $disabled_dashboard_option_[ $role ][ '0' ] = '';
44 }
45 }
46
47 foreach ( $user_roles as $role ) {
48 $user = wp_get_current_user();
49
50 if ( is_array( $user->roles ) && in_array( $role, $user->roles ) ) {
51 if ( _mw_adminimize_current_user_has_role( $role ) && is_array( $disabled_dashboard_option_[ $role ] ) ) {
52 foreach ( $disabled_dashboard_option_[ $role ] as $widget ) {
53 if ( isset( $widgets[ $widget ][ 'context' ] ) ) {
54 remove_meta_box( $widget, 'dashboard', $widgets[ $widget ][ 'context' ] );
55 }
56 }
57 }
58 }
59 }
60
61 }
62
63 function _mw_adminimize_get_dashboard_widgets() {
64
65 global $wp_meta_boxes;
66
67 $widgets = array();
68 if ( isset( $wp_meta_boxes[ 'dashboard' ] ) ) {
69
70 foreach ( $wp_meta_boxes[ 'dashboard' ] as $context => $datas ) {
71 foreach ( $datas as $priority => $data ) {
72 foreach ( $data as $widget => $value ) {
73 $widgets[ $widget ] = array(
74 'id' => $widget,
75 'title' => strip_tags(
76 preg_replace( '/( |)<span.*span>/im', '', $value[ 'title' ] )
77 ),
78 'context' => $context,
79 'priority' => $priority
80 );
81 }
82 }
83 }
84
85 }
86
87 return $widgets;
88 }
89