3 * Edit links form for inclusion in administration panels.
6 * @subpackage Administration
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;
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';
22 * Display checked checkboxes attribute for xfn microformat options.
26 * @param string $class
27 * @param string $value
28 * @param mixed $deprecated Not used.
30 function xfn_check($class, $value = '', $deprecated = '') {
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);
36 if ('' != $value && in_array($value, $rels) ) {
37 echo ' checked="checked"';
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"';
49 * Display link create form fields.
55 function link_submit_meta_box($link) {
57 <div class="submitbox" id="submitlink">
59 <div id="minor-publishing">
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'); ?>" />
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>
72 <div class="clear"></div>
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>
83 <div id="major-publishing-actions">
84 <?php do_action('post_submitbox_start'); ?>
85 <div id="delete-action">
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&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>
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') ?>" />
96 <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />
99 <div class="clear"></div>
101 <?php do_action('submitlink_box'); ?>
102 <div class="clear"></div>
106 add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', 'link', 'side', 'core');
109 * Display link categories form fields.
113 * @param object $link
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>
121 <div id="categories-all" class="tabs-panel">
122 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
124 if ( isset($link->link_id) )
125 wp_link_category_checklist($link->link_id);
127 wp_link_category_checklist();
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'); ?>
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>
150 add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', 'link', 'normal', 'core');
153 * Display form fields for changing link target.
157 * @param object $link
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>
171 <p><?php _e('Choose the target frame for your link.'); ?></p>
174 add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', 'link', 'normal', 'core');
177 * Display xfn form fields.
181 * @param object $link
183 function link_xfn_meta_box($link) {
185 <table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
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>
192 <table cellpadding="3" cellspacing="5" class="form-table">
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>
197 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
198 <?php _e('another web address of mine') ?></label>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
294 add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', 'link', 'normal', 'core');
297 * Display advanced link options form fields.
301 * @param object $link
303 function link_advanced_meta_box($link) {
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>
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>
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>
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">
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>');
328 ?></select> <?php _e('(Leave at 0 for no rating.)') ?>
334 add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core');
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);
340 require_once ('admin-header.php');
344 <?php screen_icon(); ?>
345 <h2><?php echo esc_html( $title ); ?></h2>
347 <?php if ( isset( $_GET['added'] ) ) : ?>
348 <div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
354 if ( !empty($link_added) )
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 ); ?>
361 <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
363 <div id="side-info-column" class="inner-sidebar">
366 do_action('submitlink_box');
367 $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
373 <div id="post-body-content">
374 <div id="namediv" class="stuffbox">
375 <h3><label for="link_name"><?php _e('Name') ?></label></h3>
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>
382 <div id="addressdiv" class="stuffbox">
383 <h3><label for="link_url"><?php _e('Web Address') ?></label></h3>
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> — don’t forget the <code>http://</code>'); ?></p>
390 <div id="descriptiondiv" class="stuffbox">
391 <h3><label for="link_description"><?php _e('Description') ?></label></h3>
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>
400 do_meta_boxes('link', 'normal', $link);
402 do_meta_boxes('link', 'advanced', $link);
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 ?>" />
410 <input type="hidden" name="action" value="add" />