# formscrm/3.0/includes/debug.php

FormsCRM – Connect Forms to CRM directly, version 3.0. 91 lines.

- Page: https://pluginprobe.com/plugins/formscrm/3.0/code/includes/debug.php
- Raw: https://pluginprobe.com/plugins/formscrm/3.0/raw/includes/debug.php
- Modified: 2021-06-26T06:35:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/formscrm/3.0/code/includes/debug.php#L10-L20`.

```php
<?php
/**
 * Debug functions
 *
 * Functions to debug library CRM
 *
 * @author   closemarketing
 * @category Functions
 * @package  Gravityforms CRM
 * @version  1.0.0
 */

if ( ! function_exists( 'formscrm_debug_message' ) ) {
	function formscrm_debug_message( $message ) {
		if ( WP_DEBUG == true ) {
			// Debug Mode
			echo '  <table class="widefat">
                  <thead>
                  <tr class="form-invalid">
                      <th class="row-title">' . esc_html__( 'Message Debug Mode', 'formscrm' ) . '</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                  <td><pre>';
			echo esc_html( $message );
			echo '</pre></td></tr></table>';
		}
	}
}

if ( ! function_exists( 'formscrm_error_admin_message' ) ) {
	/**
	 * Shows in WordPress error message
	 *
	 * @param string $code Code of error.
	 * @param string $message Message.
	 * @return void
	 */
	function formscrm_error_admin_message( $code, $message ) {
		echo '<div class="error">';
		echo '<p><strong>API ERROR ' . esc_html( $code ) . ': </strong> ' . esc_html( $message ) . '</p>';
		echo '</div>';
	}
}

// * Sends an email to administrator when it not creates the lead
if ( ! function_exists( 'formscrm_debug_email_lead' ) ) {
	function formscrm_debug_email_lead( $crm, $error, $data ) {
		$to      = get_option( 'admin_email' );
		$subject = 'GravityForms CRM - ' . __( 'Error creating the Lead', 'formscrm' );
		$body    = '<p>' . __( 'There was an error creating the Lead in the CRM', 'formscrm' ) . ' ' . $crm . ':</p><p><strong>' . $error . '</strong></p><p>' . __( 'Lead Data', 'formscrm' ) . ':</p>';
		foreach ( $data as $dataitem ) {
			$body .= '<p><strong>' . $dataitem['name'] . ': </strong>' . $dataitem['value'] . '</p>';
		}
		$body   .= '</br/><br/>GravityForms CRM';
		$headers = array( 'Content-Type: text/html; charset=UTF-8' );

		wp_mail( $to, $subject, $body, $headers );
	}
}

if ( ! function_exists( 'formscrm_testserver' ) ) {
	function formscrm_testserver() {
		// test curl.
		if ( ! function_exists( 'curl_version' ) ) {
			echo '<div id="message" class="error below-h2"><p><strong>' . __( 'curl is not Installed in your server. It is needed to work with CRM Libraries.', 'formscrm' ) . '</strong></p></div>';
		}
	}
}

if ( ! function_exists( 'formscrm_check_url_crm' ) ) {
	/**
	 * Checks CRM URL to see that is correct
	 *
	 * @param string $url URL to check.
	 * @return url
	 */
	function formscrm_check_url_crm( $url ) {

		if ( ! isset( $url ) ) {
			$url = '';
		}
		if ( substr( $url, -1 ) != '/' ) {
			$url .= '/'; // adds slash to url.
		}

		return $url;
	}
}

```
