Skip to content

Commit 2a6ffa1

Browse files
committed
Fix the trashed post case.
1 parent dec4b58 commit 2a6ffa1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

projects/packages/forms/src/contact-form/class-feedback-source.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public function __construct( $id = 0, $title = '', $page_number = 1, $source_typ
8989
$this->title = get_the_title( $entry_post );
9090
} elseif ( $entry_post ) {
9191
$this->permalink = '';
92+
93+
if ( $entry_post->post_status === 'trash' ) {
94+
/* translators: %s is the post title */
95+
$this->title = sprintf( __( '(trashed) %s', 'jetpack-forms' ), $this->title );
96+
}
9297
}
9398
if ( empty( $entry_post ) ) {
9499
/* translators: %s is the post title */
@@ -221,6 +226,10 @@ public function get_edit_form_url() {
221226
}
222227

223228
if ( $this->id && is_numeric( $this->id ) && $this->id > 0 && current_user_can( 'edit_post', (int) $this->id ) ) {
229+
$entry_post = get_post( $this->id );
230+
if ( $entry_post && $entry_post->post_status === 'trash' ) {
231+
return ''; // No edit link is possible for trashed posts. They need to be restored first.
232+
}
224233
return \get_edit_post_link( (int) $this->id, 'url' );
225234
}
226235

0 commit comments

Comments
 (0)