Opened 8 years ago
Last modified 8 years ago
#39651 new defect (bug)
Find Posts modal does not show post-type labels correctly
Reported by: | arkonisus | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.7.1 |
Component: | Posts, Post Types | Keywords: | needs-patch |
Focuses: | Cc: |
Description
The screenshot shows the output of four different posts in the Find Posts Modal. The last two post are correct, at the first and second post the post-type-label (e.g. cpt_example) is missing. The problem is the post-type parameter "public", if it is set to "false" the label will not be shown AND you will get the following PHP-Notice (if DEBUG is true):
Undefined index: cpt_example in ... /wp-admin/includes/ajax-actions.php on line 1803 Trying to get property of non-object in ... /wp-admin/includes/ajax-actions.php on line 1803
At the following code (1745 ff.) you will notice the reason of this issue: $post_types only includes public posts
<?php /** * Ajax handler for querying posts for the Find Posts modal. * * @see window.findPosts * * @since 3.1.0 */ function wp_ajax_find_posts() { check_ajax_referer( 'find-posts' ); $post_types = get_post_types( array( 'public' => true ), 'objects' ); ^^^^^^^^^^^^^^^^
The output of this modal shows all posts (public and unpublic), so i don't think that this "filter" was set for security reasons. In my opinion it must either show all posts correctly with their labels (which would be great) or it must suppress all "unpublic" posts completely.
Seems it will need to check if the current user can see private posts and exclude them if not.