) { echo '[TEST_LOOPBACK]'; exit; } /** * Adds the WooCommerce debug tool. * * @since 4.8.0 * * @param array $tools WooCommerce core tools * @return array */ public function add_debug_tool( $tools ) { // this key is not unique to the plugin to avoid duplicate tools $tools['sv_wc_background_job_test'] = [ 'name' => __( 'Background Processing Test', 'facebook-for-woocommerce' ), 'button' => __( 'Run Test', 'facebook-for-woocommerce' ), 'desc' => __( 'This tool will test whether your server is capable of processing background jobs.', 'facebook-for-woocommerce' ), 'callback' => [ $this, 'run_debug_tool' ], ]; return $tools; } /** * Runs the test connection debug tool. * * @since 4.8.0 * * @return string */ public function run_debug_tool() { if ( $this->test_connection() ) { $this->debug_message = esc_html__( 'Success! You should be able to process background jobs.', 'facebook-for-woocommerce' ); $result = true; } else { $this->debug_message = esc_html__( 'Could not connect. Please ask your hosting company to ensure your server has loopback connections enabled.', 'facebook-for-woocommerce' ); $result = false; } return $result; } /** * Translate the tool success message. * * This can be removed in favor of returning the message string in `run_debug_tool()` * when WC 3.1 is required, though that means the message will always be "success" styled. * * @since 4.8.0 * * @param string $translated the text to output * @param string $original the original text * @param string $domain the textdomain * @return string the updated text */ public function translate_success_message( $translated, $original, $domain ) { if ( 'woocommerce' === $domain && ( 'Tool ran.' === $original || 'There was an error calling %s' === $original ) ) { $translated = $this->debug_message; } return $translated; } /** Helper Methods ********************************************************/ /** * Gets the job handler identifier. * * @since 4.8.0 * * @return string */ public function get_identifier() { return $this->identifier; } }