~canonical-sysadmins/wordpress/4.8.3

« back to all changes in this revision

Viewing changes to wp-admin/includes/class-wp-ms-sites-list-table.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
class WP_MS_Sites_List_Table extends WP_List_Table {
11
11
 
12
12
        /**
 
13
         * Site status list.
 
14
         *
 
15
         * @since 4.3.0
 
16
         * @access public
 
17
         * @var array
 
18
         */
 
19
        public $status_list;
 
20
 
 
21
        /**
13
22
         * Constructor.
14
23
         *
15
24
         * @since 3.1.0
20
29
         * @param array $args An associative array of arguments.
21
30
         */
22
31
        public function __construct( $args = array() ) {
 
32
                $this->status_list = array(
 
33
                        'archived' => array( 'site-archived', __( 'Archived' ) ),
 
34
                        'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
 
35
                        'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
 
36
                        'mature'   => array( 'site-mature', __( 'Mature' ) )
 
37
                );
 
38
 
23
39
                parent::__construct( array(
24
40
                        'plural' => 'sites',
25
41
                        'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
26
42
                ) );
27
43
        }
28
44
 
 
45
        /**
 
46
         *
 
47
         * @return bool
 
48
         */
29
49
        public function ajax_user_can() {
30
50
                return current_user_can( 'manage_sites' );
31
51
        }
32
52
 
 
53
        /**
 
54
         *
 
55
         * @global string $s
 
56
         * @global string $mode
 
57
         * @global wpdb   $wpdb
 
58
         */
33
59
        public function prepare_items() {
34
60
                global $s, $mode, $wpdb;
35
61
 
101
127
                } elseif ( $order_by == 'lastupdated' ) {
102
128
                        $query .= ' ORDER BY last_updated ';
103
129
                } elseif ( $order_by == 'blogname' ) {
104
 
                        if ( is_subdomain_install() )
 
130
                        if ( is_subdomain_install() ) {
105
131
                                $query .= ' ORDER BY domain ';
106
 
                        else
 
132
                        } else {
107
133
                                $query .= ' ORDER BY path ';
 
134
                        }
108
135
                } elseif ( $order_by == 'blog_id' ) {
109
136
                        $query .= ' ORDER BY blog_id ';
110
137
                } else {
132
159
                ) );
133
160
        }
134
161
 
 
162
        /**
 
163
         * @access public
 
164
         */
135
165
        public function no_items() {
136
166
                _e( 'No sites found.' );
137
167
        }
138
168
 
 
169
        /**
 
170
         *
 
171
         * @return array
 
172
         */
139
173
        protected function get_bulk_actions() {
140
174
                $actions = array();
141
175
                if ( current_user_can( 'delete_sites' ) )
147
181
        }
148
182
 
149
183
        /**
 
184
         * @global string $mode
 
185
         *
150
186
         * @param string $which
151
187
         */
152
188
        protected function pagination( $which ) {
158
194
                        $this->view_switcher( $mode );
159
195
        }
160
196
 
 
197
        /**
 
198
         * @return array
 
199
         */
161
200
        public function get_columns() {
162
 
                $blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
163
201
                $sites_columns = array(
164
202
                        'cb'          => '<input type="checkbox" />',
165
 
                        'blogname'    => $blogname_columns,
 
203
                        'blogname'    => __( 'URL' ),
166
204
                        'lastupdated' => __( 'Last Updated' ),
167
205
                        'registered'  => _x( 'Registered', 'site' ),
168
 
                        'users'       => __( 'Users' )
 
206
                        'users'       => __( 'Users' ),
169
207
                );
170
208
 
171
 
                if ( has_filter( 'wpmublogsaction' ) )
 
209
                if ( has_filter( 'wpmublogsaction' ) ) {
172
210
                        $sites_columns['plugins'] = __( 'Actions' );
 
211
                }
173
212
 
174
213
                /**
175
214
                 * Filter the displayed site columns in Sites list table.
179
218
                 * @param array $sites_columns An array of displayed site columns. Default 'cb',
180
219
                 *                             'blogname', 'lastupdated', 'registered', 'users'.
181
220
                 */
182
 
                $sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns );
183
 
 
184
 
                return $sites_columns;
 
221
                return apply_filters( 'wpmu_blogs_columns', $sites_columns );
185
222
        }
186
223
 
 
224
        /**
 
225
         * @return array
 
226
         */
187
227
        protected function get_sortable_columns() {
188
228
                return array(
189
229
                        'blogname'    => 'blogname',
192
232
                );
193
233
        }
