@@ -184,6 +184,7 @@ function metabox_submission() {
184184 global $ post ;
185185 $ postmeta = get_post_meta ( $ post ->ID );
186186 $ fields = array_keys ( $ postmeta );
187+ $ home_path = get_home_path ();
187188?>
188189<p>
189190 <table class="wp-list-table widefat striped">
@@ -196,9 +197,24 @@ function metabox_submission() {
196197 <tbody>
197198 <?php foreach ( $ fields as $ field ) : ?>
198199 <?php if ( '_ ' != $ field [0 ] ) : ?>
199- <?php $ value = $ postmeta [ $ field ][0 ]; ?>
200+ <?php
201+ $ value = $ postmeta [ $ field ][0 ];
202+ $ possible_link = '' ;
203+ $ attachment_url = wp_get_attachment_url ( $ value ); // get_edit_post_link returns something awkward.
204+
205+ // Check if there is a file in that directory. If there is display a link.
206+ // Maybe add a filter for target="_blank"? Wouldn't enable by default.
207+
208+ if ( $ attachment_url ) {
209+ $ attachment_url = get_edit_post_link ($ value );
210+ $ possible_link = "<a href=' $ attachment_url' style='float: right;'>Edit attachment</a> " ;
211+ } elseif ( file_exists ( $ home_path . substr ( $ value , 1 ) ) ) {
212+ $ attachment_url = get_home_url () . $ value ;
213+ $ possible_link = "<a href=' $ attachment_url' style='float: right;'>Open file</a> " ;
214+ }
215+ ?>
200216 <tr>
201- <th><strong><?php echo $ field ; ?> </strong></th>
217+ <th><strong><?php echo $ field ; ?> </strong> <?php echo $ possible_link ; ?> </th>
202218 <?php if ( strlen ( $ value ) > 60 || strpos ( $ value , "\n" ) ) : ?>
203219 <td><textarea style="width:100%" readonly><?php echo esc_textarea ( $ value ); ?> </textarea></td>
204220 <?php else : ?>
0 commit comments