| 1 |
<?php |
| 2 |
/** |
| 3 |
* GoogleSiteKit Compatibility |
| 4 |
* Google Site Kit is doing conversion tracking using query parameters |
| 5 |
* Keys are different in Google Site Kit and WPFunnels |
| 6 |
* This class is responsible for updating the query parameters for Google Site Kit |
| 7 |
* |
| 8 |
* @package WPFunnels\Compatibility\Plugin |
| 9 |
*/ |
| 10 |
namespace WPFunnels\Compatibility\Plugin; |
| 11 |
|
| 12 |
use WPFunnels\Wpfnl_functions; |
| 13 |
use WPFunnels\Traits\SingletonTrait; |
| 14 |
|
| 15 |
/** |
| 16 |
* Google Site Kit Compatibility |
| 17 |
* |
| 18 |
* @package WPFunnels\Compatibility |
| 19 |
*/ |
| 20 |
class GoogleSiteKit extends PluginCompatibility{ |
| 21 |
use SingletonTrait; |
| 22 |
|
| 23 |
/** |
| 24 |
* Implement Filters/Hooks |
| 25 |
* to initiate the necessary updates. |
| 26 |
* |
| 27 |
* @since 3.4.13 |
| 28 |
*/ |
| 29 |
public function init() { |
| 30 |
|
| 31 |
add_filter( 'wpfunnels/update_query_param', array( $this, 'update_query_param'), 10 ); |
| 32 |
add_filter( 'wpfunnels/prepare_query_param', array( $this, 'update_query_param'), 10 ); |
| 33 |
add_filter( 'wpfunnels/order_meta', array( $this, 'update_query_param'), 10 ); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
/** |
| 38 |
* Updates the query parameters |
| 39 |
* This function checks if the 'wpfnl-key' parameter is set in the given array |
| 40 |
* If it is, the function add new param 'key' with the same value of 'wpfnl-key' and returns the updated array |
| 41 |
* If 'wpfnl-key' is not set, the function returns the original array without any changes. |
| 42 |
* |
| 43 |
* @param array $query_param |
| 44 |
* |
| 45 |
* @return array |
| 46 |
* |
| 47 |
* @since 3.4.13 |
| 48 |
*/ |
| 49 |
public function update_query_param( $query_param ) { |
| 50 |
if( isset( $query_param['wpfnl-key'] )){ |
| 51 |
$query_param['key'] = $query_param['wpfnl-key']; |
| 52 |
} |
| 53 |
return $query_param; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
/** |
| 59 |
* Check if Google Site Kit is activated |
| 60 |
* Checked out the constant 'GOOGLESITEKIT_PLUGIN_MAIN_FILE' is defined or not |
| 61 |
* If not defined, the plugin is not activated and will return false |
| 62 |
* If defined, the plugin is activated and will return true |
| 63 |
* |
| 64 |
* @return bool |
| 65 |
* @since 3.4.13 |
| 66 |
*/ |
| 67 |
public function maybe_activate() |
| 68 |
{ |
| 69 |
return defined('GOOGLESITEKIT_PLUGIN_MAIN_FILE'); |
| 70 |
} |
| 71 |
} |
| 72 |
|