Make WordPress Core

Changeset 29320


Ignore:
Timestamp:
07/29/2014 01:40:24 AM (10 years ago)
Author:
SergeyBiryukov
Message:

Avoid PHP notices in Media Library if an attachment parent post type no longer exists.

Synchronize the 'edit_post' capability check between the list table and the media grid.

fixes #27446.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r29137 r29320  
    371371?>
    372372            <td <?php echo $attributes ?>><strong>
    373                 <?php if ( current_user_can( 'edit_post', $post->post_parent ) && $parent_type && $parent_type->show_ui ) { ?>
     373                <?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
    374374                    <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
    375375                        <?php echo $title ?></a><?php
  • trunk/src/wp-includes/media-template.php

    r29303 r29320  
    396396                        <label class="setting">
    397397                            <span class="name"><?php _e( 'Uploaded To' ); ?></span>
    398                             <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
     398                            <# if ( data.uploadedToLink ) { #>
     399                                <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
     400                            <# } else { #>
     401                                <span class="value">{{ data.uploadedToTitle }}</span>
     402                            <# } #>
    399403                        </label>
    400404                    <# } #>
  • trunk/src/wp-includes/media.php

    r29281 r29320  
    26372637    if ( $attachment->post_parent ) {
    26382638        $post_parent = get_post( $attachment->post_parent );
    2639         $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
     2639        $parent_type = get_post_type_object( $post_parent->post_type );
     2640        if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $attachment->post_parent ) ) {
     2641            $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
     2642        }
    26402643        $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(No title)' );
    26412644    }
Note: See TracChangeset for help on using the changeset viewer.