I am creating a plugin in WordPress that will send some data via email. When I activate the plugin, I'm getting a white screen.
I set define('WP_DEBUG', true);
in wp-config.php
but no error messages are displayed.
Here is the code for my plugin:
<?php
/*
Plugin Name: Formulario Cotação
Plugin URI: http://solutionsagencia.com.br
Description: Plugin para cotação em 2 passos.
Version: 0.0.1
Author: Wendell Christian
Author URI: http://solutionsagencia.com.br
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
// Verifica se não existe nenhum classe com o mesmo nome
if ( ! class_exists('FormularioCotacao') ) {
class FormularioCotacao
{
public function __construct() {
/* Adiciona o shortcode */
add_shortcode( 'cotacao', array( $this, 'ExibirTexto' ) );
}
/**
* Este é um método simples que irá exibir o texto do nosso shortcode
*/
public function ExibirTexto () {
$FormularioCotacaoURL = WP_CONTENT_URL;
$FormularioCotacaoURL = WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/';
return "<div class='principal-form' id='principal-form'>
<form type='post' action='' id='cadastraForm'>
<div class='col-md-65'><div class='col-md-34'><input type='text' name='nome' id='nome' class='campo-form' placeholder='Nome' maxlength='50'></div>
<div class='col-md-34-2'><input type='email' name='email' id='email' class='campo-form' placeholder='Email' maxlength='120'/></div>
<input type='hidden' name='action' value='addCustomer'/>
<div class='col-md-30'><button type='submit' id='enviarform' class='botao-enviar'><span class='icone-cadastrar'></span>Efetue sua simulação</button>
</div>
</div>
</div>
<div id='feedback'></div>
<div id='passo2form' class='passo2form'></div>
";
}
}
/* Carrega a classe */
$FormularioCotacao_settings = new FormularioCotacao();
} // class_exists
function addCustomer(){
global $wpdb;
$nome = trim($_POST['nome']);
$email = trim($_POST['email']);
if($wpdb->insert('wp_formclientes',array(
'nome'=>$nome,
'email'=>$email
))===FALSE){
echo "Error";
}
else {
//mensagem de sucesso
}
die();
}
add_action('wp_ajax_addCustomer', 'addCustomer');
add_action('wp_ajax_nopriv_addCustomer', 'addCustomer'); // not really needed
/*Enviando email completo*/
if( isset($_POST['nome']) && ($_POST['email'])){
$para = "email@email.com";
$assunto = "Assunto" . $nome;
$conteudo =
"<b>Nome:</b> {$nome}" .
"<b>Email:</b> {$email}" .
$headers = array(
'Reply-To' => $name . '<' . $email . '>',
);
}
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
require('http://solutionsagencia.com.br/comparasaude/wp-load.php');
$status = wp_mail( $para, $assunto, $conteudo );
remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
function set_html_content_type() {
return 'text/html';
}
if ( $status ){
echo "sucesso";
} else {
}
function FormularioCotacao_addJS() {
$FormularioCotacaoURL = WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/';
wp_register_style('estilo', $FormularioCotacaoURL . 'css/estilo.css');
wp_enqueue_style('estilo', $FormularioCotacaoURL . 'css/estilo.css');
}
add_action('wp_print_scripts', 'FormularioCotacao_addJS');