3 * Edit links form for inclusion in administration panels.
6 * @subpackage Administration
10 if ( !defined('ABSPATH') )
13 if ( ! empty($link_id) ) {
14 $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
15 $submit_text = __('Update Link');
16 $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
17 $nonce_action = 'update-bookmark_' . $link_id;
19 $heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
20 $submit_text = __('Add Link');
21 $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
22 $nonce_action = 'add-bookmark';
26 * Display checked checkboxes attribute for xfn microformat options.
30 * @param string $class
31 * @param string $value
32 * @param mixed $deprecated Not used.
34 function xfn_check($class, $value = '', $deprecated = '') {
37 $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
38 $rels = preg_split('/\s+/', $link_rel);
40 if ('' != $value && in_array($value, $rels) ) {
41 echo ' checked="checked"';
45 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"';
46 if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
47 if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
48 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
53 * Display link create form fields.
59 function link_submit_meta_box($link) {
61 <div class="submitbox" id="submitlink">
63 <div id="minor-publishing">
65 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
66 <div style="display:none;">
67 <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" />
70 <div id="minor-publishing-actions">
71 <div id="preview-action">
72 <?php if ( !empty($link->link_id) ) { ?>
73 <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank" tabindex="4"><?php _e('Visit Link'); ?></a>
76 <div class="clear"></div>
79 <div id="misc-publishing-actions">
80 <div class="misc-pub-section misc-pub-section-last">
81 <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>
87 <div id="major-publishing-actions">
88 <?php do_action('post_submitbox_start'); ?>
89 <div id="delete-action">
91 if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
92 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&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>
96 <div id="publishing-action">
97 <?php if ( !empty($link->link_id) ) { ?>
98 <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" />
100 <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />
103 <div class="clear"></div>
105 <?php do_action('submitlink_box'); ?>
106 <div class="clear"></div>
110 add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', 'link', 'side', 'core');
113 * Display link categories form fields.
117 * @param object $link
119 function link_categories_meta_box($link) { ?>
120 <ul id="category-tabs">
121 <li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
122 <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
125 <div id="categories-all" class="tabs-panel">
126 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
128 if ( isset($link->link_id) )
129 wp_link_category_checklist($link->link_id);
131 wp_link_category_checklist();
136 <div id="categories-pop" class="tabs-panel" style="display: none;">
137 <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
138 <?php wp_popular_terms_checklist('link_category'); ?>
142 <div id="category-adder" class="wp-hidden-children">
143 <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
144 <p id="link-category-add" class="wp-hidden-child">
145 <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
146 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />
147 <input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php esc_attr_e( 'Add' ); ?>" />
148 <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
149 <span id="category-ajax-response"></span>
154 add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', 'link', 'normal', 'core');
157 * Display form fields for changing link target.
161 * @param object $link
163 function link_target_meta_box($link) { ?>
164 <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>
165 <p><label for="link_target_blank" class="selectit">
166 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
167 <?php _e('<code>_blank</code> - new window or tab.'); ?></label></p>
168 <p><label for="link_target_top" class="selectit">
169 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
170 <?php _e('<code>_top</code> - current window or tab, with no frames.'); ?></label></p>
171 <p><label for="link_target_none" class="selectit">
172 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
173 <?php _e('<code>_none</code> - same window or tab.'); ?></label></p>
175 <p><?php _e('Choose the target frame for your link.'); ?></p>
178 add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', 'link', 'normal', 'core');
181 * Display xfn form fields.
185 * @param object $link
187 function link_xfn_meta_box($link) {
189 <table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
191 <th style="width: 20%;" scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
192 <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>
196 <table cellpadding="3" cellspacing="5" class="form-table">
198 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </th>
199 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </span></legend>
201 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
202 <?php _e('another web address of mine') ?></label>
206 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </th>
207 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </span></legend>
208 <label for="contact">
209 <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>
210 <label for="acquaintance">
211 <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>
213 <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>
214 <label for="friendship">
215 <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>
219 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th>
220 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </span></legend>
222 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
223 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?></label>
227 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th>
228 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </span></legend>
229 <label for="co-worker">
230 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
231 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?></label>
232 <label for="colleague">
233 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
234 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?></label>
238 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </th>
239 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend>
240 <label for="co-resident">
241 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
242 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?></label>
243 <label for="neighbor">
244 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
245 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?></label>
246 <label for="geographical">
247 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
248 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
252 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </th>
253 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend>
255 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
256 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?></label>
258 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> />
259 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?></label>
261 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
262 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?></label>
263 <label for="sibling">
264 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
265 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?></label>
267 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
268 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?></label>
270 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
271 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
275 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </th>
276 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend>
278 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
279 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?></label>
281 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
282 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?></label>
284 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
285 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?></label>
286 <label for="romantic">
287 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
288 <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?></label>
295 <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>
298 add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', 'link', 'normal', 'core');
301 * Display advanced link options form fields.
305 * @param object $link
307 function link_advanced_meta_box($link) {
309 <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
310 <tr class="form-field">
311 <th valign="top" scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
312 <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>
314 <tr class="form-field">
315 <th valign="top" scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
316 <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>
318 <tr class="form-field">
319 <th valign="top" scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
320 <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>
322 <tr class="form-field">
323 <th valign="top" scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
324 <td><select name="link_rating" id="link_rating" size="1">
326 for ($r = 0; $r < 10; $r++) {
327 echo(' <option value="'. esc_attr($r) .'" ');
328 if ( isset($link->link_rating) && $link->link_rating == $r)
329 echo 'selected="selected"';
330 echo('>'.$r.'</option>');
332 ?></select> <?php _e('(Leave at 0 for no rating.)') ?>
338 add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core');
340 do_action('do_meta_boxes', 'link', 'normal', $link);
341 do_action('do_meta_boxes', 'link', 'advanced', $link);
342 do_action('do_meta_boxes', 'link', 'side', $link);
344 require_once ('admin-header.php');
348 <?php screen_icon(); ?>
349 <h2><?php echo esc_html( $title ); ?></h2>
351 <?php if ( isset( $_GET['added'] ) ) : ?>
352 <div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
358 if ( !empty($link_added) )
361 wp_nonce_field( $nonce_action );
362 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
363 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
365 <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
367 <div id="side-info-column" class="inner-sidebar">
370 do_action('submitlink_box');
371 $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
377 <div id="post-body-content">
378 <div id="namediv" class="stuffbox">
379 <h3><label for="link_name"><?php _e('Name') ?></label></h3>
381 <input type="text" name="link_name" size="30" tabindex="1" value="<?php echo esc_attr($link->link_name); ?>" id="link_name" />
382 <p><?php _e('Example: Nifty blogging software'); ?></p>
386 <div id="addressdiv" class="stuffbox">
387 <h3><label for="link_url"><?php _e('Web Address') ?></label></h3>
389 <input type="text" name="link_url" size="30" class="code" tabindex="1" value="<?php echo esc_attr($link->link_url); ?>" id="link_url" />
390 <p><?php _e('Example: <code>http://wordpress.org/</code> — don’t forget the <code>http://</code>'); ?></p>
394 <div id="descriptiondiv" class="stuffbox">
395 <h3><label for="link_description"><?php _e('Description') ?></label></h3>
397 <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" />
398 <p><?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?></p>
404 do_meta_boxes('link', 'normal', $link);
406 do_meta_boxes('link', 'advanced', $link);
409 <input type="hidden" name="action" value="save" />
410 <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
411 <input type="hidden" name="order_by" value="<?php echo esc_attr($order_by); ?>" />
412 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
414 <input type="hidden" name="action" value="add" />