1 | <?php |
||
15 | class Partner { |
||
16 | |||
17 | /** |
||
18 | * Affiliate code. |
||
19 | */ |
||
20 | const AFFILIATE_CODE = 'affiliate'; |
||
21 | |||
22 | /** |
||
23 | * Subsidiary id code. |
||
24 | */ |
||
25 | const SUBSIDIARY_CODE = 'subsidiary'; |
||
26 | |||
27 | /** |
||
28 | * Singleton instance. |
||
29 | * |
||
30 | * @since 8.1.0 |
||
31 | * |
||
32 | * @var Partner This class instance. |
||
33 | */ |
||
34 | private static $instance = null; |
||
35 | |||
36 | /** |
||
37 | * Partner constructor. |
||
38 | */ |
||
39 | private function __construct() { |
||
41 | |||
42 | /** |
||
43 | * Initializes the class or returns the singleton. |
||
44 | * |
||
45 | * @return Partner | false |
||
46 | * @since 8.1.0 |
||
47 | */ |
||
48 | public static function init() { |
||
57 | |||
58 | /** |
||
59 | * Adds the partner subsidiary code to the passed URL. |
||
60 | * |
||
61 | * @param string $url The URL. |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | public function add_subsidiary_id_as_query_arg( $url ) { |
||
68 | |||
69 | /** |
||
70 | * Adds the affiliate code to the passed URL. |
||
71 | * |
||
72 | * @param string $url The URL. |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function add_affiliate_code_as_query_arg( $url ) { |
||
79 | |||
80 | /** |
||
81 | * Returns the passed URL with the partner code added as a URL query arg. |
||
82 | * |
||
83 | * @param string $type The partner code. |
||
84 | * @param string $url The URL where the partner subsidiary id will be added. |
||
85 | * |
||
86 | * @return string The passed URL with the partner code added. |
||
87 | * @since 8.1.0 |
||
88 | */ |
||
89 | public function add_code_as_query_arg( $type, $url ) { |
||
109 | |||
110 | /** |
||
111 | * Returns a partner code. |
||
112 | * |
||
113 | * @param string $type This can be either 'affiliate' or 'subsidiary'. Returns empty string when code is unknown. |
||
114 | * |
||
115 | * @return string The partner code. |
||
116 | * @since 8.1.0 |
||
117 | */ |
||
118 | public function get_partner_code( $type ) { |
||
145 | |||
146 | /** |
||
147 | * Resets the singleton for testing purposes. |
||
148 | */ |
||
149 | public static function reset() { |
||
152 | } |
||
153 |