Only add the network order widget/register the route when multisite is active

This commit is contained in:
Chris Marslender 2017-11-06 09:30:44 -07:00
parent 59152d40be
commit 54c7165e16
No known key found for this signature in database
GPG Key ID: 5A3FF8E135EABA2C
2 changed files with 14 additions and 10 deletions

View File

@ -39,7 +39,9 @@ class WC_Admin_Dashboard {
wp_add_dashboard_widget( 'woocommerce_dashboard_status', __( 'WooCommerce status', 'woocommerce' ), array( $this, 'status_widget' ) ); wp_add_dashboard_widget( 'woocommerce_dashboard_status', __( 'WooCommerce status', 'woocommerce' ), array( $this, 'status_widget' ) );
// Network Order Widget // Network Order Widget
wp_add_dashboard_widget( 'woocommerce_network_orders', __( "WooCommerce Network Orders", 'woocommerce' ), array( $this, 'network_orders' ) ); if ( is_multisite() ) {
wp_add_dashboard_widget( 'woocommerce_network_orders', __( "WooCommerce Network Orders", 'woocommerce' ), array( $this, 'network_orders' ) );
}
} }
/** /**

View File

@ -122,15 +122,17 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
'schema' => array( $this, 'get_public_batch_schema' ), 'schema' => array( $this, 'get_public_batch_schema' ),
) ); ) );
register_rest_route( $this->namespace, '/' . $this->rest_base . '/network', array( if ( is_multisite() ) {
array( register_rest_route( $this->namespace, '/' . $this->rest_base . '/network', array(
'methods' => WP_REST_Server::READABLE, array(
'callback' => array( $this, 'network_orders' ), 'methods' => WP_REST_Server::READABLE,
'permission_callback' => array( $this, 'network_orders_permissions_check' ), 'callback' => array( $this, 'network_orders' ),
'args' => $this->get_collection_params(), 'permission_callback' => array( $this, 'network_orders_permissions_check' ),
), 'args' => $this->get_collection_params(),
'schema' => array( $this, 'get_public_item_schema' ), ),
) ); 'schema' => array( $this, 'get_public_item_schema' ),
) );
}
} }
/** /**