194
234
 
 
235
        /**
 
236
         * Handles the checkbox column output.
 
237
         *
 
238
         * @since 4.3.0
 
239
         * @access public
 
240
         *
 
241
         * @param array $blog Current site.
 
242
         */
 
243
        public function column_cb( $blog ) {
 
244
                if ( ! is_main_site( $blog['blog_id'] ) ) :
 
245
                        $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 
246
                ?>
 
247
                        <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php
 
248
                                printf( __( 'Select %s' ), $blogname );
 
249
                        ?></label>
 
250
                        <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
 
251
                <?php endif;
 
252
        }
 
253
 
 
254
        /**
 
255
         * Handles the blogname column output.
 
256
         *
 
257
         * @since 4.3.0
 
258
         * @access public
 
259
         *
 
260
         * @global string $mode
 
261
         *
 
262
         * @param array $blog Current blog.
 
263
         */
 
264
        public function column_blogname( $blog ) {
 
265
                global $mode;
 
266
 
 
267
                $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 
268
                $blog_states = array();
 
269
                reset( $this->status_list );
 
270
 
 
271
                foreach ( $this->status_list as $status => $col ) {
 
272
                        if ( $blog[ $status ] == 1 ) {
 
273
                                $blog_states[] = $col[1];
 
274
                        }
 
275
                }
 
276
                $blog_state = '';
 
277
                if ( ! empty( $blog_states ) ) {
 
278
                        $state_count = count( $blog_states );
 
279
                        $i = 0;
 
280
                        $blog_state .= ' - ';
 
281
                        foreach ( $blog_states as $state ) {
 
282
                                ++$i;
 
283
                                $sep = ( $i == $state_count ) ? '' : ', ';
 
284
                                $blog_state .= "<span class='post-state'>$state$sep</span>";
 
285
                        }
 
286
                }
 
287
 
 
288
                ?>
 
289
                <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
 
290
                <?php
 
291
                if ( 'list' !== $mode ) {
 
292
                        switch_to_blog( $blog['blog_id'] );
 
293
                        /* translators: 1: site name, 2: site tagline. */
 
294
                        echo '<p>' . sprintf( __( '%1$s &#8211; <em>%2$s</em>' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>';
 
295
                        restore_current_blog();
 
296
                }
 
297
        }
 
298
 
 
299
        /**
 
300
         * Handles the lastupdated column output.
 
301
         *
 
302
         * @since 4.3.0
 
303
         * @access public
 
304
         *
 
305
         * @param array $blog Current site.
 
306
         */
 
307
        public function column_lastupdated( $blog ) {
 
308
                global $mode;
 
309
 
 
310
                if ( 'list' == $mode ) {
 
311
                        $date = __( 'Y/m/d' );
 
312
                } else {
 
313
                        $date = __( 'Y/m/d g:i:s a' );
 
314
                }
 
315
 
 
316
                echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
 
317
        }
 
318
 
 
319
        /**
 
320
         * Handles the registered column output.
 
321
         *
 
322
         * @since 4.3.0
 
323
         * @access public
 
324
         *
 
325
         * @param array $blog Current site.
 
326
         */
 
327
        public function column_registered( $blog ) {
 
328
                global $mode;
 
329
 
 
330
                if ( 'list' == $mode ) {
 
331
                        $date = __( 'Y/m/d' );
 
332
                } else {
 
333
                        $date = __( 'Y/m/d g:i:s a' );
 
334
                }
 
335
 
 
336
                if ( $blog['registered'] == '0000-00-00 00:00:00' ) {
 
337
                        echo '&#x2014;';
 
338
                } else {
 
339
                        echo mysql2date( $date, $blog['registered'] );
 
340
                }
 
341
        }
 
342
 
 
343
        /**
 
344
         * Handles the users column output.
 
345
         *
 
346
         * @since 4.3.0
 
347
         * @access public
 
348
         *
 
349
         * @param array $blog Current site.
 
350
         */
 
351
        public function column_users( $blog ) {
 
352
                $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
 
353
                if ( ! $user_count ) {
 
354
                        $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) );
 
355
                        $user_count = count( $blog_users );
 
356
                        unset( $blog_users );
 
357
                        wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
 
358
                }
 
359
 
 
360
                printf(
 
361
                        '<a href="%s">%s</a>',
 
362
                        esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
 
363
                        number_format_i18n( $user_count )
 
364
                );
 
365
        }
 
366
 
 
367
        /**
 
368
         * Handles the plugins column output.
 
369
         *
 
370
         * @since 4.3.0
 
371
         * @access public
 
372
         *
 
373
         * @param array $blog Current site.
 
374
         */
 
