]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/edit-link-form.php
Wizard 2.8.2-scripts
[autoinstalls/wordpress.git] / wp-admin / edit-link-form.php
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 = __('Update Link');
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 /**
22  * Display checked checkboxes attribute for xfn microformat options.
23  *
24  * @since 1.0.1
25  *
26  * @param string $class
27  * @param string $value
28  * @param mixed $deprecated Not used.
29  */
30 function xfn_check($class, $value = '', $deprecated = '') {
31         global $link;
32
33         $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
34         $rels = preg_split('/\s+/', $link_rel);
35
36         if ('' != $value && in_array($value, $rels) ) {
37                 echo ' checked="checked"';
38         }
39
40         if ('' == $value) {
41                 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"';
42                 if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
43                 if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
44                 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
45         }
46 }
47
48 /**
49  * Display link create form fields.
50  *
51  * @since 2.7.0
52  *
53  * @param object $link
54  */
55 function link_submit_meta_box($link) {
56 ?>
57 <div class="submitbox" id="submitlink">
58
59 <div id="minor-publishing">
60
61 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
62 <div style="display:none;">
63 <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" />
64 </div>
65
66 <div id="minor-publishing-actions">
67 <div id="preview-action">
68 <?php if ( !empty($link->link_id) ) { ?>
69         <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank" tabindex="4"><?php _e('Visit Link'); ?></a>
70 <?php } ?>
71 </div>
72 <div class="clear"></div>
73 </div>
74
75 <div id="misc-publishing-actions">
76 <div class="misc-pub-section misc-pub-section-last">
77         <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>
78 </div>
79 </div>
80
81 </div>
82
83 <div id="major-publishing-actions">
84 <?php do_action('post_submitbox_start'); ?>
85 <div id="delete-action">
86 <?php
87 if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
88         <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
89 <?php } ?>
90 </div>
91
92 <div id="publishing-action">
93 <?php if ( !empty($link->link_id) ) { ?>
94         <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" />
95 <?php } else { ?>
96         <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />
97 <?php } ?>
98 </div>
99 <div class="clear"></div>
100 </div>
101 <?php do_action('submitlink_box'); ?>
102 <div class="clear"></div>
103 </div>
104 <?php
105 }
106 add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', 'link', 'side', 'core');
107
108 /**
109  * Display link categories form fields.
110  *
111  * @since 2.6.0
112  *
113  * @param object $link
114  */
115 function link_categories_meta_box($link) { ?>
116 <ul id="category-tabs">
117         <li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
118         <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
119 </ul>
120
121 <div id="categories-all" class="tabs-panel">
122         <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
123                 <?php
124                 if ( isset($link->link_id) )
125                         wp_link_category_checklist($link->link_id);
126                 else
127                         wp_link_category_checklist();
128                 ?>
129         </ul>
130 </div>
131
132 <div id="categories-pop" class="tabs-panel" style="display: none;">
133         <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
134                 <?php wp_popular_terms_checklist('link_category'); ?>
135         </ul>
136 </div>
137
138 <div id="category-adder" class="wp-hidden-children">
139         <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
140         <p id="link-category-add" class="wp-hidden-child">
141                 <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
142                 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />
143                 <input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php esc_attr_e( 'Add' ); ?>" />
144                 <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
145                 <span id="category-ajax-response"></span>
146         </p>
147 </div>
148 <?php
149 }
150 add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', 'link', 'normal', 'core');
151
152 /**
153  * Display form fields for changing link target.
154  *
155  * @since 2.6.0
156  *
157  * @param object $link
158  */
159 function link_target_meta_box($link) { ?>
160 <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>
161 <p><label for="link_target_blank" class="selectit">
162 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
163 <?php _e('<code>_blank</code> - new window or tab.'); ?></label></p>
164 <p><label for="link_target_top" class="selectit">
165 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
166 <?php _e('<code>_top</code> - current window or tab, with no frames.'); ?></label></p>
167 <p><label for="link_target_none" class="selectit">
168 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
169 <?php _e('<code>_none</code> - same window or tab.'); ?></label></p>
170 </fieldset>
171 <p><?php _e('Choose the target frame for your link.'); ?></p>
172 <?php
173 }
174 add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', 'link', 'normal', 'core');
175
176 /**
177  * Display xfn form fields.
178  *
179  * @since 2.6.0
180  *
181  * @param object $link
182  */
183 function link_xfn_meta_box($link) {
184 ?>
185 <table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
186         <tr>
187                 <th style="width: 20%;" scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
188                 <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td>
189         </tr>
190         <tr>
191                 <td colspan="2">
192                         <table cellpadding="3" cellspacing="5" class="form-table">
193                                 <tr>
194                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </th>
195                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </span></legend>
196                                                 <label for="me">
197                                                 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
198                                                 <?php _e('another web address of mine') ?></label>
199                                         </fieldset></td>
200                                 </tr>
201                                 <tr>
202                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </th>
203                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </span></legend>
204                                                 <label for="contact">
205                                                 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('contact') ?></label>
206                                                 <label for="acquaintance">
207                                                 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('acquaintance') ?></label>
208                                                 <label for="friend">
209                                                 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friend') ?></label>
210                                                 <label for="friendship">
211                                                 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
212                                         </fieldset></td>
213                                 </tr>
214                                 <tr>
215                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th>
216                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </span></legend>
217                                                 <label for="met">
218                                                 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
219                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?></label>
220                                         </fieldset></td>
221                                 </tr>
222                                 <tr>
223                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th>
224                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </span></legend>
225                                                 <label for="co-worker">
226                                                 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
227                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?></label>
228                                                 <label for="colleague">
229                                                 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
230                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?></label>
231                                         </fieldset></td>
232                                 </tr>
233                                 <tr>
234                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </th>
235                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend>
236                                                 <label for="co-resident">
237                                                 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
238                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?></label>
239                                                 <label for="neighbor">
240                                                 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
241                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?></label>
242                                                 <label for="geographical">
243                                                 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
244                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
245                                         </fieldset></td>
246                                 </tr>
247                                 <tr>
248                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </th>
249                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend>
250                                                 <label for="child">
251                                                 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
252                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?></label>
253                                                 <label for="kin">
254                                                 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
255                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?></label>
256                                                 <label for="parent">
257                                                 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
258                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?></label>
259                                                 <label for="sibling">
260                                                 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
261                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?></label>
262                                                 <label for="spouse">
263                                                 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
264                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?></label>
265                                                 <label for="family">
266                                                 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
267                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
268                                         </fieldset></td>
269                                 </tr>
270                                 <tr>
271                                         <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </th>
272                                         <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend>
273                                                 <label for="muse">
274                                                 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
275                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?></label>
276                                                 <label for="crush">
277                                                 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
278                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?></label>
279                                                 <label for="date">
280                                                 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
281                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?></label>
282                                                 <label for="romantic">
283                                                 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
284                                                 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?></label>
285                                         </fieldset></td>
286                                 </tr>
287                         </table>
288                 </td>
289         </tr>
290 </table>
291 <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>
292 <?php
293 }
294 add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', 'link', 'normal', 'core');
295
296 /**
297  * Display advanced link options form fields.
298  *
299  * @since 2.6.0
300  *
301  * @param object $link
302  */
303 function link_advanced_meta_box($link) {
304 ?>
305 <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
306         <tr class="form-field">
307                 <th valign="top"  scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
308                 <td><input type="text" name="link_image" class="code" id="link_image" size="50" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" style="width: 95%" /></td>
309         </tr>
310         <tr class="form-field">
311                 <th valign="top"  scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
312                 <td><input name="link_rss" class="code" type="text" id="rss_uri" value="<?php echo  ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" size="50" style="width: 95%" /></td>
313         </tr>
314         <tr class="form-field">
315                 <th valign="top"  scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
316                 <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>
317         </tr>
318         <tr class="form-field">
319                 <th valign="top"  scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
320                 <td><select name="link_rating" id="link_rating" size="1">
321                 <?php
322                         for ($r = 0; $r < 10; $r++) {
323                                 echo('            <option value="'. esc_attr($r) .'" ');
324                                 if ( isset($link->link_rating) && $link->link_rating == $r)
325                                         echo 'selected="selected"';
326                                 echo('>'.$r.'</option>');
327                         }
328                 ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
329                 </td>
330         </tr>
331 </table>
332 <?php
333 }
334 add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core');
335
336 do_action('do_meta_boxes', 'link', 'normal', $link);
337 do_action('do_meta_boxes', 'link', 'advanced', $link);
338 do_action('do_meta_boxes', 'link', 'side', $link);
339
340 require_once ('admin-header.php');
341
342 ?>
343 <div class="wrap">
344 <?php screen_icon(); ?>
345 <h2><?php echo esc_html( $title ); ?></h2>
346
347 <?php if ( isset( $_GET['added'] ) ) : ?>
348 <div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
349 <?php endif; ?>
350
351 <?php
352 if ( !empty($form) )
353         echo $form;
354 if ( !empty($link_added) )
355         echo $link_added;
356
357 wp_nonce_field( $nonce_action );
358 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
359 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
360
361 <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
362
363 <div id="side-info-column" class="inner-sidebar">
364 <?php
365
366 do_action('submitlink_box');
367 $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
368
369 ?>
370 </div>
371
372 <div id="post-body">
373 <div id="post-body-content">
374 <div id="namediv" class="stuffbox">
375 <h3><label for="link_name"><?php _e('Name') ?></label></h3>
376 <div class="inside">
377         <input type="text" name="link_name" size="30" tabindex="1" value="<?php echo esc_attr($link->link_name); ?>" id="link_name" />
378     <p><?php _e('Example: Nifty blogging software'); ?></p>
379 </div>
380 </div>
381
382 <div id="addressdiv" class="stuffbox">
383 <h3><label for="link_url"><?php _e('Web Address') ?></label></h3>
384 <div class="inside">
385         <input type="text" name="link_url" size="30" class="code" tabindex="1" value="<?php echo esc_attr($link->link_url); ?>" id="link_url" />
386     <p><?php _e('Example: <code>http://wordpress.org/</code> &#8212; don&#8217;t forget the <code>http://</code>'); ?></p>
387 </div>
388 </div>
389
390 <div id="descriptiondiv" class="stuffbox">
391 <h3><label for="link_description"><?php _e('Description') ?></label></h3>
392 <div class="inside">
393         <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo isset($link->link_description) ? esc_attr($link->link_description) : ''; ?>" id="link_description" />
394     <p><?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?></p>
395 </div>
396 </div>
397
398 <?php
399
400 do_meta_boxes('link', 'normal', $link);
401
402 do_meta_boxes('link', 'advanced', $link);
403
404 if ( $link_id ) : ?>
405 <input type="hidden" name="action" value="save" />
406 <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
407 <input type="hidden" name="order_by" value="<?php echo esc_attr($order_by); ?>" />
408 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
409 <?php else: ?>
410 <input type="hidden" name="action" value="add" />
411 <?php endif; ?>
412
413 </div>
414 </div>
415 </div>
416
417 </form>
418 </div>