File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments