3
* Links Manager List Table class.
6
* @subpackage List_Table
10
class WP_Links_List_Table extends WP_List_Table {
12
function WP_Links_List_Table() {
13
parent::WP_List_Table( array(
14
'plural' => 'bookmarks',
18
function ajax_user_can() {
19
return current_user_can( 'manage_links' );
22
function prepare_items() {
23
global $cat_id, $s, $orderby, $order;
25
wp_reset_vars( array( 'action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'orderby', 'order', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]', 's' ) );
27
$args = array( 'hide_invisible' => 0, 'hide_empty' => 0 );
29
if ( 'all' != $cat_id )
30
$args['category'] = $cat_id;
33
if ( !empty( $orderby ) )
34
$args['orderby'] = $orderby;
35
if ( !empty( $order ) )
36
$args['order'] = $order;
38
$this->items = get_bookmarks( $args );
42
_e( 'No links found.' );
45
function get_bulk_actions() {
47
$actions['delete'] = __( 'Delete' );
52
function extra_tablenav( $which ) {
55
if ( 'top' != $which )
58
<div class="alignleft actions">
60
$dropdown_options = array(
61
'selected' => $cat_id,
63
'taxonomy' => 'link_category',
64
'show_option_all' => __( 'View all categories' ),
70
wp_dropdown_categories( $dropdown_options );
71
submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
77
function get_columns() {
79
'cb' => '<input type="checkbox" />',
80
'name' => __( 'Name' ),
82
'categories' => __( 'Categories' ),
83
'rel' => __( 'Relationship' ),
84
'visible' => __( 'Visible' ),
85
'rating' => __( 'Rating' )
89
function get_sortable_columns() {
93
'visible' => 'visible',
98
function display_rows() {
103
foreach ( $this->items as $link ) {
104
$link = sanitize_bookmark( $link );
105
$link->link_name = esc_attr( $link->link_name );
106
$link->link_category = wp_get_link_cats( $link->link_id );
108
$short_url = url_shorten( $link->link_url );
110
$visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' );
111
$rating = $link->link_rating;
112
$style = ( $alt++ % 2 ) ? '' : ' class="alternate"';
114
$edit_link = get_edit_bookmark_link( $link );
116
<tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
119
list( $columns, $hidden ) = $this->get_column_info();
121
foreach ( $columns as $column_name => $column_display_name ) {
122
$class = "class='column-$column_name'";
125
if ( in_array( $column_name, $hidden ) )
126
$style = ' style="display:none;"';
128
$attributes = $class . $style;
130
switch ( $column_name ) {
132
echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'. esc_attr( $link->link_id ) .'" /></th>';
136
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 />";
139
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
140
$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>";
141
echo $this->row_actions( $actions );
146
echo "<td $attributes><a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a></td>";
149
?><td <?php echo $attributes ?>><?php
150
$cat_names = array();
151
foreach ( $link->link_category as $category ) {
152
$cat = get_term( $category, 'link_category', OBJECT, 'display' );
153
if ( is_wp_error( $cat ) )
154
echo $cat->get_error_message();
155
$cat_name = $cat->name;
156
if ( $cat_id != $category )
157
$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
158
$cat_names[] = $cat_name;
160
echo implode( ', ', $cat_names );
164
?><td <?php echo $attributes ?>><?php echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; ?></td><?php
167
?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
170
?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php
174
<td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td>