PluginProbe
BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP / trunk
BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP vtrunk
3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 3.0.0 2.4.13 2.4.12 2.4.11 2.4.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 All 110 releases
betterlinks / includes / Traits / ArgumentSchema.php

ArgumentSchema.php in BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP trunk, at includes/Traits/ArgumentSchema.php

259 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace BetterLinks\Traits;
3 if ( ! defined( 'ABSPATH' ) ) { exit; }
4
5 trait ArgumentSchema
6 {
7 public function links_schema()
8 {
9 return apply_filters('betterlinks/links_schema', [
10 'ID' => [
11 'type' => 'integer',
12 'sanitize_callback' => 'absint',
13 ],
14 'link_author' => [
15 'type' => 'integer',
16 'sanitize_callback' => 'absint',
17 ],
18 'link_date' => [
19 'type' => 'string',
20 'format' => 'date-time',
21 ],
22 'link_date_gmt' => [
23 'type' => 'string',
24 'format' => 'date-time',
25 ],
26 'link_title' => [
27 'type' => 'string',
28 'sanitize_callback' => 'sanitize_text_field',
29 ],
30 'link_slug' => [
31 'type' => 'string',
32 'sanitize_callback' => 'sanitize_text_field',
33 ],
34 'link_note' => [
35 'type' => 'string',
36 'sanitize_callback' => 'sanitize_text_field',
37 ],
38 'link_status' => [
39 'type' => 'string',
40 'sanitize_callback' => 'sanitize_text_field',
41 ],
42 'nofollow' => [
43 'type' => 'string',
44 'sanitize_callback' => 'sanitize_text_field',
45 ],
46 'sponsored' => [
47 'type' => 'string',
48 'sanitize_callback' => 'sanitize_text_field',
49 ],
50 'track_me' => [
51 'type' => 'string',
52 'sanitize_callback' => 'sanitize_text_field',
53 ],
54 'param_forwarding' => [
55 'type' => 'string',
56 'sanitize_callback' => 'sanitize_text_field',
57 ],
58 'param_struct' => [
59 'type' => 'object',
60 // 'sanitize_callback' => 'sanitize_text_field',
61 ],
62 'redirect_type' => [
63 'type' => 'string',
64 'sanitize_callback' => 'sanitize_text_field',
65 ],
66 'target_url' => [
67 'type' => 'string',
68 'sanitize_callback' => 'esc_url_raw',
69 ],
70 'short_url' => [
71 'type' => 'string',
72 'sanitize_callback' => 'sanitize_text_field',
73 ],
74 'link_modified' => [
75 'type' => 'string',
76 'format' => 'date-time',
77 ],
78 'link_modified_gmt' => [
79 'type' => 'string',
80 'format' => 'date-time',
81 ],
82 'wildcards' => [
83 'type' => 'integer',
84 'sanitize_callback' => 'absint',
85 ]
86 ]);
87 }
88 public function terms_schema()
89 {
90 return [
91 'ID' => [
92 'type' => 'integer',
93 'sanitize_callback' => 'absint',
94 ],
95 'term_name' => [
96 'type' => 'string',
97 'sanitize_callback' => 'sanitize_text_field',
98 ],
99 'term_slug' => [
100 'type' => 'string',
101 'sanitize_callback' => 'sanitize_text_field',
102 ],
103 'term_type' => [
104 'type' => 'string',
105 'sanitize_callback' => 'sanitize_text_field',
106 ],
107 ];
108 }
109 public function clicks_schema()
110 {
111 return apply_filters('betterlinks/clicks_schema', [
112 'ID' => [
113 'type' => 'integer',
114 'sanitize_callback' => 'absint',
115 ],
116 'link_id' => [
117 'type' => 'integer',
118 'sanitize_callback' => 'absint',
119 ],
120 'ip' => [
121 'type' => 'string',
122 'sanitize_callback' => 'sanitize_text_field',
123 ],
124 'browser' => [
125 'type' => 'string',
126 'sanitize_callback' => 'sanitize_text_field',
127 ],
128 'os' => [
129 'type' => 'string',
130 'sanitize_callback' => 'sanitize_text_field',
131 ],
132 'referer' => [
133 'type' => 'string',
134 'sanitize_callback' => 'sanitize_text_field',
135 ],
136 'host' => [
137 'type' => 'string',
138 'sanitize_callback' => 'sanitize_text_field',
139 ],
140 'uri' => [
141 'type' => 'string',
142 'sanitize_callback' => 'sanitize_text_field',
143 ],
144 'click_count' => [
145 'type' => 'integer',
146 'sanitize_callback' => 'absint',
147 ],
148 'visitor_id' => [
149 'type' => 'string',
150 'sanitize_callback' => 'sanitize_text_field',
151 ],
152 'click_order' => [
153 'type' => 'integer',
154 'sanitize_callback' => 'absint',
155 ],
156 'created_at' => [
157 'type' => 'string',
158 'format' => 'date-time',
159 ],
160 'created_at_gmt' => [
161 'type' => 'string',
162 'format' => 'date-time',
163 ],
164 'goal_reached' => [
165 'type' => 'integer',
166 'sanitize_callback' => 'absint',
167 ],
168 'target_url' => [
169 'type' => 'string',
170 'sanitize_callback' => 'sanitize_text_field',
171 ],
172 ]);
173 }
174 public function get_clicks_schema()
175 {
176 return $this->clicks_schema();
177 }
178 public function get_links_schema()
179 {
180 return array_merge(
181 $this->links_schema(),
182 [
183 'limit' => [
184 'type' => 'integer',
185 'default' => 5,
186 'sanitize_callback' => 'absint',
187 ],
188 'old_short_url' => [
189 'type' => 'string',
190 'sanitize_callback' => 'sanitize_text_field',
191 ],
192 'cat_id' => [
193 'type' => 'string',
194 'sanitize_callback' => 'sanitize_text_field',
195 ],
196 'cat_slug' => [
197 'type' => 'string',
198 'sanitize_callback' => 'sanitize_text_field',
199 ],
200 'tags_id' => [
201 'type' => 'array'
202 ],
203 'favorite' => [
204 'type' => 'array'
205 ],
206 'analytic' => [
207 'type' => 'array'
208 ],
209 'enable_password' => [
210 'type' => 'boolean'
211 ],
212 'password' => [
213 'type' => 'string'
214 ],
215 'enable_custom_scripts' => [
216 'type' => 'boolean'
217 ],
218 'custom_tracking_scripts' => [
219 'type' => 'string',
220 // Raw JS echoed on the cloak page — unfiltered_html only.
221 'sanitize_callback' => array( '\\BetterLinks\\Helper', 'sanitize_custom_tracking_scripts' ),
222 ],
223 ],
224 $this->terms_schema()
225 );
226 }
227
228 public function get_terms_schema()
229 {
230 return $this->terms_schema();
231 }
232
233 public function get_settings_schema()
234 {
235 return [
236 'nofollow' => [
237 'type' => 'string',
238 'sanitize_callback' => 'sanitize_text_field',
239 ],
240 'sponsored' => [
241 'type' => 'string',
242 'sanitize_callback' => 'sanitize_text_field',
243 ],
244 'track_me' => [
245 'type' => 'string',
246 'sanitize_callback' => 'sanitize_text_field',
247 ],
248 'param_forwarding' => [
249 'type' => 'string',
250 'sanitize_callback' => 'sanitize_text_field',
251 ],
252 'redirect_type' => [
253 'type' => 'string',
254 'sanitize_callback' => 'sanitize_text_field',
255 ]
256 ];
257 }
258 }
259