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 <label class="hidden" for="post-search-input"><?php _e( 'Search Links' ); ?>:</label>
82 <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
83 <input type="submit" value="<?php _e( 'Search Links' ); ?>" class="button" />
88 <div class="tablenav">
90 <div class="alignleft">
91 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
93 $categories = get_terms('link_category', "hide_empty=1");
94 $select_cat = "<select name=\"cat_id\">\n";
95 $select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('View all Categories') . "</option>\n";
96 foreach ((array) $categories as $cat)
97 $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";
98 $select_cat .= "</select>\n";
100 $select_order = "<select name=\"order_by\">\n";
101 $select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Order by Link ID') . "</option>\n";
102 $select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Order by Name') . "</option>\n";
103 $select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Order by Address') . "</option>\n";
104 $select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Order by Rating') . "</option>\n";
105 $select_order .= "</select>\n";
111 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
121 $link_columns = array(
122 'name' => '<th style="width: 15%;">' . __('Name') . '</th>',
123 'url' => '<th>' . __('URL') . '</th>',
124 'categories' => '<th>' . __('Categories') . '</th>',
125 'rel' => '<th style="text-align: center">' . __('rel') . '</th>',
126 'visible' => '<th style="text-align: center">' . __('Visible') . '</th>',
128 $link_columns = apply_filters('manage_link_columns', $link_columns);
132 if ( 'all' == $cat_id )
134 $args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0);
135 if ( !empty($_GET['s']) )
136 $args['search'] = $_GET['s'];
137 $links = get_bookmarks( $args );
141 <?php wp_nonce_field('bulk-bookmarks') ?>
142 <table class="widefat">
145 <th scope="col" class="check-column"><input type="checkbox" /></th>
146 <?php foreach($link_columns as $column_display_name) {
147 echo $column_display_name;
153 foreach ($links as $link) {
154 $link = sanitize_bookmark($link);
155 $link->link_name = attribute_escape($link->link_name);
156 $link->link_category = wp_get_link_cats($link->link_id);
157 $short_url = str_replace('http://', '', $link->link_url);
158 $short_url = str_replace('www.', '', $short_url);
159 if ('/' == substr($short_url, -1))
160 $short_url = substr($short_url, 0, -1);
161 if (strlen($short_url) > 35)
162 $short_url = substr($short_url, 0, 32).'...';
164 $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
166 $style = ($i % 2) ? '' : ' class="alternate"';
167 ?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
168 echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
169 foreach($link_columns as $column_name=>$column_display_name) {
170 switch($column_name) {
173 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 />";
174 echo $link->link_description . "</td>";
177 echo "<td><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
181 $cat_names = array();
182 foreach ($link->link_category as $category) {
183 $cat = get_term($category, 'link_category', OBJECT, 'display');
184 if ( is_wp_error( $cat ) )
185 echo $cat->get_error_message();
186 $cat_name = $cat->name;
187 if ( $cat_id != $category )
188 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
189 $cat_names[] = $cat_name;
191 echo implode(', ', $cat_names);
195 ?><td><?php echo $link->link_rel; ?></td><?php
198 ?><td style='text-align: center;'><?php echo $visible; ?></td><?php
202 <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
215 <p><?php _e('No links found.') ?></p>
219 <div id="ajax-response"></div>
221 <div class="tablenav">
228 <?php include('admin-footer.php'); ?>