Skip to content

Commit 31c6495

Browse files
committed
added comments for link logic
1 parent 7562d00 commit 31c6495

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

classes/class-cpt-wplf-submission.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,15 @@ function metabox_submission() {
202202
$possible_link = '';
203203
$attachment_url = wp_get_attachment_url( $value ); // get_edit_post_link returns something awkward.
204204

205-
// Check if there is a file in that directory. If there is display a link.
206205
// Maybe add a filter for target="_blank"? Wouldn't enable by default.
207206

208207
if ( $attachment_url ) {
208+
// If this is true, $value was a valid attachment_id.
209+
// Caveat: if user enters a numeric value here, it could be interpreted as attachment.
209210
$attachment_url = get_edit_post_link($value);
210211
$possible_link = "<a href='$attachment_url' style='float: right;'>Edit attachment</a>";
211212
} elseif ( file_exists( $home_path . substr( $value, 1 ) ) ) {
213+
// This is bit less ambiguous. Check if there's a file, and if there is, get link for it.
212214
$attachment_url = get_home_url() . $value;
213215
$possible_link = "<a href='$attachment_url' style='float: right;'>Open file</a>";
214216
}

0 commit comments

Comments
 (0)