jetpack
Last commit date
3rd-party
6 years ago
_inc
6 years ago
bin
6 years ago
css
6 years ago
extensions
6 years ago
images
7 years ago
json-endpoints
6 years ago
languages
6 years ago
logs
9 years ago
modules
6 years ago
sal
6 years ago
src
6 years ago
sync
6 years ago
vendor
6 years ago
views
7 years ago
wp-cli-templates
7 years ago
.svnignore
12 years ago
CODE-OF-CONDUCT.md
9 years ago
changelog.txt
6 years ago
class.frame-nonce-preview.php
9 years ago
class.jetpack-admin.php
7 years ago
class.jetpack-affiliate.php
7 years ago
class.jetpack-autoupdate.php
7 years ago
class.jetpack-bbpress-json-api-compat.php
9 years ago
class.jetpack-cli.php
6 years ago
class.jetpack-client-server.php
6 years ago
class.jetpack-client.php
6 years ago
class.jetpack-connection-banner.php
6 years ago
class.jetpack-constants.php
6 years ago
class.jetpack-data.php
6 years ago
class.jetpack-debugger.php
7 years ago
class.jetpack-error.php
10 years ago
class.jetpack-gutenberg.php
6 years ago
class.jetpack-heartbeat.php
7 years ago
class.jetpack-idc.php
6 years ago
class.jetpack-ixr-client.php
6 years ago
class.jetpack-jitm.php
6 years ago
class.jetpack-modules-list-table.php
6 years ago
class.jetpack-network-sites-list-table.php
9 years ago
class.jetpack-network.php
6 years ago
class.jetpack-options.php
6 years ago
class.jetpack-plan.php
6 years ago
class.jetpack-post-images.php
7 years ago
class.jetpack-signature.php
6 years ago
class.jetpack-tracks.php
6 years ago
class.jetpack-twitter-cards.php
7 years ago
class.jetpack-user-agent.php
7 years ago
class.jetpack-xmlrpc-server.php
6 years ago
class.jetpack.php
6 years ago
class.json-api-endpoints.php
6 years ago
class.json-api.php
7 years ago
class.photon.php
6 years ago
composer.json
6 years ago
functions.compat.php
6 years ago
functions.gallery.php
6 years ago
functions.global.php
6 years ago
functions.opengraph.php
7 years ago
functions.photon.php
6 years ago
jest.config.js
7 years ago
jetpack.php
6 years ago
json-api-config.php
10 years ago
json-endpoints.php
7 years ago
load-jetpack.php
6 years ago
locales.php
7 years ago
readme.txt
6 years ago
require-lib.php
6 years ago
uninstall.php
6 years ago
wpml-config.xml
10 years ago
class.jetpack-network-sites-list-table.php
149 lines
| 1 | <?php |
| 2 | |
| 3 | if( ! class_exists( 'WP_List_Table' ) ) { |
| 4 | require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
| 5 | } |
| 6 | |
| 7 | class Jetpack_Network_Sites_List_Table extends WP_List_Table { |
| 8 | |
| 9 | |
| 10 | public function get_columns() { |
| 11 | // site name, status, username connected under |
| 12 | $columns = array( |
| 13 | 'cb' => '<input type="checkbox" />', |
| 14 | 'blogname' => __( 'Site Name', 'jetpack' ), |
| 15 | 'blog_path' => __( 'Path', 'jetpack' ), |
| 16 | 'connected' => __( 'Connected', 'jetpack' ), |
| 17 | ); |
| 18 | |
| 19 | return $columns; |
| 20 | } |
| 21 | |
| 22 | public function prepare_items() { |
| 23 | $jpms = Jetpack_Network::init(); |
| 24 | |
| 25 | // Deal with bulk actions if any were requested by the user |
| 26 | $this->process_bulk_action(); |
| 27 | |
| 28 | $sites = get_sites( array( |
| 29 | 'site__not_in' => array( get_current_blog_id() ), |
| 30 | 'archived' => false, |
| 31 | 'number' => 0, |
| 32 | ) ); |
| 33 | |
| 34 | // Setup pagination |
| 35 | $per_page = 25; |
| 36 | $current_page = $this->get_pagenum(); |
| 37 | $total_items = count( $sites ); |
| 38 | $sites = array_slice( $sites, ( ( $current_page-1 ) * $per_page ), $per_page ); |
| 39 | $this->set_pagination_args( array( |
| 40 | 'total_items' => $total_items, |
| 41 | 'per_page' => $per_page |
| 42 | ) ); |
| 43 | |
| 44 | $columns = $this->get_columns(); |
| 45 | $hidden = array(); |
| 46 | $sortable = array(); |
| 47 | $this->_column_headers = array( $columns, $hidden, $sortable ); |
| 48 | $this->items = $sites; |
| 49 | } |
| 50 | |
| 51 | public function column_blogname( $item ) { |
| 52 | // http://jpms/wp-admin/network/site-info.php?id=1 |
| 53 | switch_to_blog( $item->blog_id ); |
| 54 | $jp_url = admin_url( 'admin.php?page=jetpack' ); |
| 55 | restore_current_blog(); |
| 56 | |
| 57 | $actions = array( |
| 58 | 'edit' => '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $item->blog_id ) ) . '">' . esc_html__( 'Edit', 'jetpack' ) . '</a>', |
| 59 | 'dashboard' => '<a href="' . esc_url( get_admin_url( $item->blog_id, '', 'admin' ) ) . '">' . esc_html__( 'Dashboard', 'jetpack' ) . '</a>', |
| 60 | 'view' => '<a href="' . esc_url( get_site_url( $item->blog_id, '', 'admin' ) ) . '">' . esc_html__( 'View', 'jetpack' ) . '</a>', |
| 61 | 'jetpack-' . $item->blog_id => '<a href="' . esc_url( $jp_url ) . '">Jetpack</a>', |
| 62 | ); |
| 63 | |
| 64 | return sprintf('%1$s %2$s', '<strong>' . get_blog_option( $item->blog_id, 'blogname' ) . '</strong>', $this->row_actions($actions) ); |
| 65 | } |
| 66 | |
| 67 | public function column_blog_path( $item ) { |
| 68 | return |
| 69 | '<a href="' . |
| 70 | get_site_url( $item->blog_id, '', 'admin' ) . |
| 71 | '">' . |
| 72 | str_replace( array( 'http://', 'https://' ), '', get_site_url( $item->blog_id, '', 'admin' ) ) . |
| 73 | '</a>'; |
| 74 | } |
| 75 | |
| 76 | public function column_connected( $item ) { |
| 77 | $jpms = Jetpack_Network::init(); |
| 78 | $jp = Jetpack::init(); |
| 79 | |
| 80 | switch_to_blog( $item->blog_id ); |
| 81 | |
| 82 | if ( ! is_plugin_active( 'jetpack/jetpack.php' ) ) { |
| 83 | $title = __( 'Jetpack is not active on this site.', 'jetpack' ); |
| 84 | $action = array( |
| 85 | 'manage-plugins' => '<a href="' . get_admin_url( $item->blog_id, 'plugins.php', 'admin' ) . '">' . __( 'Manage Plugins', 'jetpack' ) . '</a>', |
| 86 | ); |
| 87 | restore_current_blog(); |
| 88 | return sprintf( '%1$s %2$s', $title, $this->row_actions( $action ) ); |
| 89 | } |
| 90 | |
| 91 | if( $jp->is_active() ) { |
| 92 | // Build url for disconnecting |
| 93 | $url = $jpms->get_url( array( |
| 94 | 'name' => 'subsitedisconnect', |
| 95 | 'site_id' => $item->blog_id, |
| 96 | |
| 97 | ) ); |
| 98 | restore_current_blog(); |
| 99 | return '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Disconnect', 'jetpack' ) . '</a>'; |
| 100 | } |
| 101 | restore_current_blog(); |
| 102 | |
| 103 | // Build URL for connecting |
| 104 | $url = $jpms->get_url( array( |
| 105 | 'name' => 'subsiteregister', |
| 106 | 'site_id' => $item->blog_id, |
| 107 | ) ); |
| 108 | return '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Connect', 'jetpack' ) . '</a>'; |
| 109 | } |
| 110 | |
| 111 | public function get_bulk_actions() { |
| 112 | $actions = array( |
| 113 | 'connect' => esc_html__( 'Connect', 'jetpack' ), |
| 114 | 'disconnect' => esc_html__( 'Disconnect', 'jetpack' ) |
| 115 | ); |
| 116 | |
| 117 | return $actions; |
| 118 | } |
| 119 | |
| 120 | function column_cb($item) { |
| 121 | return sprintf( |
| 122 | '<input type="checkbox" name="bulk[]" value="%s" />', $item->blog_id |
| 123 | ); |
| 124 | } |
| 125 | |
| 126 | public function process_bulk_action() { |
| 127 | if( !isset( $_POST['bulk'] ) || empty ( $_POST['bulk'] ) ) |
| 128 | return; // Thou shall not pass! There is nothing to do |
| 129 | |
| 130 | |
| 131 | $jpms = Jetpack_Network::init(); |
| 132 | |
| 133 | $action = $this->current_action(); |
| 134 | switch ( $action ) { |
| 135 | |
| 136 | case 'connect': |
| 137 | foreach( $_POST['bulk'] as $k => $site ) { |
| 138 | $jpms->do_subsiteregister( $site ); |
| 139 | } |
| 140 | break; |
| 141 | case 'disconnect': |
| 142 | foreach( $_POST['bulk'] as $k => $site ) { |
| 143 | $jpms->do_subsitedisconnect( $site ); |
| 144 | } |
| 145 | break; |
| 146 | } |
| 147 | } |
| 148 | } // end h |
| 149 |