9
9
/** Load WordPress Administration Bootstrap */
10
10
require_once ('admin.php');
11
if ( ! current_user_can( 'manage_links' ) )
12
wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );
14
$wp_list_table = _get_list_table('WP_Links_List_Table');
12
16
// Handle bulk deletes
13
if ( isset($_GET['action']) && isset($_GET['linkcheck']) ) {
14
check_admin_referer('bulk-bookmarks');
15
$doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
17
$doaction = $wp_list_table->current_action();
17
if ( ! current_user_can('manage_links') )
18
wp_die( __('You do not have sufficient permissions to edit the links for this site.') );
19
if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {
20
check_admin_referer( 'bulk-bookmarks' );
20
22
if ( 'delete' == $doaction ) {
21
$bulklinks = (array) $_GET['linkcheck'];
23
$bulklinks = (array) $_REQUEST['linkcheck'];
22
24
foreach ( $bulklinks as $link_id ) {
23
25
$link_id = (int) $link_id;
25
wp_delete_link($link_id);
27
wp_delete_link( $link_id );
28
wp_safe_redirect( wp_get_referer() );
30
wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) );
31
} elseif ( ! empty($_GET['_wp_http_referer']) ) {
32
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
33
} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
34
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
36
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[]'));
41
if ( empty($order_by) )
42
$order_by = 'order_name';
38
$wp_list_table->prepare_items();
44
40
$title = __('Links');
45
41
$this_file = $parent_file = 'link-manager.php';
59
55
if ( ! current_user_can('manage_links') )
60
56
wp_die(__("You do not have sufficient permissions to edit the links for this site."));
70
$sqlorderby = 'description';
73
$sqlorderby = 'owner';
76
$sqlorderby = 'rating';
84
60
<div class="wrap nosubsub">
85
61
<?php screen_icon(); ?>
86
62
<h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php
87
if ( !empty($_GET['s']) )
88
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?>
63
if ( !empty($_REQUEST['s']) )
64
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
92
if ( isset($_GET['deleted']) ) {
68
if ( isset($_REQUEST['deleted']) ) {
93
69
echo '<div id="message" class="updated"><p>';
94
$deleted = (int) $_GET['deleted'];
70
$deleted = (int) $_REQUEST['deleted'];
95
71
printf(_n('%s link deleted.', '%s links deleted', $deleted), $deleted);
97
73
$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
101
<form class="search-form" action="" method="get">
102
<p class="search-box">
103
<label class="screen-reader-text" for="link-search-input"><?php _e( 'Search Links' ); ?>:</label>
104
<input type="text" id="link-search-input" name="s" value="<?php _admin_search_query(); ?>" />
105
<input type="submit" value="<?php esc_attr_e( 'Search Links' ); ?>" class="button" />
110
77
<form id="posts-filter" action="" method="get">
111
<div class="tablenav">
114
if ( 'all' == $cat_id )
116
$args = array( 'category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0 );
117
if ( ! empty( $_GET['s'] ) )
118
$args['search'] = $_GET['s'];
119
$links = get_bookmarks( $args );
123
<div class="alignleft actions">
124
<select name="action">
125
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
126
<option value="delete"><?php _e('Delete'); ?></option>
128
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
131
$categories = get_terms('link_category', array("hide_empty" => 1));
132
$select_cat = "<select name=\"cat_id\">\n";
133
$select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('View all Categories') . "</option>\n";
134
foreach ((array) $categories as $cat)
135
$select_cat .= '<option value="' . esc_attr($cat->term_id) . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n";
136
$select_cat .= "</select>\n";
138
$select_order = "<select name=\"order_by\">\n";
139
$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Order by Link ID') . "</option>\n";
140
$select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Order by Name') . "</option>\n";
141
$select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Order by Address') . "</option>\n";
142
$select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Order by Rating') . "</option>\n";
143
$select_order .= "</select>\n";
149
<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
156
<div class="clear"></div>
159
$link_columns = get_column_headers('link-manager');
160
$hidden = get_hidden_columns('link-manager');
163
<?php wp_nonce_field('bulk-bookmarks') ?>
164
<table class="widefat fixed" cellspacing="0">
167
<?php print_column_headers('link-manager'); ?>
173
<?php print_column_headers('link-manager', false); ?>
181
foreach ($links as $link) {
182
$link = sanitize_bookmark($link);
183
$link->link_name = esc_attr($link->link_name);
184
$link->link_category = wp_get_link_cats($link->link_id);
185
$short_url = str_replace('http://', '', $link->link_url);
186
$short_url = preg_replace('/^www\./i', '', $short_url);
187
if ('/' == substr($short_url, -1))
188
$short_url = substr($short_url, 0, -1);
189
if (strlen($short_url) > 35)
190
$short_url = substr($short_url, 0, 32).'...';
191
$visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
192
$rating = $link->link_rating;
193
$style = ($alt % 2) ? '' : ' class="alternate"';
195
$edit_link = get_edit_bookmark_link();
196
?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
197
foreach($link_columns as $column_name=>$column_display_name) {
198
$class = "class=\"column-$column_name\"";
201
if ( in_array($column_name, $hidden) )
202
$style = ' style="display:none;"';
204
$attributes = "$class$style";
206
switch($column_name) {
208
echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'. esc_attr($link->link_id) .'" /></th>';
212
echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
214
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
215
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm('" . 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;\">" . __('Delete') . "</a>";
216
$action_count = count($actions);
218
echo '<div class="row-actions">';
219
foreach ( $actions as $action => $linkaction ) {
221
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
222
echo "<span class='$action'>$linkaction$sep</span>";
228
echo "<td $attributes><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
231
?><td <?php echo $attributes ?>><?php
232
$cat_names = array();
233
foreach ($link->link_category as $category) {
234
$cat = get_term($category, 'link_category', OBJECT, 'display');
235
if ( is_wp_error( $cat ) )
236
echo $cat->get_error_message();
237
$cat_name = $cat->name;
238
if ( $cat_id != $category )
239
$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
240
$cat_names[] = $cat_name;
242
echo implode(', ', $cat_names);
246
?><td <?php echo $attributes ?>><?php echo empty($link->link_rel) ? '<br />' : $link->link_rel; ?></td><?php
249
?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
252
?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php
256
<td <?php echo $attributes ?>><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
268
<div class="tablenav">
270
<div class="alignleft actions">
271
<select name="action2">
272
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
273
<option value="delete"><?php _e('Delete'); ?></option>
275
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
279
<p><?php _e( 'No links found.' ) ?></p>
79
<?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>
81
<?php $wp_list_table->display(); ?>
287
83
<div id="ajax-response"></div>