[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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   *
  15   * @see WP_List_Table
  16   */
  17  class WP_MS_Sites_List_Table extends WP_List_Table {
  18  
  19      /**
  20       * Site status list.
  21       *
  22       * @since 4.3.0
  23       * @var array
  24       */
  25      public $status_list;
  26  
  27      /**
  28       * Constructor.
  29       *
  30       * @since 3.1.0
  31       *
  32       * @see WP_List_Table::__construct() for more information on default arguments.
  33       *
  34       * @param array $args An associative array of arguments.
  35       */
  36  	public function __construct( $args = array() ) {
  37          $this->status_list = array(
  38              'archived' => array( 'site-archived', __( 'Archived' ) ),
  39              'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
  40              'deleted'  => array( 'site-deleted', __( 'Flagged for Deletion' ) ),
  41              'mature'   => array( 'site-mature', __( 'Mature' ) ),
  42          );
  43  
  44          parent::__construct(
  45              array(
  46                  'plural' => 'sites',
  47                  'screen' => $args['screen'] ?? null,
  48              )
  49          );
  50      }
  51  
  52      /**
  53       * Checks if the current user has permissions to manage sites.
  54       *
  55       * @since 3.1.0
  56       *
  57       * @return bool Whether the user can manage sites.
  58       */
  59  	public function ajax_user_can() {
  60          return current_user_can( 'manage_sites' );
  61      }
  62  
  63      /**
  64       * Prepares the list of sites for display.
  65       *
  66       * @since 3.1.0
  67       *
  68       * @global string $s    Search string.
  69       * @global wpdb   $wpdb WordPress database abstraction object.
  70       */
  71  	public function prepare_items() {
  72          global $s, $wpdb;
  73  
  74          $per_page = $this->get_items_per_page( 'sites_network_per_page' );
  75  
  76          $pagenum = $this->get_pagenum();
  77  
  78          $s    = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
  79          $wild = '';
  80          if ( str_contains( $s, '*' ) ) {
  81              $wild = '*';
  82              $s    = trim( $s, '*' );
  83          }
  84  
  85          /*
  86           * If the network is large and a search is not being performed, show only
  87           * the latest sites with no paging in order to avoid expensive count queries.
  88           */
  89          if ( ! $s && wp_is_large_network() ) {
  90              if ( ! isset( $_REQUEST['orderby'] ) ) {
  91                  $_GET['orderby']     = '';
  92                  $_REQUEST['orderby'] = '';
  93              }
  94              if ( ! isset( $_REQUEST['order'] ) ) {
  95                  $_GET['order']     = 'DESC';
  96                  $_REQUEST['order'] = 'DESC';
  97              }
  98          }
  99  
 100          $args = array(
 101              'number'     => (int) $per_page,
 102              'offset'     => (int) ( ( $pagenum - 1 ) * $per_page ),
 103              'network_id' => get_current_network_id(),
 104          );
 105  
 106          if ( empty( $s ) ) {
 107              // Nothing to do.
 108          } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s )
 109              || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
 110              || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
 111              || preg_match( '/^[0-9]{1,3}\.$/', $s )
 112          ) {
 113              // IPv4 address.
 114              $reg_blog_ids = $wpdb->get_col(
 115                  $wpdb->prepare(
 116                      "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s",
 117                      $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' )
 118                  )
 119              );
 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 = $_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       * Displays a message when no sites are found.
 206       *
 207       * @since 3.1.0
 208       */
 209  	public function no_items() {
 210          _e( 'No sites found.' );
 211      }
 212  
 213      /**
 214       * Gets links to filter sites by status.
 215       *
 216       * @since 5.3.0
 217       *
 218       * @return array
 219       */
 220  	protected function get_views() {
 221          $counts = wp_count_sites();
 222  
 223          $statuses = array(
 224              /* translators: %s: Number of sites. */
 225              'all'      => _nx_noop(
 226                  'All <span class="count">(%s)</span>',
 227                  'All <span class="count">(%s)</span>',
 228                  'sites'
 229              ),
 230  
 231              /* translators: %s: Number of sites. */
 232              'public'   => _n_noop(
 233                  'Public <span class="count">(%s)</span>',
 234                  'Public <span class="count">(%s)</span>'
 235              ),
 236  
 237              /* translators: %s: Number of sites. */
 238              'archived' => _n_noop(
 239                  'Archived <span class="count">(%s)</span>',
 240                  'Archived <span class="count">(%s)</span>'
 241              ),
 242  
 243              /* translators: %s: Number of sites. */
 244              'mature'   => _n_noop(
 245                  'Mature <span class="count">(%s)</span>',
 246                  'Mature <span class="count">(%s)</span>'
 247              ),
 248  
 249              /* translators: %s: Number of sites. */
 250              'spam'     => _nx_noop(
 251                  'Spam <span class="count">(%s)</span>',
 252                  'Spam <span class="count">(%s)</span>',
 253                  'sites'
 254              ),
 255  
 256              /* translators: %s: Number of sites. */
 257              'deleted'  => _n_noop(
 258                  'Flagged for Deletion <span class="count">(%s)</span>',
 259                  'Flagged for Deletion <span class="count">(%s)</span>'
 260              ),
 261          );
 262  
 263          $view_links       = array();
 264          $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
 265          $url              = 'sites.php';
 266  
 267          foreach ( $statuses as $status => $label_count ) {
 268              if ( (int) $counts[ $status ] > 0 ) {
 269                  $label = sprintf(
 270                      translate_nooped_plural( $label_count, $counts[ $status ] ),
 271                      number_format_i18n( $counts[ $status ] )
 272                  );
 273  
 274                  $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
 275  
 276                  $view_links[ $status ] = array(
 277                      'url'     => esc_url( $full_url ),
 278                      'label'   => $label,
 279                      'current' => $requested_status === $status || ( '' === $requested_status && 'all' === $status ),
 280                  );
 281              }
 282          }
 283  
 284          return $this->get_views_links( $view_links );
 285      }
 286  
 287      /**
 288       * Gets an associative array of bulk actions for this table.
 289       *
 290       * @since 3.1.0
 291       *
 292       * @return array<string, string> An associative array of bulk actions.
 293       */
 294  	protected function get_bulk_actions() {
 295          $actions = array();
 296          if ( current_user_can( 'delete_sites' ) ) {
 297              $actions['delete'] = __( 'Delete' );
 298          }
 299          $actions['spam']    = _x( 'Mark as spam', 'site' );
 300          $actions['notspam'] = _x( 'Not spam', 'site' );
 301  
 302          return $actions;
 303      }
 304  
 305      /**
 306       * Displays extra controls between bulk actions and pagination.
 307       *
 308       * @since 5.3.0
 309       *
 310       * @param string $which The location of the extra table nav markup: Either 'top' or 'bottom'.
 311       */
 312  	protected function extra_tablenav( $which ) {
 313          ?>
 314          <div class="alignleft actions">
 315          <?php
 316          if ( 'top' === $which ) {
 317              ob_start();
 318  
 319              /**
 320               * Fires before the Filter button on the MS sites list table.
 321               *
 322               * @since 5.3.0
 323               *
 324               * @param string $which The location of the extra table nav markup: Either 'top' or 'bottom'.
 325               */
 326              do_action( 'restrict_manage_sites', $which );
 327  
 328              $output = ob_get_clean();
 329  
 330              if ( ! empty( $output ) ) {
 331                  echo $output;
 332                  submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'site-query-submit' ) );
 333              }
 334          }
 335          ?>
 336          </div>
 337          <?php
 338          /**
 339           * Fires immediately following the closing "actions" div in the tablenav for the
 340           * MS sites list table.
 341           *
 342           * @since 5.3.0
 343           *
 344           * @param string $which The location of the extra table nav markup: Either 'top' or 'bottom'.
 345           */
 346          do_action( 'manage_sites_extra_tablenav', $which );
 347      }
 348  
 349      /**
 350       * Gets an array of column titles keyed by their column name.
 351       *
 352       * @since 3.1.0
 353       *
 354       * @return string[] Array of column titles keyed by their column name.
 355       */
 356  	public function get_columns() {
 357          $sites_columns = array(
 358              'cb'          => '<input type="checkbox" />',
 359              'blogname'    => __( 'URL' ),
 360              'lastupdated' => __( 'Last Updated' ),
 361              'registered'  => _x( 'Registered', 'site' ),
 362              'users'       => __( 'Users' ),
 363          );
 364  
 365          if ( has_filter( 'wpmublogsaction' ) ) {
 366              $sites_columns['plugins'] = __( 'Actions' );
 367          }
 368  
 369          /**
 370           * Filters the displayed site columns in Sites list table.
 371           *
 372           * @since MU (3.0.0)
 373           *
 374           * @param string[] $sites_columns An array of displayed site columns. Default 'cb',
 375           *                               'blogname', 'lastupdated', 'registered', 'users'.
 376           */
 377          return apply_filters( 'wpmu_blogs_columns', $sites_columns );
 378      }
 379  
 380      /**
 381       * Gets an array of sortable columns.
 382       *
 383       * @since 3.1.0
 384       *
 385       * @return array<string, mixed> An array of sortable columns.
 386       */
 387  	protected function get_sortable_columns() {
 388  
 389          if ( is_subdomain_install() ) {
 390              $blogname_abbr         = __( 'Domain' );
 391              $blogname_orderby_text = __( 'Table ordered by Site Domain Name.' );
 392          } else {
 393              $blogname_abbr         = __( 'Path' );
 394              $blogname_orderby_text = __( 'Table ordered by Site Path.' );
 395          }
 396  
 397          return array(
 398              'blogname'    => array( 'blogname', false, $blogname_abbr, $blogname_orderby_text ),
 399              'lastupdated' => array( 'lastupdated', true, __( 'Last Updated' ), __( 'Table ordered by Last Updated.' ) ),
 400              'registered'  => array( 'blog_id', true, _x( 'Registered', 'site' ), __( 'Table ordered by Site Registered Date.' ), 'desc' ),
 401          );
 402      }
 403  
 404      /**
 405       * Handles the checkbox column output.
 406       *
 407       * @since 4.3.0
 408       * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
 409       *
 410       * @param array $item Current site.
 411       */
 412  	public function column_cb( $item ) {
 413          // Restores the more descriptive, specific name for use within this method.
 414          $blog = $item;
 415  
 416          if ( ! is_main_site( $blog['blog_id'] ) ) :
 417              $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 418              ?>
 419              <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
 420              <label for="blog_<?php echo $blog['blog_id']; ?>">
 421                  <span class="screen-reader-text">
 422                  <?php
 423                  /* translators: %s: Site URL. */
 424                  printf( __( 'Select %s' ), $blogname );
 425                  ?>
 426                  </span>
 427              </label>
 428              <?php
 429          endif;
 430      }
 431  
 432      /**
 433       * Handles the ID column output.
 434       *
 435       * @since 4.4.0
 436       *
 437       * @param array $blog Current site.
 438       */
 439  	public function column_id( $blog ) {
 440          echo $blog['blog_id'];
 441      }
 442  
 443      /**
 444       * Handles the site name column output.
 445       *
 446       * @since 4.3.0
 447       *
 448       * @param array $blog Current site.
 449       */
 450  	public function column_blogname( $blog ) {
 451          $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 452  
 453          ?>
 454          <strong>
 455              <?php
 456              printf(
 457                  '<a href="%1$s" class="edit">%2$s</a>',
 458                  esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ),
 459                  $blogname
 460              );
 461  
 462              $this->site_states( $blog );
 463              ?>
 464          </strong>
 465          <?php
 466      }
 467  
 468      /**
 469       * Handles the lastupdated column output.
 470       *
 471       * @since 4.3.0
 472       *
 473       * @param array $blog Current site.
 474       */
 475  	public function column_lastupdated( $blog ) {
 476          $date = __( 'Y/m/d g:i:s a' );
 477  
 478          if ( '0000-00-00 00:00:00' === $blog['last_updated'] ) {
 479              _e( 'Never' );
 480          } else {
 481              echo mysql2date( $date, $blog['last_updated'] );
 482          }
 483      }
 484  
 485      /**
 486       * Handles the registered column output.
 487       *
 488       * @since 4.3.0
 489       *
 490       * @param array $blog Current site.
 491       */
 492  	public function column_registered( $blog ) {
 493          $date = __( 'Y/m/d g:i:s a' );
 494  
 495          if ( '0000-00-00 00:00:00' === $blog['registered'] ) {
 496              echo '&#x2014;';
 497          } else {
 498              echo mysql2date( $date, $blog['registered'] );
 499          }
 500      }
 501  
 502      /**
 503       * Handles the users column output.
 504       *
 505       * @since 4.3.0
 506       *
 507       * @param array $blog Current site.
 508       */
 509  	public function column_users( $blog ) {
 510          $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
 511          if ( ! $user_count ) {
 512              $blog_users = new WP_User_Query(
 513                  array(
 514                      'blog_id'     => $blog['blog_id'],
 515                      'fields'      => 'ID',
 516                      'number'      => 1,
 517                      'count_total' => true,
 518                  )
 519              );
 520              $user_count = $blog_users->get_total();
 521              wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
 522          }
 523  
 524          printf(
 525              '<a href="%1$s">%2$s</a>',
 526              esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
 527              number_format_i18n( $user_count )
 528          );
 529      }
 530  
 531      /**
 532       * Handles the plugins column output.
 533       *
 534       * @since 4.3.0
 535       *
 536       * @param array $blog Current site.
 537       */
 538  	public function column_plugins( $blog ) {
 539          if ( has_filter( 'wpmublogsaction' ) ) {
 540              /**
 541               * Fires inside the auxiliary 'Actions' column of the Sites list table.
 542               *
 543               * By default this column is hidden unless something is hooked to the action.
 544               *
 545               * @since MU (3.0.0)
 546               *
 547               * @param int $blog_id The site ID.
 548               */
 549              do_action( 'wpmublogsaction', $blog['blog_id'] );
 550          }
 551      }
 552  
 553      /**
 554       * Handles output for the default column.
 555       *
 556       * @since 4.3.0
 557       * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
 558       *
 559       * @param array  $item        Current site.
 560       * @param string $column_name Current column name.
 561       */
 562  	public function column_default( $item, $column_name ) {
 563          // Restores the more descriptive, specific name for use within this method.
 564          $blog = $item;
 565  
 566          /**
 567           * Fires for each registered custom column in the Sites list table.
 568           *
 569           * @since 3.1.0
 570           *
 571           * @param string $column_name The name of the column to display.
 572           * @param int    $blog_id     The site ID.
 573           */
 574          do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
 575      }
 576  
 577      /**
 578       * Generates the list table rows.
 579       *
 580       * @since 3.1.0
 581       */
 582  	public function display_rows() {
 583          foreach ( $this->items as $blog ) {
 584              $blog  = $blog->to_array();
 585              $class = '';
 586              reset( $this->status_list );
 587  
 588              foreach ( $this->status_list as $status => $col ) {
 589                  if ( '1' === $blog[ $status ] ) {
 590                      $class = " class='{$col[0]}'";
 591                  }
 592              }
 593  
 594              echo "<tr{$class}>";
 595  
 596              $this->single_row_columns( $blog );
 597  
 598              echo '</tr>';
 599          }
 600      }
 601  
 602      /**
 603       * Determines whether to output comma-separated site states.
 604       *
 605       * @since 5.3.0
 606       *
 607       * @param array<string, mixed> $site An array of site data.
 608       */
 609  	protected function site_states( $site ) {
 610          $site_states = array();
 611  
 612          // $site is still an array, so get the object.
 613          $_site = WP_Site::get_instance( $site['blog_id'] );
 614  
 615          if ( is_main_site( $_site->id ) ) {
 616              $site_states['main'] = __( 'Main' );
 617          }
 618  
 619          reset( $this->status_list );
 620  
 621          $site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
 622          foreach ( $this->status_list as $status => $col ) {
 623              if ( '1' === $_site->{$status} && $site_status !== $status ) {
 624                  $site_states[ $col[0] ] = $col[1];
 625              }
 626          }
 627  
 628          /**
 629           * Filters the default site display states for items in the Sites list table.
 630           *
 631           * @since 5.3.0
 632           *
 633           * @param string[] $site_states An array of site states. Default 'Main',
 634           *                              'Archived', 'Mature', 'Spam', 'Flagged for Deletion'.
 635           * @param WP_Site  $site        The current site object.
 636           */
 637          $site_states = apply_filters( 'display_site_states', $site_states, $_site );
 638  
 639          if ( ! empty( $site_states ) ) {
 640              $state_count = count( $site_states );
 641              $separator   = wp_get_list_item_separator();
 642  
 643              $i = 0;
 644  
 645              echo ' &mdash; ';
 646  
 647              foreach ( $site_states as $state ) {
 648                  ++$i;
 649  
 650                  $suffix = ( $i < $state_count ) ? $separator : '';
 651  
 652                  echo "<span class='post-state'>{$state}{$suffix}</span>";
 653              }
 654          }
 655      }
 656  
 657      /**
 658       * Gets the name of the default primary column.
 659       *
 660       * @since 4.3.0
 661       *
 662       * @return string Name of the default primary column, in this case, 'blogname'.
 663       */
 664  	protected function get_default_primary_column_name() {
 665          return 'blogname';
 666      }
 667  
 668      /**
 669       * Generates and displays row action links.
 670       *
 671       * @since 4.3.0
 672       * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
 673       *
 674       * @param array  $item        Site being acted upon.
 675       * @param string $column_name Current column name.
 676       * @param string $primary     Primary column name.
 677       * @return string Row actions output for sites in Multisite, or an empty string
 678       *                if the current column is not the primary column.
 679       */
 680  	protected function handle_row_actions( $item, $column_name, $primary ) {
 681          if ( $primary !== $column_name ) {
 682              return '';
 683          }
 684  
 685          // Restores the more descriptive, specific name for use within this method.
 686          $blog = $item;
 687  
 688          $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 689  
 690          // Preordered.
 691          $actions = array(
 692              'edit'       => '',
 693              'backend'    => '',
 694              'activate'   => '',
 695              'deactivate' => '',
 696              'archive'    => '',
 697              'unarchive'  => '',
 698              'spam'       => '',
 699              'unspam'     => '',
 700              'delete'     => '',
 701              'visit'      => '',
 702          );
 703  
 704          $actions['edit'] = sprintf(
 705              '<a href="%1$s">%2$s</a>',
 706              esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ),
 707              __( 'Edit' )
 708          );
 709  
 710          $actions['backend'] = sprintf(
 711              '<a href="%1$s" class="edit">%2$s</a>',
 712              esc_url( get_admin_url( $blog['blog_id'] ) ),
 713              __( 'Dashboard' )
 714          );
 715  
 716          if ( ! is_main_site( $blog['blog_id'] ) ) {
 717              if ( '1' === $blog['deleted'] ) {
 718                  $actions['activate'] = sprintf(
 719                      '<a href="%1$s">%2$s</a>',
 720                      esc_url(
 721                          wp_nonce_url(
 722                              network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ),
 723                              'activateblog_' . $blog['blog_id']
 724                          )
 725                      ),
 726                      _x( 'Remove Deletion Flag', 'site' )
 727                  );
 728              } else {
 729                  $actions['deactivate'] = sprintf(
 730                      '<a href="%1$s">%2$s</a>',
 731                      esc_url(
 732                          wp_nonce_url(
 733                              network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ),
 734                              'deactivateblog_' . $blog['blog_id']
 735                          )
 736                      ),
 737                      __( 'Flag for Deletion' )
 738                  );
 739              }
 740  
 741              if ( '1' === $blog['archived'] ) {
 742                  $actions['unarchive'] = sprintf(
 743                      '<a href="%1$s">%2$s</a>',
 744                      esc_url(
 745                          wp_nonce_url(
 746                              network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ),
 747                              'unarchiveblog_' . $blog['blog_id']
 748                          )
 749                      ),
 750                      __( 'Unarchive' )
 751                  );
 752              } else {
 753                  $actions['archive'] = sprintf(
 754                      '<a href="%1$s">%2$s</a>',
 755                      esc_url(
 756                          wp_nonce_url(
 757                              network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ),
 758                              'archiveblog_' . $blog['blog_id']
 759                          )
 760                      ),
 761                      _x( 'Archive', 'verb; site' )
 762                  );
 763              }
 764  
 765              if ( '1' === $blog['spam'] ) {
 766                  $actions['unspam'] = sprintf(
 767                      '<a href="%1$s">%2$s</a>',
 768                      esc_url(
 769                          wp_nonce_url(
 770                              network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ),
 771                              'unspamblog_' . $blog['blog_id']
 772                          )
 773                      ),
 774                      _x( 'Not Spam', 'site' )
 775                  );
 776              } else {
 777                  $actions['spam'] = sprintf(
 778                      '<a href="%1$s">%2$s</a>',
 779                      esc_url(
 780                          wp_nonce_url(
 781                              network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ),
 782                              'spamblog_' . $blog['blog_id']
 783                          )
 784                      ),
 785                      _x( 'Spam', 'site' )
 786                  );
 787              }
 788  
 789              if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
 790                  $actions['delete'] = sprintf(
 791                      '<a href="%1$s">%2$s</a>',
 792                      esc_url(
 793                          wp_nonce_url(
 794                              network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ),
 795                              'deleteblog_' . $blog['blog_id']
 796                          )
 797                      ),
 798                      __( 'Delete Permanently' )
 799                  );
 800              }
 801          }
 802  
 803          $actions['visit'] = sprintf(
 804              '<a href="%1$s" rel="bookmark">%2$s</a>',
 805              esc_url( get_home_url( $blog['blog_id'], '/' ) ),
 806              __( 'Visit' )
 807          );
 808  
 809          /**
 810           * Filters the action links displayed for each site in the Sites list table.
 811           *
 812           * The 'Edit', 'Dashboard', 'Delete Permanently', and 'Visit' links are displayed by
 813           * default for each site. The site's status determines whether to show the
 814           * 'Remove Deletion Flag' or 'Flag for Deletion' link, 'Unarchive' or 'Archive' links, and
 815           * 'Not Spam' or 'Spam' link for each site.
 816           *
 817           * @since 3.1.0
 818           *
 819           * @param string[] $actions  An array of action links to be displayed.
 820           * @param int      $blog_id  The site ID.
 821           * @param string   $blogname Site path, formatted depending on whether it is a sub-domain
 822           *                           or subdirectory multisite installation.
 823           */
 824          $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
 825  
 826          return $this->row_actions( $actions );
 827      }
 828  
 829      /**
 830       * Returns a clean label for the primary (URL) column's row header `aria-label`.
 831       *
 832       * Provides screen readers with just the site title as the row header name,
 833       * preventing them from computing the name from the full cell content.
 834       *
 835       * @since 7.1.0
 836       *
 837       * @param array $blog The current site properties array.
 838       * @return string The site title, or the site URL (domain + path) if the title is empty.
 839       */
 840  	protected function get_primary_column_aria_label( $blog ) {
 841          $blog_name = html_entity_decode( (string) get_blog_option( $blog['blog_id'], 'blogname', '' ), ENT_QUOTES, get_bloginfo( 'charset' ) );
 842          $blog_name = wp_strip_all_tags( $blog_name );
 843  
 844          // Fall back to the blog URL and path if the blog name is empty.
 845          return '' !== $blog_name ? $blog_name : untrailingslashit( $blog['domain'] . $blog['path'] );
 846      }
 847  }


Generated : Wed Nov 4 08:20:38 2026 Cross-referenced by PHPXref