PHP Cross Reference of WordPress Subversion HEAD |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 // Links 5 // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com 6 7 require_once ('admin.php'); 8 9 wp_enqueue_script( 'wp-lists' ); 10 11 wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]')); 12 13 if (empty ($cat_id)) 14 $cat_id = 'all'; 15 16 if (empty ($order_by)) 17 $order_by = 'order_name'; 18 19 $title = __('Manage Blogroll'); 20 $this_file = $parent_file = 'link-manager.php'; 21 include_once ("./admin-header.php"); 22 23 if (!current_user_can('manage_links')) 24 wp_die(__("You do not have sufficient permissions to edit the links for this blog.")); 25 26 switch ($order_by) { 27 case 'order_id' : 28 $sqlorderby = 'id'; 29 break; 30 case 'order_url' : 31 $sqlorderby = 'url'; 32 break; 33 case 'order_desc' : 34 $sqlorderby = 'description'; 35 break; 36 case 'order_owner' : 37 $sqlorderby = 'owner'; 38 break; 39 case 'order_rating' : 40 $sqlorderby = 'rating'; 41 break; 42 case 'order_name' : 43 default : 44 $sqlorderby = 'name'; 45 break; 46 } 47 ?> 48 <script type="text/javascript"> 49 /* <![CDATA[ */ 50 function checkAll(form) 51 { 52 for (i = 0, n = form.elements.length; i < n; i++) { 53 if(form.elements[i].type == "checkbox") { 54 if(form.elements[i].checked == true) 55 form.elements[i].checked = false; 56 else 57 form.elements[i].checked = true; 58 } 59 } 60 } 61 62 jQuery(function($){$('#the-list').wpList();}); 63 64 /* ]]> */ 65 </script> 66 67 <?php 68 if ( isset($_GET['deleted']) ) { 69 echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>'; 70 $deleted = (int) $_GET['deleted']; 71 printf(__ngettext('%s link deleted.', '%s links deleted', $deleted), $deleted); 72 echo '</p></div>'; 73 } 74 ?> 75 76 <div class="wrap"> 77 78 <h2><?php _e('Blogroll Management'); ?></h2> 79 <p><?php _e('Here you <a href="link-add.php">add links</a> to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it’s called a “blogroll.”'); ?></p> 80 <form id="cats" method="get" action=""> 81 <p><?php 82 $categories = get_terms('link_category', "hide_empty=1"); 83 $select_cat = "<select name=\"cat_id\">\n"; 84 $select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('All') . "</option>\n"; 85 foreach ((array) $categories as $cat) 86 $select_cat .= '<option value="' . $cat->term_id . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n"; 87 $select_cat .= "</select>\n"; 88 89 $select_order = "<select name=\"order_by\">\n"; 90 $select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Link ID') . "</option>\n"; 91 $select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Name') . "</option>\n"; 92 $select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Address') . "</option>\n"; 93 $select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Rating') . "</option>\n"; 94 $select_order .= "</select>\n"; 95 96 printf(__('Currently showing %1$s links ordered by %2$s'), $select_cat, $select_order); 97 ?> 98 <input type="submit" name="action" value="<?php _e('Update »') ?>" /></p> 99 </form> 100 <?php 101 $link_columns = array( 102 'name' => '<th width="15%">' . __('Name') . '</th>', 103 'url' => '<th>' . __('URL') . '</th>', 104 'categories' => '<th>' . __('Categories') . '</th>', 105 'rel' => '<th style="text-align: center">' . __('rel') . '</th>', 106 'visible' => '<th style="text-align: center">' . __('Visible') . '</th>', 107 'action' => '<th colspan="2" style="text-align: center">' . __('Action') . '</th>', 108 ); 109 $link_columns = apply_filters('manage_link_columns', $link_columns); 110 ?> 111 112 <?php 113 if ( 'all' == $cat_id ) 114 $cat_id = ''; 115 $links = get_bookmarks( "category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0" ); 116 if ( $links ) { 117 ?> 118 119 <form id="links" method="post" action="link.php"> 120 <?php wp_nonce_field('bulk-bookmarks') ?> 121 <input type="hidden" name="link_id" value="" /> 122 <input type="hidden" name="action" value="" /> 123 <input type="hidden" name="order_by" value="<?php echo attribute_escape($order_by); ?>" /> 124 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 125 <table class="widefat"> 126 <thead> 127 <tr> 128 <?php foreach($link_columns as $column_display_name) { 129 echo $column_display_name; 130 } ?> 131 <th style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th> 132 </tr> 133 </thead> 134 <tbody id="the-list" class="list:link"> 135 <?php 136 foreach ($links as $link) { 137 $link = sanitize_bookmark($link); 138 $link->link_name = attribute_escape($link->link_name); 139 $link->link_category = wp_get_link_cats($link->link_id); 140 $short_url = str_replace('http://', '', $link->link_url); 141 $short_url = str_replace('www.', '', $short_url); 142 if ('/' == substr($short_url, -1)) 143 $short_url = substr($short_url, 0, -1); 144 if (strlen($short_url) > 35) 145 $short_url = substr($short_url, 0, 32).'...'; 146 147 $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No'); 148 ++ $i; 149 $style = ($i % 2) ? '' : ' class="alternate"'; 150 ?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php 151 foreach($link_columns as $column_name=>$column_display_name) { 152 switch($column_name) { 153 case 'name': 154 ?><td><strong><?php echo $link->link_name; ?></strong><br /><?php 155 echo $link->link_description . "</td>"; 156 break; 157 case 'url': 158 echo "<td><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>"; 159 break; 160 case 'categories': 161 ?><td><?php 162 $cat_names = array(); 163 foreach ($link->link_category as $category) { 164 $cat = get_term($category, 'link_category', OBJECT, 'display'); 165 if ( is_wp_error( $cat ) ) 166 echo $cat->get_error_message(); 167 $cat_name = $cat->name; 168 if ( $cat_id != $category ) 169 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; 170 $cat_names[] = $cat_name; 171 } 172 echo implode(', ', $cat_names); 173 ?> </td><?php 174 break; 175 case 'rel': 176 ?><td><?php echo $link->link_rel; ?></td><?php 177 break; 178 case 'visible': 179 ?><td align='center'><?php echo $visible; ?></td><?php 180 break; 181 case 'action': 182 echo "<td><a href='link.php?link_id=$link->link_id&action=edit' class='edit'>" . __('Edit') . '</a></td>'; 183 echo "<td><a href='" . wp_nonce_url('link.php?link_id='.$link->link_id.'&action=delete', 'delete-bookmark_' . $link->link_id ) . "' class='delete:the-list:link-$link->link_id delete'>" . __('Delete') . '</a></td>'; 184 break; 185 default: 186 ?> 187 <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td> 188 <?php 189 break; 190 191 } 192 } 193 echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>'; 194 echo "\n </tr>\n"; 195 } 196 ?> 197 </tbody> 198 </table> 199 200 <div id="ajax-response"></div> 201 202 <p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Links »') ?>" onclick="return confirm('<?php echo js_escape(__("You are about to delete these links permanently.\n'Cancel' to stop, 'OK' to delete.")); ?>')" /></p> 203 </form> 204 205 <?php } ?> 206 207 </div> 208 209 <?php include ('admin-footer.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |