Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created December 3, 2014 08:37
Show Gist options
  • Select an option

  • Save ChromeOrange/15faeef86e84271dc6a0 to your computer and use it in GitHub Desktop.

Select an option

Save ChromeOrange/15faeef86e84271dc6a0 to your computer and use it in GitHub Desktop.
Remote GET test for WooCommerce and WooThemes Helper.
/**
* Add to theme functions.php
* Check the System Status
*/
add_filter( 'woocommerce_debug_posting' , 'custom_wp_remote_get_test' );
function custom_wp_remote_get_test( $posting ) {
// WP Remote Get Check
$posting['wp_remote_get']['name'] = __( 'Remote Get', 'woocommerce');
$posting['wp_remote_get']['help'] = '<a href="#" class="help_tip" data-tip="' . esc_attr__( 'WooCommerce plugins may use this method of communication when checking for plugin updates.', 'woocommerce' ) . '">[?]</a>';
$response = wp_remote_get( 'http://www.woothemes.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) );
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$posting['wp_remote_get']['note'] = __( 'wp_remote_get() was successful - The WooCommerce plugin updater should work.', 'woocommerce' );
$posting['wp_remote_get']['success'] = true;
} else {
$posting['wp_remote_get']['note'] = __( 'wp_remote_get() failed. The WooCommerce plugin updater won\'t work with your server. Contact your hosting provider.', 'woocommerce' ) . ' ' . $response->get_error_message();
if ( $response->get_error_message() ) {
$posting['wp_remote_get']['note'] .= ' ' . sprintf( __( 'Error: %s', 'woocommerce' ), $response->get_error_message() );
}
$posting['wp_remote_get']['success'] = false;
}
return $posting;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment