Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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
- {
- /**
- * Este é o construtor da classe. Tudo aqui será executado quando o
- * plugin for ativado.
- */
- 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__)).'/';
- $urlsite = site_url();
- return "<div class='principal-form' id='principal-form'>
- <div class='col-md-35'><div class='titulo-inicie'>INICIE SUA COTAÇÃO AQUI</div></div>
- <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'/>
- <input type='hidden' name='urlsite' id='urlsite' value='".$urlsite."'/>
- <div class='col-md-30'><button type='submit' id='enviarform' class='botao-enviar'><span class='icone-cadastrar'></span>Efetue sua simulação</button>
- </form>
- </div>
- </div>
- </div>
- <div id='feedback'></div>
- <div id='passo2form' class='passo2form'></div>
- <div class='col-md-100' id='botao-enviar-2'>
- <div class='col-md-70 margin-bottom-15 margin-top-15'><button type='submit' id='enviarform2' class='botao-enviar'><span class='icone-cadastrar'></span>Efetue sua simulação</button>
- </div></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*/
- add_action('init', function(){
- if ( isset( $_POST['cf-submitted'] ) ) {
- $nome = trim($_POST['nome']);
- $email = trim($_POST['email']);
- $comparar = ($_POST['comparar']);
- $tipo = ($_POST['tipo']);
- $telefone = ($_POST['telefone']);
- $profissao = ($_POST['profissao']);
- $zd = ($_POST['z-d']);
- $para = "wendell@solutionsagencia.com.br";
- $assunto = "Cotação em Compara Saúde" . $nome;
- $conteudo =
- "<b>Nome:</b> $nome" .
- "<br><b>Email:</b> $email" .
- "<br><b>Comparar:</b> $comparar" .
- "<br><b>Tipo:</b> $tipo" .
- "<br><b>Telefone:</b> $telefone" .
- "<br><b>Profissão:</b> $profissao" .
- "<br><b>0 a 18:</b> $zd";
- $headers = array('Content-Type: text/html; charset=UTF-8',
- 'Reply-To' => $name . '<' . $email . '>');
- $status = wp_mail( $para, $assunto, $conteudo, $headers );
- if ( $status ){
- echo "";
- } else {
- echo "erro";
- }
- }
- });
- function FormularioCotacao_addJS() {
- $FormularioCotacaoURL = WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/';
- wp_register_script('processa', $FormularioCotacaoURL . 'js/processa.js');
- wp_register_style('estilo', $FormularioCotacaoURL . 'css/estilo.css');
- wp_enqueue_style('estilo', $FormularioCotacaoURL . 'css/estilo.css');
- wp_enqueue_script('processa', $FormularioCotacaoURL . 'js/processa.js', array ( 'jquery' ), 1.12, true);
- wp_localize_script('processa', 'UrlCotacao', array('pluginsUrl' => plugins_url(),));
- }
- add_action('wp_print_scripts', 'FormularioCotacao_addJS');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement