| 1 |
<?php |
| 2 |
|
| 3 |
// Settings |
| 4 |
add_action('admin_init', 'udb_settings'); |
| 5 |
|
| 6 |
function udb_settings() { |
| 7 |
|
| 8 |
// Register Settings |
| 9 |
register_setting( 'udb-widgets-settings-group', 'removeallwidgets' ); |
| 10 |
|
| 11 |
register_setting( 'udb-widgets-settings-group', 'welcome' ); |
| 12 |
register_setting( 'udb-widgets-settings-group', 'incominglinks' ); |
| 13 |
register_setting( 'udb-widgets-settings-group', 'plugins' ); |
| 14 |
register_setting( 'udb-widgets-settings-group', 'primary' ); |
| 15 |
register_setting( 'udb-widgets-settings-group', 'secondary' ); |
| 16 |
register_setting( 'udb-widgets-settings-group', 'quickpress' ); |
| 17 |
register_setting( 'udb-widgets-settings-group', 'drafts' ); |
| 18 |
register_setting( 'udb-widgets-settings-group', 'comments' ); |
| 19 |
register_setting( 'udb-widgets-settings-group', 'rightnow' ); |
| 20 |
register_setting( 'udb-widgets-settings-group', 'activity' ); |
| 21 |
|
| 22 |
// Settings Sections |
| 23 |
add_settings_section( |
| 24 |
'udb-remove-all-widgets', |
| 25 |
__('WordPress Dashboard Widgets', 'ultimatedashboard'), |
| 26 |
'udb_remove_all_widgets_callback', |
| 27 |
'ultimate-dashboard' |
| 28 |
); |
| 29 |
|
| 30 |
add_settings_section( |
| 31 |
'udb-remove-single-widgets', |
| 32 |
'', |
| 33 |
'udb_remove_single_widgets_callback', |
| 34 |
'ultimate-dashboard' |
| 35 |
); |
| 36 |
|
| 37 |
// Settings Fields |
| 38 |
add_settings_field( |
| 39 |
'remove-all-widgets', |
| 40 |
__('Remove all Widgets', 'ultimatedashboard'), |
| 41 |
'remove_all_widgets_callback', |
| 42 |
'ultimate-dashboard', |
| 43 |
'udb-remove-all-widgets' |
| 44 |
); |
| 45 |
|
| 46 |
add_settings_field( |
| 47 |
'remove-single-widgets', |
| 48 |
__('Remove individual Widgets', 'ultimatedashboard'), |
| 49 |
'remove_single_widgets_callback', |
| 50 |
'ultimate-dashboard', |
| 51 |
'udb-remove-single-widgets' |
| 52 |
); |
| 53 |
} |
| 54 |
|
| 55 |
// Section Description | Remove all Widgets |
| 56 |
function udb_remove_all_widgets_callback() { |
| 57 |
// _e('Hier hast du die Möglichkeit, alle oder vereinzelte Dashboard Widgets auszublenden.', 'ultimatedashboard'); |
| 58 |
} |
| 59 |
|
| 60 |
// Section Description | Remove single Widgets |
| 61 |
function udb_remove_single_widgets_callback() { |
| 62 |
// _e('Hier hast du die Möglichkeit einzelne Widgets auszublenden.', 'ultimatedashboard'); |
| 63 |
} |
| 64 |
|
| 65 |
// Output Settings |
| 66 |
function remove_all_widgets_callback() { |
| 67 |
$removeallwidgets = get_option('removeallwidgets'); |
| 68 |
echo '<label><input type="checkbox" name="removeallwidgets" value="1" '. checked( $removeallwidgets, 1, false ) .' />'.__('All','ultimatedashboard').'</label>'; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
function remove_single_widgets_callback() { |
| 73 |
$welcome = get_option('welcome'); |
| 74 |
echo '<label><input type="checkbox" name="welcome" value="1" '. checked( $welcome, 1, false ) .' />'.__('Welcome Panel','ultimatedashboard').'</label>'; |
| 75 |
echo '<br>'; |
| 76 |
$incominglinks = get_option('incominglinks'); |
| 77 |
echo '<label><input type="checkbox" name="incominglinks" value="1" '. checked( $incominglinks, 1, false ) .' />'.__('Incoming Links','ultimatedashboard').'</label>'; |
| 78 |
echo '<br>'; |
| 79 |
$plugins = get_option('plugins'); |
| 80 |
echo '<label><input type="checkbox" name="plugins" value="1" '. checked( $plugins, 1, false ) .' />'.__('Plugins','ultimatedashboard').'</label>'; |
| 81 |
echo '<br>'; |
| 82 |
$primary = get_option('primary'); |
| 83 |
echo '<label><input type="checkbox" name="primary" value="1" '. checked( $primary, 1, false ) .' />'.__('WordPress News','ultimatedashboard').'</label>'; |
| 84 |
echo '<br>'; |
| 85 |
$secondary = get_option('secondary'); |
| 86 |
echo '<label><input type="checkbox" name="secondary" value="1" '. checked( $secondary, 1, false ) .' />'.__('Secondary','ultimatedashboard').'</label>'; |
| 87 |
echo '<br>'; |
| 88 |
$quickpress = get_option('quickpress'); |
| 89 |
echo '<label><input type="checkbox" name="quickpress" value="1" '. checked( $quickpress, 1, false ) .' />'.__('QuickPress','ultimatedashboard').'</label>'; |
| 90 |
echo '<br>'; |
| 91 |
$drafts = get_option('drafts'); |
| 92 |
echo '<label><input type="checkbox" name="drafts" value="1" '. checked( $drafts, 1, false ) .' />'.__('Quick Draft','ultimatedashboard').'</label>'; |
| 93 |
echo '<br>'; |
| 94 |
$comments = get_option('comments'); |
| 95 |
echo '<label><input type="checkbox" name="comments" value="1" '. checked( $comments, 1, false ) .' />'.__('Comments','ultimatedashboard').'</label>'; |
| 96 |
echo '<br>'; |
| 97 |
$rightnow = get_option('rightnow'); |
| 98 |
echo '<label><input type="checkbox" name="rightnow" value="1" '. checked( $rightnow, 1, false ) .' />'.__('Right now','ultimatedashboard').'</label>'; |
| 99 |
echo '<br>'; |
| 100 |
$activity = get_option('activity'); |
| 101 |
echo '<label><input type="checkbox" name="activity" value="1" '. checked( $activity, 1, false ) .' />'.__('Activity','ultimatedashboard').'</label>'; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
// Remove WordPress default Dashboard Widgets |
| 106 |
function remove_dashboard_meta() { |
| 107 |
|
| 108 |
if(get_option('removeallwidgets')) { |
| 109 |
remove_action('welcome_panel', 'wp_welcome_panel'); |
| 110 |
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); |
| 111 |
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); |
| 112 |
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); |
| 113 |
remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' ); |
| 114 |
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); |
| 115 |
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); |
| 116 |
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); |
| 117 |
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); |
| 118 |
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal'); |
| 119 |
|
| 120 |
} else { |
| 121 |
|
| 122 |
if(get_option('welcome') == 1) { |
| 123 |
remove_action('welcome_panel', 'wp_welcome_panel'); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
if(get_option('incominglinks') == 1) { |
| 128 |
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal'); |
| 129 |
} |
| 130 |
|
| 131 |
if(get_option('plugins') == 1) { |
| 132 |
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); |
| 133 |
} |
| 134 |
|
| 135 |
if(get_option('primary') == 1) { |
| 136 |
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); |
| 137 |
} |
| 138 |
|
| 139 |
if(get_option('secondary') == 1) { |
| 140 |
remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' ); |
| 141 |
} |
| 142 |
|
| 143 |
if(get_option('quickpress') == 1) { |
| 144 |
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); |
| 145 |
} |
| 146 |
|
| 147 |
if(get_option('drafts') == 1) { |
| 148 |
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); |
| 149 |
} |
| 150 |
|
| 151 |
if(get_option('comments') == 1) { |
| 152 |
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); |
| 153 |
} |
| 154 |
|
| 155 |
if(get_option('rightnow') == 1) { |
| 156 |
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); |
| 157 |
} |
| 158 |
|
| 159 |
if(get_option('activity') == 1) { |
| 160 |
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal'); |
| 161 |
} |
| 162 |
|
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
add_action( 'admin_init', 'remove_dashboard_meta' ); |