PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.12.2
Independent Analytics – WordPress Analytics Plugin v2.12.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 / Report.php
independent-analytics / IAWP Last commit date
AJAX 10 months ago Admin_Page 11 months ago Click_Tracking 1 year ago Custom_WordPress_Columns 1 year ago Data_Pruning 1 year ago Date_Picker 1 year ago Date_Range 11 months ago Ecommerce 1 year ago Email_Reports 11 months ago Examiner 11 months ago Filter_Lists 1 year ago Form_Submissions 11 months ago Integrations 1 year ago Interval 1 year ago Menu_Bar_Stats 1 year ago Migrations 1 year ago Models 10 months ago Overview 11 months ago Public_API 1 year ago Rows 10 months ago Statistics 11 months ago Tables 11 months ago Utils 11 months ago Appearance.php 1 year ago Campaign_Builder.php 1 year ago Capability_Manager.php 1 year ago Chart.php 1 year ago Chart_Data.php 1 year ago Click_Tracking.php 1 year ago Cron_Job.php 1 year ago Cron_Manager.php 1 year ago Current_Traffic_Finder.php 1 year ago Dashboard_Options.php 11 months ago Dashboard_Widget.php 2 years ago Database.php 1 year ago Database_Manager.php 11 months ago Empty_Report_Option.php 2 years ago Env.php 1 year ago Examiner_Config.php 11 months ago Filters.php 1 year ago Geo_Database_Background_Job.php 1 year ago Geo_Database_Manager.php 11 months ago Geoposition.php 1 year ago Icon_Directory.php 2 years ago Icon_Directory_Factory.php 2 years ago Illuminate_Builder.php 10 months ago Independent_Analytics.php 11 months ago Interrupt.php 1 year ago Known_Referrers.php 11 months ago MainWP.php 1 year ago Map.php 1 year ago Map_Data.php 1 year ago Migration_Fixer_Job.php 1 year ago Patch.php 1 year ago Payload_Validator.php 1 year ago Plugin_Conflict_Detector.php 11 months ago Plugin_Group.php 1 year ago Plugin_Group_Option.php 2 years ago Query.php 1 year ago Query_Taps.php 11 months ago Quick_Stats.php 11 months ago REST_API.php 11 months ago Real_Time.php 1 year ago Report.php 1 year ago Report_Finder.php 1 year ago Report_Options_Parser.php 1 year ago Resource_Identifier.php 1 year ago Settings.php 11 months ago Sort_Configuration.php 1 year ago Tables.php 1 year ago Track_Resource_Changes.php 1 year ago View.php 11 months ago View_Counter.php 1 year ago Views_Over_Time_Finder.php 1 year ago WP_Option_Cache_Bust.php 2 years ago
Report.php
121 lines
1 <?php
2
3 namespace IAWP;
4
5 use IAWP\Form_Submissions\Form;
6 use IAWP\Statistics\Statistic;
7 use IAWP\Tables\Columns\Column;
8 use IAWP\Tables\Table;
9 use IAWPSCOPED\Illuminate\Support\Collection;
10 /** @internal */
11 class Report
12 {
13 private $attributes;
14 public function __construct(object $attributes)
15 {
16 $this->attributes = $attributes;
17 // Convert string report ids to integers if the string is just numbers
18 if (\is_string($this->attributes->report_id) && \ctype_digit($this->attributes->report_id)) {
19 $this->attributes->report_id = \intval($this->attributes->report_id);
20 }
21 }
22 /**
23 * Will return an int for saved reports and a string for base reports
24 *
25 * @return int|string
26 */
27 public function id()
28 {
29 return $this->attributes->report_id;
30 }
31 public function type() : string
32 {
33 return $this->attributes->type;
34 }
35 public function type_label() : string
36 {
37 $labels = ['overview' => \__('Overview', 'independent-analytics'), 'real-time' => \__('Real-Time', 'independent-analytics'), 'views' => \__('Pages', 'independent-analytics'), 'referrers' => \__('Referrers', 'independent-analytics'), 'geo' => \__('Geo', 'independent-analytics'), 'devices' => \__('Devices', 'independent-analytics'), 'campaigns' => \__('Campaigns', 'independent-analytics'), 'clicks' => \__('Clicks', 'independent-analytics')];
38 return $labels[$this->type()] ?? 'Report';
39 }
40 public function name() : string
41 {
42 return $this->attributes->name;
43 }
44 public function group_name() : ?string
45 {
46 return $this->attributes->group_name ?? null;
47 }
48 public function url() : string
49 {
50 if (!$this->is_saved_report()) {
51 return \IAWPSCOPED\iawp_dashboard_url(['tab' => $this->attributes->type]);
52 }
53 return \IAWPSCOPED\iawp_dashboard_url(['tab' => $this->attributes->type, 'report' => $this->attributes->report_id]);
54 }
55 public function is_saved_report() : bool
56 {
57 return \is_int($this->id());
58 }
59 public function filters() : ?array
60 {
61 $array = (array) $this->attributes;
62 if (\array_key_exists('filters', $array) && \is_string($array['filters'])) {
63 $filters = \json_decode($array['filters'], \true);
64 if (\false !== $filters && \is_array($filters)) {
65 return $filters;
66 }
67 }
68 return null;
69 }
70 public function has_filters() : bool
71 {
72 return \is_array($this->filters()) && \count($this->filters()) > 0;
73 }
74 public function is_current() : bool
75 {
76 return (new \IAWP\Env())->is_currently_viewed($this->is_saved_report() ? $this->id() : $this->type());
77 }
78 public function is_favorite() : bool
79 {
80 return (new \IAWP\Env())->is_favorite($this->is_saved_report() ? $this->id() : $this->type());
81 }
82 public function to_array() : array
83 {
84 $array = (array) $this->attributes;
85 if (\array_key_exists('columns', $array) && !\is_null($array['columns'])) {
86 $array['columns'] = \json_decode($array['columns'], \true);
87 }
88 if (\array_key_exists('filters', $array) && !\is_null($array['filters'])) {
89 $array['filters'] = \json_decode($array['filters'], \true);
90 }
91 return $array;
92 }
93 /**
94 * @return Column[]
95 */
96 public function get_supported_columns() : array
97 {
98 /** @var Table $table_class */
99 $table_class = \IAWP\Env::get_table($this->type());
100 $table = new $table_class($this->group_name());
101 return \array_values($table->get_columns());
102 }
103 public function get_supported_statistics() : array
104 {
105 $statistics = [new Statistic(['id' => 'visitors', 'name' => \__('Visitors', 'independent-analytics'), 'plugin_group' => 'general', 'is_visible_in_dashboard_widget' => \true]), new Statistic(['id' => 'views', 'name' => \__('Views', 'independent-analytics'), 'plugin_group' => 'general', 'is_visible_in_dashboard_widget' => \true]), new Statistic(['id' => 'sessions', 'name' => \__('Sessions', 'independent-analytics'), 'plugin_group' => 'general']), new Statistic(['id' => 'average_session_duration', 'name' => \__('Average Session Duration', 'independent-analytics'), 'plugin_group' => 'general', 'format' => 'time']), new Statistic(['id' => 'bounce_rate', 'name' => \__('Bounce Rate', 'independent-analytics'), 'plugin_group' => 'general', 'format' => 'percent', 'is_growth_good' => \false]), new Statistic(['id' => 'views_per_session', 'name' => \__('Views Per Session', 'independent-analytics'), 'plugin_group' => 'general', 'format' => 'decimal']), new Statistic(['id' => 'clicks', 'name' => \__('Clicks', 'independent-analytics'), 'plugin_group' => 'general', 'requires_pro' => \true]), new Statistic(['id' => 'wc_orders', 'name' => \__('Orders', 'independent-analytics'), 'plugin_group' => 'ecommerce']), new Statistic(['id' => 'wc_gross_sales', 'name' => \__('Gross Sales', 'independent-analytics'), 'plugin_group' => 'ecommerce', 'format' => 'rounded-currency']), new Statistic(['id' => 'wc_refunds', 'name' => \__('Refunds', 'independent-analytics'), 'plugin_group' => 'ecommerce']), new Statistic(['id' => 'wc_refunded_amount', 'name' => \__('Refunded Amount', 'independent-analytics'), 'plugin_group' => 'ecommerce', 'format' => 'rounded-currency']), new Statistic(['id' => 'wc_net_sales', 'name' => \__('Total Sales', 'independent-analytics'), 'plugin_group' => 'ecommerce', 'format' => 'rounded-currency']), new Statistic(['id' => 'wc_conversion_rate', 'name' => \__('Conversion Rate', 'independent-analytics'), 'plugin_group' => 'ecommerce', 'format' => 'percent']), new Statistic(['id' => 'wc_earnings_per_visitor', 'name' => \__('Earnings Per Visitor', 'independent-analytics'), 'plugin_group' => 'ecommerce', 'format' => 'currency']), new Statistic(['id' => 'wc_average_order_volume', 'name' => \__('Average Order Volume', 'independent-analytics'), 'plugin_group' => 'ecommerce', 'format' => 'rounded-currency']), new Statistic(['id' => 'form_submissions', 'name' => \__('Form Submissions', 'independent-analytics'), 'plugin_group' => 'forms']), new Statistic(['id' => 'form_conversion_rate', 'name' => \__('Form Conversion Rate', 'independent-analytics'), 'plugin_group' => 'forms', 'format' => 'percent'])];
106 foreach (Form::get_forms() as $form) {
107 if (!$form->is_plugin_active()) {
108 continue;
109 }
110 $statistics[] = new Statistic(['id' => 'form_submissions_for_' . $form->id(), 'name' => \sprintf(\_x('%s Submissions', 'Title of the contact form', 'independent-analytics'), $form->title()), 'plugin_group' => 'forms', 'is_subgroup_plugin_active' => $form->is_plugin_active(), 'plugin_group_header' => $form->plugin_name()]);
111 $statistics[] = new Statistic(['id' => 'form_conversion_rate_for_' . $form->id(), 'name' => \sprintf(\_x('%s Conversion Rate', 'Title of the contact form', 'independent-analytics'), $form->title()), 'plugin_group' => 'forms', 'is_subgroup_plugin_active' => $form->is_plugin_active(), 'plugin_group_header' => $form->plugin_name(), 'format' => 'percent']);
112 }
113 if ($this->type() === 'clicks') {
114 $statistics = [new Statistic(['id' => 'clicks', 'name' => \__('Clicks', 'independent-analytics'), 'plugin_group' => 'general'])];
115 }
116 return Collection::make($statistics)->filter(function (Statistic $statistic) {
117 return $statistic->is_enabled() && $statistic->is_group_plugin_enabled() && $statistic->is_subgroup_plugin_enabled();
118 })->values()->all();
119 }
120 }
121