PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / utils / class-traffic-channel.php

class-traffic-channel.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/utils/class-traffic-channel.php

144 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace OPTN\Includes\Utils;
4
5 class TrafficChannel {
6
7 private static $organic_sources = array(
8 'www.google' => array( 'q=' ),
9 'daum.net/' => array( 'q=' ),
10 'eniro.se/' => array( 'search_word=', 'hitta:' ),
11 'naver.com/' => array( 'query=' ),
12 'yahoo.com/' => array( 'p=' ),
13 'msn.com/' => array( 'q=' ),
14 'bing.com/' => array( 'q=' ),
15 'aol.com/' => array( 'query=', 'encquery=' ),
16 'lycos.com/' => array( 'query=' ),
17 'ask.com/' => array( 'q=' ),
18 'altavista.com/' => array( 'q=' ),
19 'search.netscape.com/' => array( 'query=' ),
20 'cnn.com/SEARCH/' => array( 'query=' ),
21 'about.com/' => array( 'terms=' ),
22 'mamma.com/' => array( 'query=' ),
23 'alltheweb.com/' => array( 'q=' ),
24 'voila.fr/' => array( 'rdata=' ),
25 'search.virgilio.it/' => array( 'qs=' ),
26 'baidu.com/' => array( 'wd=' ),
27 'alice.com/' => array( 'qs=' ),
28 'yandex.com/' => array( 'text=' ),
29 'najdi.org.mk/' => array( 'q=' ),
30 'aol.com/' => array( 'q=' ),
31 'mamma.com/' => array( 'query=' ),
32 'seznam.cz/' => array( 'q=' ),
33 'search.com/' => array( 'q=' ),
34 'wp.pl/' => array( 'szukai=' ),
35 'online.onetcenter.org/' => array( 'qt=' ),
36 'szukacz.pl/' => array( 'q=' ),
37 'yam.com/' => array( 'k=' ),
38 'pchome.com/' => array( 'q=' ),
39 'kvasir.no/' => array( 'q=' ),
40 'sesam.no/' => array( 'q=' ),
41 'ozu.es/' => array( 'q=' ),
42 'terra.com/' => array( 'query=' ),
43 'mynet.com/' => array( 'q=' ),
44 'ekolay.net/' => array( 'q=' ),
45 'rambler.ru/' => array( 'words=' ),
46 );
47
48 private static $social_media_domains = array(
49 'facebook.com',
50 'twitter.com',
51 'instagram.com',
52 'linkedin.com',
53 'tiktok.com',
54 'pinterest.com',
55 'snapchat.com',
56 'reddit.com',
57 'youtube.com',
58 );
59
60 private static function is_direct_traffic() {
61 if ( ! isset( $_SERVER['HTTP_REFERER'] ) || empty( $_SERVER['HTTP_REFERER'] ) ) {
62 return true;
63 }
64 return false;
65 }
66
67 private static function is_social_media_traffic() {
68 if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
69 return false;
70 }
71
72 $referrer = sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) );
73
74 foreach ( self::$social_media_domains as $domain ) {
75 if ( strpos( $referrer, $domain ) !== false ) {
76 return true;
77 }
78 }
79 return false;
80 }
81
82 private static function is_paid_search_traffic() {
83 if ( isset( $_GET['utm_medium'] ) && 'cpc' === strtolower( sanitize_text_field( wp_unslash( $_GET['utm_medium'] ) ) ) ) { // phpcs:ignore
84 return true;
85 }
86
87 if ( isset( $_GET['gclid'] ) ) { // phpcs:ignore
88 return true;
89 }
90
91 if ( isset( $_GET['msclkid'] ) ) { // phpcs:ignore
92 return true;
93 }
94
95 return false;
96 }
97
98
99 /**
100 * Check if source is organic
101 *
102 * @return boolean
103 */
104 private static function is_organic_search_traffic() {
105 if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
106 return false;
107 }
108
109 foreach ( self::$organic_sources as $searchEngine => $queries ) {
110 if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ), $searchEngine ) !== false ) { // phpcs:ignore
111 foreach ( $queries as $query ) {
112 if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ), $query ) !== false ) { // phpcs:ignore
113 return true;
114 }
115 }
116 }
117 }
118
119 return false;
120 }
121
122 public static function get_traffic_channels() {
123 $channels = array();
124
125 if ( self::is_direct_traffic() ) {
126 $channels[] = 'direct';
127 }
128
129 if ( self::is_social_media_traffic() ) {
130 $channels[] = 'social';
131 }
132
133 if ( self::is_paid_search_traffic() ) {
134 $channels[] = 'paid';
135 }
136
137 if ( self::is_organic_search_traffic() ) {
138 $channels[] = 'org';
139 }
140
141 return $channels;
142 }
143 }
144