Changeset 2792
- Timestamp:
- 03/24/2016 07:08:17 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r2791 r2792 43 43 add_filter( 'wp_ajax_add-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' ) ); 44 44 add_filter( 'wp_ajax_delete-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'remove_committer' ) ); 45 46 // Page access within wp-admin. 45 47 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 46 48 add_action( 'load-index.php', array( $this, 'disable_admin_page' ) ); 49 add_action( 'load-profile.php', array( $this, 'disable_admin_page' ) ); 47 50 } 48 51 … … 89 92 } 90 93 94 /** 95 * Customizes the admin menu according to the current user's privileges. 96 */ 91 97 public function admin_menu() { 92 // WordPress requires that the plugin post_type have at least one submenu accessible *other* than itself. 93 // If it doesn't have at least one submenu then users who cannot also publish posts will not be able to access the post type. 98 99 /* 100 * WordPress requires that the plugin post_type have at least one submenu accessible *other* than itself. 101 * If it doesn't have at least one submenu then users who cannot also publish posts will not be able to access the post type. 102 */ 94 103 add_submenu_page( 'edit.php?post_type=plugin', 'Plugin Handbook', 'Plugin Handbook', 'read', 'handbook', function() {} ); 95 104 add_submenu_page( 'edit.php?post_type=plugin', 'Readme Validator', 'Readme Validator', 'read', 'readme_validator', function() {} ); 96 105 97 remove_menu_page( 'index.php' ); 98 remove_menu_page( 'profile.php' ); 106 if ( ! current_user_can( 'manage_options' ) ) { 107 remove_menu_page( 'index.php' ); 108 remove_menu_page( 'profile.php' ); 109 } 110 } 111 112 /** 113 * Disables admin pages. 114 */ 115 public function disable_admin_page() { 116 if ( ! current_user_can( 'manage_options' ) ) { 117 118 // Dashboard is plugin dashboard. 119 if ( 'load-index.php' === current_action() ) { 120 wp_safe_redirect( admin_url( 'edit.php?post_type=plugin' ) ); 121 exit; 122 } 123 124 wp_die( __( 'You do not have permission to access this page.', 'wporg-plugins' ), '', array( 125 'back_link' => true, 126 ) ); 127 } 99 128 } 100 129
Note: See TracChangeset
for help on using the changeset viewer.