PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.14.2
Independent Analytics – WordPress Analytics Plugin v2.14.2
2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / IAWP / Query_Taps.php
independent-analytics / IAWP Last commit date
AJAX 5 months ago Admin_Page 5 months ago Click_Tracking 5 months ago ColumnOptions 6 months ago Cron 9 months ago Custom_WordPress_Columns 8 months ago Data_Pruning 5 months ago Date_Picker 5 months ago Date_Range 5 months ago Ecommerce 5 months ago Email_Reports 5 months ago Examiner 11 months ago Favicon 5 months ago Form_Submissions 5 months ago Integrations 6 months ago Interval 1 year ago Journey 5 months ago Migrations 5 months ago Models 5 months ago Overview 5 months ago Public_API 5 months ago Rows 5 months ago Statistics 5 months ago Tables 5 months ago Utils 5 months ago Views 5 months ago WooCommerceOrderMetaBox 5 months ago Admin_Bar_Stats.php 5 months ago Appearance.php 1 year ago Campaign_Builder.php 5 months ago Capability_Manager.php 1 year ago Chart.php 9 months ago Chart_Data.php 1 year ago Click_Tracking.php 1 year ago Cron_Job.php 5 months ago Cron_Manager.php 5 months ago Current_Traffic_Finder.php 1 year ago Dashboard_Options.php 6 months ago Dashboard_Widget.php 2 years ago Database.php 8 months ago Database_Manager.php 5 months ago Empty_Report_Option.php 2 years ago Env.php 6 months ago Examiner_Config.php 11 months ago FetchFaviconsJob.php 5 months ago Filters.php 5 months ago Geo_Database_Health_Check_Job.php 9 months ago Geo_Database_Manager.php 6 months ago Geoposition.php 1 year ago Icon_Directory.php 6 months ago Icon_Directory_Factory.php 2 years ago Illuminate_Builder.php 10 months ago Independent_Analytics.php 5 months ago Interrupt.php 1 year ago Known_Referrers.php 6 months ago MainWP.php 1 year ago Map.php 9 months ago Map_Data.php 1 year ago Migration_Fixer_Job.php 5 months ago Patch.php 1 year ago Payload_Validator.php 9 months ago Plugin_Conflict_Detector.php 6 months ago Plugin_Group.php 6 months ago Plugin_Group_Option.php 2 years ago Query.php 1 year ago Query_Taps.php 5 months ago Quick_Stats.php 11 months ago REST_API.php 6 months ago Real_Time.php 5 months ago Report.php 1 year ago Report_Finder.php 6 months ago Report_Options_Parser.php 9 months ago Resource_Identifier.php 9 months ago Settings.php 6 months ago Sort_Configuration.php 9 months ago Tables.php 8 months ago Track_Resource_Changes.php 1 year ago View_Counter.php 6 months ago Views_Over_Time_Finder.php 1 year ago VisitorSaltRefreshInterval.php 6 months ago WP_Option_Cache_Bust.php 2 years ago
Query_Taps.php
134 lines
1 <?php
2
3 namespace IAWP;
4
5 use IAWPSCOPED\Illuminate\Database\Query\Builder;
6 use IAWPSCOPED\Illuminate\Database\Query\JoinClause;
7 use IAWPSCOPED\Illuminate\Support\Str;
8 /** @internal */
9 class Query_Taps
10 {
11 public static function tap_authored_content_check($should_join_resources = \true)
12 {
13 return function (Builder $query) use($should_join_resources) {
14 if (!\is_user_logged_in() || \IAWP\Capability_Manager::can_view_all_analytics()) {
15 return;
16 }
17 if ($should_join_resources) {
18 $resources_table = \IAWP\Query::get_table_name(\IAWP\Query::RESOURCES);
19 $query->leftJoin($query->raw($resources_table . ' AS resources'), function (JoinClause $join) {
20 $join->on('views.resource_id', '=', 'resources.id');
21 });
22 }
23 $query->where('resources.cached_author_id', '=', \get_current_user_id());
24 };
25 }
26 public static function tap_authored_content_for_clicks()
27 {
28 return function (Builder $query) {
29 if (!\is_user_logged_in() || \IAWP\Capability_Manager::can_view_all_analytics()) {
30 return;
31 }
32 $resources_table = \IAWP\Query::get_table_name(\IAWP\Query::RESOURCES);
33 $query->leftJoin($query->raw($resources_table . ' AS resources'), function (JoinClause $join) {
34 $join->on('views.resource_id', '=', 'resources.id');
35 });
36 $query->where('resources.cached_author_id', '=', \get_current_user_id());
37 };
38 }
39 public static function tap_related_to_examined_record(?\IAWP\Examiner_Config $config)
40 {
41 return function (Builder $query) use($config) {
42 if (!$config) {
43 return;
44 }
45 $column = self::examiner_type_to_column($config->group());
46 if (!$column) {
47 return;
48 }
49 if ($config->group() === 'referrer_type') {
50 $query->leftJoin(\IAWP\Tables::referrers() . ' AS referrers', 'sessions.referrer_id', '=', 'referrers.id');
51 }
52 $campaign_groups = ['landing_page', 'utm_source', 'utm_medium', 'utm_campaign'];
53 if (\in_array($config->group(), $campaign_groups)) {
54 $query->leftJoin(\IAWP\Tables::campaigns() . ' AS campaigns', 'sessions.campaign_id', '=', 'campaigns.campaign_id');
55 }
56 if ($config->group() === 'link' || $config->group() === 'link_pattern') {
57 $query->leftJoin(\IAWP\Tables::clicked_links() . ' AS clicked_links', 'clicked_links.click_id', '=', 'clicks.click_id');
58 $query->leftJoin(\IAWP\Tables::links() . ' AS links', 'links.id', '=', 'clicked_links.link_id');
59 }
60 $query->where($column, '=', $config->id());
61 };
62 }
63 public static function tap_related_to_examined_record_for_previous_period(?\IAWP\Examiner_Config $config, array $tables)
64 {
65 return function (Builder $query) use($config, $tables) {
66 if (!$config) {
67 return;
68 }
69 $column = self::examiner_type_to_column($config->group());
70 if (!$column) {
71 return;
72 }
73 $table = Str::before($column, '.');
74 if (!\in_array($table, $tables)) {
75 if ($table === 'views') {
76 $query->leftJoin(\IAWP\Tables::views() . ' AS views', 'sessions.session_id', '=', 'views.session_id');
77 }
78 if ($table === 'referrers') {
79 $query->leftJoin(\IAWP\Tables::referrers() . ' AS referrers', 'sessions.referrer_id', '=', 'referrers.id');
80 }
81 if ($table === 'campaigns') {
82 $query->leftJoin(\IAWP\Tables::campaigns() . ' AS campaigns', 'sessions.campaign_id', '=', 'campaigns.campaign_id');
83 }
84 if ($table === 'links') {
85 if (!\in_array('views', $tables)) {
86 $query->leftJoin(\IAWP\Tables::views() . ' AS views', 'sessions.session_id', '=', 'views.session_id');
87 }
88 $query->leftJoin(\IAWP\Tables::clicks() . ' AS clicks', 'views.id', '=', 'clicks.view_id');
89 $query->leftJoin(\IAWP\Tables::clicked_links() . ' AS clicked_links', 'clicked_links.click_id', '=', 'clicks.click_id');
90 $query->leftJoin(\IAWP\Tables::links() . ' AS links', 'links.id', '=', 'clicked_links.link_id');
91 }
92 }
93 $query->where($column, '=', $config->id());
94 };
95 }
96 private static function examiner_type_to_column(string $group) : ?string
97 {
98 switch ($group) {
99 case 'page':
100 return 'views.resource_id';
101 case 'referrer':
102 return 'sessions.referrer_id';
103 case 'referrer_type':
104 return 'referrers.referrer_type_id';
105 case 'country':
106 return 'sessions.country_id';
107 case 'city':
108 return 'sessions.city_id';
109 case 'device_type':
110 return 'sessions.device_type_id';
111 case 'os':
112 return 'sessions.device_os_id';
113 case 'browser':
114 return 'sessions.device_browser_id';
115 case 'campaign':
116 return 'sessions.campaign_id';
117 case 'landing_page':
118 return 'campaigns.landing_page_id';
119 case 'utm_source':
120 return 'campaigns.utm_source_id';
121 case 'utm_medium':
122 return 'campaigns.utm_medium_id';
123 case 'utm_campaign':
124 return 'campaigns.utm_campaign_id';
125 case 'link':
126 return 'links.id';
127 case 'link_pattern':
128 return 'links.link_rule_id';
129 default:
130 return null;
131 }
132 }
133 }
134