PluginProbe
Plausible Analytics / trunk
Plausible Analytics vtrunk
2.6.1 2.6.0 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 All 52 releases
plausible-analytics / src / Integrations.php

Integrations.php in Plausible Analytics trunk, at src/Integrations.php

74 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plausible Analytics | Integrations
5 * @since 2.1.0
6 * @package WordPress
7 * @subpackage Plausible Analytics
8 */
9
10 namespace Plausible\Analytics\WP;
11
12 class Integrations {
13 const PURCHASE_TRACKED_META_KEY = '_plausible_analytics_purchase_tracked';
14
15 const SCRIPT_WRAPPER = '<script defer id="plausible-analytics-integration-tracking">document.addEventListener("DOMContentLoaded", () => { %s });</script>';
16
17 /**
18 * Build class.
19 */
20 public function __construct() {
21 $this->init();
22 }
23
24 /**
25 * Run available integrations.
26 * @return void
27 */
28 private function init() {
29 // WooCommerce
30 if ( self::is_wc_active() && EnhancedMeasurements::is_enabled( EnhancedMeasurements::ECOMMERCE_REVENUE ) ) {
31 new Integrations\WooCommerce(); // @codeCoverageIgnore
32 }
33
34 // Easy Digital Downloads
35 if ( self::is_edd_active() && EnhancedMeasurements::is_enabled( EnhancedMeasurements::ECOMMERCE_REVENUE ) ) {
36 new Integrations\EDD(); // @codeCoverageIgnore
37 }
38
39 // Form Plugins
40 if ( EnhancedMeasurements::is_enabled( EnhancedMeasurements::FORM_COMPLETIONS ) ) {
41 new Integrations\FormSubmit(); // @codeCoverageIgnore
42 }
43
44 // Search Queries
45 if ( EnhancedMeasurements::is_enabled( EnhancedMeasurements::SEARCH_QUERIES ) ) {
46 new Integrations\Search(); // @codeCoverageIgnore
47 }
48 }
49
50 /**
51 * Checks if WooCommerce is installed and activated.
52 * @return bool
53 */
54 public static function is_wc_active() {
55 return apply_filters( 'plausible_analytics_integrations_woocommerce', function_exists( 'WC' ) );
56 }
57
58 /**
59 * Checks if Easy Digital Downloads is installed and activated.
60 * @return bool
61 */
62 public static function is_edd_active() {
63 return apply_filters( 'plausible_analytics_integrations_edd', function_exists( 'EDD' ) );
64 }
65
66 /**
67 * Checks if EDD Recurring is installed and activated.
68 * @return mixed|null
69 */
70 public static function is_edd_recurring_active() {
71 return apply_filters( 'plausible_analytics_integrations_edd_recurring', function_exists( 'EDD_Recurring' ) );
72 }
73 }
74