angelovcom.net

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-wp-ms-sites-list-table.php (20397B)


      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 	 *
    400 	 * @param array $blog Current site.
    401 	 */
    402 	public function column_cb( $blog ) {
    403 		if ( ! is_main_site( $blog['blog_id'] ) ) :
    404 			$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
    405 			?>
    406 			<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>">
    407 				<?php
    408 				/* translators: %s: Site URL. */
    409 				printf( __( 'Select %s' ), $blogname );
    410 				?>
    411 			</label>
    412 			<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
    413 			<?php
    414 		endif;
    415 	}
    416 
    417 	/**
    418 	 * Handles the ID column output.
    419 	 *
    420 	 * @since 4.4.0
    421 	 *
    422 	 * @param array $blog Current site.
    423 	 */
    424 	public function column_id( $blog ) {
    425 		echo $blog['blog_id'];
    426 	}
    427 
    428 	/**
    429 	 * Handles the site name column output.
    430 	 *
    431 	 * @since 4.3.0
    432 	 *
    433 	 * @global string $mode List table view mode.
    434 	 *
    435 	 * @param array $blog Current site.
    436 	 */
    437 	public function column_blogname( $blog ) {
    438 		global $mode;
    439 
    440 		$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
    441 
    442 		?>
    443 		<strong>
    444 			<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
    445 			<?php $this->site_states( $blog ); ?>
    446 		</strong>
    447 		<?php
    448 		if ( 'list' !== $mode ) {
    449 			switch_to_blog( $blog['blog_id'] );
    450 			echo '<p>';
    451 			printf(
    452 				/* translators: 1: Site title, 2: Site tagline. */
    453 				__( '%1$s &#8211; %2$s' ),
    454 				get_option( 'blogname' ),
    455 				'<em>' . get_option( 'blogdescription' ) . '</em>'
    456 			);
    457 			echo '</p>';
    458 			restore_current_blog();
    459 		}
    460 	}
    461 
    462 	/**
    463 	 * Handles the lastupdated column output.
    464 	 *
    465 	 * @since 4.3.0
    466 	 *
    467 	 * @global string $mode List table view mode.
    468 	 *
    469 	 * @param array $blog Current site.
    470 	 */
    471 	public function column_lastupdated( $blog ) {
    472 		global $mode;
    473 
    474 		if ( 'list' === $mode ) {
    475 			$date = __( 'Y/m/d' );
    476 		} else {
    477 			$date = __( 'Y/m/d g:i:s a' );
    478 		}
    479 
    480 		echo ( '0000-00-00 00:00:00' === $blog['last_updated'] ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
    481 	}
    482 
    483 	/**
    484 	 * Handles the registered column output.
    485 	 *
    486 	 * @since 4.3.0
    487 	 *
    488 	 * @global string $mode List table view mode.
    489 	 *
    490 	 * @param array $blog Current site.
    491 	 */
    492 	public function column_registered( $blog ) {
    493 		global $mode;
    494 
    495 		if ( 'list' === $mode ) {
    496 			$date = __( 'Y/m/d' );
    497 		} else {
    498 			$date = __( 'Y/m/d g:i:s a' );
    499 		}
    500 
    501 		if ( '0000-00-00 00:00:00' === $blog['registered'] ) {
    502 			echo '&#x2014;';
    503 		} else {
    504 			echo mysql2date( $date, $blog['registered'] );
    505 		}
    506 	}
    507 
    508 	/**
    509 	 * Handles the users column output.
    510 	 *
    511 	 * @since 4.3.0
    512 	 *
    513 	 * @param array $blog Current site.
    514 	 */
    515 	public function column_users( $blog ) {
    516 		$user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
    517 		if ( ! $user_count ) {
    518 			$blog_users = new WP_User_Query(
    519 				array(
    520 					'blog_id'     => $blog['blog_id'],
    521 					'fields'      => 'ID',
    522 					'number'      => 1,
    523 					'count_total' => true,
    524 				)
    525 			);
    526 			$user_count = $blog_users->get_total();
    527 			wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
    528 		}
    529 
    530 		printf(
    531 			'<a href="%s">%s</a>',
    532 			esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
    533 			number_format_i18n( $user_count )
    534 		);
    535 	}
    536 
    537 	/**
    538 	 * Handles the plugins column output.
    539 	 *
    540 	 * @since 4.3.0
    541 	 *
    542 	 * @param array $blog Current site.
    543 	 */
    544 	public function column_plugins( $blog ) {
    545 		if ( has_filter( 'wpmublogsaction' ) ) {
    546 			/**
    547 			 * Fires inside the auxiliary 'Actions' column of the Sites list table.
    548 			 *
    549 			 * By default this column is hidden unless something is hooked to the action.
    550 			 *
    551 			 * @since MU (3.0.0)
    552 			 *
    553 			 * @param int $blog_id The site ID.
    554 			 */
    555 			do_action( 'wpmublogsaction', $blog['blog_id'] );
    556 		}
    557 	}
    558 
    559 	/**
    560 	 * Handles output for the default column.
    561 	 *
    562 	 * @since 4.3.0
    563 	 *
    564 	 * @param array  $blog        Current site.
    565 	 * @param string $column_name Current column name.
    566 	 */
    567 	public function column_default( $blog, $column_name ) {
    568 		/**
    569 		 * Fires for each registered custom column in the Sites list table.
    570 		 *
    571 		 * @since 3.1.0
    572 		 *
    573 		 * @param string $column_name The name of the column to display.
    574 		 * @param int    $blog_id     The site ID.
    575 		 */
    576 		do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
    577 	}
    578 
    579 	/**
    580 	 * @global string $mode List table view mode.
    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 	 * Maybe output comma-separated site states.
    604 	 *
    605 	 * @since 5.3.0
    606 	 *
    607 	 * @param array $site
    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 === (int) $_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 array $site_states An array of site states. Default 'Main',
    634 		 *                           'Archived', 'Mature', 'Spam', 'Deleted'.
    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 			$i           = 0;
    642 			echo ' &mdash; ';
    643 			foreach ( $site_states as $state ) {
    644 				++$i;
    645 				( $i == $state_count ) ? $sep = '' : $sep = ', ';
    646 				echo "<span class='post-state'>{$state}{$sep}</span>";
    647 			}
    648 		}
    649 	}
    650 
    651 	/**
    652 	 * Gets the name of the default primary column.
    653 	 *
    654 	 * @since 4.3.0
    655 	 *
    656 	 * @return string Name of the default primary column, in this case, 'blogname'.
    657 	 */
    658 	protected function get_default_primary_column_name() {
    659 		return 'blogname';
    660 	}
    661 
    662 	/**
    663 	 * Generates and displays row action links.
    664 	 *
    665 	 * @since 4.3.0
    666 	 *
    667 	 * @param array  $blog        Site being acted upon.
    668 	 * @param string $column_name Current column name.
    669 	 * @param string $primary     Primary column name.
    670 	 * @return string Row actions output for sites in Multisite, or an empty string
    671 	 *                if the current column is not the primary column.
    672 	 */
    673 	protected function handle_row_actions( $blog, $column_name, $primary ) {
    674 		if ( $primary !== $column_name ) {
    675 			return '';
    676 		}
    677 
    678 		$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
    679 
    680 		// Preordered.
    681 		$actions = array(
    682 			'edit'       => '',
    683 			'backend'    => '',
    684 			'activate'   => '',
    685 			'deactivate' => '',
    686 			'archive'    => '',
    687 			'unarchive'  => '',
    688 			'spam'       => '',
    689 			'unspam'     => '',
    690 			'delete'     => '',
    691 			'visit'      => '',
    692 		);
    693 
    694 		$actions['edit']    = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
    695 		$actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
    696 		if ( get_network()->site_id != $blog['blog_id'] ) {
    697 			if ( '1' == $blog['deleted'] ) {
    698 				$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>';
    699 			} else {
    700 				$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>';
    701 			}
    702 
    703 			if ( '1' == $blog['archived'] ) {
    704 				$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>';
    705 			} else {
    706 				$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>';
    707 			}
    708 
    709 			if ( '1' == $blog['spam'] ) {
    710 				$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>';
    711 			} else {
    712 				$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>';
    713 			}
    714 
    715 			if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
    716 				$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>';
    717 			}
    718 		}
    719 
    720 		$actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
    721 
    722 		/**
    723 		 * Filters the action links displayed for each site in the Sites list table.
    724 		 *
    725 		 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
    726 		 * default for each site. The site's status determines whether to show the
    727 		 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
    728 		 * 'Not Spam' or 'Spam' link for each site.
    729 		 *
    730 		 * @since 3.1.0
    731 		 *
    732 		 * @param string[] $actions  An array of action links to be displayed.
    733 		 * @param int      $blog_id  The site ID.
    734 		 * @param string   $blogname Site path, formatted depending on whether it is a sub-domain
    735 		 *                           or subdirectory multisite installation.
    736 		 */
    737 		$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
    738 
    739 		return $this->row_actions( $actions );
    740 	}
    741 }