- Timestamp:
- 05/29/2015 02:40:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php
r32642 r32644 247 247 $blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path']; 248 248 249 list( $columns, $hidden ) = $this->get_column_info();249 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 250 250 251 251 foreach ( $columns as $column_name => $column_display_name ) { 252 $classes = "$column_name column-$column_name"; 253 if ( $primary === $column_name ) { 254 $classes .= ' has-row-actions column-primary'; 255 } 256 252 257 $style = ''; 253 if ( in_array( $column_name, $hidden ) ) 258 if ( in_array( $column_name, $hidden ) ) { 254 259 $style = ' style="display:none;"'; 255 256 switch ( $column_name ) { 257 case 'cb': ?> 258 <th scope="row" class="check-column"> 259 <?php if ( ! is_main_site( $blog['blog_id'] ) ) : ?> 260 <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php printf( __( 'Select %s' ), $blogname ); ?></label> 261 <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" /> 262 <?php endif; ?> 263 </th> 264 <?php 265 break; 266 267 case 'id':?> 268 <th scope="row"> 269 <?php echo $blog['blog_id'] ?> 270 </th> 271 <?php 272 break; 273 274 case 'blogname': 275 echo "<td class='column-$column_name $column_name'$style>"; ?> 260 } 261 262 $attributes = "class='$classes'$style"; 263 264 if ( 'cb' === $column_name ) { 265 ?> 266 <th scope="row" class="check-column"> 267 <?php if ( ! is_main_site( $blog['blog_id'] ) ) : ?> 268 <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php printf( __( 'Select %s' ), $blogname ); ?></label> 269 <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" /> 270 <?php endif; ?> 271 </th> 272 <?php 273 } elseif ( 'id' === $column_name ) { 274 ?> 275 <th scope="row"> 276 <?php echo $blog['blog_id'] ?> 277 </th> 278 <?php 279 } else { 280 echo "<td $attributes>"; 281 282 switch ( $column_name ) { 283 case 'blogname': 284 ?> 276 285 <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> 277 286 <?php … … 282 291 restore_current_blog(); 283 292 } 284 285 // Preordered. 286 $actions = array( 287 'edit' => '', 'backend' => '', 288 'activate' => '', 'deactivate' => '', 289 'archive' => '', 'unarchive' => '', 290 'spam' => '', 'unspam' => '', 291 'delete' => '', 292 'visit' => '', 293 ); 294 295 $actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>'; 296 $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>'; 297 if ( get_current_site()->blog_id != $blog['blog_id'] ) { 298 if ( $blog['deleted'] == '1' ) { 299 $actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>'; 300 } else { 301 $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Deactivate' ) . '</a></span>'; 302 } 303 304 if ( $blog['archived'] == '1' ) { 305 $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Unarchive' ) . '</a></span>'; 306 } else { 307 $actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>'; 308 } 309 310 if ( $blog['spam'] == '1' ) { 311 $actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>'; 312 } else { 313 $actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>'; 314 } 315 316 if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { 317 $actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Delete' ) . '</a></span>'; 318 } 293 break; 294 295 case 'lastupdated': 296 echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); 297 break; 298 299 case 'registered': 300 if ( $blog['registered'] == '0000-00-00 00:00:00' ) { 301 echo '—'; 302 } else { 303 echo mysql2date( $date, $blog['registered'] ); 319 304 } 320 321 $actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>'; 322 323 /** 324 * Filter the action links displayed for each site in the Sites list table. 325 * 326 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by 327 * default for each site. The site's status determines whether to show the 328 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and 329 * 'Not Spam' or 'Spam' link for each site. 330 * 331 * @since 3.1.0 332 * 333 * @param array $actions An array of action links to be displayed. 334 * @param int $blog_id The site ID. 335 * @param string $blogname Site path, formatted depending on whether it is a sub-domain 336 * or subdirectory multisite install. 337 */ 338 $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); 339 echo $this->row_actions( $actions ); 340 ?> 341 </td> 342 <?php 343 break; 344 345 case 'lastupdated': 346 echo "<td class='$column_name column-$column_name'$style>"; 347 echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?> 348 </td> 349 <?php 350 break; 351 case 'registered': 352 echo "<td class='$column_name column-$column_name'$style>"; 353 if ( $blog['registered'] == '0000-00-00 00:00:00' ) 354 echo '—'; 355 else 356 echo mysql2date( $date, $blog['registered'] ); 357 ?> 358 </td> 359 <?php 360 break; 361 case 'users': 362 echo "<td class='$column_name column-$column_name'$style>"; 305 break; 306 307 case 'users': 363 308 $blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) ); 364 309 if ( is_array( $blogusers ) ) { … … 377 322 echo '<strong>' . $blogusers_warning . '</strong><br />'; 378 323 } 379 ?> 380 </td> 381 <?php 382 break; 383 384 case 'plugins': ?> 385 <?php if ( has_filter( 'wpmublogsaction' ) ) { 386 echo "<td class='$column_name column-$column_name'$style>"; 387 /** 388 * Fires inside the auxiliary 'Actions' column of the Sites list table. 389 * 390 * By default this column is hidden unless something is hooked to the action. 391 * 392 * @since MU 393 * 394 * @param int $blog_id The site ID. 395 */ 396 do_action( 'wpmublogsaction', $blog['blog_id'] ); ?> 397 </td> 398 <?php } 399 break; 400 401 default: 402 echo "<td class='$column_name column-$column_name'$style>"; 403 /** 404 * Fires for each registered custom column in the Sites list table. 405 * 406 * @since 3.1.0 407 * 408 * @param string $column_name The name of the column to display. 409 * @param int $blog_id The site ID. 410 */ 411 do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); 412 echo "</td>"; 413 break; 324 break; 325 326 case 'plugins': 327 if ( has_filter( 'wpmublogsaction' ) ) { 328 /** 329 * Fires inside the auxiliary 'Actions' column of the Sites list table. 330 * 331 * By default this column is hidden unless something is hooked to the action. 332 * 333 * @since MU 334 * 335 * @param int $blog_id The site ID. 336 */ 337 do_action( 'wpmublogsaction', $blog['blog_id'] ); 338 } 339 break; 340 341 default: 342 /** 343 * Fires for each registered custom column in the Sites list table. 344 * 345 * @since 3.1.0 346 * 347 * @param string $column_name The name of the column to display. 348 * @param int $blog_id The site ID. 349 */ 350 do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); 351 break; 352 } 353 354 echo $this->handle_row_actions( $blog, $column_name, $primary ); 355 echo '</td>'; 414 356 } 415 357 } … … 419 361 } 420 362 } 363 364 /** 365 * Get name of default primary column 366 * 367 * @since 4.3.0 368 * @access protected 369 * 370 * @return string 371 */ 372 protected function get_default_primary_column_name() { 373 return 'blogname'; 374 } 375 376 /** 377 * Generate and display row actions links 378 * 379 * @since 4.3.0 380 * @access protected 381 * 382 * @param object $blog Blog being acted upon 383 * @param string $column_name Current column name 384 * @param string $primary Primary column name 385 * 386 * @return string 387 */ 388 protected function handle_row_actions( $blog, $column_name, $primary ) { 389 global $current_site; 390 391 if ( $primary === $column_name ) { 392 $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path']; 393 394 // Preordered. 395 $actions = array( 396 'edit' => '', 'backend' => '', 397 'activate' => '', 'deactivate' => '', 398 'archive' => '', 'unarchive' => '', 399 'spam' => '', 'unspam' => '', 400 'delete' => '', 401 'visit' => '', 402 ); 403 404 $actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>'; 405 $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>'; 406 if ( get_current_site()->blog_id != $blog['blog_id'] ) { 407 if ( $blog['deleted'] == '1' ) { 408 $actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>'; 409 } else { 410 $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Deactivate' ) . '</a></span>'; 411 } 412 413 if ( $blog['archived'] == '1' ) { 414 $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Unarchive' ) . '</a></span>'; 415 } else { 416 $actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>'; 417 } 418 419 if ( $blog['spam'] == '1' ) { 420 $actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>'; 421 } else { 422 $actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm' ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>'; 423 } 424 425 if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { 426 $actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Delete' ) . '</a></span>'; 427 } 428 } 429 430 $actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>'; 431 432 /** 433 * Filter the action links displayed for each site in the Sites list table. 434 * 435 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by 436 * default for each site. The site's status determines whether to show the 437 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and 438 * 'Not Spam' or 'Spam' link for each site. 439 * 440 * @since 3.1.0 441 * 442 * @param array $actions An array of action links to be displayed. 443 * @param int $blog_id The site ID. 444 * @param string $blogname Site path, formatted depending on whether it is a sub-domain 445 * or subdirectory multisite install. 446 */ 447 $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); 448 return $this->row_actions( $actions ); 449 } 450 } 421 451 }
Note: See TracChangeset
for help on using the changeset viewer.