Projects : mp-wp : mp-wp_genesis
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 echo attribute_escape( __('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&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo 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;"><?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 _e('Update Link') ?>" /> |
95 | <?php } else { ?> |
96 | <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php _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 | <div id="category-adder" class="wp-hidden-children"> |
117 | <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4> |
118 | <p id="link-category-add" class="wp-hidden-child"> |
119 | <label class="hidden" for="newcat"><?php _e( '+ Add New Category' ); ?></label> |
120 | <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" aria-required="true" /> |
121 | <input type="button" id="category-add-sumbit" class="add:categorychecklist:linkcategorydiv button" value="<?php _e( 'Add' ); ?>" /> |
122 | <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?> |
123 | <span id="category-ajax-response"></span> |
124 | </p> |
125 | </div> |
126 | |
127 | <ul id="category-tabs"> |
128 | <li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li> |
129 | <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li> |
130 | </ul> |
131 | |
132 | <div id="categories-all" class="ui-tabs-panel"> |
133 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
134 | <?php |
135 | if ( isset($link->link_id) ) |
136 | wp_link_category_checklist($link->link_id); |
137 | else |
138 | wp_link_category_checklist(); |
139 | ?> |
140 | </ul> |
141 | </div> |
142 | |
143 | <div id="categories-pop" class="ui-tabs-panel" style="display: none;"> |
144 | <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> |
145 | <?php wp_popular_terms_checklist('link_category'); ?> |
146 | </ul> |
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="hidden"><?php _e('Target') ?></legend> |
161 | <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 | <code>_blank</code></label><br /> |
164 | <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 | <code>_top</code></label><br /> |
167 | <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('none') ?></label> |
170 | </fieldset> |
171 | <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> |
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 _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 ) ? $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 _e('identity') ?> </th> |
195 | <td><fieldset><legend class="hidden"> <?php _e('identity') ?> </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 _e('friendship') ?> </th> |
203 | <td><fieldset><legend class="hidden"> <?php _e('friendship') ?> </legend> |
204 | <label for="contact"> |
205 | <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _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 _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 _e('friend') ?></label> |
210 | <label for="friendship"> |
211 | <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label> |
212 | </fieldset></td> |
213 | </tr> |
214 | <tr> |
215 | <th scope="row"> <?php _e('physical') ?> </th> |
216 | <td><fieldset><legend class="hidden"> <?php _e('physical') ?> </legend> |
217 | <label for="met"> |
218 | <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> |
219 | <?php _e('met') ?></label> |
220 | </fieldset></td> |
221 | </tr> |
222 | <tr> |
223 | <th scope="row"> <?php _e('professional') ?> </th> |
224 | <td><fieldset><legend class="hidden"> <?php _e('professional') ?> </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 _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 _e('colleague') ?></label> |
231 | </fieldset></td> |
232 | </tr> |
233 | <tr> |
234 | <th scope="row"> <?php _e('geographical') ?> </th> |
235 | <td><fieldset><legend class="hidden"> <?php _e('geographical') ?> </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 _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 _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 _e('none') ?></label> |
245 | </fieldset></td> |
246 | </tr> |
247 | <tr> |
248 | <th scope="row"> <?php _e('family') ?> </th> |
249 | <td><fieldset><legend class="hidden"> <?php _e('family') ?> </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 _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 _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 _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 _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 _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 _e('none') ?></label> |
268 | </fieldset></td> |
269 | </tr> |
270 | <tr> |
271 | <th scope="row"> <?php _e('romantic') ?> </th> |
272 | <td><fieldset><legend class="hidden"> <?php _e('romantic') ?> </legend> |
273 | <label for="muse"> |
274 | <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> |
275 | <?php _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 _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 _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 _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" id="link_image" size="50" value="<?php echo ( isset( $link->link_image ) ? $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" type="text" id="rss_uri" value="<?php echo ( isset( $link->link_rss ) ? $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="'.$r.'" '); |
324 | if ( isset($link->link_rating) && $link->link_rating == $r) |
325 | echo 'selected="selected"'; |
326 | echo('>'.$r.'</option>'); |
327 | } |
328 | ?></select> <?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 | |
344 | |
345 | <div class="wrap"> |
346 | <?php screen_icon(); ?> |
347 | <h2><?php echo wp_specialchars( $title ); ?></h2> |
348 | |
349 | <?php if ( isset( $_GET['added'] ) ) : ?> |
350 | <div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div> |
351 | <?php endif; ?> |
352 | |
353 | <?php |
354 | if ( !empty($form) ) |
355 | echo $form; |
356 | if ( !empty($link_added) ) |
357 | echo $link_added; |
358 | |
359 | wp_nonce_field( $nonce_action ); |
360 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
361 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
362 | |
363 | <div id="poststuff" class="metabox-holder"> |
364 | |
365 | <div id="side-info-column" class="inner-sidebar"> |
366 | <?php |
367 | |
368 | do_action('submitlink_box'); |
369 | $side_meta_boxes = do_meta_boxes( 'link', 'side', $link ); |
370 | |
371 | ?> |
372 | </div> |
373 | |
374 | <div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>"> |
375 | <div id="post-body-content" class="has-sidebar-content"> |
376 | <div id="namediv" class="stuffbox"> |
377 | <h3><label for="link_name"><?php _e('Name') ?></label></h3> |
378 | <div class="inside"> |
379 | <input type="text" name="link_name" size="30" tabindex="1" value="<?php echo $link->link_name; ?>" id="link_name" /> |
380 | <p><?php _e('Example: Nifty blogging software'); ?></p> |
381 | </div> |
382 | </div> |
383 | |
384 | <div id="addressdiv" class="stuffbox"> |
385 | <h3><label for="link_url"><?php _e('Web Address') ?></label></h3> |
386 | <div class="inside"> |
387 | <input type="text" name="link_url" size="30" tabindex="1" value="<?php echo $link->link_url; ?>" id="link_url" /> |
388 | <p><?php _e('Example: <code>http://wordpress.org/</code> — don’t forget the <code>http://</code>'); ?></p> |
389 | </div> |
390 | </div> |
391 | |
392 | <div id="descriptiondiv" class="stuffbox"> |
393 | <h3><label for="link_description"><?php _e('Description') ?></label></h3> |
394 | <div class="inside"> |
395 | <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo isset($link->link_description) ? $link->link_description : ''; ?>" id="link_description" /> |
396 | <p><?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?></p> |
397 | </div> |
398 | </div> |
399 | |
400 | <?php |
401 | |
402 | do_meta_boxes('link', 'normal', $link); |
403 | |
404 | do_meta_boxes('link', 'advanced', $link); |
405 | |
406 | if ( $link_id ) : ?> |
407 | <input type="hidden" name="action" value="save" /> |
408 | <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> |
409 | <input type="hidden" name="order_by" value="<?php echo attribute_escape($order_by); ?>" /> |
410 | <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> |
411 | <?php else: ?> |
412 | <input type="hidden" name="action" value="add" /> |
413 | <?php endif; ?> |
414 | |
415 | </div> |
416 | </div> |
417 | </div> |
418 | |
419 | </form> |
420 | </div> |