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() { |
||
62 | |||
63 | /** |
||
64 | * Adds the partner subsidiary code to the passed URL. |
||
65 | * |
||
66 | * @param string $url The URL. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function add_subsidiary_id_as_query_arg( $url ) { |
||
73 | |||
74 | /** |
||
75 | * Adds the affiliate code to the passed URL. |
||
76 | * |
||
77 | * @param string $url The URL. |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function add_affiliate_code_as_query_arg( $url ) { |
||
84 | |||
85 | /** |
||
86 | * Adds the partner subsidiary code to the passed array. |
||
87 | * |
||
88 | * @param array $params The parameters array. |
||
89 | * |
||
90 | * @return array |
||
91 | * @since 9.7.0 |
||
92 | */ |
||
93 | public function add_subsidiary_id_to_params_array( $params ) { |
||
99 | |||
100 | /** |
||
101 | * Adds the affiliate code to the passed array. |
||
102 | * |
||
103 | * @param array $params The parameters array. |
||
104 | * |
||
105 | * @return array |
||
106 | * @since 9.7.0 |
||
107 | */ |
||
108 | public function add_affiliate_code_to_params_array( $params ) { |
||
114 | |||
115 | /** |
||
116 | * Returns the passed URL with the partner code added as a URL query arg. |
||
117 | * |
||
118 | * @param string $type The partner code. |
||
119 | * @param string $url The URL where the partner subsidiary id will be added. |
||
120 | * |
||
121 | * @return string The passed URL with the partner code added. |
||
122 | * @since 8.1.0 |
||
123 | */ |
||
124 | public function add_code_as_query_arg( $type, $url ) { |
||
127 | |||
128 | /** |
||
129 | * Gets the partner code in an associative array format |
||
130 | * |
||
131 | * @param string $type The partner code. |
||
132 | * @return array |
||
133 | * @since 9.7.0 |
||
134 | */ |
||
135 | private function get_code_as_array( $type ) { |
||
155 | |||
156 | /** |
||
157 | * Returns a partner code. |
||
158 | * |
||
159 | * @param string $type This can be either 'affiliate' or 'subsidiary'. Returns empty string when code is unknown. |
||
160 | * |
||
161 | * @return string The partner code. |
||
162 | * @since 8.1.0 |
||
163 | */ |
||
164 | public function get_partner_code( $type ) { |
||
191 | |||
192 | /** |
||
193 | * Resets the singleton for testing purposes. |
||
194 | */ |
||
195 | public static function reset() { |
||
198 | } |
||
199 |