|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Generate random date. |
|
4
|
|
|
* |
|
5
|
|
|
* @see http://stackoverflow.com/a/14186825 |
|
6
|
|
|
* @param [type] $min_date [description] |
|
|
|
|
|
|
7
|
|
|
* @param [type] $max_date [description] |
|
|
|
|
|
|
8
|
|
|
* @return [type] [description] |
|
|
|
|
|
|
9
|
|
|
*/ |
|
10
|
|
|
function wpbo_rand_date( $min_date, $max_date ) { |
|
11
|
|
|
/* Gets 2 dates as string, earlier and later date. |
|
12
|
|
|
Returns date in between them. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
$rand_epoch = rand( $min_date, $max_date ); |
|
16
|
|
|
|
|
17
|
|
|
return date( 'Y-m-d H:i:s', $rand_epoch ); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
function wpbo_input_dummy( $lines = 5 ) { |
|
21
|
|
|
|
|
22
|
|
|
if( isset( $_GET['wpbo_dummy'] ) && is_numeric( $_GET['wpbo_dummy'] ) ) |
|
23
|
|
|
$lines = $_GET['wpbo_dummy']; |
|
24
|
|
|
|
|
25
|
|
|
/* Max conversion rate */ |
|
26
|
|
|
$ratio = 10; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/* Max conversion added based on max ratio */ |
|
29
|
|
|
$max = ( 20 * $lines ) / 100; |
|
30
|
|
|
|
|
31
|
|
|
$args = array( |
|
32
|
|
|
'post_type' => 'wpbo-popup', |
|
33
|
|
|
'post_status' => 'publish', |
|
34
|
|
|
'posts_per_page' => -1, |
|
35
|
|
|
|
|
36
|
|
|
); |
|
37
|
|
|
|
|
38
|
|
|
$popups = new WP_Query( $args ); |
|
39
|
|
|
|
|
40
|
|
|
if( count( $popups->posts ) >= 1 ) { |
|
41
|
|
|
|
|
42
|
|
|
foreach( $popups->posts as $popup ) { |
|
43
|
|
|
|
|
44
|
|
|
/* Count ratio */ |
|
45
|
|
|
$limit = 0; |
|
46
|
|
|
|
|
47
|
|
|
$types = array( |
|
48
|
|
|
'impression', |
|
49
|
|
|
'conversion' |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
for( $count = 0; $count <= $lines; $count++ ) { |
|
53
|
|
|
|
|
54
|
|
|
if( $limit >= $max ) |
|
55
|
|
|
$types[1] = 'impression'; |
|
56
|
|
|
|
|
57
|
|
|
$dtype = rand( 0, 1 ); |
|
58
|
|
|
$dtype = $types[$dtype]; |
|
59
|
|
|
$time = wpbo_rand_date( strtotime( 'first day of January last year', time() ), strtotime( 'last day of December this year', time() ) ); |
|
60
|
|
|
|
|
61
|
|
|
if( $dtype === 'conversion' ) |
|
62
|
|
|
++$limit; |
|
63
|
|
|
|
|
64
|
|
|
wpbo_db_insert_data( array( 'time' => $time, 'data_type' => $dtype, 'popup_id' => $popup->ID, ), false ); |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
function wpbo_add_dummy() { |
|
75
|
|
|
add_action( 'init', 'wpbo_input_dummy' ); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
if ( isset( $_GET['wpbo_dummy'] ) ) { |
|
79
|
|
|
wpbo_add_dummy(); |
|
80
|
|
|
} |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.