From fe1e12df18d178602c88110b538bea8eb6673dc8 Mon Sep 17 00:00:00 2001 From: Patrick Garman Date: Thu, 10 May 2012 06:37:10 -0500 Subject: [PATCH] WC_Debug Filters Added some filters which allow extensions to tie into the debug page. --- admin/woocommerce-admin-debug.php | 113 ++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/admin/woocommerce-admin-debug.php b/admin/woocommerce-admin-debug.php index 91bdc94b415..e0dea153c28 100644 --- a/admin/woocommerce-admin-debug.php +++ b/admin/woocommerce-admin-debug.php @@ -9,7 +9,20 @@ function woocommerce_debug() { global $woocommerce; - + $tools = apply_filters( 'wc_debug_tools', array( + 'clear_transients' => array( + 'name' => __('Transients','woocommerce'), + 'button' => __('Clear Transients','woocommerce'), + 'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ), + ), + 'reset_roles' => array( + 'name' => __('Capabilities','woocommerce'), + 'button' => __('Reset Capabilities','woocommerce'), + 'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ), + ), + ) ); + $classes = array('alternate',''); + $class = 0; ?>

@@ -37,6 +50,19 @@ function woocommerce_debug() { echo '

' . __('Roles successfully reset', 'woocommerce') . '

'; break; + default: + if( isset( $tools[$_GET['action']]['callback'] ) ) { + $callback = $tools[$_GET['action']]['callback']; + $return = call_user_func( $callback ); + if( $return === false ) { + if( is_array( $callback ) ) { + echo '

' . sprintf( __('There was an error calling %s::%s', 'woocommerce'), get_class( $callback[0] ), $callback[1] ) . '

'; + + } else { + echo '

' . sprintf( __('There was an error calling %s', 'woocommerce'), $callback ) . '

'; + } + } + } } } ?> @@ -288,31 +314,49 @@ function woocommerce_debug() { + '; + $posting['fsockopen_curl']['success'] = false; + } + + // WP Remote Post Check + $posting['wp_remote_post']['name'] = __('WP Remote Post Check','woocommerce'); + $params = array( + 'sslverify' => false, + 'timeout' => 30, + 'user-agent' => 'WooCommerce/'.$woocommerce->version + ); + $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params ); + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { + $posting['wp_remote_post']['note'] = __('wp_remote_post() was successful - PayPal IPN is working.', 'woocommerce'); + $posting['wp_remote_post']['success'] = true; + } else { + $posting['wp_remote_post']['note'] = __('wp_remote_post() failed. PayPal IPN won\'t work with your server. Contact your hosting provider. Error: ', 'woocommerce') . $response->get_error_message(); + $posting['wp_remote_post']['success'] = false; + } + + $posting = apply_filters( 'wc_debug_posting', $posting ); + ?> + - - - ' . __('Your server has fsockopen or Curl enabled.', 'woocommerce'). ''; - else - echo '' . __('Your server does not have fsockopen or Curl enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce'). ''; ?> - - - - false, - 'timeout' => 30, - 'user-agent' => 'WooCommerce/'.$woocommerce->version - ); - $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params ); - - if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) - echo '' . __('wp_remote_post() was successful - PayPal IPN is working.', 'woocommerce'). ''; - else - echo '' . __('wp_remote_post() failed. PayPal IPN won\'t work with your server. Contact your hosting provider. Error: ', 'woocommerce') . $response->get_error_message() . ''; - ?> + + + + + + + + + @@ -320,26 +364,19 @@ function woocommerce_debug() { - + - - + $tool) { ?> + +

- - -

- - - - - -

- - + +

+