PluginProbe
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager / trunk
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager vtrunk
0.0.11 0.0.10 0.0.9 0.0.8 0.0.7 0.0.6 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5
cookiez / modules / connect / module.php

module.php in Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager trunk, at modules/connect/module.php

77 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Cookiez\Modules\Connect;
4
5 use ElementorOne\Connect\Facade;
6 use Cookiez\Classes\Module_Base;
7 use Cookiez\Modules\Connect\Classes\Config;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13 /**
14 * Class Module
15 */
16 class Module extends Module_Base {
17
18 /**
19 * Get module name.
20 * Retrieve the module name.
21 * @access public
22 * @return string Module name.
23 */
24 public function get_name(): string {
25 return 'connect';
26 }
27
28 public static function is_connected(): bool {
29 $facade = self::get_connect();
30 $access_token = $facade->data()->get_access_token();
31
32 return (bool) $access_token && $facade->utils()->is_valid_home_url();
33 }
34
35 public static function get_connect(): Facade {
36 return Facade::get( Config::PLUGIN_SLUG );
37 }
38
39 public function authorize_url( $authorize_url ) {
40 $utm_params = [];
41
42 $sm_campaign = get_transient( 'elementor_cookiez_campaign' );
43 if ( false === $sm_campaign ) {
44 return $authorize_url;
45 }
46
47 foreach ( [ 'source', 'medium', 'campaign' ] as $key ) {
48 if ( ! empty( $sm_campaign[ $key ] ) ) {
49 $utm_params[ 'utm_' . $key ] = $sm_campaign[ $key ];
50 }
51 }
52
53 if ( ! empty( $utm_params ) ) {
54 $authorize_url = add_query_arg( $utm_params, $authorize_url );
55 }
56
57 return $authorize_url;
58 }
59
60 public function __construct() {
61 add_filter( 'elementor_one/cookiez_connect_authorize_url', [ $this, 'authorize_url' ] );
62
63 Facade::make( [
64 'app_name' => Config::APP_NAME,
65 'app_prefix' => Config::APP_PREFIX,
66 'app_rest_namespace' => Config::APP_REST_NAMESPACE,
67 'base_url' => Config::BASE_URL,
68 'admin_page' => Config::ADMIN_PAGE,
69 'app_type' => Config::APP_TYPE,
70 'scopes' => Config::SCOPES,
71 'state_nonce' => Config::STATE_NONCE,
72 'connect_mode' => Config::CONNECT_MODE,
73 'plugin_slug' => Config::PLUGIN_SLUG,
74 ] );
75 }
76 }
77