[ Index ]

PHP Cross Reference of WordPress

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 $mode List table view mode.
  66       * @global string $s
  67       * @global wpdb   $wpdb WordPress database abstraction object.
  68       */
  69  	public function prepare_items() {
  70          global $mode, $s, $wpdb;
  71  
  72          if ( ! empty( $_REQUEST['mode'] ) ) {
  73              $mode = 'excerpt' === $_REQUEST['mode'] ? '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'     => (int) $per_page,
 107              'offset'     => (int) ( ( $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  	protected function get_views() {
 218          $counts = wp_count_sites();
 219  
 220          $statuses = array(
 221              /* translators: %s: Number of sites. */
 222              'all'      => _nx_noop(
 223                  'All <span class="count">(%s)</span>',
 224                  'All <span class="count">(%s)</span>',
 225                  'sites'
 226              ),
 227  
 228              /* translators: %s: Number of sites. */
 229              'public'   => _n_noop(
 230                  'Public <span class="count">(%s)</span>',
 231                  'Public <span class="count">(%s)</span>'
 232              ),
 233  
 234              /* translators: %s: Number of sites. */
 235              'archived' => _n_noop(
 236                  'Archived <span class="count">(%s)</span>',
 237                  'Archived <span class="count">(%s)</span>'
 238              ),
 239  
 240              /* translators: %s: Number of sites. */
 241              'mature'   => _n_noop(
 242                  'Mature <span class="count">(%s)</span>',
 243                  'Mature <span class="count">(%s)</span>'
 244              ),
 245  
 246              /* translators: %s: Number of sites. */
 247              'spam'     => _nx_noop(
 248                  'Spam <span class="count">(%s)</span>',
 249                  'Spam <span class="count">(%s)</span>',
 250                  'sites'
 251              ),
 252  
 253              /* translators: %s: Number of sites. */
 254              'deleted'  => _n_noop(
 255                  'Deleted <span class="count">(%s)</span>',
 256                  'Deleted <span class="count">(%s)</span>'
 257              ),
 258          );
 259  
 260          $view_links       = array();
 261          $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
 262          $url              = 'sites.php';
 263  
 264          foreach ( $statuses as $status => $label_count ) {
 265              $current_link_attributes = $requested_status === $status || ( '' === $requested_status && 'all' === $status )
 266                  ? ' class="current" aria-current="page"'
 267                  : '';
 268              if ( (int) $counts[ $status ] > 0 ) {
 269                  $label    = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
 270                  $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
 271  
 272                  $view_links[ $status ] = sprintf(
 273                      '<a href="%1$s"%2$s>%3$s</a>',
 274                      esc_url( $full_url ),
 275                      $current_link_attributes,
 276                      $label
 277                  );
 278              }
 279          }
 280  
 281          return $view_links;
 282      }
 283  
 284      /**
 285       * @return array
 286       */
 287  	protected function get_bulk_actions() {
 288          $actions = array();
 289          if ( current_user_can( 'delete_sites' ) ) {
 290              $actions['delete'] = __( 'Delete' );
 291          }
 292          $actions['spam']    = _x( 'Mark as spam', 'site' );
 293          $actions['notspam'] = _x( 'Not spam', 'site' );
 294  
 295          return $actions;
 296      }
 297  
 298      /**
 299       * @global string $mode List table view mode.
 300       *
 301       * @param string $which The location of the pagination nav markup: 'top' or 'bottom'.
 302       */
 303  	protected function pagination( $which ) {
 304          global $mode;
 305  
 306          parent::pagination( $which );
 307  
 308          if ( 'top' === $which ) {
 309              $this->view_switcher( $mode );
 310          }
 311      }
 312  
 313      /**
 314       * Extra controls to be displayed between bulk actions and pagination.
 315       *
 316       * @since 5.3.0
 317       *
 318       * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
 319       */
 320  	protected function extra_tablenav( $which ) {
 321          ?>
 322          <div class="alignleft actions">
 323          <?php
 324          if ( 'top' === $which ) {
 325              ob_start();
 326  
 327              /**
 328               * Fires before the Filter button on the MS sites list table.
 329               *
 330               * @since 5.3.0
 331               *
 332               * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
 333               */
 334              do_action( 'restrict_manage_sites', $which );
 335  
 336              $output = ob_get_clean();
 337  
 338              if ( ! empty( $output ) ) {
 339                  echo $output;
 340                  submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'site-query-submit' ) );
 341              }
 342          }
 343          ?>
 344          </div>
 345          <?php
 346          /**
 347           * Fires immediately following the closing "actions" div in the tablenav for the
 348           * MS sites list table.
 349           *
 350           * @since 5.3.0
 351           *
 352           * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
 353           */
 354          do_action( 'manage_sites_extra_tablenav', $which );
 355      }
 356  
 357      /**
 358       * @return array
 359       */
 360  	public function get_columns() {
 361          $sites_columns = array(
 362              'cb'          => '<input type="checkbox" />',
 363              'blogname'    => __( 'URL' ),
 364              'lastupdated' => __( 'Last Updated' ),
 365              'registered'  => _x( 'Registered', 'site' ),
 366              'users'       => __( 'Users' ),
 367          );
 368  
 369          if ( has_filter( 'wpmublogsaction' ) ) {
 370              $sites_columns['plugins'] = __( 'Actions' );
 371          }
 372  
 373          /**
 374           * Filters the displayed site columns in Sites list table.
 375           *
 376           * @since MU (3.0.0)
 377           *
 378           * @param string[] $sites_columns An array of displayed site columns. Default 'cb',
 379           *                               'blogname', 'lastupdated', 'registered', 'users'.
 380           */
 381          return apply_filters( 'wpmu_blogs_columns', $sites_columns );
 382      }
 383  
 384      /**
 385       * @return array
 386       */
 387  	protected function get_sortable_columns() {
 388          return array(
 389              'blogname'    => 'blogname',
 390              'lastupdated' => 'lastupdated',
 391              'registered'  => 'blog_id',
 392          );
 393      }
 394  
 395      /**
 396       * Handles the checkbox column output.
 397       *
 398       * @since 4.3.0
 399       * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
 400       *
 401       * @param array $item Current site.
 402       */
 403  	public function column_cb( $item ) {
 404          // Restores the more descriptive, specific name for use within this method.
 405          $blog = $item;
 406  
 407          if ( ! is_main_site( $blog['blog_id'] ) ) :
 408              $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 409              ?>
 410              <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>">
 411                  <?php
 412                  /* translators: %s: Site URL. */
 413                  printf( __( 'Select %s' ), $blogname );
 414                  ?>
 415              </label>
 416              <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
 417              <?php
 418          endif;
 419      }
 420  
 421      /**
 422       * Handles the ID column output.
 423       *
 424       * @since 4.4.0
 425       *
 426       * @param array $blog Current site.
 427       */
 428  	public function column_id( $blog ) {
 429          echo $blog['blog_id'];
 430      }
 431  
 432      /**
 433       * Handles the site name column output.
 434       *
 435       * @since 4.3.0
 436       *
 437       * @global string $mode List table view mode.
 438       *
 439       * @param array $blog Current site.
 440       */
 441  	public function column_blogname( $blog ) {
 442          global $mode;
 443  
 444          $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 445  
 446          ?>
 447          <strong>
 448              <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
 449              <?php $this->site_states( $blog ); ?>
 450          </strong>
 451          <?php
 452          if ( 'list' !== $mode ) {
 453              switch_to_blog( $blog['blog_id'] );
 454              echo '<p>';
 455              printf(
 456                  /* translators: 1: Site title, 2: Site tagline. */
 457                  __( '%1$s &#8211; %2$s' ),
 458                  get_option( 'blogname' ),
 459                  '<em>' . get_option( 'blogdescription' ) . '</em>'
 460              );
 461              echo '</p>';
 462              restore_current_blog();
 463          }
 464      }
 465  
 466      /**
 467       * Handles the lastupdated column output.
 468       *
 469       * @since 4.3.0
 470       *
 471       * @global string $mode List table view mode.
 472       *
 473       * @param array $blog Current site.
 474       */
 475  	public function column_lastupdated( $blog ) {
 476          global $mode;
 477  
 478          if ( 'list' === $mode ) {
 479              $date = __( 'Y/m/d' );
 480          } else {
 481              $date = __( 'Y/m/d g:i:s a' );
 482          }
 483  
 484          echo ( '0000-00-00 00:00:00' === $blog['last_updated'] ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
 485      }
 486  
 487      /**
 488       * Handles the registered column output.
 489       *
 490       * @since 4.3.0
 491       *
 492       * @global string $mode List table view mode.
 493       *
 494       * @param array $blog Current site.
 495       */
 496  	public function column_registered( $blog ) {
 497          global $mode;
 498  
 499          if ( 'list' === $mode ) {
 500              $date = __( 'Y/m/d' );
 501          } else {
 502              $date = __( 'Y/m/d g:i:s a' );
 503          }
 504  
 505          if ( '0000-00-00 00:00:00' === $blog['registered'] ) {
 506              echo '&#x2014;';
 507          } else {
 508              echo mysql2date( $date, $blog['registered'] );
 509          }
 510      }
 511  
 512      /**
 513       * Handles the users column output.
 514       *
 515       * @since 4.3.0
 516       *
 517       * @param array $blog Current site.
 518       */
 519  	public function column_users( $blog ) {
 520          $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
 521          if ( ! $user_count ) {
 522              $blog_users = new WP_User_Query(
 523                  array(
 524                      'blog_id'     => $blog['blog_id'],
 525                      'fields'      => 'ID',
 526                      'number'      => 1,
 527                      'count_total' => true,
 528                  )
 529              );
 530              $user_count = $blog_users->get_total();
 531              wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
 532          }
 533  
 534          printf(
 535              '<a href="%s">%s</a>',
 536              esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
 537              number_format_i18n( $user_count )
 538          );
 539      }
 540  
 541      /**
 542       * Handles the plugins column output.
 543       *
 544       * @since 4.3.0
 545       *
 546       * @param array $blog Current site.
 547       */
 548  	public function column_plugins( $blog ) {
 549          if ( has_filter( 'wpmublogsaction' ) ) {
 550              /**
 551               * Fires inside the auxiliary 'Actions' column of the Sites list table.
 552               *
 553               * By default this column is hidden unless something is hooked to the action.
 554               *
 555               * @since MU (3.0.0)
 556               *
 557               * @param int $blog_id The site ID.
 558               */
 559              do_action( 'wpmublogsaction', $blog['blog_id'] );
 560          }
 561      }
 562  
 563      /**
 564       * Handles output for the default column.
 565       *
 566       * @since 4.3.0
 567       * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
 568       *
 569       * @param array  $item        Current site.
 570       * @param string $column_name Current column name.
 571       */
 572  	public function column_default( $item, $column_name ) {
 573          /**
 574           * Fires for each registered custom column in the Sites list table.
 575           *
 576           * @since 3.1.0
 577           *
 578           * @param string $column_name The name of the column to display.
 579           * @param int    $blog_id     The site ID.
 580           */
 581          do_action( 'manage_sites_custom_column', $column_name, $item['blog_id'] );
 582      }
 583  
 584      /**
 585       * @global string $mode List table view mode.
 586       */
 587  	public function display_rows() {
 588          foreach ( $this->items as $blog ) {
 589              $blog  = $blog->to_array();
 590              $class = '';
 591              reset( $this->status_list );
 592  
 593              foreach ( $this->status_list as $status => $col ) {
 594                  if ( 1 == $blog[ $status ] ) {
 595                      $class = " class='{$col[0]}'";
 596                  }
 597              }
 598  
 599              echo "<tr{$class}>";
 600  
 601              $this->single_row_columns( $blog );
 602  
 603              echo '</tr>';
 604          }
 605      }
 606  
 607      /**
 608       * Maybe output comma-separated site states.
 609       *
 610       * @since 5.3.0
 611       *
 612       * @param array $site
 613       */
 614  	protected function site_states( $site ) {
 615          $site_states = array();
 616  
 617          // $site is still an array, so get the object.
 618          $_site = WP_Site::get_instance( $site['blog_id'] );
 619  
 620          if ( is_main_site( $_site->id ) ) {
 621              $site_states['main'] = __( 'Main' );
 622          }
 623  
 624          reset( $this->status_list );
 625  
 626          $site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
 627          foreach ( $this->status_list as $status => $col ) {
 628              if ( ( 1 === (int) $_site->{$status} ) && ( $site_status !== $status ) ) {
 629                  $site_states[ $col[0] ] = $col[1];
 630              }
 631          }
 632  
 633          /**
 634           * Filters the default site display states for items in the Sites list table.
 635           *
 636           * @since 5.3.0
 637           *
 638           * @param string[] $site_states An array of site states. Default 'Main',
 639           *                              'Archived', 'Mature', 'Spam', 'Deleted'.
 640           * @param WP_Site  $site        The current site object.
 641           */
 642          $site_states = apply_filters( 'display_site_states', $site_states, $_site );
 643  
 644          if ( ! empty( $site_states ) ) {
 645              $state_count = count( $site_states );
 646  
 647              $i = 0;
 648  
 649              echo ' &mdash; ';
 650  
 651              foreach ( $site_states as $state ) {
 652                  ++$i;
 653  
 654                  $sep = ( $i < $state_count ) ? ', ' : '';
 655  
 656                  echo "<span class='post-state'>{$state}{$sep}</span>";
 657              }
 658          }
 659      }
 660  
 661      /**
 662       * Gets the name of the default primary column.
 663       *
 664       * @since 4.3.0
 665       *
 666       * @return string Name of the default primary column, in this case, 'blogname'.
 667       */
 668  	protected function get_default_primary_column_name() {
 669          return 'blogname';
 670      }
 671  
 672      /**
 673       * Generates and displays row action links.
 674       *
 675       * @since 4.3.0
 676       * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
 677       *
 678       * @param array  $item        Site being acted upon.
 679       * @param string $column_name Current column name.
 680       * @param string $primary     Primary column name.
 681       * @return string Row actions output for sites in Multisite, or an empty string
 682       *                if the current column is not the primary column.
 683       */
 684  	protected function handle_row_actions( $item, $column_name, $primary ) {
 685          if ( $primary !== $column_name ) {
 686              return '';
 687          }
 688  
 689          // Restores the more descriptive, specific name for use within this method.
 690          $blog     = $item;
 691          $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 692  
 693          // Preordered.
 694          $actions = array(
 695              'edit'       => '',
 696              'backend'    => '',
 697              'activate'   => '',
 698              'deactivate' => '',
 699              'archive'    => '',
 700              'unarchive'  => '',
 701              'spam'       => '',
 702              'unspam'     => '',
 703              'delete'     => '',
 704              'visit'      => '',
 705          );
 706  
 707          $actions['edit']    = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
 708          $actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
 709          if ( get_network()->site_id != $blog['blog_id'] ) {
 710              if ( '1' == $blog['deleted'] ) {
 711                  $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>';
 712              } else {
 713                  $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>';
 714              }
 715  
 716              if ( '1' == $blog['archived'] ) {
 717                  $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>';
 718              } else {
 719                  $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>';
 720              }
 721  
 722              if ( '1' == $blog['spam'] ) {
 723                  $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>';
 724              } else {
 725                  $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>';
 726              }
 727  
 728              if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
 729                  $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>';
 730              }
 731          }
 732  
 733          $actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
 734  
 735          /**
 736           * Filters the action links displayed for each site in the Sites list table.
 737           *
 738           * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
 739           * default for each site. The site's status determines whether to show the
 740           * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
 741           * 'Not Spam' or 'Spam' link for each site.
 742           *
 743           * @since 3.1.0
 744           *
 745           * @param string[] $actions  An array of action links to be displayed.
 746           * @param int      $blog_id  The site ID.
 747           * @param string   $blogname Site path, formatted depending on whether it is a sub-domain
 748           *                           or subdirectory multisite installation.
 749           */
 750          $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
 751  
 752          return $this->row_actions( $actions );
 753      }
 754  }


Generated: Fri Apr 19 01:00:02 2024 Cross-referenced by PHPXref 0.7.1