mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 15:31:42 +01:00
Avoid PHP notices in Media Library if an attachment parent does not exist. props trepmal, viniciusmassuchetto, alex-ye, adamsilverstein for initial patches. fixes #22312. fixes #23154.
git-svn-id: http://core.svn.wordpress.org/trunk@24182 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d55dfbf477
commit
23479edf3f
@ -302,13 +302,11 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
break;
|
||||
|
||||
case 'parent':
|
||||
if ( $post->post_parent > 0 ) {
|
||||
if ( get_post( $post->post_parent ) ) {
|
||||
$title =_draft_or_post_title( $post->post_parent );
|
||||
}
|
||||
if ( $post->post_parent > 0 && get_post( $post->post_parent ) ) {
|
||||
$title = _draft_or_post_title( $post->post_parent );
|
||||
?>
|
||||
<td <?php echo $attributes ?>><strong>
|
||||
<?php if( current_user_can( 'edit_post', $post->post_parent ) ) { ?>
|
||||
<?php if ( current_user_can( 'edit_post', $post->post_parent ) ) { ?>
|
||||
<a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
|
||||
<?php echo $title ?></a><?php
|
||||
} else {
|
||||
@ -320,7 +318,7 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
} else {
|
||||
?>
|
||||
<td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
|
||||
<?php if( $user_can_edit ) {?>
|
||||
<?php if ( $user_can_edit ) { ?>
|
||||
<a class="hide-if-no-js"
|
||||
onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
|
||||
href="#the-list">
|
||||
|
@ -301,9 +301,9 @@ function get_attachment_link( $post = null, $leavename = false ) {
|
||||
$link = false;
|
||||
|
||||
$post = get_post( $post );
|
||||
$parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
|
||||
|
||||
if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) {
|
||||
$parent = get_post($post->post_parent);
|
||||
if ( $wp_rewrite->using_permalinks() && $parent ) {
|
||||
if ( 'page' == $parent->post_type )
|
||||
$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user