function wpbo_input_dummy($lines = 5) { if (isset($_GET['wpbo_dummy']) && is_numeric($_GET['wpbo_dummy'])) { $lines = $_GET['wpbo_dummy']; } /* Max conversion rate */ $ratio = 10; /* Max conversion added based on max ratio */ $max = 20 * $lines / 100; $args = array('post_type' => 'wpbo-popup', 'post_status' => 'publish', 'posts_per_page' => -1); $popups = new WP_Query($args); if (count($popups->posts) >= 1) { foreach ($popups->posts as $popup) { /* Count ratio */ $limit = 0; $types = array('impression', 'conversion'); for ($count = 0; $count <= $lines; $count++) { if ($limit >= $max) { $types[1] = 'impression'; } $dtype = rand(0, 1); $dtype = $types[$dtype]; $time = wpbo_rand_date(strtotime('first day of January last year', time()), strtotime('last day of December this year', time())); if ($dtype === 'conversion') { ++$limit; } wpbo_db_insert_data(array('time' => $time, 'data_type' => $dtype, 'popup_id' => $popup->ID), false); } } } }
/** * Log a new popup conversion * * @since 2.0 * @return int|WP_Error */ public function new_conversion() { $log = wpbo_db_insert_data(array('popup_id' => $this->popup_id, 'data_type' => 'conversion', 'ip_address' => wpbo_get_ip_address(), 'referer' => esc_url($_SERVER['HTTP_REFERER']), 'user_agent' => $_SERVER['HTTP_USER_AGENT']), false); return $log; }