Skip to content

Instantly share code, notes, and snippets.

@fabianomaximiano
Created October 24, 2016 15:48
Show Gist options
  • Save fabianomaximiano/c00d9ffb5172308137f555194db6b7ca to your computer and use it in GitHub Desktop.
Save fabianomaximiano/c00d9ffb5172308137f555194db6b7ca to your computer and use it in GitHub Desktop.
/**
* Formulario - com odin
**/
function odin_contact_form() {
$form = new Odin_Contact_Form(
'contact_form', // ID do formulário
'[email protected]' // E-mail do destinatário.
//array( '[email protected]', '[email protected]' ), // array com e-mails que receberão cópia.
//array( '[email protected]' ) // array com e-mails que receberão cópia oculta.
// array( 'class' => 'form' ) // array com atributos para o formulário.
// 'file' // string com método que será enviado o anexo, no caso 'file' como anexo e 'url' para enviar links.
);
$form->set_fields(
array(
array(
'fields' => array(
array(
'id' => 'sender_name', // Obrigatório
'label' => array(
'text' => __( 'Nome Completo', 'odin' ), // Obrigatório
'class' => 'example-class example-class-2'
),
'type' => 'text', // Obrigatório
'required' => true, // Opcional (bool)
'attributes' => array( // Opcional (html input elements)
'placeholder' => __( 'Digite o seu nome' )
)
),
array(
'id' => 'sender_email', // Obrigatório
'label' => array(
'text' => __( 'E-mail', 'odin' ), // Obrigatório
'class' => 'example-class example-class-2'
),
'type' => 'email', // Obrigatório
'required' => true, // Opcional (bool)
'attributes' => array( // Opcional (html input elements)
'placeholder' => __( 'Digite o seu e-mail!' )
),
'description' => __( 'Adicione um endereço de e-mail válido', 'odin' ) // Opcional
),
array(
'id' => 'sender_phone', // Obrigatório
'label' => array(
'text' => __( 'Telefone', 'odin' ), // Obrigatório
'class' => 'example-class example-class-2'
),
'type' => 'text', // Obrigatório
'required' => true, // Opcional (bool)
'attributes' => array( // Opcional (html input elements)
'placeholder' => __( 'Digite o seu Telefone' )
),
'description' => __( 'Adicione um endereço de e-mail válido', 'odin' ) // Opcional
),
array(
'id' => 'sender_message', // Obrigatório
'label' => array(
'text' => __( 'Mensagem', 'odin' ), // Obrigatório
'class' => 'example-class example-class-2'
),
'type' => 'textarea', // Obrigatório
'required' => true, // Opcional (bool)
'attributes' => array( // Opcional (html input elements)
'placeholder' => __( 'Digite a sua mensagem' )
),
),
)
)
)
);
$form->set_subject( __( 'Email enviado [sender_name] <[sender_email]>', 'odin' ) );
$form->set_content_type( 'html' );
$form->set_reply_to( 'sender_email' );
return $form;
}
add_action( 'init', array( odin_contact_form(), 'init' ), 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment