$data) { if ($network == $key) { $r = isset($data['name']) ? $data['name'] : ''; } } if ($r == '') { $r = $key; } return $r; } } if (!function_exists('essb_subscribe_conversion_position_name')) { function essb_subscribe_conversion_position_name($position) { $r = ''; if ($position == 'shortcode') { $r = __('Shortcode', 'essb'); } if ($position == 'widget') { $r = __('Widget', 'essb'); } if ($position == 'belowcontent') { $r = __('Subscribe Form Below Content', 'essb'); } if (strpos($position, 'flyout') !== false) { $position_data = explode('-', $position); $r = __('Subscribers Flyout', 'essb'); if ($position_data[1] == 'time') { $r .= ': Timed delay'; } if ($position_data[1] == 'scroll') { $r .= ': On scroll'; } if ($position_data[1] == 'exit') { $r .= ': Exit intent'; } } if (strpos($position, 'booster') !== false) { $position_data = explode('-', $position); $r = __('Subscribers Booster', 'essb'); if ($position_data[1] == 'time') { $r .= ': Timed delay'; } if ($position_data[1] == 'scroll') { $r .= ': On scroll'; } if ($position_data[1] == 'exit') { $r .= ': Exit intent'; } } if ($r == '') { $r = $position; } return $r; } } if (!function_exists('essb_data_sorter')) { function essb_data_sorter($a, $b) { $c1 = isset($a['clicks']) ? $a['clicks'] : 0; $c2 = isset($b['clicks']) ? $b['clicks'] : 0; $v1 = isset($a['views']) ? $a['views'] : 0; $v2 = isset($b['views']) ? $b['views'] : 0; if ($v1 != 0) { $x = $c1 * 100 / $v1; } else { $x = 0; } if ($v2 != 0) { $y = $c2 * 100 / $v2; } else { $y = 0; } if ($x == $y) { return 0; } return ($x < $y) ? 1 : -1; } } function essb_subscribe_conversions_dashboard_report() { $reset_conversion = isset($_REQUEST['reset_subscribe_conversion']) ? $_REQUEST['reset_subscribe_conversion'] : ''; $conversions_data = get_option('essb-subscribe-conversions-lite'); if ($reset_conversion == 'true') { $conversions_data = array(); update_option('essb-subscribe-conversions-lite', $conversions_data); echo ''; } if (!is_array($conversions_data)) { $conversions_data = array(); } $total_views = 0; $total_clicks = 0; if (isset($conversions_data['totals'])) { if (isset($conversions_data['totals']['positions'])) { foreach ($conversions_data['totals']['positions'] as $key => $data) { $total_views += isset($data['views']) ? intval($data['views']) : 0; $total_clicks += isset($data['clicks']) ? intval($data['clicks']) : 0; } } } if (intval($total_views) > 0) { $total_percent = $total_clicks * 100 / $total_views; } else { $total_percent = 0; } if (is_nan($total_percent)) { $total_percent = 0; } ?> '', 'value' => 0); $best_network = array('key' => '', 'value' => 0); if (isset($conversions_data['totals']) && isset($conversions_data['totals']['positions'])) { foreach ($conversions_data['totals']['positions'] as $key => $data) { if ($key == '') continue; $single_views = isset($data['views']) ? intval($data['views']) : 0; $single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0; $single_percent = $single_clicks * 100 / $single_views; if ($best_position['key'] == '') { $best_position['key'] = $key; $best_position['value'] = $single_percent; } else { if ($best_position['value'] < $single_percent) { $best_position['key'] = $key; $best_position['value'] = $single_percent; } } } } if (isset($conversions_data['totals']) && isset($conversions_data['totals']['networks'])) { foreach ($conversions_data['totals']['networks'] as $key => $data) { if ($key == '') continue; $single_views = isset($data['views']) ? intval($data['views']) : 0; $single_clicks = isset($data['clicks']) ? intval($data['clicks']) : 0; $single_percent = $single_clicks * 100 / $single_views; if ($best_network['key'] == '') { $best_network['key'] = $key; $best_network['value'] = $single_percent; } else { if ($best_network['value'] < $single_percent) { $best_network['key'] = $key; $best_network['value'] = $single_percent; } } } } echo '