[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> class-wp-ms-sites-list-table.php (source)

   1  <?php
   2  /**
   3   * List Table API: WP_MS_Sites_List_Table class
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   * @since 3.1.0
   8   */
   9  
  10  /**
  11   * Core class used to implement displaying sites in a list table for the network admin.
  12   *
  13   * @since 3.1.0
  14   * @access private
  15   *
  16   * @see WP_List_Table
  17   */
  18  class WP_MS_Sites_List_Table extends WP_List_Table {
  19  
  20      /**
  21       * Site status list.
  22       *
  23       * @since 4.3.0
  24       * @var array
  25       */
  26      public $status_list;
  27  
  28      /**
  29       * Constructor.
  30       *
  31       * @since 3.1.0
  32       *
  33       * @see WP_List_Table::__construct() for more information on default arguments.
  34       *
  35       * @param array $args An associative array of arguments.
  36       */
  37  	public function __construct( $args = array() ) {
  38          $this->status_list = array(
  39              'archived' => array( 'site-archived', __( 'Archived' ) ),
  40              'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
  41              'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
  42              'mature'   => array( 'site-mature', __( 'Mature' ) ),
  43          );
  44  
  45          parent::__construct(
  46              array(
  47                  'plural' => 'sites',
  48                  'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
  49              )
  50          );
  51      }
  52  
  53      /**
  54       * @return bool
  55       */
  56  	public function ajax_user_can() {
  57          return current_user_can( 'manage_sites' );
  58      }
  59  
  60      /**
  61       * Prepares the list of sites for display.
  62       *
  63       * @since 3.1.0
  64       *
  65       * @global string $s
  66       * @global string $mode
  67       * @global wpdb   $wpdb WordPress database abstraction object.
  68       */
  69  	public function prepare_items() {
  70          global $s, $mode, $wpdb;
  71  
  72          if ( ! empty( $_REQUEST['mode'] ) ) {
  73              $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
  74              set_user_setting( 'sites_list_mode', $mode );
  75          } else {
  76              $mode = get_user_setting( 'sites_list_mode', 'list' );
  77          }
  78  
  79          $per_page = $this->get_items_per_page( 'sites_network_per_page' );
  80  
  81          $pagenum = $this->get_pagenum();
  82  
  83          $s    = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
  84          $wild = '';
  85          if ( false !== strpos( $s, '*' ) ) {
  86              $wild = '*';
  87              $s    = trim( $s, '*' );
  88          }
  89  
  90          /*
  91           * If the network is large and a search is not being performed, show only
  92           * the latest sites with no paging in order to avoid expensive count queries.
  93           */
  94          if ( ! $s && wp_is_large_network() ) {
  95              if ( ! isset( $_REQUEST['orderby'] ) ) {
  96                  $_GET['orderby']     = '';
  97                  $_REQUEST['orderby'] = '';
  98              }
  99              if ( ! isset( $_REQUEST['order'] ) ) {
 100                  $_GET['order']     = 'DESC';
 101                  $_REQUEST['order'] = 'DESC';
 102              }
 103          }
 104  
 105          $args = array(
 106              'number'     => intval( $per_page ),
 107              'offset'     => intval( ( $pagenum - 1 ) * $per_page ),
 108              'network_id' => get_current_network_id(),
 109          );
 110  
 111          if ( empty( $s ) ) {
 112              // Nothing to do.
 113          } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
 114                      preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
 115                      preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
 116                      preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
 117              // IPv4 address
 118              $sql          = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
 119              $reg_blog_ids = $wpdb->get_col( $sql );
 120  
 121              if ( $reg_blog_ids ) {
 122                  $args['site__in'] = $reg_blog_ids;
 123              }
 124          } elseif ( is_numeric( $s ) && empty( $wild ) ) {
 125              $args['ID'] = $s;
 126          } else {
 127              $args['search'] = $s;
 128  
 129              if ( ! is_subdomain_install() ) {
 130                  $args['search_columns'] = array( 'path' );
 131              }
 132          }
 133  
 134          $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
 135          if ( 'registered' === $order_by ) {
 136              // registered is a valid field name.
 137          } elseif ( 'lastupdated' === $order_by ) {
 138              $order_by = 'last_updated';
 139          } elseif ( 'blogname' === $order_by ) {
 140              if ( is_subdomain_install() ) {
 141                  $order_by = 'domain';
 142              } else {
 143                  $order_by = 'path';
 144              }
 145          } elseif ( 'blog_id' === $order_by ) {
 146              $order_by = 'id';
 147          } elseif ( ! $order_by ) {
 148              $order_by = false;
 149          }
 150  
 151          $args['orderby'] = $order_by;
 152  
 153          if ( $order_by ) {
 154              $args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC';
 155          }
 156  
 157          if ( wp_is_large_network() ) {
 158              $args['no_found_rows'] = true;
 159          } else {
 160              $args['no_found_rows'] = false;
 161          }
 162  
 163          // Take into account the role the user has selected.
 164          $status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
 165          if ( in_array( $status, array( 'public', 'archived', 'mature', 'spam', 'deleted' ), true ) ) {
 166              $args[ $status ] = 1;
 167          }
 168  
 169          /**
 170           * Filters the arguments for the site query in the sites list table.
 171           *
 172           * @since 4.6.0
 173           *
 174           * @param array $args An array of get_sites() arguments.
 175           */
 176          $args = apply_filters( 'ms_sites_list_table_query_args', $args );
 177  
 178          $_sites = get_sites( $args );
 179          if ( is_array( $_sites ) ) {
 180              update_site_cache( $_sites );
 181  
 182              $this->items = array_slice( $_sites, 0, $per_page );
 183          }
 184  
 185          $total_sites = get_sites(
 186              array_merge(
 187                  $args,
 188                  array(
 189                      'count'  => true,
 190                      'offset' => 0,
 191                      'number' => 0,
 192                  )
 193              )
 194          );
 195  
 196          $this->set_pagination_args(
 197              array(
 198                  'total_items' => $total_sites,
 199                  'per_page'    => $per_page,
 200              )
 201          );
 202      }
 203  
 204      /**
 205       */
 206  	public function no_items() {
 207          _e( 'No sites found.' );
 208      }
 209  
 210      /**
 211       * Gets links to filter sites by status.
 212       *
 213       * @since 5.3.0
 214       *
 215       * @return array
 216       *
 217       */
 218  	protected function get_views() {
 219          $counts = wp_count_sites();
 220  
 221          $statuses = array(
 222              /* translators: %s: Number of sites. */
 223              'all'      => _nx_noop(
 224                  'All <span class="count">(%s)</span>',
 225                  'All <span class="count">(%s)</span>',
 226                  'sites'
 227              ),
 228  
 229              /* translators: %s: Number of sites. */
 230              'public'   => _n_noop(
 231                  'Public <span class="count">(%s)</span>',
 232                  'Public <span class="count">(%s)</span>'
 233              ),
 234  
 235              /* translators: %s: Number of sites. */
 236              'archived' => _n_noop(
 237                  'Archived <span class="count">(%s)</span>',
 238                  'Archived <span class="count">(%s)</span>'
 239              ),
 240  
 241              /* translators: %s: Number of sites. */
 242              'mature'   => _n_noop(
 243                  'Mature <span class="count">(%s)</span>',
 244                  'Mature <span class="count">(%s)</span>'
 245              ),
 246  
 247              /* translators: %s: Number of sites. */
 248              'spam'     => _nx_noop(
 249                  'Spam <span class="count">(%s)</span>',
 250                  'Spam <span class="count">(%s)</span>',
 251                  'sites'
 252              ),
 253  
 254              /* translators: %s: Number of sites. */
 255              'deleted'  => _n_noop(
 256                  'Deleted <span class="count">(%s)</span>',
 257                  'Deleted <span class="count">(%s)</span>'
 258              ),
 259          );
 260  
 261          $view_links       = array();
 262          $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
 263          $url              = 'sites.php';
 264  
 265          foreach ( $statuses as $status => $label_count ) {
 266              $current_link_attributes = $requested_status === $status || ( $requested_status === '' && 'all' === $status )
 267                  ? ' class="current" aria-current="page"'
 268                  : '';
 269              if ( (int) $counts[ $status ] > 0 ) {
 270                  $label    = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
 271                  $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
 272  
 273                  $view_links[ $status ] = sprintf(
 274                      '<a href="%1$s"%2$s>%3$s</a>',
 275                      esc_url( $full_url ),
 276                      $current_link_attributes,
 277                      $label
 278                  );
 279              }
 280          }
 281  
 282          return $view_links;
 283      }
 284  
 285      /**
 286       * @return array
 287       */
 288  	protected function get_bulk_actions() {
 289          $actions = array();
 290          if ( current_user_can( 'delete_sites' ) ) {
 291              $actions['delete'] = __( 'Delete' );
 292          }
 293          $actions['spam']    = _x( 'Mark as Spam', 'site' );
 294          $actions['notspam'] = _x( 'Not Spam', 'site' );
 295  
 296          return $actions;
 297      }
 298  
 299      /**
 300       * @global string $mode List table view mode.
 301       *
 302       * @param string $which The location of the pagination nav markup: 'top' or 'bottom'.
 303       */
 304  	protected function pagination( $which ) {
 305          global $mode;
 306  
 307          parent::pagination( $which );
 308  
 309          if ( 'top' === $which ) {
 310              $this->view_switcher( $mode );
 311          }
 312      }
 313  
 314      /**
 315       * Extra controls to be displayed between bulk actions and pagination.
 316       *
 317       * @since 5.3.0
 318       *
 319       * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
 320       */
 321  	protected function extra_tablenav( $which ) {
 322          ?>
 323          <div class="alignleft actions">
 324          <?php
 325          if ( 'top' === $which ) {
 326              ob_start();
 327  
 328              /**
 329               * Fires before the Filter button on the MS sites list table.
 330               *
 331               * @since 5.3.0
 332               *
 333               * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
 334               */
 335              do_action( 'restrict_manage_sites', $which );
 336              $output = ob_get_clean();
 337              if ( ! empty( $output ) ) {
 338                  echo $output;
 339                  submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'site-query-submit' ) );
 340              }
 341          }
 342          ?>
 343          </div>
 344          <?php
 345          /**
 346           * Fires immediately following the closing "actions" div in the tablenav for the
 347           * MS sites list table.
 348           *
 349           * @since 5.3.0
 350           *
 351           * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
 352           */
 353          do_action( 'manage_sites_extra_tablenav', $which );
 354      }
 355  
 356      /**
 357       * @return array
 358       */
 359  	public function get_columns() {
 360          $sites_columns = array(
 361              'cb'          => '<input type="checkbox" />',
 362              'blogname'    => __( 'URL' ),
 363              'lastupdated' => __( 'Last Updated' ),
 364              'registered'  => _x( 'Registered', 'site' ),
 365              'users'       => __( 'Users' ),
 366          );
 367  
 368          if ( has_filter( 'wpmublogsaction' ) ) {
 369              $sites_columns['plugins'] = __( 'Actions' );
 370          }
 371  
 372          /**
 373           * Filters the displayed site columns in Sites list table.
 374           *
 375           * @since MU (3.0.0)
 376           *
 377           * @param string[] $sites_columns An array of displayed site columns. Default 'cb',
 378           *                               'blogname', 'lastupdated', 'registered', 'users'.
 379           */
 380          return apply_filters( 'wpmu_blogs_columns', $sites_columns );
 381      }
 382  
 383      /**
 384       * @return array
 385       */
 386  	protected function get_sortable_columns() {
 387          return array(
 388              'blogname'    => 'blogname',
 389              'lastupdated' => 'lastupdated',
 390              'registered'  => 'blog_id',
 391          );
 392      }
 393  
 394      /**
 395       * Handles the checkbox column output.
 396       *
 397       * @since 4.3.0
 398       *
 399       * @param array $blog Current site.
 400       */
 401  	public function column_cb( $blog ) {
 402          if ( ! is_main_site( $blog['blog_id'] ) ) :
 403              $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 404              ?>
 405              <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>">
 406                  <?php
 407                  /* translators: %s: Site URL. */
 408                  printf( __( 'Select %s' ), $blogname );
 409                  ?>
 410              </label>
 411              <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
 412              <?php
 413          endif;
 414      }
 415  
 416      /**
 417       * Handles the ID column output.
 418       *
 419       * @since 4.4.0
 420       *
 421       * @param array $blog Current site.
 422       */
 423  	public function column_id( $blog ) {
 424          echo $blog['blog_id'];
 425      }
 426  
 427      /**
 428       * Handles the site name column output.
 429       *
 430       * @since 4.3.0
 431       *
 432       * @global string $mode List table view mode.
 433       *
 434       * @param array $blog Current site.
 435       */
 436  	public function column_blogname( $blog ) {
 437          global $mode;
 438  
 439          $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 440  
 441          ?>
 442          <strong>
 443              <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
 444              <?php $this->site_states( $blog ); ?>
 445          </strong>
 446          <?php
 447          if ( 'list' !== $mode ) {
 448              switch_to_blog( $blog['blog_id'] );
 449              echo '<p>';
 450              printf(
 451                  /* translators: 1: Site title, 2: Site tagline. */
 452                  __( '%1$s &#8211; %2$s' ),
 453                  get_option( 'blogname' ),
 454                  '<em>' . get_option( 'blogdescription' ) . '</em>'
 455              );
 456              echo '</p>';
 457              restore_current_blog();
 458          }
 459      }
 460  
 461      /**
 462       * Handles the lastupdated column output.
 463       *
 464       * @since 4.3.0
 465       *
 466       * @global string $mode List table view mode.
 467       *
 468       * @param array $blog Current site.
 469       */
 470  	public function column_lastupdated( $blog ) {
 471          global $mode;
 472  
 473          if ( 'list' === $mode ) {
 474              $date = __( 'Y/m/d' );
 475          } else {
 476              $date = __( 'Y/m/d g:i:s a' );
 477          }
 478  
 479          echo ( $blog['last_updated'] === '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
 480      }
 481  
 482      /**
 483       * Handles the registered column output.
 484       *
 485       * @since 4.3.0
 486       *
 487       * @global string $mode List table view mode.
 488       *
 489       * @param array $blog Current site.
 490       */
 491  	public function column_registered( $blog ) {
 492          global $mode;
 493  
 494          if ( 'list' === $mode ) {
 495              $date = __( 'Y/m/d' );
 496          } else {
 497              $date = __( 'Y/m/d g:i:s a' );
 498          }
 499  
 500          if ( $blog['registered'] === '0000-00-00 00:00:00' ) {
 501              echo '&#x2014;';
 502          } else {
 503              echo mysql2date( $date, $blog['registered'] );
 504          }
 505      }
 506  
 507      /**
 508       * Handles the users column output.
 509       *
 510       * @since 4.3.0
 511       *
 512       * @param array $blog Current site.
 513       */
 514  	public function column_users( $blog ) {
 515          $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
 516          if ( ! $user_count ) {
 517              $blog_users = new WP_User_Query(
 518                  array(
 519                      'blog_id'     => $blog['blog_id'],
 520                      'fields'      => 'ID',
 521                      'number'      => 1,
 522                      'count_total' => true,
 523                  )
 524              );
 525              $user_count = $blog_users->get_total();
 526              wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
 527          }
 528  
 529          printf(
 530              '<a href="%s">%s</a>',
 531              esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
 532              number_format_i18n( $user_count )
 533          );
 534      }
 535  
 536      /**
 537       * Handles the plugins column output.
 538       *
 539       * @since 4.3.0
 540       *
 541       * @param array $blog Current site.
 542       */
 543  	public function column_plugins( $blog ) {
 544          if ( has_filter( 'wpmublogsaction' ) ) {
 545              /**
 546               * Fires inside the auxiliary 'Actions' column of the Sites list table.
 547               *
 548               * By default this column is hidden unless something is hooked to the action.
 549               *
 550               * @since MU (3.0.0)
 551               *
 552               * @param int $blog_id The site ID.
 553               */
 554              do_action( 'wpmublogsaction', $blog['blog_id'] );
 555          }
 556      }
 557  
 558      /**
 559       * Handles output for the default column.
 560       *
 561       * @since 4.3.0
 562       *
 563       * @param array  $blog        Current site.
 564       * @param string $column_name Current column name.
 565       */
 566  	public function column_default( $blog, $column_name ) {
 567          /**
 568           * Fires for each registered custom column in the Sites list table.
 569           *
 570           * @since 3.1.0
 571           *
 572           * @param string $column_name The name of the column to display.
 573           * @param int    $blog_id     The site ID.
 574           */
 575          do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
 576      }
 577  
 578      /**
 579       * @global string $mode
 580       */
 581  	public function display_rows() {
 582          foreach ( $this->items as $blog ) {
 583              $blog  = $blog->to_array();
 584              $class = '';
 585              reset( $this->status_list );
 586  
 587              foreach ( $this->status_list as $status => $col ) {
 588                  if ( $blog[ $status ] == 1 ) {
 589                      $class = " class='{$col[0]}'";
 590                  }
 591              }
 592  
 593              echo "<tr{$class}>";
 594  
 595              $this->single_row_columns( $blog );
 596  
 597              echo '</tr>';
 598          }
 599      }
 600  
 601      /**
 602       * Maybe output comma-separated site states.
 603       *
 604       * @since 5.3.0
 605       *
 606       * @param array $site
 607       */
 608  	protected function site_states( $site ) {
 609          $site_states = array();
 610  
 611          // $site is still an array, so get the object.
 612          $_site = WP_Site::get_instance( $site['blog_id'] );
 613  
 614          if ( is_main_site( $_site->id ) ) {
 615              $site_states['main'] = __( 'Main' );
 616          }
 617  
 618          reset( $this->status_list );
 619  
 620          $site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
 621          foreach ( $this->status_list as $status => $col ) {
 622              if ( ( 1 === intval( $_site->{$status} ) ) && ( $site_status !== $status ) ) {
 623                  $site_states[ $col[0] ] = $col[1];
 624              }
 625          }
 626  
 627          /**
 628           * Filter the default site display states for items in the Sites list table.
 629           *
 630           * @since 5.3.0
 631           *
 632           * @param array $site_states An array of site states. Default 'Main',
 633           *                           'Archived', 'Mature', 'Spam', 'Deleted'.
 634           * @param WP_Site $site The current site object.
 635           */
 636          $site_states = apply_filters( 'display_site_states', $site_states, $_site );
 637  
 638          if ( ! empty( $site_states ) ) {
 639              $state_count = count( $site_states );
 640              $i           = 0;
 641              echo ' &mdash; ';
 642              foreach ( $site_states as $state ) {
 643                  ++$i;
 644                  ( $i == $state_count ) ? $sep = '' : $sep = ', ';
 645                  echo "<span class='post-state'>{$state}{$sep}</span>";
 646              }
 647          }
 648      }
 649  
 650      /**
 651       * Gets the name of the default primary column.
 652       *
 653       * @since 4.3.0
 654       *
 655       * @return string Name of the default primary column, in this case, 'blogname'.
 656       */
 657  	protected function get_default_primary_column_name() {
 658          return 'blogname';
 659      }
 660  
 661      /**
 662       * Generates and displays row action links.
 663       *
 664       * @since 4.3.0
 665       *
 666       * @param object $blog        Site being acted upon.
 667       * @param string $column_name Current column name.
 668       * @param string $primary     Primary column name.
 669       * @return string Row actions output.
 670       */
 671  	protected function handle_row_actions( $blog, $column_name, $primary ) {
 672          if ( $primary !== $column_name ) {
 673              return;
 674          }
 675  
 676          $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 677  
 678          // Preordered.
 679          $actions = array(
 680              'edit'       => '',
 681              'backend'    => '',
 682              'activate'   => '',
 683              'deactivate' => '',
 684              'archive'    => '',
 685              'unarchive'  => '',
 686              'spam'       => '',
 687              'unspam'     => '',
 688              'delete'     => '',
 689              'visit'      => '',
 690          );
 691  
 692          $actions['edit']    = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
 693          $actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
 694          if ( get_network()->site_id != $blog['blog_id'] ) {
 695              if ( $blog['deleted'] == '1' ) {
 696                  $actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
 697              } else {
 698                  $actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
 699              }
 700  
 701              if ( $blog['archived'] == '1' ) {
 702                  $actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>';
 703              } else {
 704                  $actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
 705              }
 706  
 707              if ( $blog['spam'] == '1' ) {
 708                  $actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>';
 709              } else {
 710                  $actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';
 711              }
 712  
 713              if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
 714                  $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>';
 715              }
 716          }
 717  
 718          $actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
 719  
 720          /**
 721           * Filters the action links displayed for each site in the Sites list table.
 722           *
 723           * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
 724           * default for each site. The site's status determines whether to show the
 725           * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
 726           * 'Not Spam' or 'Spam' link for each site.
 727           *
 728           * @since 3.1.0
 729           *
 730           * @param string[] $actions  An array of action links to be displayed.
 731           * @param int      $blog_id  The site ID.
 732           * @param string   $blogname Site path, formatted depending on whether it is a sub-domain
 733           *                           or subdirectory multisite installation.
 734           */
 735          $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
 736          return $this->row_actions( $actions );
 737      }
 738  }


Generated: Tue Oct 22 08:20:01 2019 Cross-referenced by PHPXref 0.7