375
        public function column_plugins( $blog ) {
 
376
                if ( has_filter( 'wpmublogsaction' ) ) {
 
377
                        /**
 
378
                         * Fires inside the auxiliary 'Actions' column of the Sites list table.
 
379
                         *
 
380
                         * By default this column is hidden unless something is hooked to the action.
 
381
                         *
 
382
                         * @since MU
 
383
                         *
 
384
                         * @param int $blog_id The site ID.
 
385
                         */
 
386
                        do_action( 'wpmublogsaction', $blog['blog_id'] );
 
387
                }
 
388
        }
 
389
 
 
390
        /**
 
391
         * Handles output for the default column.
 
392
         *
 
393
         * @since 4.3.0
 
394
         * @access public
 
395
         *
 
396
         * @param array  $blog        Current site.
 
397
         * @param string $column_name Current column name.
 
398
         */
 
399
        public function column_default( $blog, $column_name ) {
 
400
                /**
 
401
                 * Fires for each registered custom column in the Sites list table.
 
402
                 *
 
403
                 * @since 3.1.0
 
404
                 *
 
405
                 * @param string $column_name The name of the column to display.
 
406
                 * @param int    $blog_id     The site ID.
 
407
                 */
 
408
                do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
 
409
        }
 
410
 
 
411
        /**
 
412
         *
 
413
         * @global string $mode
 
414
         */
