root/trunk/wp-admin/edit-link-form.php

Revision 8753, 16.6 kB (checked in by ryan, 1 week ago)

Show Settings for edit link form. see #7552

  • Property svn:eol-style set to native
Line 
1 <?php
2 /**
3  * Edit links form for inclusion in administration panels.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 if ( ! empty($link_id) ) {
10     $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
11     $submit_text = __('Save Changes');
12     $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
13     $nonce_action = 'update-bookmark_' . $link_id;
14 } else {
15     $heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
16     $submit_text = __('Add Link');
17     $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
18     $nonce_action = 'add-bookmark';
19 }
20
21 function xfn_check($class, $value = '', $deprecated = '') {
22     global $link;
23
24     $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
25     $rels = preg_split('/\s+/', $link_rel);
26
27     if ('' != $value && in_array($value, $rels) ) {
28         echo ' checked="checked"';
29     }
30
31     if ('' == $value) {
32         if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"';
33         if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
34         if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
35         if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
36     }
37 }
38 ?>
39
40 <?php function link_submit_meta_box($link) { ?>
41 <div class="submitbox" id="submitlink">
42
43 <div class="inside-submitbox">
44 <p><label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label></p>
45 </div>
46
47 <p class="submit">
48 <input type="submit" class="button button-highlighted" name="save" value="<?php _e('Save'); ?>" tabindex="4" />
49 <?php
50 if ( ( 'edit' == $action) && current_user_can('manage_links') )
51     echo "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm('" . js_escape( sprintf( __("You are about to delete this link '%s'\n'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete&nbsp;link') . "</a>";
52 ?>
53 </p>
54 <?php do_action('submitlink_box'); ?>
55 </div>
56 <?php
57 }
58 add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', 'link', 'side', 'core');
59
60 function link_categories_meta_box($link) { ?>
61 <div id="category-adder" class="wp-hidden-children">
62     <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
63     <p id="link-category-add" class="wp-hidden-child">
64         <label class="hidden" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
65         <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" aria-required="true" />
66         <input type="button" id="category-add-sumbit" class="add:categorychecklist:linkcategorydiv button" value="<?php _e( 'Add' ); ?>" />
67         <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
68         <span id="category-ajax-response"></span>
69     </p>
70 </div>
71
72 <ul id="category-tabs">
73     <li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
74     <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
75 </ul>
76
77 <div id="categories-all" class="ui-tabs-panel">
78     <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
79         <?php
80         if ( isset($link->link_id) )
81             wp_link_category_checklist($link->link_id);
82         else
83             wp_link_category_checklist();
84         ?>
85     </ul>
86 </div>
87
88 <div id="categories-pop" class="ui-tabs-panel" style="display: none;">
89     <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
90         <?php wp_popular_terms_checklist('link_category'); ?>
91     </ul>
92 </div>
93 <?php
94 }
95 add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', 'link', 'normal', 'core');
96
97 function link_target_meta_box($link) { ?>
98 <fieldset><legend class="hidden"><?php _e('Target') ?></legend>
99 <label for="link_target_blank" class="selectit">
100 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
101 <code>_blank</code></label><br />
102 <label for="link_target_top" class="selectit">
103 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
104 <code>_top</code></label><br />
105 <label for="link_target_none" class="selectit">
106 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
107 <?php _e('none') ?></label>
108 </fieldset>
109 <p><?php _e('Choose the frame your link targets. Essentially this means if you choose <code>_blank</code> your link will open in a new window.'); ?></p>
110 <?php
111 }
112 add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', 'link', 'normal', 'core');
113
114 function link_xfn_meta_box($link) {
115 ?>
116 <table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
117     <tr>
118         <th style="width: 20%;" scope="row"><label for="link_rel"><?php _e('rel:') ?></label></th>
119         <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo ( isset( $link->link_rel ) ? $link->link_rel : ''); ?>" /></td>
120     </tr>
121     <tr>
122         <td colspan="2">
123             <table cellpadding="3" cellspacing="5" class="form-table">
124                 <tr>
125                     <th scope="row"> <?php _e('identity') ?> </th>
126                     <td><fieldset><legend class="hidden"> <?php _e('identity') ?> </legend>
127                         <label for="me">
128                         <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
129                         <?php _e('another web address of mine') ?></label>
130                     </fieldset></td>
131                 </tr>
132                 <tr>
133                     <th scope="row"> <?php _e('friendship') ?> </th>
134                     <td><fieldset><legend class="hidden"> <?php _e('friendship') ?> </legend>
135                         <label for="contact">
136                         <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
137                         <label for="acquaintance">
138                         <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php _e('acquaintance') ?></label>
139                         <label for="friend">
140                         <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
141                         <label for="friendship">
142                         <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
143                     </fieldset></td>
144                 </tr>
145                 <tr>
146                     <th scope="row"> <?php _e('physical') ?> </th>
147                     <td><fieldset><legend class="hidden"> <?php _e('physical') ?> </legend>
148                         <label for="met">
149                         <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
150                         <?php _e('met') ?></label>
151                     </fieldset></td>
152                 </tr>
153                 <tr>
154                     <th scope="row"> <?php _e('professional') ?> </th>
155                     <td><fieldset><legend class="hidden"> <?php _e('professional') ?> </legend>
156                         <label for="co-worker">
157                         <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
158                         <?php _e('co-worker') ?></label>
159                         <label for="colleague">
160                         <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
161                         <?php _e('colleague') ?></label>
162                     </fieldset></td>
163                 </tr>
164                 <tr>
165                     <th scope="row"> <?php _e('geographical') ?> </th>
166                     <td><fieldset><legend class="hidden"> <?php _e('geographical') ?> </legend>
167                         <label for="co-resident">
168                         <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
169                         <?php _e('co-resident') ?></label>
170                         <label for="neighbor">
171                         <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
172                         <?php _e('neighbor') ?></label>
173                         <label for="geographical">
174                         <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
175                         <?php _e('none') ?></label>
176                     </fieldset></td>
177                 </tr>
178                 <tr>
179                     <th scope="row"> <?php _e('family') ?> </th>
180                     <td><fieldset><legend class="hidden"> <?php _e('family') ?> </legend>
181                         <label for="child">
182                         <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
183                         <?php _e('child') ?></label>
184                         <label for="kin">
185                         <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
186                         <?php _e('kin') ?></label>
187                         <label for="parent">
188                         <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
189                         <?php _e('parent') ?></label>
190                         <label for="sibling">
191                         <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
192                         <?php _e('sibling') ?></label>
193                         <label for="spouse">
194                         <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
195                         <?php _e('spouse') ?></label>
196                         <label for="family">
197                         <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
198                         <?php _e('none') ?></label>
199                     </fieldset></td>
200                 </tr>
201                 <tr>
202                     <th scope="row"> <?php _e('romantic') ?> </th>
203                     <td><fieldset><legend class="hidden"> <?php _e('romantic') ?> </legend>
204                         <label for="muse">
205                         <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
206                         <?php _e('muse') ?></label>
207                         <label for="crush">
208                         <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
209                         <?php _e('crush') ?></label>
210                         <label for="date">
211                         <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
212                         <?php _e('date') ?></label>
213                         <label for="romantic">
214                         <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
215                         <?php _e('sweetheart') ?></label>
216                     </fieldset></td>
217                 </tr>
218             </table>
219         </td>
220     </tr>
221 </table>
222 <p><?php _e('If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="http://gmpg.org/xfn/">XFN</a>.'); ?></p>
223 <?php
224 }
225 add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', 'link', 'normal', 'core');
226
227 function link_advanced_meta_box($link) {
228 ?>
229 <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
230     <tr class="form-field">
231         <th valign="top"  scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
232         <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo ( isset( $link->link_image ) ? $link->link_image : ''); ?>" style="width: 95%" /></td>
233     </tr>
234     <tr class="form-field">
235         <th valign="top"  scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
236         <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo  ( isset( $link->link_rss ) ? $link->link_rss : ''); ?>" size="50" style="width: 95%" /></td>
237     </tr>
238     <tr class="form-field">
239         <th valign="top"  scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
240         <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo  ( isset( $link->link_notes ) ? $link->link_notes : ''); ?></textarea></td>
241     </tr>
242     <tr class="form-field">
243         <th valign="top"  scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
244         <td><select name="link_rating" id="link_rating" size="1">
245         <?php
246             for ($r = 0; $r < 10; $r++) {
247                 echo('            <option value="'.$r.'" ');
248                 if ( isset($link->link_rating) && $link->link_rating == $r)
249                     echo 'selected="selected"';
250                 echo('>'.$r.'</option>');
251             }
252         ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
253         </td>
254     </tr>
255 </table>
256 <?php
257 }
258 add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core');
259
260 echo $form;
261 echo $link_added;
262
263 wp_nonce_field($nonce_action);
264 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
265 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
266
267 <div class="wrap">
268 <h2><?php echo $heading; ?></h2>
269
270 <?php if ( !empty($link->link_id) ) { ?>
271 <div id="previewview">
272 <a class="button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a>
273 </div>
274 <?php } ?>
275
276 <!--
277 <p id="big-add-button">
278 <span id="previewview">
279 <?php if ( !empty($link_id) ) { ?>
280 <a class="button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a>
281 <?php } ?>
282 </span>
283 </p>
284 -->
285
286 <!-- TODO
287 <div class="inside">
288 <p><label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label></p>
289 </div>
290
291 <div class="side-info">
292 <h5><?php _e('Related') ?></h5>
293
294 <ul>
295 <li><a href="link-manager.php"><?php _e('Manage All Links') ?></a></li>
296 <li><a href="edit-link-categories.php"><?php _e('Manage All Link Categories') ?></a></li>
297 <li><a href="link-import.php"><?php _e('Import Links') ?></a></li>
298 <?php do_action('link_relatedlinks_list'); ?>
299 </ul>
300 </div>
301 -->
302
303 <div id="poststuff">
304
305 <div id="show-settings"><a href="#edit_settings" id="show-settings-link" class="hide-if-no-js"><?php _e('Show Settings') ?></a>
306 <a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Settings') ?></a></div>
307
308 <div id="edit-settings" class="hide-if-js hide-if-no-js">
309 <div id="edit-settings-wrap">
310 <h5><?php _e('Show on screen') ?></h5>
311 <div class="metabox-prefs">
312 <?php meta_box_prefs('link') ?>
313 <br class="clear" />
314 </div></div>
315 </div>
316
317 <div id="side-info-column" class="inner-sidebar">
318 <?php
319
320 do_action('submitlink_box');
321 $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
322
323 ?>
324 </div>
325
326 <div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>">
327 <div id="post-body-content" class="has-sidebar-content">
328 <div id="namediv" class="stuffbox">
329 <h3><label for="link_name"><?php _e('Name') ?></label></h3>
330 <div class="inside">
331     <input type="text" name="link_name" size="30" tabindex="1" value="<?php echo $link->link_name; ?>" id="link_name" /><br />
332     <?php _e('Example: Nifty blogging software'); ?>
333 </div>
334 </div>
335
336 <div id="addressdiv" class="stuffbox">
337 <h3><label for="link_url"><?php _e('Web Address') ?></label></h3>
338 <div class="inside">
339     <input type="text" name="link_url" size="30" tabindex="1" value="<?php echo $link->link_url; ?>" id="link_url" /><br />
340     <?php _e('Example: <code>http://wordpress.org/</code> &#8212; don&#8217;t forget the <code>http://</code>'); ?>
341 </div>
342 </div>
343
344 <div id="descriptiondiv" class="stuffbox">
345 <h3><label for="link_description"><?php _e('Description') ?></label></h3>
346 <div class="inside">
347     <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo $link->link_description; ?>" id="link_description" /><br />
348     <?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?>
349 </div>
350 </div>
351
352 <?php
353
354 do_meta_boxes('link', 'normal', $link);
355
356 do_meta_boxes('link', 'advanced', $link);
357
358 if ( $link_id ) : ?>
359 <input type="hidden" name="action" value="save" />
360 <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
361 <input type="hidden" name="order_by" value="<?php echo attribute_escape($order_by); ?>" />
362 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
363 <?php else: ?>
364 <input type="hidden" name="action" value="add" />
365 <?php endif; ?>
366
367 </div>
368 </div>
369 </div>
370
371 </div>
372 </form>
373
Note: See TracBrowser for help on using the browser.