Changeset 1470376
- Timestamp:
- 08/08/2016 11:28:04 PM (10 years ago)
- Location:
- menus/trunk
- Files:
-
- 2 edited
-
ds_wp3_menus.php (modified) (7 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
menus/trunk/ds_wp3_menus.php
r1384851 r1470376 3 3 Plugin Name: Menus 4 4 Plugin URI: http://wordpress.org/extend/plugins/menus/ 5 Version: 4. 35 Version: 4.6 6 6 Description: Wordpress Multisite Network plugin to toggle more of the administration menus in the same way "Plugins" is already toggled. Go to Network-->Settings->Menu Settings to "Enable administration menus". All menus are unchecked and disabled by default, except when logged in as Network Admin. 7 7 Author: dsader … … 21 21 */ 22 22 23 class ds_menus { 24 function ds_menus() { 23 class DS_Menus { 25 24 //------------------------------------------------------------------------// 26 25 //---Hooks----------------------------------------------------------------// 27 26 //------------------------------------------------------------------------// 28 add_filter( 'mu_menu_items', array(&$this, 'ds_mu_menu_options' )); // hook Network->Settings 29 add_action( 'wpmu_options', array(&$this, 'ds_menu_option'), -99 ); // add a note below the Network->Settings 30 add_action( 'admin_menu', array(&$this, 'ds_menu_disable'), 99 ); // toggles the menus - high priority catches widgets menu, too. 31 add_action( 'jetpack_admin_menu', array(&$this, 'ds_jetpack_admin_menu_disable'), 99 ); // toggles the menus added by jetpack, too. 32 add_action( 'admin_menu', array(&$this, 'ds_menu_plugins_disable'), 999 ); // toggles the menus added by plugins, too. 33 add_filter( 'admin_bar_menu', array(&$this, 'ds_reduce_favorite_actions'), 999 ); //hook admin head favorites 34 add_action( 'admin_page_access_denied', array(&$this, 'ds_access_denied_splash'), 99 ); 35 36 37 $menu_perms = get_site_option( "menu_items" ); 38 if( !isset($menu_perms[ 'app_cus' ]) ) { 39 add_action( 'admin_init', array(&$this, 'ds_customize'), 10 ); 40 add_filter( 'init', array(&$this,'ds_removecustmizer_metacap'), 10 ); 41 } 42 43 } 27 function __construct() { 28 add_filter( 'mu_menu_items', array($this, 'ds_mu_menu_options' )); // hook Network->Settings 29 add_action( 'wpmu_options', array($this, 'ds_menu_option'), -99 ); // add a note below the Network->Settings 30 add_action( 'admin_menu', array($this, 'ds_menu_disable'), 99 ); // toggles the menus - high priority catches widgets menu, too. 31 add_action( 'jetpack_admin_menu', array($this, 'ds_jetpack_admin_menu_disable'), 99 ); // toggles the menus added by jetpack, too. 32 add_action( 'admin_menu', array($this, 'ds_menu_plugins_disable'), 999 ); // toggles the menus added by plugins, too. 33 add_filter( 'admin_bar_menu', array($this, 'ds_reduce_favorite_actions'), 999 ); //hook admin head favorites 34 add_action( 'admin_page_access_denied', array($this, 'ds_access_denied_splash'), 99 ); 35 $menu_perms = get_site_option( "menu_items" ); 36 if( !isset($menu_perms[ 'app_cus' ]) ) { 37 add_action( 'admin_init', array($this, 'ds_customize'), 10 ); 38 add_filter( 'init', array($this,'ds_removecustmizer_metacap'), 10 ); 39 } 40 41 } 44 42 //------------------------------------------------------------------------// 45 43 //---Functions to Enable/Disable admin menus------------------------------// 46 44 //------------------------------------------------------------------------// 47 45 48 function ds_customize() {46 function ds_customize() { 49 47 remove_action( 'plugins_loaded', '_wp_customize_include', 10); 50 48 remove_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings', 11); 51 add_action( 'load-customize.php', array(&$this, 'ds_override_load_customizer_action') ); 52 } 53 function ds_override_load_customizer_action() { 49 add_action( 'load-customize.php', array($this, 'ds_override_load_customizer_action') ); 50 } 51 52 function ds_override_load_customizer_action() { 54 53 wp_die( __( 'The Customizer is currently disabled.' ) ); 55 54 } 56 function ds_removecustmizer_metacap() { 57 add_filter( 'map_meta_cap', array(&$this,'ds_removecustmizer_metacap_filter'), 10, 4 ); 58 59 } 60 function ds_removecustmizer_metacap_filter( $caps = array(), $cap = '', $user_id = 0, $args = array() ) { 55 56 function ds_removecustmizer_metacap() { 57 add_filter( 'map_meta_cap', array($this,'ds_removecustmizer_metacap_filter'), 10, 4 ); 58 } 59 60 function ds_removecustmizer_metacap_filter( $caps = array(), $cap = '', $user_id = 0, $args = array() ) { 61 61 if ($cap == 'customize' ) { 62 62 return array( 'nope' ); //thanx wp-crap 63 63 } 64 64 return $caps; 65 }66 67 function ds_access_denied_splash() {65 } 66 67 function ds_access_denied_splash() { 68 68 //redirects WP "You do not have sufficient permissions to access this page." to dashboard or add custom message instead. 69 69 $user_id = get_current_user_id(); 70 70 $redirect = get_dashboard_url( $user_id ); 71 71 wp_redirect( $redirect ); 72 // wp_die(__('The White Rabbit says you do not have sufficient permissions to access this page.')); 73 exit; 74 75 } 76 77 function ds_menu_plugins_disable() { 78 global $submenu, $menu; 72 exit; 73 } 74 75 function ds_menu_plugins_disable() { 76 global $submenu, $menu; 79 77 $menu_perms = get_site_option( "menu_items" ); 80 78 if( is_array( $menu_perms ) == false ) … … 83 81 if( !isset($menu_perms[ 'super_admin' ] ) && is_super_admin()) 84 82 return; 85 //http://wordpress.stackexchange.com/questions/95837/remove-a-menu-item-created-by-a-plugin 86 // remove_menu_page( 'polls' ); 87 // remove_menu_page( 'ratings' ); 88 // remove_menu_page( 'feedback' ); 89 // remove_submenu_page( 'feedback', 'polls' ); 90 // remove_submenu_page( 'feedback', 'ratings' ); 91 // remove_submenu_page( 'themes.php', 'editcss' ); 92 // remove_submenu_page( 'themes.php', 'custom-header' ); 93 // remove_submenu_page( 'themes.php', 'custom-background' ); 94 // remove_submenu_page( 'themes.php', 'theme_options' ); 95 96 } 97 98 function ds_jetpack_admin_menu_disable() { 99 global $submenu, $menu; 83 } 84 85 function ds_jetpack_admin_menu_disable() { 86 global $submenu, $menu; 100 87 $menu_perms = get_site_option( "menu_items" ); 101 88 if( is_array( $menu_perms ) == false ) … … 141 128 } 142 129 143 }144 145 146 147 148 function ds_reduce_favorite_actions ($wp_toolbar) {149 $menu_perms = get_site_option( "menu_items" );150 151 if( !isset( $menu_perms[ 'super_admin' ] ) && is_super_admin())152 return $wp_toolbar;130 } 131 132 133 134 135 function ds_reduce_favorite_actions ($wp_toolbar) { 136 $menu_perms = get_site_option( "menu_items" ); 137 138 if( !isset( $menu_perms[ 'super_admin' ] ) && is_super_admin()) 139 return $wp_toolbar; 153 140 154 141 if( !isset( $menu_perms[ 'posts_new' ] ) && current_user_can('edit_posts') ) { … … 200 187 $wp_toolbar->remove_node( 'header' ); 201 188 } 202 }203 204 function ds_menu_disable() {205 global $submenu, $menu;189 } 190 191 function ds_menu_disable() { 192 global $submenu, $menu; 206 193 $menu_perms = get_site_option( "menu_items" ); 207 194 if( is_array( $menu_perms ) == false ) … … 215 202 216 203 217 // 'Dashboard'218 if( !isset($menu_perms[ 'menu_dashboard' ]) && current_user_can('read')) {204 // 'Dashboard' 205 if( !isset($menu_perms[ 'menu_dashboard' ]) && current_user_can('read')) { 219 206 if(!empty($menu)) { 220 207 foreach($menu as $key => $sm) { … … 607 594 } 608 595 } 609 if (class_exists("ds_menus")) { 610 $ds_menus = new ds_menus(); 611 } 596 new DS_Menus(); 612 597 ?> -
menus/trunk/readme.txt
r1470271 r1470376 40 40 41 41 == Changelog == 42 = 4.3 = 43 * Tested up to: WP 4.5, hides Customizer by default, enable @ Network->Settings 44 45 = 3.7.1 = 46 * Tested up to: WP 3.7.1 major rewrite for 3.7.1 42 = 4.6 = 43 * WP 4.6 tests OK, cleanup php notices 47 44 48 45 == Upgrade Notice == 49 = 4. 3=50 * Tested up to: WP 4.5, hides Customizer by default, enable @ Network->Settings46 = 4.6 = 47 * WP 4.6 tests OK, cleanup php notices
Note: See TracChangeset
for help on using the changeset viewer.