195
415
        public function display_rows() {
196
 
                global $mode;
197
 
 
198
 
                $status_list = array(
199
 
                        'archived' => array( 'site-archived', __( 'Archived' ) ),
200
 
                        'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
201
 
                        'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
202
 
                        'mature'   => array( 'site-mature', __( 'Mature' ) )
203
 
                );
204
 
 
205
 
                if ( 'list' == $mode ) {
206
 
                        $date = __( 'Y/m/d' );
207
 
                } else {
208
 
                        $date = __( 'Y/m/d g:i:s a' );
209
 
                }
210
 
 
211
416
                foreach ( $this->items as $blog ) {
212
417
                        $class = '';
213
 
                        reset( $status_list );
 
418
                        reset( $this->status_list );
214
419
 
215
 
                        $blog_states = array();
216
 
                        foreach ( $status_list as $status => $col ) {
217
 
                                if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
 
420
                        foreach ( $this->status_list as $status => $col ) {
 
421
                                if ( $blog[ $status ] == 1 ) {
218
422
                                        $class = " class='{$col[0]}'";
219
 
                                        $blog_states[] = $col[1];
220
 
                                }
221
 
                        }
222
 
                        $blog_state = '';
223
 
                        if ( ! empty( $blog_states ) ) {
224
 
                                $state_count = count( $blog_states );
225
 
                                $i = 0;
226
 
                                $blog_state .= ' - ';
227
 
                                foreach ( $blog_states as $state ) {
228
 
                                        ++$i;
229
 
                                        ( $i == $state_count ) ? $sep = '' : $sep = ', ';
230
 
                                        $blog_state .= "<span class='post-state'>$state$sep</span>";
231
 
                                }
232
 
                        }
 
423
                                }
 
424
                        }
 
425
 
233
426
                        echo "<tr{$class}>";
234
427
 
235
 
                        $blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
236
 
 
237
 
                        list( $columns, $hidden ) = $this->get_column_info();
238
 
 
239
 
                        foreach ( $columns as $column_name => $column_display_name ) {
240
 
                                $style = '';
241
 
                                if ( in_array( $column_name, $hidden ) )
242
 
                                        $style = ' style="display:none;"';
243
 
 
244
 
                                switch ( $column_name ) {
245
 
                                        case 'cb': ?>
246
 
                                                <th scope="row" class="check-column">
247
 
                                                        <?php if ( ! is_main_site( $blog['blog_id'] ) ) : ?>
248
 
                                                        <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php printf( __( 'Select %s' ), $blogname ); ?></label>
249
 
                                                        <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
250
 
                                                        <?php endif; ?>
251
 
                                                </th>
252
 
                                        <?php
253
 
                                        break;
254
 
 
255
 
                                        case 'id':?>
256
 
                                                <th scope="row">
257
 
                                                        <?php echo $blog['blog_id'] ?>
258
 
                                                </th>
259
 
                                        <?php
260
 
                                        break;
261
 
 
262
 
                                        case 'blogname':
263
 
                                                echo "<td class='column-$column_name $column_name'$style>"; ?>
264
 
                                                        <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
265
 
                                                        <?php
266
 
                                                        if ( 'list' != $mode ) {
267
 
                                                                switch_to_blog( $blog['blog_id'] );
268
 
                                                                echo '<p>' . sprintf( _x( '%1$s &#8211; <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>';
269
 
                                                                restore_current_blog();
270
 
                                                        }
271
 
 
272
 
                                                        // Preordered.
273
 
                                                        $actions = array(
274
 
                                                                'edit' => '', 'backend' => '',
275
 
                                                                'activate' => '', 'deactivate' => '',
276
 
                                                                'archive' => '', 'unarchive' => '',
277
 
                                                                'spam' => '', 'unspam' => '',
278
 
                                                                'delete' => '',
279
 
                                                                'visit' => '',
280
 
                                                        );
281
 
 
282
 
                                                        $actions['edit']        = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
283
 
                                                        $actions['backend']     = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
284
 
                                                        if ( get_current_site()->blog_id != $blog['blog_id'] ) {
285
 
                                                                if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
286
 
                                                                        $actions['activate']    = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
287
 
                                                                else
288
 
                                                                        $actions['deactivate']  = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>';
289
 
 
290
 
                                                                if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
291
 
                                                                        $actions['unarchive']   = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>';
292
 
                                                                else
293
 
                                                                        $actions['archive']     = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
294
 
 
295
 
                                                                if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
296
 
                                                                        $actions['unspam']      = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
297
 
                                                                else
298
 
                                                                        $actions['spam']        = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
299
 
 
300
 
                                                                if ( current_user_can( 'delete_site', $blog['blog_id'] ) )
301
 
                                                                        $actions['delete']      = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>';
302
 
                                                        }
303
 
 
304
 
                                                        $actions['visit']       = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
305
 
 
306
 
                                                        /**
307
 
                                                         * Filter the action links displayed for each site in the Sites list table.
308
 
                                                         *
309
 
                                                         * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
310
 
                                                         * default for each site. The site's status determines whether to show the
311
 
                                                         * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
312
 
                                                         * 'Not Spam' or 'Spam' link for each site.
313
 
                                                         *
314
 
                                                         * @since 3.1.0
315
 
                                                         *
316
 
                                                         * @param array  $actions  An array of action links to be displayed.
317
 
                                                         * @param int    $blog_id  The site ID.
318
 
                                                         * @param string $blogname Site path, formatted depending on whether it is a sub-domain
319
 
                                                         *                         or subdirectory multisite install.
320
 
                                                         */
321
 
                                                        $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
322
 
                                                        echo $this->row_actions( $actions );
323
 
                                        ?>
324
 
                                                </td>
325
 
                                        <?php
326
 
                                        break;
327
 
 
328
 
                                        case 'lastupdated':
329
 
                                                echo "<td class='$column_name column-$column_name'$style>";
330
 
                                                        echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?>
331
 
                                                </td>
332
 
                                        <?php
333
 
                                        break;
334
 
                                case 'registered':
335
 
                                                echo "<td class='$column_name column-$column_name'$style>";
336
 
                                                if ( $blog['registered'] == '0000-00-00 00:00:00' )
337
 
                                                        echo '&#x2014;';
338
 
                                                else
339
 
                                                        echo mysql2date( $date, $blog['registered'] );
340
 
                                                ?>
341
 
                                                </td>
342
 
                                        <?php
343
 
                                        break;
344
 
                                case 'users':
345
 
                                                echo "<td class='$column_name column-$column_name'$style>";
346
 
                                                        $blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) );
347
 
                                                        if ( is_array( $blogusers ) ) {
348
 
                                                                $blogusers_warning = '';
349
 
                                                                if ( count( $blogusers ) > 5 ) {
350
 
                                                                        $blogusers = array_slice( $blogusers, 0, 5 );
351
 
                                                                        $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'More' ) . '</a>';
352
 
                                                                }
353
 
                                                                foreach ( $blogusers as $user_object ) {
354
 
                                                                        echo '<a href="' . esc_url( network_admin_url( 'user-edit.php?user_id=' . $user_object->ID ) ) . '">' . esc_html( $user_object->user_login ) . '</a> ';
355
 
                                                                        if ( 'list' != $mode )
356
 
                                                                                echo '( ' . $user_object->user_email . ' )';
357
 
                                                                        echo '<br />';
358
 
                                                                }
359
 
                                                                if ( $blogusers_warning != '' )
360
 
                                                                        echo '<strong>' . $blogusers_warning . '</strong><br />';
361
 
                                                        }
362
 
                                                        ?>
363
 
                                                </td>
364
 
                                        <?php
365
 
                                        break;
366
 
 
367
 
                                case 'plugins': ?>
368
 
                                        <?php if ( has_filter( 'wpmublogsaction' ) ) {
369
 
                                        echo "<td class='$column_name column-$column_name'$style>";
370
 
                                                /**
371
 
                                                 * Fires inside the auxiliary 'Actions' column of the Sites list table.
372
 
                                                 *
373
 
                                                 * By default this column is hidden unless something is hooked to the action.
374
 
                                                 *
375
 
                                                 * @since MU
376
 
                                                 *
377
 
                                                 * @param int $blog_id The site ID.
378
 
                                                 */
379
 
                                                do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
380
 
                                        </td>
381
 
                                        <?php }
382
 
                                        break;
383
 
 
384
 
                                default:
385
 
                                        echo "<td class='$column_name column-$column_name'$style>";
386
 
                                        /**
387
 
                                         * Fires for each registered custom column in the Sites list table.
388
 
                                         *
389
 
                                         * @since 3.1.0
390
 
                                         *
391
 
                                         * @param string $column_name The name of the column to display.
392
 
                                         * @param int    $blog_id     The site ID.
393
 
                                         */
394
 
                                        do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
395
 
                                        echo "</td>";
396
 
                                        break;
397
 
                                }
398
 
                        }
