Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Formulario Cotação
  4. Plugin URI: http://solutionsagencia.com.br
  5. Description: Plugin para cotação em 2 passos.
  6. Version: 0.0.1
  7. Author: Wendell Christian
  8. Author URI: http://solutionsagencia.com.br
  9. License: GPLv2 or later
  10. License URI: http://www.gnu.org/licenses/gpl-2.0.html
  11. */
  12.  
  13.  
  14. // Verifica se não existe nenhum classe com o mesmo nome
  15. if ( ! class_exists('FormularioCotacao') ) {
  16.  
  17. class FormularioCotacao
  18. {
  19.  
  20.  
  21. public function __construct() {
  22. /* Adiciona o shortcode */
  23. add_shortcode( 'cotacao', array( $this, 'ExibirTexto' ) );
  24. }
  25.  
  26. /**
  27. * Este é um método simples que irá exibir o texto do nosso shortcode
  28. */
  29. public function ExibirTexto () {
  30. $FormularioCotacaoURL = WP_CONTENT_URL;
  31. $FormularioCotacaoURL = WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/';
  32. return "<div class='principal-form' id='principal-form'>
  33. <form type='post' action='' id='cadastraForm'>
  34. <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>
  35. <div class='col-md-34-2'><input type='email' name='email' id='email' class='campo-form' placeholder='Email' maxlength='120'/></div>
  36. <input type='hidden' name='action' value='addCustomer'/>
  37. <div class='col-md-30'><button type='submit' id='enviarform' class='botao-enviar'><span class='icone-cadastrar'></span>Efetue sua simulação</button>
  38. </div>
  39. </div>
  40.  
  41. </div>
  42. <div id='feedback'></div>
  43. <div id='passo2form' class='passo2form'></div>
  44.  
  45. ";
  46. }
  47.  
  48. }
  49.  
  50. /* Carrega a classe */
  51. $FormularioCotacao_settings = new FormularioCotacao();
  52.  
  53. } // class_exists
  54.  
  55.  
  56. function addCustomer(){
  57.  
  58. global $wpdb;
  59.  
  60. $nome = trim($_POST['nome']);
  61. $email = trim($_POST['email']);
  62.  
  63. if($wpdb->insert('wp_formclientes',array(
  64. 'nome'=>$nome,
  65. 'email'=>$email
  66. ))===FALSE){
  67.  
  68. echo "Error";
  69.  
  70. }
  71. else {
  72.  
  73. //mensagem de sucesso
  74.  
  75. }
  76. die();
  77. }
  78. add_action('wp_ajax_addCustomer', 'addCustomer');
  79. add_action('wp_ajax_nopriv_addCustomer', 'addCustomer'); // not really needed
  80.  
  81.  
  82. /*Enviando email completo*/
  83.  
  84. if( isset($_POST['nome']) && ($_POST['email'])){
  85.  
  86.  
  87. $para = "email@email.com";
  88. $assunto = "Assunto" . $nome;
  89. $conteudo =
  90. "<b>Nome:</b> {$nome}" .
  91. "<b>Email:</b> {$email}" .
  92.  
  93. $headers = array(
  94. 'Reply-To' => $name . '<' . $email . '>',
  95. );
  96.  
  97. }
  98.  
  99. add_filter( 'wp_mail_content_type', 'set_html_content_type' );
  100.  
  101. require('http://solutionsagencia.com.br/comparasaude/wp-load.php');
  102.  
  103. $status = wp_mail( $para, $assunto, $conteudo );
  104.  
  105.  
  106. remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
  107.  
  108. function set_html_content_type() {
  109. return 'text/html';
  110. }
  111.  
  112.  
  113. if ( $status ){
  114. echo "sucesso";
  115. } else {
  116. }
  117.  
  118.  
  119.  
  120. function FormularioCotacao_addJS() {
  121. $FormularioCotacaoURL = WP_CONTENT_URL.'/plugins/'.plugin_basename( dirname(__FILE__)).'/';
  122. wp_register_style('estilo', $FormularioCotacaoURL . 'css/estilo.css');
  123. wp_enqueue_style('estilo', $FormularioCotacaoURL . 'css/estilo.css');
  124. }
  125.  
  126. add_action('wp_print_scripts', 'FormularioCotacao_addJS');
  127.  
  128. define( 'WP_DEBUG_LOG', true );
  129.  
  130. require('http://solutionsagencia.com.br/comparasaude/wp-load.php');
  131.  
  132. $status = wp_mail( $para, $assunto, $conteudo );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement