Changeset 15891
- Timestamp:
- 10/21/2010 02:55:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/capabilities.php
r15890 r15891 820 820 case 'delete_page': 821 821 $author_data = get_userdata( $user_id ); 822 //echo "post ID: {$args[0]}<br />";823 822 $post = get_post( $args[0] ); 824 823 $post_type = get_post_type_object( $post->post_type ); 824 825 825 if ( 'delete_post' == $cap && $post_type && 'post' != $post_type->capability_type && ! $post_type->map_meta_cap ) { 826 826 $args = array_merge( array( $post_type->cap->delete_post, $user_id ), $args ); … … 828 828 } 829 829 830 if ( '' != $post->post_author ) {830 if ( '' != $post->post_author && post_type_supports( $post_type->name, 'author' ) ) { 831 831 $post_author_data = get_userdata( $post->post_author ); 832 832 } else { 833 //No author set yet so default to current user for cap checks 833 // No author set yet or post type doesn't support authors, 834 // so default to current user for cap checks. 834 835 $post_author_data = $author_data; 835 836 } … … 862 863 case 'edit_page': 863 864 $author_data = get_userdata( $user_id ); 864 //echo "post ID: {$args[0]}<br />";865 865 $post = get_post( $args[0] ); 866 867 866 $post_type = get_post_type_object( $post->post_type ); 867 868 868 if ( 'edit_post' == $cap && $post_type && 'post' != $post_type->capability_type && ! $post_type->map_meta_cap ) { 869 869 $args = array_merge( array( $post_type->cap->edit_post, $user_id ), $args ); 870 870 return call_user_func_array( 'map_meta_cap', $args ); 871 871 } 872 $post_author_data = get_userdata( $post->post_author ); 872 873 if ( '' != $post->post_author && post_type_supports( $post_type->name, 'author' ) ) { 874 $post_author_data = get_userdata( $post->post_author ); 875 } else { 876 // No author set yet or post type doesn't support authors, 877 // so default to current user for cap checks. 878 $post_author_data = $author_data; 879 } 880 873 881 //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />"; 874 882 // If the user is the author... … … 896 904 case 'read_post': 897 905 case 'read_page': 906 $author_data = get_userdata( $user_id ); 898 907 $post = get_post( $args[0] ); 899 908 $post_type = get_post_type_object( $post->post_type ); 909 900 910 if ( 'read_post' == $cap && $post_type && 'post' != $post_type->capability_type && ! $post_type->map_meta_cap ) { 901 911 $args = array_merge( array( $post_type->cap->read_post, $user_id ), $args ); … … 908 918 } 909 919 910 $author_data = get_userdata( $user_id ); 911 $post_author_data = get_userdata( $post->post_author ); 920 if ( '' != $post->post_author && post_type_supports( $post_type->name, 'author' ) ) { 921 $post_author_data = get_userdata( $post->post_author ); 922 } else { 923 // No author set yet or post type doesn't support authors, 924 // so default to current user for cap checks. 925 $post_author_data = $author_data; 926 } 927 912 928 if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) 913 929 $caps[] = $post_type->cap->read;
Note: See TracChangeset
for help on using the changeset viewer.