- Timestamp:
- 06/13/2015 03:32:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-links-list-table.php
r32724 r32753 153 153 154 154 /** 155 * 156 * @global int $cat_id 157 */ 155 * @since 4.3.0 156 * 157 * @param object $link 158 */ 159 public function column_cb( $link ) { 160 ?> 161 <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label> 162 <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> 163 <?php 164 } 165 166 /** 167 * @since 4.3.0 168 * 169 * @param object $link 170 */ 171 public function column_name( $link ) { 172 $edit_link = get_edit_bookmark_link( $link ); 173 ?> 174 <strong><a class="row-title" href="<?php echo $edit_link ?>" title="<?php 175 echo esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ); 176 ?>"><?php echo $link->link_name ?></a></strong><br /> 177 <?php 178 } 179 180 /** 181 * @since 4.3.0 182 * 183 * @param object $link 184 */ 185 public function column_url( $link ) { 186 $short_url = url_shorten( $link->link_url ); 187 echo "<a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a>"; 188 } 189 190 /** 191 * @since 4.3.0 192 * 193 * @global $cat_id 194 * 195 * @param object $link 196 */ 197 public function column_categories( $link ) { 198 global $cat_id; 199 200 $cat_names = array(); 201 foreach ( $link->link_category as $category ) { 202 $cat = get_term( $category, 'link_category', OBJECT, 'display' ); 203 if ( is_wp_error( $cat ) ) { 204 echo $cat->get_error_message(); 205 } 206 $cat_name = $cat->name; 207 if ( $cat_id != $category ) { 208 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; 209 } 210 $cat_names[] = $cat_name; 211 } 212 echo implode( ', ', $cat_names ); 213 } 214 215 /** 216 * @since 4.3.0 217 * 218 * @param object $link 219 */ 220 public function column_rel( $link ) { 221 echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; 222 } 223 224 /** 225 * @since 4.3.0 226 * 227 * @param object $link 228 */ 229 public function column_visible( $link ) { 230 if ( 'Y' === $link->link_visible ) { 231 _e( 'Yes' ); 232 } else { 233 _e( 'No' ); 234 } 235 } 236 237 /** 238 * @since 4.3.0 239 * 240 * @param object $link 241 */ 242 public function column_rating( $link ) { 243 echo $link->link_rating; 244 } 245 246 /** 247 * @since 4.3.0 248 * 249 * @param object $link 250 * @param string $column_name 251 */ 252 public function column_default( $link, $column_name ) { 253 /** 254 * Fires for each registered custom link column. 255 * 256 * @since 2.1.0 257 * 258 * @param string $column_name Name of the custom column. 259 * @param int $link_id Link ID. 260 */ 261 do_action( 'manage_link_custom_column', $column_name, $link->link_id ); 262 } 263 158 264 public function display_rows() { 159 global $cat_id;160 161 265 foreach ( $this->items as $link ) { 162 266 $link = sanitize_bookmark( $link ); 163 267 $link->link_name = esc_attr( $link->link_name ); 164 268 $link->link_category = wp_get_link_cats( $link->link_id ); 165 166 $short_url = url_shorten( $link->link_url );167 168 $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' );169 $rating = $link->link_rating;170 171 $edit_link = get_edit_bookmark_link( $link );172 269 ?> 173 270 <tr id="link-<?php echo $link->link_id; ?>"> 174 <?php 175 176 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 177 178 foreach ( $columns as $column_name => $column_display_name ) { 179 $classes = "$column_name column-$column_name"; 180 if ( $primary === $column_name ) { 181 $classes .= ' has-row-actions column-primary'; 182 } 183 184 if ( in_array( $column_name, $hidden ) ) { 185 $classes .= ' hidden'; 186 } 187 188 $attributes = "class='$classes'"; 189 190 if ( 'cb' === $column_name ) { 191 ?> 192 <th scope="row" class="check-column"> 193 <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label> 194 <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> 195 </th> 196 <?php 197 } else { 198 echo "<td $attributes>"; 199 200 switch ( $column_name ) { 201 case 'name': 202 echo "<strong><a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ) . "'>$link->link_name</a></strong><br />"; 203 break; 204 case 'url': 205 echo "<a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a>"; 206 break; 207 case 'categories': 208 $cat_names = array(); 209 foreach ( $link->link_category as $category ) { 210 $cat = get_term( $category, 'link_category', OBJECT, 'display' ); 211 if ( is_wp_error( $cat ) ) 212 echo $cat->get_error_message(); 213 $cat_name = $cat->name; 214 if ( $cat_id != $category ) 215 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; 216 $cat_names[] = $cat_name; 217 } 218 echo implode( ', ', $cat_names ); 219 break; 220 case 'rel': 221 echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; 222 break; 223 case 'visible': 224 echo $visible; 225 break; 226 case 'rating': 227 echo $rating; 228 break; 229 default: 230 /** 231 * Fires for each registered custom link column. 232 * 233 * @since 2.1.0 234 * 235 * @param string $column_name Name of the custom column. 236 * @param int $link_id Link ID. 237 */ 238 do_action( 'manage_link_custom_column', $column_name, $link->link_id ); 239 break; 240 } 241 242 echo $this->handle_row_actions( $link, $column_name, $primary ); 243 echo '</td>'; 244 } 245 } 246 ?> 271 <?php $this->single_row_columns( $link ) ?> 247 272 </tr> 248 273 <?php
Note: See TracChangeset
for help on using the changeset viewer.