3 require_once ('admin.php');
6 if ( isset($_GET['deleteit']) && isset($_GET['linkcheck']) ) {
7 check_admin_referer('bulk-bookmarks');
9 if ( ! current_user_can('manage_links') )
10 wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
12 foreach ( (array) $_GET['linkcheck'] as $link_id) {
13 $link_id = (int) $link_id;
15 wp_delete_link($link_id);
18 $sendback = wp_get_referer();
19 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
20 wp_redirect($sendback);
22 } elseif ( !empty($_GET['_wp_http_referer']) ) {
23 wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
27 wp_enqueue_script('admin-forms');
29 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[]'));
34 if (empty ($order_by))
35 $order_by = 'order_name';
37 $title = __('Manage Links');
38 $this_file = $parent_file = 'edit.php';
39 include_once ("./admin-header.php");
41 if (!current_user_can('manage_links'))
42 wp_die(__("You do not have sufficient permissions to edit the links for this blog."));
52 $sqlorderby = 'description';
55 $sqlorderby = 'owner';
58 $sqlorderby = 'rating';
66 if ( isset($_GET['deleted']) ) {
67 echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
68 $deleted = (int) $_GET['deleted'];
69 printf(__ngettext('%s link deleted.', '%s links deleted', $deleted), $deleted);
71 $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
77 <form id="posts-filter" action="" method="get">
78 <h2><?php printf( __( 'Manage Links (<a href="%s">add new</a>)' ), 'link-add.php' ); ?></h2>
81 <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
82 <input type="submit" value="<?php _e( 'Search Links' ); ?>" class="button" />
87 <div class="tablenav">
89 <div class="alignleft">
90 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
92 $categories = get_terms('link_category', "hide_empty=1");
93 $select_cat = "<select name=\"cat_id\">\n";
94 $select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('View all Categories') . "</option>\n";
95 foreach ((array) $categories as $cat)
96 $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";
97 $select_cat .= "</select>\n";
99 $select_order = "<select name=\"order_by\">\n";
100 $select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Order by Link ID') . "</option>\n";
101 $select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Order by Name') . "</option>\n";
102 $select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Order by Address') . "</option>\n";
103 $select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Order by Rating') . "</option>\n";
104 $select_order .= "</select>\n";
110 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
120 $link_columns = array(
121 'name' => '<th style="width: 15%;">' . __('Name') . '</th>',
122 'url' => '<th>' . __('URL') . '</th>',
123 'categories' => '<th>' . __('Categories') . '</th>',
124 'rel' => '<th style="text-align: center">' . __('rel') . '</th>',
125 'visible' => '<th style="text-align: center">' . __('Visible') . '</th>',
127 $link_columns = apply_filters('manage_link_columns', $link_columns);
131 if ( 'all' == $cat_id )
133 $args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0);
134 if ( !empty($_GET['s']) )
135 $args['search'] = $_GET['s'];
136 $links = get_bookmarks( $args );
140 <?php wp_nonce_field('bulk-bookmarks') ?>
141 <table class="widefat">
144 <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
145 <?php foreach($link_columns as $column_display_name) {
146 echo $column_display_name;
152 foreach ($links as $link) {
153 $link = sanitize_bookmark($link);
154 $link->link_name = attribute_escape($link->link_name);
155 $link->link_category = wp_get_link_cats($link->link_id);
156 $short_url = str_replace('http://', '', $link->link_url);
157 $short_url = str_replace('www.', '', $short_url);
158 if ('/' == substr($short_url, -1))
159 $short_url = substr($short_url, 0, -1);
160 if (strlen($short_url) > 35)
161 $short_url = substr($short_url, 0, 32).'...';
163 $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
165 $style = ($i % 2) ? '' : ' class="alternate"';
166 ?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
167 echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
168 foreach($link_columns as $column_name=>$column_display_name) {
169 switch($column_name) {
172 echo "<td><strong><a class='row-title' href='link.php?link_id=$link->link_id&action=edit' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "' class='edit'>$link->link_name</a></strong><br />";
173 echo $link->link_description . "</td>";
176 echo "<td><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
180 $cat_names = array();
181 foreach ($link->link_category as $category) {
182 $cat = get_term($category, 'link_category', OBJECT, 'display');
183 if ( is_wp_error( $cat ) )
184 echo $cat->get_error_message();
185 $cat_name = $cat->name;
186 if ( $cat_id != $category )
187 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
188 $cat_names[] = $cat_name;
190 echo implode(', ', $cat_names);
194 ?><td><?php echo $link->link_rel; ?></td><?php
197 ?><td style='text-align: center;'><?php echo $visible; ?></td><?php
201 <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
214 <p><?php _e('No links found.') ?></p>
218 <div id="ajax-response"></div>
220 <div class="tablenav">
227 <?php include('admin-footer.php'); ?>