399
 
                        ?>
400
 
                        </tr>
401
 
                        <?php
402
 
                }
 
428
                        $this->single_row_columns( $blog );
 
429
 
 
430
                        echo '</tr>';
 
431
                }
 
432
        }
 
433
 
 
434
        /**
 
435
         * Gets the name of the default primary column.
 
436
         *
 
437
         * @since 4.3.0
 
438
         * @access protected
 
439
         *
 
440
         * @return string Name of the default primary column, in this case, 'blogname'.
 
441
         */
 
442
        protected function get_default_primary_column_name() {
 
443
                return 'blogname';
 
444
        }
 
445
 
 
446
        /**
 
447
         * Generates and displays row action links.
 
448
         *
 
449
         * @since 4.3.0
 
450
         * @access protected
 
451
         *
 
452
         * @param object $blog        Blog being acted upon.
 
453
         * @param string $column_name Current column name.
 
454
         * @param string $primary     Primary column name.
 
455
         * @return string Row actions output.
 
456
         */
 
457
        protected function handle_row_actions( $blog, $column_name, $primary ) {
 
458
                if ( $primary !== $column_name ) {
 
459
                        return;
 
460
                }
 
461
 
 
462
                $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
 
463
 
 
464
                // Preordered.
 
465
                $actions = array(
 
466
                        'edit' => '', 'backend' => '',
 
467
                        'activate' => '', 'deactivate' => '',
 
468
                        'archive' => '', 'unarchive' => '',
 
469
                        'spam' => '', 'unspam' => '',
 
470
                        'delete' => '',
 
471
                        'visit' => '',
 
472
                );
 
473
 
 
474
                $actions['edit']        = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
 
475
                $actions['backend']     = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
 
476
                if ( get_current_site()->blog_id != $blog['blog_id'] ) {
 
477
                        if ( $blog['deleted'] == '1' ) {
 
478
                                $actions['activate']   = '<span class="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></span>';
 
479
                        } else {
 
480
                                $actions['deactivate'] = '<span class="activate"><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></span>';
 
481
                        }
 
482
 
 
483
                        if ( $blog['archived'] == '1' ) {
 
484
                                $actions['unarchive'] = '<span class="archive"><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></span>';
 
485
                        } else {
 
486
                                $actions['archive']   = '<span class="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></span>';
 
487
                        }
 
488
 
 
489
                        if ( $blog['spam'] == '1' ) {
 
490
                                $actions['unspam'] = '<span class="spam"><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></span>';
 
491
                        } else {
 
492
                                $actions['spam']   = '<span class="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></span>';
 
493
                        }
 
494
 
 
495
                        if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
 
496
                                $actions['delete'] = '<span class="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></span>';
 
497
                        }
 
498
                }
 
499
 
 
500
                $actions['visit']       = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
 
501
 
 
502
                /**
 
503
                 * Filter the action links displayed for each site in the Sites list table.
 
504
                 *
 
505
                 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
 
506
                 * default for each site. The site's status determines whether to show the
 
507
                 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
 
508
                 * 'Not Spam' or 'Spam' link for each site.
 
509
                 *
 
510
                 * @since 3.1.0
 
511
                 *
 
512
                 * @param array  $actions  An array of action links to be displayed.
 
513
                 * @param int    $blog_id  The site ID.
 
514
                 * @param string $blogname Site path, formatted depending on whether it is a sub-domain
 
515
                 *                         or subdirectory multisite install.
 
516
                 */
 
517
                $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
 
518
                return $this->row_actions( $actions );
403
519
        }
404
520
}