api_client = $api_client; add_filter( 'woocommerce_debug_tools', array( $this, 'woocommerce_debug_tools' ) ); } function woocommerce_debug_tools( $tools ) { $tools['test_wcc_connection'] = array( 'name' => __( 'Test your WooCommerce Services connection', 'woocommerce-services' ), 'button' => __( 'Test Connection', 'woocommerce-services' ), 'desc' => __( 'This will test your WooCommerce Services connection to ensure everything is working correctly', 'woocommerce-services' ), 'callback' => array( $this, 'test_connection' ), ); return $tools; } function test_connection() { $test_request = $this->api_client->auth_test(); if ( $test_request && ! is_wp_error( $test_request ) && $test_request->authorized ) { echo '

' . __( 'Your site is succesfully communicating to the WooCommerce Services API.', 'woocommerce-services' ) . '

'; } else { echo '

' . __( 'ERROR: Your site has a problem connecting to the WooCommerce Services API. Please make sure your Jetpack connection is working.', 'woocommerce-services' ) . '

'; } } } }