Changeset 12707
- Timestamp:
- 07/03/2023 08:05:26 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/admin.php
r12706 r12707 58 58 // Modify admin menu links for photo posts. 59 59 add_action( 'admin_menu', [ __CLASS__, 'modify_admin_menu_links' ] ); 60 61 // Restrict Media Library access. 62 add_action( 'admin_init', [ __CLASS__, 'restrict_media_library_access' ] ); 63 add_action( 'admin_menu', [ __CLASS__, 'disable_media_library' ] ); 60 64 61 65 // Navigate to next post after moderation. … … 1034 1038 1035 1039 /** 1040 * Restricts direct access to the Media Library by moderators. 1041 */ 1042 public static function restrict_media_library_access() { 1043 global $pagenow; 1044 if ( 1045 'upload.php' === $pagenow 1046 && 1047 ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) 1048 ) { 1049 wp_die( __( 'Sorry, you are not allowed to access the media library.', 'wporg-photos' ) ); 1050 } 1051 } 1052 1053 /** 1054 * Removes "Media Library" from the admin menu for moderators. 1055 */ 1056 public static function disable_media_library() { 1057 if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { 1058 remove_menu_page( 'upload.php' ); 1059 } 1060 } 1061 1062 /** 1036 1063 * Modifies admin menu links for photo posts. 1037 1064 *
Note: See TracChangeset
for help on using the changeset viewer.