| [ XREF Home ] [ Index ] |
PHP Cross Reference of WordPress TrunkProvided by Yoast |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Links Manager List Table class. 4 * 5 * @package WordPress 6 * @subpackage List_Table 7 * @since 3.1.0 8 * @access private 9 */ 10 class WP_Links_List_Table extends WP_List_Table { 11 12 function __construct() { 13 parent::__construct( array( 14 'plural' => 'bookmarks', 15 ) ); 16 } 17 18 function ajax_user_can() { 19 return current_user_can( 'manage_links' ); 20 } 21 22 function prepare_items() { 23 global $cat_id, $s, $orderby, $order; 24 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' ) ); 26 27 $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); 28 29 if ( 'all' != $cat_id ) 30 $args['category'] = $cat_id; 31 if ( !empty( $s ) ) 32 $args['search'] = $s; 33 if ( !empty( $orderby ) ) 34 $args['orderby'] = $orderby; 35 if ( !empty( $order ) ) 36 $args['order'] = $order; 37 38 $this->items = get_bookmarks( $args ); 39 } 40 41 function no_items() { 42 _e( 'No links found.' ); 43 } 44 45 function get_bulk_actions() { 46 $actions = array(); 47 $actions['delete'] = __( 'Delete' ); 48 49 return $actions; 50 } 51 52 function extra_tablenav( $which ) { 53 global $cat_id; 54 55 if ( 'top' != $which ) 56 return; 57 ?> 58 <div class="alignleft actions"> 59 <?php 60 $dropdown_options = array( 61 'selected' => $cat_id, 62 'name' => 'cat_id', 63 'taxonomy' => 'link_category', 64 'show_option_all' => __( 'View all categories' ), 65 'hide_empty' => true, 66 'hierarchical' => 1, 67 'show_count' => 0, 68 'orderby' => 'name', 69 ); 70 wp_dropdown_categories( $dropdown_options ); 71 submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); 72 ?> 73 </div> 74 <?php 75 } 76 77 function get_columns() { 78 return array( 79 'cb' => '<input type="checkbox" />', 80 'name' => __( 'Name' ), 81 'url' => __( 'URL' ), 82 'categories' => __( 'Categories' ), 83 'rel' => __( 'Relationship' ), 84 'visible' => __( 'Visible' ), 85 'rating' => __( 'Rating' ) 86 ); 87 } 88 89 function get_sortable_columns() { 90 return array( 91 'name' => 'name', 92 'url' => 'url', 93 'visible' => 'visible', 94 'rating' => 'rating' 95 ); 96 } 97 98 function display_rows() { 99 global $cat_id; 100 101 $alt = 0; 102 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 ); 107 108 $short_url = url_shorten( $link->link_url ); 109 110 $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' ); 111 $rating = $link->link_rating; 112 $style = ( $alt++ % 2 ) ? '' : ' class="alternate"'; 113 114 $edit_link = get_edit_bookmark_link( $link ); 115 ?> 116 <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>> 117 <?php 118 119 list( $columns, $hidden ) = $this->get_column_info(); 120 121 foreach ( $columns as $column_name => $column_display_name ) { 122 $class = "class='column-$column_name'"; 123 124 $style = ''; 125 if ( in_array( $column_name, $hidden ) ) 126 $style = ' style="display:none;"'; 127 128 $attributes = $class . $style; 129 130 switch ( $column_name ) { 131 case 'cb': 132 echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'. esc_attr( $link->link_id ) .'" /></th>'; 133 break; 134 135 case 'name': 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 />"; 137 138 $actions = array(); 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 ); 142 143 echo '</td>'; 144 break; 145 case 'url': 146 echo "<td $attributes><a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a></td>"; 147 break; 148 case 'categories': 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; 159 } 160 echo implode( ', ', $cat_names ); 161 ?></td><?php 162 break; 163 case 'rel': 164 ?><td <?php echo $attributes ?>><?php echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; ?></td><?php 165 break; 166 case 'visible': 167 ?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php 168 break; 169 case 'rating': 170 ?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php 171 break; 172 default: 173 ?> 174 <td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td> 175 <?php 176 break; 177 } 178 } 179 ?> 180 </tr> 181 <?php 182 } 183 } 184 } 185 186 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jun 1 08:30:02 2011 |
Cross-referenced by PHPXref 0.7 Provided by Yoast and awesome WordPress Hosting |