Make WordPress Core

Changeset 34177


Ignore:
Timestamp:
09/15/2015 10:26:22 AM (9 years ago)
Author:
johnbillion
Message:

Remove the ability to view the post listing screen and post editing screen for post types with show_ui set to false. It is unexpected and unintended behaviour that this is allowed.

If your plugin or site does rely on this behaviour, the arguments that are passed to register_post_type() should be altered so that show_ui is true, and arguments such as show_in_menu, show_in_nav_menus, and show_in_admin_bar are false.

Fixes #33763
Props swissspidy, johnbillion

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit.php

    r33861 r34177  
    1212if ( ! $typenow )
    1313    wp_die( __( 'Invalid post type' ) );
     14
     15if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ) ) ) {
     16    wp_die( __( 'You are not allowed to edit posts in this post type.' ) );
     17}
    1418
    1519if ( 'attachment' === $typenow ) {
  • trunk/src/wp-admin/post.php

    r34027 r34177  
    110110        wp_die( __( 'Unknown post type.' ) );
    111111
     112    if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ) ) ) {
     113        wp_die( __( 'You are not allowed to edit posts in this post type.' ) );
     114    }
     115
    112116    if ( ! current_user_can( 'edit_post', $post_id ) )
    113117        wp_die( __( 'You are not allowed to edit this item.' ) );
  • trunk/src/wp-includes/link-template.php

    r34176 r34177  
    12291229        return;
    12301230
     1231    if ( ! in_array( $post->post_type, get_post_types( array( 'show_ui' => true ) ) ) ) {
     1232        return;
     1233    }
     1234
    12311235    /**
    12321236     * Filter the post edit link.
Note: See TracChangeset for help on using the changeset viewer.