Plugin Directory

Changeset 1470376


Ignore:
Timestamp:
08/08/2016 11:28:04 PM (10 years ago)
Author:
dsader
Message:

WP 4.6 tests OK, cleanup php notices

Location:
menus/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • menus/trunk/ds_wp3_menus.php

    r1384851 r1470376  
    33Plugin Name: Menus
    44Plugin URI: http://wordpress.org/extend/plugins/menus/
    5 Version: 4.3
     5Version: 4.6
    66Description: 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.
    77Author: dsader
     
    2121*/
    2222
    23 class ds_menus {
    24 function ds_menus() {
     23class DS_Menus {
    2524//------------------------------------------------------------------------//
    2625//---Hooks----------------------------------------------------------------//
    2726//------------------------------------------------------------------------//
    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    }
    4442//------------------------------------------------------------------------//
    4543//---Functions to Enable/Disable admin menus------------------------------//
    4644//------------------------------------------------------------------------//
    4745
    48 function ds_customize() {
     46    function ds_customize() {
    4947        remove_action( 'plugins_loaded', '_wp_customize_include', 10);
    5048        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() {
    5453        wp_die( __( 'The Customizer is currently disabled.' ) );
    5554    }
    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() ) {
    6161    if ($cap == 'customize' ) {
    6262        return array( 'nope' ); //thanx wp-crap
    6363    }
    6464    return $caps;
    65 }
    66 
    67 function ds_access_denied_splash() {
     65    }
     66
     67    function ds_access_denied_splash() {
    6868    //redirects WP "You do not have sufficient permissions to access this page." to dashboard or add custom message instead.
    6969            $user_id = get_current_user_id();
    7070            $redirect = get_dashboard_url( $user_id );
    7171            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;
    7977        $menu_perms = get_site_option( "menu_items" );
    8078        if( is_array( $menu_perms ) == false )
     
    8381            if( !isset($menu_perms[ 'super_admin' ] ) && is_super_admin())
    8482            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;
    10087        $menu_perms = get_site_option( "menu_items" );
    10188        if( is_array( $menu_perms ) == false )
     
    141128    }
    142129
    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;
    153140       
    154141        if( !isset( $menu_perms[ 'posts_new' ] ) && current_user_can('edit_posts') ) {
     
    200187            $wp_toolbar->remove_node( 'header' );
    201188        }
    202 }
    203 
    204 function ds_menu_disable() {
    205     global $submenu, $menu;
     189    }
     190
     191    function ds_menu_disable() {
     192        global $submenu, $menu;
    206193        $menu_perms = get_site_option( "menu_items" );
    207194        if( is_array( $menu_perms ) == false )
     
    215202
    216203
    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')) {
    219206        if(!empty($menu)) {
    220207            foreach($menu as $key => $sm) {
     
    607594    }
    608595}
    609 if (class_exists("ds_menus")) {
    610     $ds_menus = new ds_menus();
    611 }
     596new DS_Menus();
    612597?>
  • menus/trunk/readme.txt

    r1470271 r1470376  
    4040
    4141== 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
    4744
    4845== Upgrade Notice ==
    49 = 4.3 =
    50 * Tested up to: WP 4.5, hides Customizer by default, enable @ Network->Settings
     46= 4.6 =
     47* WP 4.6 tests OK, cleanup php notices
Note: See TracChangeset for help on using the changeset viewer.