Commit ee1d6346 authored by agnez's avatar agnez

contact form pour fiche gasap WIP

parent c6effb22
......@@ -21,33 +21,33 @@ function i18n() {
add_action( 'init', 'create_post_types' );
function create_post_types() {
register_post_type('contentpiece', //Content pieces
register_post_type('gasap', // GASAP
array(
'labels' => array(
'name' => _x( 'Content Pieces', 'post type general name', 'gasap-posttypes' ),
'singular_name' => _x( 'Content Piece', 'post type singular name', 'gasap-posttypes' ),
'add_new' => _x( 'Add New', 'Content Piece', 'gasap-posttypes' ),
'add_new_item' => __( 'Add New Content Piece', 'gasap-posttypes' ),
'edit_item' => __( 'Edit Content Piece', 'gasap-posttypes' ),
'new_item' => __( 'New Content Piece', 'gasap-posttypes' ),
'view' => __( 'View Content Piece', 'gasap-posttypes' ),
'view_item' => __( 'View Content Piece', 'gasap-posttypes' ),
'search_items' => __( 'Search Content Pieces', 'gasap-posttypes' ),
'not_found' => __( 'No Content Pieces found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No Content Pieces found in Trash', 'gasap-posttypes' ),
'name' => _x( 'GASAP', 'post type general name', 'gasap-posttypes' ),
'singular_name' => _x( 'GASAP', 'post type singular name', 'gasap-posttypes' ),
'add_new' => _x( 'Add New', 'GASAP', 'gasap-posttypes' ),
'add_new_item' => __( 'Add New GASAP', 'gasap-posttypes' ),
'edit_item' => __( 'Edit GASAP', 'gasap-posttypes' ),
'new_item' => __( 'New GASAP', 'gasap-posttypes' ),
'view' => __( 'View GASAP', 'gasap-posttypes' ),
'view_item' => __( 'View GASAP', 'gasap-posttypes' ),
'search_items' => __( 'Search GASAP', 'gasap-posttypes' ),
'not_found' => __( 'No GASAP found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No GASAP found in Trash', 'gasap-posttypes' ),
),
'public' => true,
'public' => true,
'has_archive' => false,
'show_ui' => true,
'exclude_from_search' => true,
'has_archive' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'capability_type' => 'page',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'capability_type' => 'post',
'query_var' => true,
'menu_position' => 13,
'menu_position' => 7,
)
);
register_post_type('producer', // Producers
);
register_post_type('producer', // Producers
array(
'labels' => array(
'name' => _x( 'Producers', 'post type general name', 'gasap-posttypes' ),
......@@ -56,8 +56,6 @@ function create_post_types() {
'add_new_item' => __( 'Add New Producer', 'gasap-posttypes' ),
'edit_item' => __( 'Edit Producer', 'gasap-posttypes' ),
'new_item' => __( 'New Producer', 'gasap-posttypes' ),
'view' => __( 'View Producer', 'gasap-posttypes' ),
'view_item' => __( 'View Producer', 'gasap-posttypes' ),
'search_items' => __( 'Search Producers', 'gasap-posttypes' ),
'not_found' => __( 'No Producers found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No Producers found in Trash', 'gasap-posttypes' ),
......@@ -73,20 +71,18 @@ function create_post_types() {
'menu_position' => 8,
)
);
register_post_type('gasap', // GASAP
register_post_type('worker', // employés
array(
'labels' => array(
'name' => _x( 'GASAP', 'post type general name', 'gasap-posttypes' ),
'singular_name' => _x( 'GASAP', 'post type singular name', 'gasap-posttypes' ),
'add_new' => _x( 'Add New', 'GASAP', 'gasap-posttypes' ),
'add_new_item' => __( 'Add New GASAP', 'gasap-posttypes' ),
'edit_item' => __( 'Edit GASAP', 'gasap-posttypes' ),
'new_item' => __( 'New GASAP', 'gasap-posttypes' ),
'view' => __( 'View GASAP', 'gasap-posttypes' ),
'view_item' => __( 'View GASAP', 'gasap-posttypes' ),
'search_items' => __( 'Search GASAP', 'gasap-posttypes' ),
'not_found' => __( 'No GASAP found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No GASAP found in Trash', 'gasap-posttypes' ),
'name' => _x( 'Workers', 'post type general name', 'gasap-posttypes' ),
'singular_name' => _x( 'Worker', 'post type singular name', 'gasap-posttypes' ),
'add_new' => _x( 'Add New', 'Worker', 'gasap-posttypes' ),
'add_new_item' => __( 'Add New Worker', 'gasap-posttypes' ),
'edit_item' => __( 'Edit Worker', 'gasap-posttypes' ),
'new_item' => __( 'New Worker', 'gasap-posttypes' ),
'search_items' => __( 'Search Worker', 'gasap-posttypes' ),
'not_found' => __( 'No Worker found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No Worker found in Trash', 'gasap-posttypes' ),
),
'public' => false,
'has_archive' => false,
......@@ -96,9 +92,9 @@ function create_post_types() {
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'capability_type' => 'post',
'query_var' => true,
'menu_position' => 7,
'menu_position' => 11,
)
);
);
register_post_type('partner', // partenaires
array(
'labels' => array(
......@@ -108,8 +104,6 @@ function create_post_types() {
'add_new_item' => __( 'Add New Partner', 'gasap-posttypes' ),
'edit_item' => __( 'Edit Partner', 'gasap-posttypes' ),
'new_item' => __( 'New Partner', 'gasap-posttypes' ),
'view' => __( 'View Partner', 'gasap-posttypes' ),
'view_item' => __( 'View Partner', 'gasap-posttypes' ),
'search_items' => __( 'Search Partner', 'gasap-posttypes' ),
'not_found' => __( 'No Partner found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No Partner found in Trash', 'gasap-posttypes' ),
......@@ -121,36 +115,34 @@ function create_post_types() {
'hierarchical' => false,
'supports' => array( 'title', 'thumbnail', ),
'capability_type' => 'post',
'query_var' => true,
'query_var' => true,
'menu_position' => 12,
)
);
register_post_type('worker', // employés
register_post_type('contentpiece', //Content pieces
array(
'labels' => array(
'name' => _x( 'Workers', 'post type general name', 'gasap-posttypes' ),
'singular_name' => _x( 'Worker', 'post type singular name', 'gasap-posttypes' ),
'add_new' => _x( 'Add New', 'Worker', 'gasap-posttypes' ),
'add_new_item' => __( 'Add New Worker', 'gasap-posttypes' ),
'edit_item' => __( 'Edit Worker', 'gasap-posttypes' ),
'new_item' => __( 'New Worker', 'gasap-posttypes' ),
'view' => __( 'View Worker', 'gasap-posttypes' ),
'view_item' => __( 'View Worker', 'gasap-posttypes' ),
'search_items' => __( 'Search Worker', 'gasap-posttypes' ),
'not_found' => __( 'No Worker found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No Worker found in Trash', 'gasap-posttypes' ),
'name' => _x( 'Content Pieces', 'post type general name', 'gasap-posttypes' ),
'singular_name' => _x( 'Content Piece', 'post type singular name', 'gasap-posttypes' ),
'add_new' => _x( 'Add New', 'Content Piece', 'gasap-posttypes' ),
'add_new_item' => __( 'Add New Content Piece', 'gasap-posttypes' ),
'edit_item' => __( 'Edit Content Piece', 'gasap-posttypes' ),
'new_item' => __( 'New Content Piece', 'gasap-posttypes' ),
'search_items' => __( 'Search Content Pieces', 'gasap-posttypes' ),
'not_found' => __( 'No Content Pieces found', 'gasap-posttypes' ),
'not_found_in_trash' => __( 'No Content Pieces found in Trash', 'gasap-posttypes' ),
),
'public' => false,
'has_archive' => false,
'public' => false,
'show_ui' => true,
'exclude_from_search' => true,
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'capability_type' => 'post',
'query_var' => true,
'menu_position' => 11,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'capability_type' => 'page',
'query_var' => true,
'menu_position' => 13,
)
);
);
}
/**
......
......@@ -138,7 +138,7 @@ main .uk-container{
}
#snippet_avantages, /*p12*/
#snippet_avantages_prod {
background: url(images/bg_avantages.png) center bottom no-repeat transparent;
background: url(images/bg_avantages.png) center bottom no-repeat @bleu-ciel;
padding-bottom: 100px;
padding-top: 30px;
background-size:100% auto;
......
<?php
//test https://premium.wpmudev.org/blog/how-to-build-your-own-wordpress-contact-form-and-why/?utm_expid=3606929-94.Ie3dH-CaRwe6MU3VrZsdvw.0
//response generation function
$response = "";
//function to generate response
function generate_response($type, $message){
global $response;
if($type == "success") $response = "<div class='success'>{$message}</div>";
else $response = "<div class='error'>{$message}</div>";
}
//response messages
$not_human = "Human verification incorrect.";
$missing_content = "Please supply all information.";
$email_invalid = "Email Address Invalid.";
$message_unsent = "Message was not sent. Try Again.";
$message_sent = "Thanks! Your message has been sent.";
//user posted variables
$name = $_POST['message_name'];
$email = $_POST['message_email'];
$message = $_POST['message_text'];
$human = $_POST['message_human'];
//php mailer variables
$to = get_post_meta( get_the_ID(), 'gasap_mailreferent', true );
$bcc = get_option('admin_email');
$subject = "Someone sent a message from ".get_bloginfo('name');
$headers = 'From: '. $email . "\r\n" .
'Reply-To: ' . $email . "\r\n";
if(!$human == 0){
if($human != 2) generate_response("error", $not_human); //not human!
else {
//validate email
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
generate_response("error", $email_invalid);
else //email is valid
{
//validate presence of name and message
if(empty($name) || empty($message)){
generate_response("error", $missing_content);
}
else //ready to go!
{
$sent = mail($to, $subject, $message, $headers);
if($sent) generate_response("success", $message_sent); //message sent!
else generate_response("error", $message_unsent); //message wasn't sent
}
}
}
}
else if ($_POST['submitted']) generate_response("error", $missing_content);
?>
<div id="respond">
<?php echo $response; ?>
<form action="<?php the_permalink(); ?>" method="post">
<p><label for="name">Name: <span>*</span></label> <br><input type="text" id="message_name" value="<?php echo esc_attr($_POST['message_name']); ?>"></p>
<p><label for="message_email">Email: <span>*</span></label> <br><input type="text" id="message_email" value="<?php echo esc_attr($_POST['message_email']); ?>"></p>
<p><label for="message_text">Message: <span>*</span></label> <br><textarea type="text" id="message_text"><?php echo esc_textarea($_POST['message_text']); ?></textarea></p>
<p><label for="message_human">Human Verification: <span>*</span></label> <br><input type="text" style="width: 60px;" id="message_human"> + 3 = 5</p>
<input type="hidden" id="submitted" value="1">
<p><input type="submit"></p>
</form>
</div>
<?php
wp_reset_postdata();
\ No newline at end of file
<?php
add_action( 'beans_post_after_markup', 'add_after_gasapsingle' );
function add_after_gasapsingle() {
include (get_stylesheet_directory() . '/assets/template_parts/form_contact_gasap.php');
include (get_stylesheet_directory() . '/assets/template_parts/footer.php');
}
// Load the document which is always needed at the bottom of template files.
beans_load_document();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment