-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
58 lines (42 loc) · 1.82 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
Plugin Name: DIVI + sForms = Integration
Plugin URI: https://github.com/systemo-biz/divi-sforms-connect
Description: Интеграция темы DIVI и плагина sForms
Author: Системо
Author URI: http://systemo.biz
//Support https://github.com/afragen/github-updater
GitHub Plugin URI: https://github.com/systemo-biz/divi-sforms-connect
GitHub Branch: master
Version: 20160405
*/
function divi_sforms_save_mail($msg_mail){
//$data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
//var_dump($data);
//В условии $msg_mail['to'] - это проверка на логику DIVI. WP письма не добавляют данные в это поле, а DIVI да. Хранить все сообщения от WP нам не нужно, тк их может быть много.
if(empty($_POST['_wpnonce-et-pb-contact-form-submitted'])) return $msg_mail;
//substr($text,0,1)
if(is_plugin_active( 'forms-by-systemo/index.php' )) {
$data = array(
'post_title' => $msg_mail['subject'],
'post_type' => 'message_cp',
'post_content' => $msg_mail['message'],
'post_status' => 'publish',
'post_author' => 1,
);
// Вставляем данные в БД
$post_id = wp_insert_post( $data );
//add_post_meta($post_id, 'email_send', '1');
add_post_meta($post_id, 'divi_email_data', print_r($msg_mail, true));
//add_post_meta($post_id, 'divi_email_data', print_r($_COOKIE, true));
if(isset($_COOKIE)) {
set_meta_utm_s($_COOKIE, $post_id);
add_post_meta($post_id, 'coockie_text', print_r($_COOKIE, true));
}
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
add_post_meta($post_id, 'divi_current_url', $current_url);
}
return $msg_mail;
}
add_filter( 'wp_mail', 'divi_sforms_save_mail' );