108 'network_id' => get_current_network_id(), |
107 'network_id' => get_current_network_id(), |
109 ); |
108 ); |
110 |
109 |
111 if ( empty( $s ) ) { |
110 if ( empty( $s ) ) { |
112 // Nothing to do. |
111 // Nothing to do. |
113 } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) || |
112 } 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 ) || |
113 || 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 ) || |
114 || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) |
116 preg_match( '/^[0-9]{1,3}\.$/', $s ) ) { |
115 || preg_match( '/^[0-9]{1,3}\.$/', $s ) |
|
116 ) { |
117 // IPv4 address. |
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 ) ? '%' : '' ) ); |
118 $sql = $wpdb->prepare( |
|
119 "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", |
|
120 $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) |
|
121 ); |
|
122 |
119 $reg_blog_ids = $wpdb->get_col( $sql ); |
123 $reg_blog_ids = $wpdb->get_col( $sql ); |
120 |
124 |
121 if ( $reg_blog_ids ) { |
125 if ( $reg_blog_ids ) { |
122 $args['site__in'] = $reg_blog_ids; |
126 $args['site__in'] = $reg_blog_ids; |
123 } |
127 } |
260 $view_links = array(); |
264 $view_links = array(); |
261 $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : ''; |
265 $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : ''; |
262 $url = 'sites.php'; |
266 $url = 'sites.php'; |
263 |
267 |
264 foreach ( $statuses as $status => $label_count ) { |
268 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 if ( (int) $counts[ $status ] > 0 ) { |
269 $label = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) ); |
270 $label = sprintf( |
|
271 translate_nooped_plural( $label_count, $counts[ $status ] ), |
|
272 number_format_i18n( $counts[ $status ] ) |
|
273 ); |
|
274 |
270 $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url ); |
275 $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url ); |
271 |
276 |
272 $view_links[ $status ] = sprintf( |
277 $view_links[ $status ] = array( |
273 '<a href="%1$s"%2$s>%3$s</a>', |
278 'url' => esc_url( $full_url ), |
274 esc_url( $full_url ), |
279 'label' => $label, |
275 $current_link_attributes, |
280 'current' => $requested_status === $status || ( '' === $requested_status && 'all' === $status ), |
276 $label |
|
277 ); |
281 ); |
278 } |
282 } |
279 } |
283 } |
280 |
284 |
281 return $view_links; |
285 return $this->get_views_links( $view_links ); |
282 } |
286 } |
283 |
287 |
284 /** |
288 /** |
285 * @return array |
289 * @return array |
286 */ |
290 */ |
347 * Fires immediately following the closing "actions" div in the tablenav for the |
351 * Fires immediately following the closing "actions" div in the tablenav for the |
348 * MS sites list table. |
352 * MS sites list table. |
349 * |
353 * |
350 * @since 5.3.0 |
354 * @since 5.3.0 |
351 * |
355 * |
352 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. |
356 * @param string $which The location of the extra table nav markup: Either 'top' or 'bottom'. |
353 */ |
357 */ |
354 do_action( 'manage_sites_extra_tablenav', $which ); |
358 do_action( 'manage_sites_extra_tablenav', $which ); |
355 } |
359 } |
356 |
360 |
357 /** |
361 /** |
358 * @return array |
362 * @return string[] Array of column titles keyed by their column name. |
359 */ |
363 */ |
360 public function get_columns() { |
364 public function get_columns() { |
361 $sites_columns = array( |
365 $sites_columns = array( |
362 'cb' => '<input type="checkbox" />', |
366 'cb' => '<input type="checkbox" />', |
363 'blogname' => __( 'URL' ), |
367 'blogname' => __( 'URL' ), |
383 |
387 |
384 /** |
388 /** |
385 * @return array |
389 * @return array |
386 */ |
390 */ |
387 protected function get_sortable_columns() { |
391 protected function get_sortable_columns() { |
|
392 |
|
393 if ( is_subdomain_install() ) { |
|
394 $blogname_abbr = __( 'Domain' ); |
|
395 $blogname_orderby_text = __( 'Table ordered by Site Domain Name.' ); |
|
396 } else { |
|
397 $blogname_abbr = __( 'Path' ); |
|
398 $blogname_orderby_text = __( 'Table ordered by Site Path.' ); |
|
399 } |
|
400 |
388 return array( |
401 return array( |
389 'blogname' => 'blogname', |
402 'blogname' => array( 'blogname', false, $blogname_abbr, $blogname_orderby_text ), |
390 'lastupdated' => 'lastupdated', |
403 'lastupdated' => array( 'lastupdated', true, __( 'Last Updated' ), __( 'Table ordered by Last Updated.' ) ), |
391 'registered' => 'blog_id', |
404 'registered' => array( 'blog_id', true, _x( 'Registered', 'site' ), __( 'Table ordered by Site Registered Date.' ), 'desc' ), |
392 ); |
405 ); |
393 } |
406 } |
394 |
407 |
395 /** |
408 /** |
396 * Handles the checkbox column output. |
409 * Handles the checkbox column output. |
568 * |
594 * |
569 * @param array $item Current site. |
595 * @param array $item Current site. |
570 * @param string $column_name Current column name. |
596 * @param string $column_name Current column name. |
571 */ |
597 */ |
572 public function column_default( $item, $column_name ) { |
598 public function column_default( $item, $column_name ) { |
|
599 // Restores the more descriptive, specific name for use within this method. |
|
600 $blog = $item; |
|
601 |
573 /** |
602 /** |
574 * Fires for each registered custom column in the Sites list table. |
603 * Fires for each registered custom column in the Sites list table. |
575 * |
604 * |
576 * @since 3.1.0 |
605 * @since 3.1.0 |
577 * |
606 * |
578 * @param string $column_name The name of the column to display. |
607 * @param string $column_name The name of the column to display. |
579 * @param int $blog_id The site ID. |
608 * @param int $blog_id The site ID. |
580 */ |
609 */ |
581 do_action( 'manage_sites_custom_column', $column_name, $item['blog_id'] ); |
610 do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); |
582 } |
611 } |
583 |
612 |
584 /** |
613 /** |
585 * @global string $mode List table view mode. |
614 * @global string $mode List table view mode. |
586 */ |
615 */ |
702 'unspam' => '', |
732 'unspam' => '', |
703 'delete' => '', |
733 'delete' => '', |
704 'visit' => '', |
734 'visit' => '', |
705 ); |
735 ); |
706 |
736 |
707 $actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>'; |
737 $actions['edit'] = sprintf( |
708 $actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>'; |
738 '<a href="%1$s">%2$s</a>', |
709 if ( get_network()->site_id != $blog['blog_id'] ) { |
739 esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ), |
710 if ( '1' == $blog['deleted'] ) { |
740 __( 'Edit' ) |
711 $actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>'; |
741 ); |
|
742 |
|
743 $actions['backend'] = sprintf( |
|
744 '<a href="%1$s" class="edit">%2$s</a>', |
|
745 esc_url( get_admin_url( $blog['blog_id'] ) ), |
|
746 __( 'Dashboard' ) |
|
747 ); |
|
748 |
|
749 if ( ! is_main_site( $blog['blog_id'] ) ) { |
|
750 if ( '1' === $blog['deleted'] ) { |
|
751 $actions['activate'] = sprintf( |
|
752 '<a href="%1$s">%2$s</a>', |
|
753 esc_url( |
|
754 wp_nonce_url( |
|
755 network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), |
|
756 'activateblog_' . $blog['blog_id'] |
|
757 ) |
|
758 ), |
|
759 _x( 'Activate', 'site' ) |
|
760 ); |
712 } else { |
761 } else { |
713 $actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>'; |
762 $actions['deactivate'] = sprintf( |
714 } |
763 '<a href="%1$s">%2$s</a>', |
715 |
764 esc_url( |
716 if ( '1' == $blog['archived'] ) { |
765 wp_nonce_url( |
717 $actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>'; |
766 network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), |
|
767 'deactivateblog_' . $blog['blog_id'] |
|
768 ) |
|
769 ), |
|
770 __( 'Deactivate' ) |
|
771 ); |
|
772 } |
|
773 |
|
774 if ( '1' === $blog['archived'] ) { |
|
775 $actions['unarchive'] = sprintf( |
|
776 '<a href="%1$s">%2$s</a>', |
|
777 esc_url( |
|
778 wp_nonce_url( |
|
779 network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), |
|
780 'unarchiveblog_' . $blog['blog_id'] |
|
781 ) |
|
782 ), |
|
783 __( 'Unarchive' ) |
|
784 ); |
718 } else { |
785 } else { |
719 $actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>'; |
786 $actions['archive'] = sprintf( |
720 } |
787 '<a href="%1$s">%2$s</a>', |
721 |
788 esc_url( |
722 if ( '1' == $blog['spam'] ) { |
789 wp_nonce_url( |
723 $actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>'; |
790 network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), |
|
791 'archiveblog_' . $blog['blog_id'] |
|
792 ) |
|
793 ), |
|
794 _x( 'Archive', 'verb; site' ) |
|
795 ); |
|
796 } |
|
797 |
|
798 if ( '1' === $blog['spam'] ) { |
|
799 $actions['unspam'] = sprintf( |
|
800 '<a href="%1$s">%2$s</a>', |
|
801 esc_url( |
|
802 wp_nonce_url( |
|
803 network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), |
|
804 'unspamblog_' . $blog['blog_id'] |
|
805 ) |
|
806 ), |
|
807 _x( 'Not Spam', 'site' ) |
|
808 ); |
724 } else { |
809 } else { |
725 $actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>'; |
810 $actions['spam'] = sprintf( |
|
811 '<a href="%1$s">%2$s</a>', |
|
812 esc_url( |
|
813 wp_nonce_url( |
|
814 network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), |
|
815 'spamblog_' . $blog['blog_id'] |
|
816 ) |
|
817 ), |
|
818 _x( 'Spam', 'site' ) |
|
819 ); |
726 } |
820 } |
727 |
821 |
728 if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { |
822 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&action2=deleteblog&id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>'; |
823 $actions['delete'] = sprintf( |
730 } |
824 '<a href="%1$s">%2$s</a>', |
731 } |
825 esc_url( |
732 |
826 wp_nonce_url( |
733 $actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>'; |
827 network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ), |
|
828 'deleteblog_' . $blog['blog_id'] |
|
829 ) |
|
830 ), |
|
831 __( 'Delete' ) |
|
832 ); |
|
833 } |
|
834 } |
|
835 |
|
836 $actions['visit'] = sprintf( |
|
837 '<a href="%1$s" rel="bookmark">%2$s</a>', |
|
838 esc_url( get_home_url( $blog['blog_id'], '/' ) ), |
|
839 __( 'Visit' ) |
|
840 ); |
734 |
841 |
735 /** |
842 /** |
736 * Filters the action links displayed for each site in the Sites list table. |
843 * Filters the action links displayed for each site in the Sites list table. |
737 * |
844 * |
738 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by |
845 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by |