archive-xunpan.php
1.5 KB
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
<?php
function contact_form_num_func_new( $atts, $content = "" ) {
global $wpdb;
$wpcf7_contact = $wpdb->get_results("select * from wp_cf7_data_entry e left join wp_cf7_data d on e.data_id = d.id where e.cf7_id=19 AND e.name ='Email'");
$wpcf7_contact_price = $wpdb->get_results("select * from wp_cf7_data_entry e left join wp_cf7_data d on e.data_id = d.id where e.cf7_id=20 AND e.name ='Email'");
$wpcf7_contact_all = array_merge($wpcf7_contact,$wpcf7_contact_price);
$red_flag =0;
$orange_flag =0;
$blue_flag =0;
$last_1_days_arr = array(date('Y-m-d',strtotime('-1 days')));
$last_3_days_arr = array(date('Y-m-d',strtotime('-2 days')),date('Y-m-d',strtotime('-3 days')),date('Y-m-d',strtotime('-4 days')),date('Y-m-d',strtotime('-5 days')),date('Y-m-d',strtotime('-6 days')));
foreach($wpcf7_contact_all as $v){
if(date('Y-m-d',strtotime($v->created)) ==date('Y-m-d')){
$red_flag = 1;
}
if(in_array(date('Y-m-d',strtotime($v->created)),$last_1_days_arr)){
$orange_flag = 1;
}
if(in_array(date('Y-m-d',strtotime($v->created)),$last_3_days_arr)){
$blue_flag = 1;
}
}
$wpcf7_contact_form_num = count($wpcf7_contact) + count($wpcf7_contact_price);
if($red_flag){
$color = $red_flag?"red":'';
}elseif($orange_flag){
$color = $orange_flag?"orange":"";
}else{
$color = $blue_flag?"blue":"";
}
$str = "<p style='font-size:12px;color:".$color."'>".$wpcf7_contact_form_num."</p>";
return $str;
}
add_shortcode( 'contact_form_num_new', 'contact_form_num_func_new' );
echo do_shortcode('[contact_form_num_new]');?>