| 1 |
<?php |
| 2 |
/** |
| 3 |
* Debug functions |
| 4 |
* |
| 5 |
* Functions to debug library CRM |
| 6 |
* |
| 7 |
* @author closemarketing |
| 8 |
* @category Functions |
| 9 |
* @package Gravityforms CRM |
| 10 |
* @version 1.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! function_exists( 'formscrm_debug_message' ) ) { |
| 14 |
function formscrm_debug_message( $message ) { |
| 15 |
if ( WP_DEBUG == true ) { |
| 16 |
// Debug Mode |
| 17 |
echo ' <table class="widefat"> |
| 18 |
<thead> |
| 19 |
<tr class="form-invalid"> |
| 20 |
<th class="row-title">' . esc_html__( 'Message Debug Mode', 'formscrm' ) . '</th> |
| 21 |
</tr> |
| 22 |
</thead> |
| 23 |
<tbody> |
| 24 |
<tr> |
| 25 |
<td><pre>'; |
| 26 |
echo esc_html( $message ); |
| 27 |
echo '</pre></td></tr></table>'; |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
if ( ! function_exists( 'formscrm_error_admin_message' ) ) { |
| 33 |
/** |
| 34 |
* Shows in WordPress error message |
| 35 |
* |
| 36 |
* @param string $code Code of error. |
| 37 |
* @param string $message Message. |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
function formscrm_error_admin_message( $code, $message ) { |
| 41 |
echo '<div class="error">'; |
| 42 |
echo '<p><strong>API ERROR ' . esc_html( $code ) . ': </strong> ' . esc_html( $message ) . '</p>'; |
| 43 |
echo '</div>'; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
// * Sends an email to administrator when it not creates the lead |
| 48 |
if ( ! function_exists( 'formscrm_debug_email_lead' ) ) { |
| 49 |
function formscrm_debug_email_lead( $crm, $error, $data ) { |
| 50 |
$to = get_option( 'admin_email' ); |
| 51 |
$subject = 'FormsCRM - ' . __( 'Error creating the Lead', 'formscrm' ); |
| 52 |
$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>'; |
| 53 |
foreach ( $data as $dataitem ) { |
| 54 |
$body .= '<p><strong>' . $dataitem['name'] . ': </strong>' . $dataitem['value'] . '</p>'; |
| 55 |
} |
| 56 |
$body .= '</br/><br/>FormsCRM'; |
| 57 |
$headers = array( 'Content-Type: text/html; charset=UTF-8' ); |
| 58 |
|
| 59 |
wp_mail( $to, $subject, $body, $headers ); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
if ( ! function_exists( 'formscrm_testserver' ) ) { |
| 64 |
function formscrm_testserver() { |
| 65 |
// test curl. |
| 66 |
if ( ! function_exists( 'curl_version' ) ) { |
| 67 |
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>'; |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
if ( ! function_exists( 'formscrm_check_url_crm' ) ) { |
| 73 |
/** |
| 74 |
* Checks CRM URL to see that is correct |
| 75 |
* |
| 76 |
* @param string $url URL to check. |
| 77 |
* @return url |
| 78 |
*/ |
| 79 |
function formscrm_check_url_crm( $url ) { |
| 80 |
|
| 81 |
if ( ! isset( $url ) ) { |
| 82 |
$url = ''; |
| 83 |
} |
| 84 |
if ( substr( $url, -1 ) != '/' ) { |
| 85 |
$url .= '/'; // adds slash to url. |
| 86 |
} |
| 87 |
|
| 88 |
return $url; |
| 89 |
} |
| 90 |
} |
| 91 |
|