|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package Pods |
|
4
|
|
|
*/ |
|
5
|
|
|
class PodsUI { |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @var null Nonce for security |
|
9
|
|
|
*/ |
|
10
|
|
|
private $_nonce = null; |
|
11
|
|
|
|
|
12
|
|
|
// internal |
|
13
|
|
|
/** |
|
14
|
|
|
* @var bool|PodsData |
|
15
|
|
|
*/ |
|
16
|
|
|
private $pods_data = false; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var array |
|
20
|
|
|
*/ |
|
21
|
|
|
private $actions = array( |
|
22
|
|
|
'manage', |
|
23
|
|
|
'add', |
|
24
|
|
|
'edit', |
|
25
|
|
|
'duplicate', |
|
26
|
|
|
'save', |
|
27
|
|
|
//'view', |
|
28
|
|
|
'delete', |
|
29
|
|
|
'reorder', |
|
30
|
|
|
'export' |
|
31
|
|
|
); |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var array |
|
35
|
|
|
*/ |
|
36
|
|
|
private $ui_page = array(); |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var bool |
|
40
|
|
|
*/ |
|
41
|
|
|
private $unique_identifier = false; |
|
42
|
|
|
|
|
43
|
|
|
// base |
|
44
|
|
|
public $x = array(); |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var array|bool|mixed|null|Pods |
|
48
|
|
|
*/ |
|
49
|
|
|
public $pod = false; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var int |
|
53
|
|
|
*/ |
|
54
|
|
|
public $id = 0; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
public $num = ''; // allows multiple co-existing PodsUI instances with separate functionality in URL |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var array |
|
63
|
|
|
*/ |
|
64
|
|
|
static $excluded = array( |
|
|
|
|
|
|
65
|
|
|
'do', |
|
66
|
|
|
'id', |
|
67
|
|
|
'pg', |
|
68
|
|
|
'search', |
|
69
|
|
|
'filter_*', |
|
70
|
|
|
'orderby', |
|
71
|
|
|
'orderby_dir', |
|
72
|
|
|
'limit', |
|
73
|
|
|
'action', |
|
74
|
|
|
'action_bulk', |
|
75
|
|
|
'action_bulk_ids', |
|
76
|
|
|
'_wpnonce', |
|
77
|
|
|
'view', |
|
78
|
|
|
'export', |
|
79
|
|
|
'export_type', |
|
80
|
|
|
'export_delimiter', |
|
81
|
|
|
'remove_export', |
|
82
|
|
|
'updated', |
|
83
|
|
|
'duplicate', |
|
84
|
|
|
'message' |
|
85
|
|
|
); // used in var_update |
|
86
|
|
|
|
|
87
|
|
|
static $allowed = array( |
|
|
|
|
|
|
88
|
|
|
'page', |
|
89
|
|
|
'post_type' |
|
90
|
|
|
); |
|
91
|
|
|
|
|
92
|
|
|
// ui |
|
93
|
|
|
/** |
|
94
|
|
|
* @var bool |
|
95
|
|
|
*/ |
|
96
|
|
|
public $item = false; // to be set with localized string |
|
97
|
|
|
/** |
|
98
|
|
|
* @var bool |
|
99
|
|
|
*/ |
|
100
|
|
|
public $items = false; // to be set with localized string |
|
101
|
|
|
/** |
|
102
|
|
|
* @var bool |
|
103
|
|
|
*/ |
|
104
|
|
|
public $heading = false; // to be set with localized string array |
|
105
|
|
|
/** |
|
106
|
|
|
* @var bool |
|
107
|
|
|
*/ |
|
108
|
|
|
public $header = false; // to be set with localized string array |
|
109
|
|
|
/** |
|
110
|
|
|
* @var bool |
|
111
|
|
|
*/ |
|
112
|
|
|
public $label = false; // to be set with localized string array |
|
113
|
|
|
/** |
|
114
|
|
|
* @var bool |
|
115
|
|
|
*/ |
|
116
|
|
|
public $icon = false; |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @var bool |
|
120
|
|
|
*/ |
|
121
|
|
|
public $css = false; // set to a URL of stylesheet to include |
|
122
|
|
|
/** |
|
123
|
|
|
* @var bool |
|
124
|
|
|
*/ |
|
125
|
|
|
public $wpcss = false; // set to true to include WP Admin stylesheets |
|
126
|
|
|
/** |
|
127
|
|
|
* @var array |
|
128
|
|
|
*/ |
|
129
|
|
|
public $fields = array( |
|
130
|
|
|
'manage' => array(), |
|
131
|
|
|
'search' => array(), |
|
132
|
|
|
'form' => array(), |
|
133
|
|
|
'add' => array(), |
|
134
|
|
|
'edit' => array(), |
|
135
|
|
|
'duplicate' => array(), |
|
136
|
|
|
'view' => array(), |
|
137
|
|
|
'reorder' => array(), |
|
138
|
|
|
'export' => array() |
|
139
|
|
|
); |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @var bool |
|
143
|
|
|
*/ |
|
144
|
|
|
public $searchable = true; |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @var bool |
|
148
|
|
|
*/ |
|
149
|
|
|
public $sortable = true; |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @var bool |
|
153
|
|
|
*/ |
|
154
|
|
|
public $pagination = true; |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @var bool |
|
158
|
|
|
*/ |
|
159
|
|
|
public $pagination_total = true; |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @var array |
|
163
|
|
|
*/ |
|
164
|
|
|
public $export = array( |
|
165
|
|
|
'on' => false, |
|
166
|
|
|
'formats' => array( |
|
167
|
|
|
'csv' => ',', |
|
168
|
|
|
'tsv' => "\t", |
|
169
|
|
|
'xml' => false, |
|
170
|
|
|
'json' => false |
|
171
|
|
|
), |
|
172
|
|
|
'url' => false, |
|
173
|
|
|
'type' => false |
|
174
|
|
|
); |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @var array |
|
178
|
|
|
*/ |
|
179
|
|
|
public $reorder = array( |
|
180
|
|
|
'on' => false, |
|
181
|
|
|
'limit' => 250, |
|
182
|
|
|
'orderby' => false, |
|
183
|
|
|
'orderby_dir' => 'ASC', |
|
184
|
|
|
'sql' => null |
|
185
|
|
|
); |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @var array |
|
189
|
|
|
*/ |
|
190
|
|
|
public $screen_options = array(); // set to 'page' => 'Text'; false hides link |
|
191
|
|
|
/** |
|
192
|
|
|
* @var array |
|
193
|
|
|
*/ |
|
194
|
|
|
public $help = array(); // set to 'page' => 'Text'; 'page' => array('link' => 'yourhelplink'); false hides link |
|
|
|
|
|
|
195
|
|
|
|
|
196
|
|
|
// data |
|
197
|
|
|
/** |
|
198
|
|
|
* @var bool |
|
199
|
|
|
*/ |
|
200
|
|
|
public $search = false; |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @var bool |
|
204
|
|
|
*/ |
|
205
|
|
|
public $filters_enhanced = false; |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @var array |
|
209
|
|
|
*/ |
|
210
|
|
|
public $filters = array(); |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @var string |
|
214
|
|
|
*/ |
|
215
|
|
|
public $view = false; |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* @var array |
|
219
|
|
|
*/ |
|
220
|
|
|
public $views = array(); |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* @var bool |
|
224
|
|
|
*/ |
|
225
|
|
|
public $search_across = true; |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* @var bool |
|
229
|
|
|
*/ |
|
230
|
|
|
public $search_across_picks = false; |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @var bool |
|
234
|
|
|
*/ |
|
235
|
|
|
public $default_none = false; |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @var array |
|
239
|
|
|
*/ |
|
240
|
|
|
public $where = array( |
|
241
|
|
|
'manage' => null, |
|
242
|
|
|
/*'edit' => null, |
|
|
|
|
|
|
243
|
|
|
'duplicate' => null, |
|
244
|
|
|
'delete' => null,*/ |
|
245
|
|
|
'reorder' => null |
|
246
|
|
|
); |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* @var bool |
|
250
|
|
|
*/ |
|
251
|
|
|
public $orderby = false; |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* @var string |
|
255
|
|
|
*/ |
|
256
|
|
|
public $orderby_dir = 'DESC'; |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* @var int |
|
260
|
|
|
*/ |
|
261
|
|
|
public $limit = 25; |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @var int |
|
265
|
|
|
*/ |
|
266
|
|
|
public $page = 1; |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* @var int |
|
270
|
|
|
*/ |
|
271
|
|
|
public $total = 0; |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* @var int |
|
275
|
|
|
*/ |
|
276
|
|
|
public $total_found = 0; |
|
277
|
|
|
|
|
278
|
|
|
/** |
|
279
|
|
|
* @var array |
|
280
|
|
|
*/ |
|
281
|
|
|
public $session = array( |
|
282
|
|
|
'search', |
|
283
|
|
|
'filters' |
|
284
|
|
|
); // allowed: search, filters, show_per_page, orderby (priority over usermeta) |
|
285
|
|
|
/** |
|
286
|
|
|
* @var array |
|
287
|
|
|
*/ |
|
288
|
|
|
public $user = array( |
|
289
|
|
|
'show_per_page', |
|
290
|
|
|
'orderby' |
|
291
|
|
|
); // allowed: search, filters, show_per_page, orderby (priority under session) |
|
292
|
|
|
|
|
293
|
|
|
// advanced data |
|
294
|
|
|
/** |
|
295
|
|
|
* @var array |
|
296
|
|
|
*/ |
|
297
|
|
|
public $sql = array( |
|
298
|
|
|
'table' => null, |
|
299
|
|
|
'field_id' => 'id', |
|
300
|
|
|
'field_index' => 'name', |
|
301
|
|
|
'select' => null, |
|
302
|
|
|
'sql' => null |
|
303
|
|
|
); |
|
304
|
|
|
|
|
305
|
|
|
/** |
|
306
|
|
|
* @var array |
|
307
|
|
|
*/ |
|
308
|
|
|
public $params = array(); |
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* @var bool|array |
|
312
|
|
|
*/ |
|
313
|
|
|
public $data = false; |
|
314
|
|
|
|
|
315
|
|
|
/** |
|
316
|
|
|
* @var bool|array |
|
317
|
|
|
*/ |
|
318
|
|
|
public $data_full = false; |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* @var array |
|
322
|
|
|
*/ |
|
323
|
|
|
public $data_keys = array(); |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* @var array |
|
327
|
|
|
*/ |
|
328
|
|
|
public $row = array(); |
|
329
|
|
|
|
|
330
|
|
|
// actions |
|
331
|
|
|
/** |
|
332
|
|
|
* @var string |
|
333
|
|
|
*/ |
|
334
|
|
|
public $action = 'manage'; |
|
335
|
|
|
|
|
336
|
|
|
/** |
|
337
|
|
|
* @var string |
|
338
|
|
|
*/ |
|
339
|
|
|
public $action_bulk = false; |
|
340
|
|
|
|
|
341
|
|
|
/** |
|
342
|
|
|
* @var array |
|
343
|
|
|
*/ |
|
344
|
|
|
public $bulk = array(); |
|
345
|
|
|
|
|
346
|
|
|
/** |
|
347
|
|
|
* @var array |
|
348
|
|
|
*/ |
|
349
|
|
|
public $action_after = array( |
|
350
|
|
|
'add' => 'edit', |
|
351
|
|
|
'edit' => 'edit', |
|
352
|
|
|
'duplicate' => 'edit' |
|
353
|
|
|
); // set action to 'manage' |
|
354
|
|
|
/** |
|
355
|
|
|
* @var bool |
|
356
|
|
|
*/ |
|
357
|
|
|
public $do = false; |
|
358
|
|
|
|
|
359
|
|
|
/** |
|
360
|
|
|
* @var array |
|
361
|
|
|
*/ |
|
362
|
|
|
public $action_links = array( |
|
363
|
|
|
'manage' => null, |
|
364
|
|
|
'add' => null, |
|
365
|
|
|
'edit' => null, |
|
366
|
|
|
'duplicate' => null, |
|
367
|
|
|
'view' => null, |
|
368
|
|
|
'delete' => null, |
|
369
|
|
|
'reorder' => null |
|
370
|
|
|
); // custom links (ex. /my-link/{@id}/ |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* @var array |
|
374
|
|
|
*/ |
|
375
|
|
|
public $actions_disabled = array( |
|
376
|
|
|
'view', |
|
377
|
|
|
'export' |
|
378
|
|
|
); // disable actions |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* @var array |
|
382
|
|
|
*/ |
|
383
|
|
|
public $actions_hidden = array(); // hide actions to not show them but allow them |
|
384
|
|
|
|
|
385
|
|
|
/** |
|
386
|
|
|
* @var array |
|
387
|
|
|
*/ |
|
388
|
|
|
public $actions_custom = array(); // overwrite existing actions or add your own |
|
389
|
|
|
|
|
390
|
|
|
/** |
|
391
|
|
|
* @var array |
|
392
|
|
|
*/ |
|
393
|
|
|
public $actions_bulk = array(); // enabled bulk actions |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* @var array |
|
397
|
|
|
*/ |
|
398
|
|
|
public $restrict = array( |
|
399
|
|
|
'manage' => null, |
|
400
|
|
|
'edit' => null, |
|
401
|
|
|
'duplicate' => null, |
|
402
|
|
|
'delete' => null, |
|
403
|
|
|
'reorder' => null, |
|
404
|
|
|
'author_restrict' => null |
|
405
|
|
|
); |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* @var array |
|
409
|
|
|
*/ |
|
410
|
|
|
public $extra = array( |
|
411
|
|
|
'total' => null |
|
412
|
|
|
); |
|
413
|
|
|
|
|
414
|
|
|
/** |
|
415
|
|
|
* @var string |
|
416
|
|
|
*/ |
|
417
|
|
|
public $style = 'post_type'; |
|
418
|
|
|
|
|
419
|
|
|
/** |
|
420
|
|
|
* @var bool |
|
421
|
|
|
*/ |
|
422
|
|
|
public $save = false; // Allow custom save handling for tables that aren't Pod-based |
|
423
|
|
|
|
|
424
|
|
|
/** |
|
425
|
|
|
* Generate UI for Data Management |
|
426
|
|
|
* |
|
427
|
|
|
* @param mixed $options Object, Array, or String containing Pod or Options to be used |
|
428
|
|
|
* @param bool $deprecated Set to true to support old options array from Pods UI plugin |
|
429
|
|
|
* |
|
430
|
|
|
* @return \PodsUI |
|
|
|
|
|
|
431
|
|
|
* |
|
432
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html |
|
433
|
|
|
* @since 2.0 |
|
434
|
|
|
*/ |
|
435
|
|
|
public function __construct ( $options, $deprecated = false ) { |
|
436
|
|
|
|
|
437
|
|
|
$this->_nonce = pods_v( '_wpnonce', 'request' ); |
|
438
|
|
|
|
|
439
|
|
|
$object = null; |
|
440
|
|
|
|
|
441
|
|
|
if ( is_object( $options ) ) { |
|
442
|
|
|
$object = $options; |
|
443
|
|
|
$options = array(); |
|
444
|
|
|
|
|
445
|
|
|
if ( isset( $object->ui ) ) { |
|
446
|
|
|
$options = (array) $object->ui; |
|
447
|
|
|
|
|
448
|
|
|
unset( $object->ui ); |
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
|
|
if ( is_object( $object ) && ( 'Pods' == get_class( $object ) || 'Pod' == get_class( $object ) ) ) |
|
452
|
|
|
$this->pod =& $object; |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
if ( !is_array( $options ) ) { |
|
456
|
|
|
// @todo need to come back to this and allow for multi-dimensional strings |
|
457
|
|
|
// like: option=value&option2=value2&option3=key[val],key2[val2]&option4=this,that,another |
|
458
|
|
|
if ( false !== strpos( $options, '=' ) || false !== strpos( $options, '&' ) ) |
|
459
|
|
|
parse_str( $options, $options ); |
|
460
|
|
|
else |
|
461
|
|
|
$options = array( 'pod' => $options ); |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
if ( !is_object( $object ) && isset( $options[ 'pod' ] ) ) { |
|
465
|
|
|
if ( is_object( $options[ 'pod' ] ) ) |
|
466
|
|
|
$this->pod = $options[ 'pod' ]; |
|
467
|
|
|
elseif ( isset( $options[ 'id' ] ) ) |
|
468
|
|
|
$this->pod = pods( $options[ 'pod' ], $options[ 'id' ] ); |
|
469
|
|
|
else |
|
470
|
|
|
$this->pod = pods( $options[ 'pod' ] ); |
|
471
|
|
|
|
|
472
|
|
|
unset( $options[ 'pod' ] ); |
|
473
|
|
|
} |
|
474
|
|
|
elseif ( is_object( $object ) ) |
|
475
|
|
|
$this->pod = $object; |
|
476
|
|
|
|
|
477
|
|
|
if ( false !== $deprecated || ( is_object( $this->pod ) && 'Pod' == get_class( $this->pod ) ) ) |
|
478
|
|
|
$options = $this->setup_deprecated( $options ); |
|
479
|
|
|
|
|
480
|
|
|
if ( is_object( $this->pod ) && 'Pod' == get_class( $this->pod ) && is_object( $this->pod->_data ) ) |
|
|
|
|
|
|
481
|
|
|
$this->pods_data =& $this->pod->_data; |
|
|
|
|
|
|
482
|
|
|
elseif ( is_object( $this->pod ) && 'Pods' == get_class( $this->pod ) && is_object( $this->pod->data ) ) |
|
483
|
|
|
$this->pods_data =& $this->pod->data; |
|
484
|
|
|
elseif ( is_object( $this->pod ) ) |
|
485
|
|
|
$this->pods_data = pods_data( $this->pod->pod ); |
|
486
|
|
|
elseif ( !is_object( $this->pod ) ) |
|
487
|
|
|
$this->pods_data = pods_data( $this->pod ); |
|
488
|
|
|
|
|
489
|
|
|
$options = $this->do_hook( 'pre_init', $options ); |
|
490
|
|
|
|
|
491
|
|
|
$this->setup( $options ); |
|
492
|
|
|
|
|
493
|
|
|
if ( is_object( $this->pods_data ) && is_object( $this->pod ) && 0 < $this->id ) { |
|
494
|
|
|
if ( $this->id != $this->pods_data->id ) |
|
495
|
|
|
$this->row = $this->pods_data->fetch( $this->id ); |
|
496
|
|
|
else |
|
497
|
|
|
$this->row = $this->pods_data->row; |
|
498
|
|
|
} |
|
499
|
|
|
|
|
500
|
|
|
if ( ( !is_object( $this->pod ) || 'Pods' != get_class( $this->pod ) ) && false === $this->sql[ 'table' ] && false === $this->data ) { |
|
501
|
|
|
echo $this->error( __( '<strong>Error:</strong> Pods UI needs a Pods object or a Table definition to run from, see the User Guide for more information.', 'pods' ) ); |
|
502
|
|
|
|
|
503
|
|
|
return false; |
|
|
|
|
|
|
504
|
|
|
} |
|
505
|
|
|
|
|
506
|
|
|
// Assign pod labels |
|
507
|
|
|
// @todo This is also done in setup(), maybe a better / more central way? |
|
508
|
|
|
if ( is_object( $this->pod ) && ! empty( $this->pod->pod_data[ 'options' ] ) ) { |
|
509
|
|
|
$pod_options = $this->pod->pod_data[ 'options' ]; |
|
510
|
|
|
$pod_options = apply_filters( 'pods_advanced_content_type_pod_data_' . $this->pod->pod_data[ 'name' ], $pod_options, $this->pod->pod_data[ 'name' ] ); |
|
511
|
|
|
$pod_options = apply_filters( 'pods_advanced_content_type_pod_data', $pod_options, $this->pod->pod_data[ 'name' ] ); |
|
512
|
|
|
|
|
513
|
|
|
$this->label = array_merge( $this->label, $pod_options ); |
|
514
|
|
|
} |
|
515
|
|
|
|
|
516
|
|
|
$this->go(); |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
/** |
|
520
|
|
|
* @param $deprecated_options |
|
521
|
|
|
* |
|
522
|
|
|
* @return array |
|
523
|
|
|
*/ |
|
524
|
|
|
public function setup_deprecated ( $deprecated_options ) { |
|
525
|
|
|
$options = array(); |
|
526
|
|
|
|
|
527
|
|
|
if ( isset( $deprecated_options[ 'id' ] ) ) |
|
528
|
|
|
$options[ 'id' ] = $deprecated_options[ 'id' ]; |
|
529
|
|
|
if ( isset( $deprecated_options[ 'action' ] ) ) |
|
530
|
|
|
$options[ 'action' ] = $deprecated_options[ 'action' ]; |
|
531
|
|
|
if ( isset( $deprecated_options[ 'num' ] ) ) |
|
532
|
|
|
$options[ 'num' ] = $deprecated_options[ 'num' ]; |
|
533
|
|
|
|
|
534
|
|
|
if ( isset( $deprecated_options[ 'title' ] ) ) |
|
535
|
|
|
$options[ 'items' ] = $deprecated_options[ 'title' ]; |
|
536
|
|
|
if ( isset( $deprecated_options[ 'item' ] ) ) |
|
537
|
|
|
$options[ 'item' ] = $deprecated_options[ 'item' ]; |
|
538
|
|
|
|
|
539
|
|
|
if ( isset( $deprecated_options[ 'label' ] ) ) |
|
540
|
|
|
$options[ 'label' ] = array( |
|
541
|
|
|
'add' => $deprecated_options[ 'label' ], |
|
542
|
|
|
'edit' => $deprecated_options[ 'label' ], |
|
543
|
|
|
'duplicate' => $deprecated_options[ 'label' ] |
|
544
|
|
|
); |
|
545
|
|
|
if ( isset( $deprecated_options[ 'label_add' ] ) ) { |
|
546
|
|
|
if ( isset( $options[ 'label' ] ) ) |
|
547
|
|
|
$options[ 'label' ][ 'add' ] = $deprecated_options[ 'label_add' ]; |
|
548
|
|
|
else |
|
549
|
|
|
$options[ 'label' ] = array( 'add' => $deprecated_options[ 'label_add' ] ); |
|
550
|
|
|
} |
|
551
|
|
|
if ( isset( $deprecated_options[ 'label_edit' ] ) ) { |
|
552
|
|
|
if ( isset( $options[ 'label' ] ) ) |
|
553
|
|
|
$options[ 'label' ][ 'edit' ] = $deprecated_options[ 'label_edit' ]; |
|
554
|
|
|
else |
|
555
|
|
|
$options[ 'label' ] = array( 'edit' => $deprecated_options[ 'label_edit' ] ); |
|
556
|
|
|
} |
|
557
|
|
|
if ( isset( $deprecated_options[ 'label_duplicate' ] ) ) { |
|
558
|
|
|
if ( isset( $options[ 'label' ] ) ) |
|
559
|
|
|
$options[ 'label' ][ 'duplicate' ] = $deprecated_options[ 'label_duplicate' ]; |
|
560
|
|
|
else |
|
561
|
|
|
$options[ 'label' ] = array( 'duplicate' => $deprecated_options[ 'label_duplicate' ] ); |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
|
|
if ( isset( $deprecated_options[ 'icon' ] ) ) |
|
565
|
|
|
$options[ 'icon' ] = $deprecated_options[ 'icon' ]; |
|
566
|
|
|
|
|
567
|
|
|
if ( isset( $deprecated_options[ 'columns' ] ) ) |
|
568
|
|
|
$options[ 'fields' ] = array( 'manage' => $deprecated_options[ 'columns' ] ); |
|
569
|
|
|
if ( isset( $deprecated_options[ 'reorder_columns' ] ) ) { |
|
570
|
|
|
if ( isset( $options[ 'fields' ] ) ) |
|
571
|
|
|
$options[ 'fields' ][ 'reorder' ] = $deprecated_options[ 'reorder_columns' ]; |
|
572
|
|
|
else |
|
573
|
|
|
$options[ 'fields' ] = array( 'reorder' => $deprecated_options[ 'reorder_columns' ] ); |
|
574
|
|
|
} |
|
575
|
|
View Code Duplication |
if ( isset( $deprecated_options[ 'add_fields' ] ) ) { |
|
576
|
|
|
if ( isset( $options[ 'fields' ] ) ) { |
|
577
|
|
|
if ( !isset( $options[ 'fields' ][ 'add' ] ) ) |
|
578
|
|
|
$options[ 'fields' ][ 'add' ] = $deprecated_options[ 'add_fields' ]; |
|
579
|
|
|
if ( !isset( $options[ 'fields' ][ 'edit' ] ) ) |
|
580
|
|
|
$options[ 'fields' ][ 'edit' ] = $deprecated_options[ 'add_fields' ]; |
|
581
|
|
|
if ( !isset( $options[ 'fields' ][ 'duplicate' ] ) ) |
|
582
|
|
|
$options[ 'fields' ][ 'duplicate' ] = $deprecated_options[ 'add_fields' ]; |
|
583
|
|
|
} |
|
584
|
|
|
else |
|
585
|
|
|
$options[ 'fields' ] = array( |
|
586
|
|
|
'add' => $deprecated_options[ 'add_fields' ], |
|
587
|
|
|
'edit' => $deprecated_options[ 'add_fields' ], |
|
588
|
|
|
'duplicate' => $deprecated_options[ 'add_fields' ] |
|
589
|
|
|
); |
|
590
|
|
|
} |
|
591
|
|
View Code Duplication |
if ( isset( $deprecated_options[ 'edit_fields' ] ) ) { |
|
592
|
|
|
if ( isset( $options[ 'fields' ] ) ) { |
|
593
|
|
|
if ( !isset( $options[ 'fields' ][ 'add' ] ) ) |
|
594
|
|
|
$options[ 'fields' ][ 'add' ] = $deprecated_options[ 'edit_fields' ]; |
|
595
|
|
|
if ( !isset( $options[ 'fields' ][ 'edit' ] ) ) |
|
596
|
|
|
$options[ 'fields' ][ 'edit' ] = $deprecated_options[ 'edit_fields' ]; |
|
597
|
|
|
if ( !isset( $options[ 'fields' ][ 'duplicate' ] ) ) |
|
598
|
|
|
$options[ 'fields' ][ 'duplicate' ] = $deprecated_options[ 'edit_fields' ]; |
|
599
|
|
|
} |
|
600
|
|
|
else |
|
601
|
|
|
$options[ 'fields' ] = array( |
|
602
|
|
|
'add' => $deprecated_options[ 'edit_fields' ], |
|
603
|
|
|
'edit' => $deprecated_options[ 'edit_fields' ], |
|
604
|
|
|
'duplicate' => $deprecated_options[ 'edit_fields' ] |
|
605
|
|
|
); |
|
606
|
|
|
} |
|
607
|
|
|
if ( isset( $deprecated_options[ 'duplicate_fields' ] ) ) { |
|
608
|
|
|
if ( isset( $options[ 'fields' ] ) ) |
|
609
|
|
|
$options[ 'fields' ][ 'duplicate' ] = $deprecated_options[ 'duplicate_fields' ]; |
|
610
|
|
|
else |
|
611
|
|
|
$options[ 'fields' ] = array( 'duplicate' => $deprecated_options[ 'duplicate_fields' ] ); |
|
612
|
|
|
} |
|
613
|
|
|
|
|
614
|
|
|
if ( isset( $deprecated_options[ 'session_filters' ] ) && false === $deprecated_options[ 'session_filters' ] ) |
|
615
|
|
|
$options[ 'session' ] = false; |
|
616
|
|
View Code Duplication |
if ( isset( $deprecated_options[ 'user_per_page' ] ) ) { |
|
617
|
|
|
if ( isset( $options[ 'user' ] ) && !empty( $options[ 'user' ] ) ) |
|
618
|
|
|
$options[ 'user' ] = array( 'orderby' ); |
|
619
|
|
|
else |
|
620
|
|
|
$options[ 'user' ] = false; |
|
621
|
|
|
} |
|
622
|
|
View Code Duplication |
if ( isset( $deprecated_options[ 'user_sort' ] ) ) { |
|
623
|
|
|
if ( isset( $options[ 'user' ] ) && !empty( $options[ 'user' ] ) ) |
|
624
|
|
|
$options[ 'user' ] = array( 'show_per_page' ); |
|
625
|
|
|
else |
|
626
|
|
|
$options[ 'user' ] = false; |
|
627
|
|
|
} |
|
628
|
|
|
|
|
629
|
|
|
if ( isset( $deprecated_options[ 'custom_list' ] ) ) { |
|
630
|
|
|
if ( isset( $options[ 'actions_custom' ] ) ) |
|
631
|
|
|
$options[ 'actions_custom' ][ 'manage' ] = $deprecated_options[ 'custom_list' ]; |
|
632
|
|
|
else |
|
633
|
|
|
$options[ 'actions_custom' ] = array( 'manage' => $deprecated_options[ 'custom_list' ] ); |
|
634
|
|
|
} |
|
635
|
|
|
if ( isset( $deprecated_options[ 'custom_reorder' ] ) ) { |
|
636
|
|
|
if ( isset( $options[ 'actions_custom' ] ) ) |
|
637
|
|
|
$options[ 'actions_custom' ][ 'reorder' ] = $deprecated_options[ 'custom_reorder' ]; |
|
638
|
|
|
else |
|
639
|
|
|
$options[ 'actions_custom' ] = array( 'reorder' => $deprecated_options[ 'custom_reorder' ] ); |
|
640
|
|
|
} |
|
641
|
|
|
if ( isset( $deprecated_options[ 'custom_add' ] ) ) { |
|
642
|
|
|
if ( isset( $options[ 'actions_custom' ] ) ) |
|
643
|
|
|
$options[ 'actions_custom' ][ 'add' ] = $deprecated_options[ 'custom_add' ]; |
|
644
|
|
|
else |
|
645
|
|
|
$options[ 'actions_custom' ] = array( 'add' => $deprecated_options[ 'custom_add' ] ); |
|
646
|
|
|
} |
|
647
|
|
|
if ( isset( $deprecated_options[ 'custom_edit' ] ) ) { |
|
648
|
|
|
if ( isset( $options[ 'actions_custom' ] ) ) |
|
649
|
|
|
$options[ 'actions_custom' ][ 'edit' ] = $deprecated_options[ 'custom_edit' ]; |
|
650
|
|
|
else |
|
651
|
|
|
$options[ 'actions_custom' ] = array( 'edit' => $deprecated_options[ 'custom_edit' ] ); |
|
652
|
|
|
} |
|
653
|
|
|
if ( isset( $deprecated_options[ 'custom_duplicate' ] ) ) { |
|
654
|
|
|
if ( isset( $options[ 'actions_custom' ] ) ) |
|
655
|
|
|
$options[ 'actions_custom' ][ 'duplicate' ] = $deprecated_options[ 'custom_duplicate' ]; |
|
656
|
|
|
else |
|
657
|
|
|
$options[ 'actions_custom' ] = array( 'duplicate' => $deprecated_options[ 'custom_duplicate' ] ); |
|
658
|
|
|
} |
|
659
|
|
|
if ( isset( $deprecated_options[ 'custom_delete' ] ) ) { |
|
660
|
|
|
if ( isset( $options[ 'actions_custom' ] ) ) |
|
661
|
|
|
$options[ 'actions_custom' ][ 'delete' ] = $deprecated_options[ 'custom_delete' ]; |
|
662
|
|
|
else |
|
663
|
|
|
$options[ 'actions_custom' ] = array( 'delete' => $deprecated_options[ 'custom_delete' ] ); |
|
664
|
|
|
} |
|
665
|
|
|
if ( isset( $deprecated_options[ 'custom_save' ] ) ) { |
|
666
|
|
|
if ( isset( $options[ 'actions_custom' ] ) ) |
|
667
|
|
|
$options[ 'actions_custom' ][ 'save' ] = $deprecated_options[ 'custom_save' ]; |
|
668
|
|
|
else |
|
669
|
|
|
$options[ 'actions_custom' ] = array( 'save' => $deprecated_options[ 'custom_save' ] ); |
|
670
|
|
|
} |
|
671
|
|
|
|
|
672
|
|
|
if ( isset( $deprecated_options[ 'custom_actions' ] ) ) |
|
673
|
|
|
$options[ 'actions_custom' ] = $deprecated_options[ 'custom_actions' ]; |
|
674
|
|
|
if ( isset( $deprecated_options[ 'action_after_save' ] ) ) |
|
675
|
|
|
$options[ 'action_after' ] = array( |
|
676
|
|
|
'add' => $deprecated_options[ 'action_after_save' ], |
|
677
|
|
|
'edit' => $deprecated_options[ 'action_after_save' ], |
|
678
|
|
|
'duplicate' => $deprecated_options[ 'action_after_save' ] |
|
679
|
|
|
); |
|
680
|
|
|
if ( isset( $deprecated_options[ 'edit_link' ] ) ) { |
|
681
|
|
|
if ( isset( $options[ 'action_links' ] ) ) |
|
682
|
|
|
$options[ 'action_links' ][ 'edit' ] = $deprecated_options[ 'edit_link' ]; |
|
683
|
|
|
else |
|
684
|
|
|
$options[ 'action_links' ] = array( 'edit' => $deprecated_options[ 'edit_link' ] ); |
|
685
|
|
|
} |
|
686
|
|
|
if ( isset( $deprecated_options[ 'view_link' ] ) ) { |
|
687
|
|
|
if ( isset( $options[ 'action_links' ] ) ) |
|
688
|
|
|
$options[ 'action_links' ][ 'view' ] = $deprecated_options[ 'view_link' ]; |
|
689
|
|
|
else |
|
690
|
|
|
$options[ 'action_links' ] = array( 'view' => $deprecated_options[ 'view_link' ] ); |
|
691
|
|
|
} |
|
692
|
|
|
if ( isset( $deprecated_options[ 'duplicate_link' ] ) ) { |
|
693
|
|
|
if ( isset( $options[ 'action_links' ] ) ) |
|
694
|
|
|
$options[ 'action_links' ][ 'duplicate' ] = $deprecated_options[ 'duplicate_link' ]; |
|
695
|
|
|
else |
|
696
|
|
|
$options[ 'action_links' ] = array( 'duplicate' => $deprecated_options[ 'duplicate_link' ] ); |
|
697
|
|
|
} |
|
698
|
|
|
|
|
699
|
|
|
if ( isset( $deprecated_options[ 'reorder' ] ) ) |
|
700
|
|
|
$options[ 'reorder' ] = array( |
|
701
|
|
|
'on' => $deprecated_options[ 'reorder' ], |
|
702
|
|
|
'orderby' => $deprecated_options[ 'reorder' ] |
|
703
|
|
|
); |
|
704
|
|
|
if ( isset( $deprecated_options[ 'reorder_sort' ] ) && isset( $options[ 'reorder' ] ) ) |
|
705
|
|
|
$options[ 'reorder' ][ 'orderby' ] = $deprecated_options[ 'reorder_sort' ]; |
|
706
|
|
|
if ( isset( $deprecated_options[ 'reorder_limit' ] ) && isset( $options[ 'reorder' ] ) ) |
|
707
|
|
|
$options[ 'reorder' ][ 'limit' ] = $deprecated_options[ 'reorder_limit' ]; |
|
708
|
|
|
if ( isset( $deprecated_options[ 'reorder_sql' ] ) && isset( $options[ 'reorder' ] ) ) |
|
709
|
|
|
$options[ 'reorder' ][ 'sql' ] = $deprecated_options[ 'reorder_sql' ]; |
|
710
|
|
|
|
|
711
|
|
|
if ( isset( $deprecated_options[ 'sort' ] ) ) |
|
712
|
|
|
$options[ 'orderby' ] = $deprecated_options[ 'sort' ]; |
|
713
|
|
|
if ( isset( $deprecated_options[ 'sortable' ] ) ) |
|
714
|
|
|
$options[ 'sortable' ] = $deprecated_options[ 'sortable' ]; |
|
715
|
|
|
if ( isset( $deprecated_options[ 'limit' ] ) ) |
|
716
|
|
|
$options[ 'limit' ] = $deprecated_options[ 'limit' ]; |
|
717
|
|
|
|
|
718
|
|
|
if ( isset( $deprecated_options[ 'where' ] ) ) { |
|
719
|
|
|
if ( isset( $options[ 'where' ] ) ) |
|
720
|
|
|
$options[ 'where' ][ 'manage' ] = $deprecated_options[ 'where' ]; |
|
721
|
|
|
else |
|
722
|
|
|
$options[ 'where' ] = array( 'manage' => $deprecated_options[ 'where' ] ); |
|
723
|
|
|
} |
|
724
|
|
View Code Duplication |
if ( isset( $deprecated_options[ 'edit_where' ] ) ) { |
|
725
|
|
|
/*if ( isset( $options[ 'where' ] ) ) |
|
|
|
|
|
|
726
|
|
|
$options[ 'where' ][ 'edit' ] = $deprecated_options[ 'edit_where' ]; |
|
727
|
|
|
else |
|
728
|
|
|
$options[ 'where' ] = array( 'edit' => $deprecated_options[ 'edit_where' ] );*/ |
|
729
|
|
|
|
|
730
|
|
|
if ( isset( $options[ 'restrict' ] ) ) |
|
731
|
|
|
$options[ 'restrict' ][ 'edit' ] = (array) $deprecated_options[ 'edit_where' ]; |
|
732
|
|
|
else |
|
733
|
|
|
$options[ 'restrict' ] = array( 'edit' => (array) $deprecated_options[ 'edit_where' ] ); |
|
734
|
|
|
} |
|
735
|
|
View Code Duplication |
if ( isset( $deprecated_options[ 'duplicate_where' ] ) ) { |
|
736
|
|
|
/*if ( isset( $options[ 'where' ] ) ) |
|
|
|
|
|
|
737
|
|
|
$options[ 'where' ][ 'duplicate' ] = $deprecated_options[ 'duplicate_where' ]; |
|
738
|
|
|
else |
|
739
|
|
|
$options[ 'where' ] = array( 'duplicate' => $deprecated_options[ 'duplicate_where' ] );*/ |
|
740
|
|
|
|
|
741
|
|
|
if ( isset( $options[ 'restrict' ] ) ) |
|
742
|
|
|
$options[ 'restrict' ][ 'duplicate' ] = (array) $deprecated_options[ 'duplicate_where' ]; |
|
743
|
|
|
else |
|
744
|
|
|
$options[ 'restrict' ] = array( 'duplicate' => (array) $deprecated_options[ 'duplicate_where' ] ); |
|
745
|
|
|
} |
|
746
|
|
View Code Duplication |
if ( isset( $deprecated_options[ 'delete_where' ] ) ) { |
|
747
|
|
|
/*if ( isset( $options[ 'where' ] ) ) |
|
|
|
|
|
|
748
|
|
|
$options[ 'where' ][ 'delete' ] = $deprecated_options[ 'delete_where' ]; |
|
749
|
|
|
else |
|
750
|
|
|
$options[ 'where' ] = array( 'delete' => $deprecated_options[ 'delete_where' ] );*/ |
|
751
|
|
|
|
|
752
|
|
|
if ( isset( $options[ 'restrict' ] ) ) |
|
753
|
|
|
$options[ 'restrict' ][ 'delete' ] = (array) $deprecated_options[ 'delete_where' ]; |
|
754
|
|
|
else |
|
755
|
|
|
$options[ 'restrict' ] = array( 'delete' => (array) $deprecated_options[ 'delete_where' ] ); |
|
756
|
|
|
} |
|
757
|
|
|
if ( isset( $deprecated_options[ 'reorder_where' ] ) ) { |
|
758
|
|
|
if ( isset( $options[ 'where' ] ) ) |
|
759
|
|
|
$options[ 'where' ][ 'reorder' ] = $deprecated_options[ 'reorder_where' ]; |
|
760
|
|
|
else |
|
761
|
|
|
$options[ 'where' ] = array( 'reorder' => $deprecated_options[ 'reorder_where' ] ); |
|
762
|
|
|
} |
|
763
|
|
|
|
|
764
|
|
|
if ( isset( $deprecated_options[ 'sql' ] ) ) |
|
765
|
|
|
$options[ 'sql' ] = array( 'sql' => $deprecated_options[ 'sql' ] ); |
|
766
|
|
|
|
|
767
|
|
|
if ( isset( $deprecated_options[ 'search' ] ) ) |
|
768
|
|
|
$options[ 'searchable' ] = $deprecated_options[ 'search' ]; |
|
769
|
|
|
if ( isset( $deprecated_options[ 'search_across' ] ) ) |
|
770
|
|
|
$options[ 'search_across' ] = $deprecated_options[ 'search_across' ]; |
|
771
|
|
|
if ( isset( $deprecated_options[ 'search_across_picks' ] ) ) |
|
772
|
|
|
$options[ 'search_across_picks' ] = $deprecated_options[ 'search_across_picks' ]; |
|
773
|
|
|
if ( isset( $deprecated_options[ 'filters' ] ) ) |
|
774
|
|
|
$options[ 'filters' ] = $deprecated_options[ 'filters' ]; |
|
775
|
|
|
if ( isset( $deprecated_options[ 'custom_filters' ] ) ) { |
|
776
|
|
|
if ( is_callable( $deprecated_options[ 'custom_filters' ] ) ) |
|
777
|
|
|
add_filter( 'pods_ui_filters', $deprecated_options[ 'custom_filters' ] ); |
|
778
|
|
|
else { |
|
779
|
|
|
global $pods_ui_custom_filters; |
|
|
|
|
|
|
780
|
|
|
$pods_ui_custom_filters = $deprecated_options[ 'custom_filters' ]; |
|
781
|
|
|
add_filter( 'pods_ui_filters', array( $this, 'deprecated_filters' ) ); |
|
782
|
|
|
} |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
if ( isset( $deprecated_options[ 'disable_actions' ] ) ) |
|
786
|
|
|
$options[ 'actions_disabled' ] = $deprecated_options[ 'disable_actions' ]; |
|
787
|
|
|
if ( isset( $deprecated_options[ 'hide_actions' ] ) ) |
|
788
|
|
|
$options[ 'actions_hidden' ] = $deprecated_options[ 'hide_actions' ]; |
|
789
|
|
|
|
|
790
|
|
|
if ( isset( $deprecated_options[ 'wpcss' ] ) ) |
|
791
|
|
|
$options[ 'wpcss' ] = $deprecated_options[ 'wpcss' ]; |
|
792
|
|
|
|
|
793
|
|
|
$remaining_options = array_diff_assoc( $options, $deprecated_options ); |
|
794
|
|
|
|
|
795
|
|
|
foreach ( $remaining_options as $option => $value ) { |
|
796
|
|
|
if ( isset( $deprecated_options[ $option ] ) && isset( $this->$option ) ) |
|
797
|
|
|
$options[ $option ] = $value; |
|
798
|
|
|
} |
|
799
|
|
|
|
|
800
|
|
|
return $options; |
|
801
|
|
|
} |
|
802
|
|
|
|
|
803
|
|
|
/** |
|
804
|
|
|
* |
|
805
|
|
|
*/ |
|
806
|
|
|
public function deprecated_filters () { |
|
807
|
|
|
global $pods_ui_custom_filters; |
|
|
|
|
|
|
808
|
|
|
echo $pods_ui_custom_filters; |
|
809
|
|
|
} |
|
810
|
|
|
|
|
811
|
|
|
/** |
|
812
|
|
|
* @param $options |
|
813
|
|
|
* |
|
814
|
|
|
* @return array|bool|mixed|null|PodsArray |
|
815
|
|
|
*/ |
|
816
|
|
|
public function setup ( $options ) { |
|
817
|
|
|
$options = pods_array( $options ); |
|
818
|
|
|
|
|
819
|
|
|
$options->validate( 'num', '', 'absint' ); |
|
820
|
|
|
|
|
821
|
|
|
if ( empty( $options->num ) ) |
|
|
|
|
|
|
822
|
|
|
$options->num = ''; |
|
|
|
|
|
|
823
|
|
|
|
|
824
|
|
|
$options->validate( 'id', pods_var( 'id' . $options->num, 'get', $this->id ) ); |
|
|
|
|
|
|
825
|
|
|
|
|
826
|
|
|
$options->validate( 'do', pods_var( 'do' . $options->num, 'get', $this->do ), 'in_array', array( |
|
|
|
|
|
|
827
|
|
|
'save', |
|
828
|
|
|
'create' |
|
829
|
|
|
) ); |
|
830
|
|
|
|
|
831
|
|
|
$options->validate( 'excluded', self::$excluded, 'array_merge' ); |
|
832
|
|
|
|
|
833
|
|
|
$options->validate( 'action', pods_var( 'action' . $options->num, 'get', $this->action, null, true ), 'in_array', $this->actions ); |
|
|
|
|
|
|
834
|
|
|
$options->validate( 'actions_bulk', $this->actions_bulk, 'array_merge' ); |
|
835
|
|
|
$options->validate( 'action_bulk', pods_var( 'action_bulk' . $options->num, 'get', $this->action_bulk, null, true ), 'isset', $this->actions_bulk ); |
|
|
|
|
|
|
836
|
|
|
|
|
837
|
|
|
$bulk = pods_var( 'action_bulk_ids' . $options->num, 'get', array(), null, true ); |
|
|
|
|
|
|
838
|
|
|
|
|
839
|
|
|
if ( !empty( $bulk ) ) |
|
840
|
|
|
$bulk = (array) pods_var( 'action_bulk_ids' . $options->num, 'get', array(), null, true ); |
|
841
|
|
|
else |
|
842
|
|
|
$bulk = array(); |
|
843
|
|
|
|
|
844
|
|
|
$options->validate( 'bulk', $bulk, 'array_merge', $this->bulk ); |
|
845
|
|
|
|
|
846
|
|
|
$options->validate( 'views', $this->views, 'array' ); |
|
847
|
|
|
$options->validate( 'view', pods_var( 'view' . $options->num, 'get', $this->view, null, true ), 'isset', $this->views ); |
|
|
|
|
|
|
848
|
|
|
|
|
849
|
|
|
$options->validate( 'searchable', $this->searchable, 'boolean' ); |
|
850
|
|
|
$options->validate( 'search', pods_var( 'search' . $options->num, 'get' ) ); |
|
|
|
|
|
|
851
|
|
|
$options->validate( 'search_across', $this->search_across, 'boolean' ); |
|
852
|
|
|
$options->validate( 'search_across_picks', $this->search_across_picks, 'boolean' ); |
|
853
|
|
|
$options->validate( 'filters', $this->filters, 'array' ); |
|
854
|
|
|
$options->validate( 'filters_enhanced', $this->filters_enhanced, 'boolean' ); |
|
855
|
|
|
$options->validate( 'where', $this->where, 'array_merge' ); |
|
856
|
|
|
|
|
857
|
|
|
$options->validate( 'pagination', $this->pagination, 'boolean' ); |
|
858
|
|
|
$options->validate( 'page', pods_var( 'pg' . $options->num, 'get', $this->page ), 'absint' ); |
|
|
|
|
|
|
859
|
|
|
$options->validate( 'limit', pods_var( 'limit' . $options->num, 'get', $this->limit ), 'int' ); |
|
|
|
|
|
|
860
|
|
|
|
|
861
|
|
|
if ( isset( $this->pods_data ) && is_object( $this->pods_data ) ) { |
|
862
|
|
|
$this->sql = array( |
|
863
|
|
|
'table' => $this->pods_data->table, |
|
864
|
|
|
'field_id' => $this->pods_data->field_id, |
|
865
|
|
|
'field_index' => $this->pods_data->field_index |
|
866
|
|
|
); |
|
867
|
|
|
} |
|
868
|
|
|
$options->validate( 'sql', $this->sql, 'array_merge' ); |
|
869
|
|
|
|
|
870
|
|
|
$options->validate( 'orderby_dir', strtoupper( pods_v( 'orderby_dir' . $options[ 'num' ], 'get', $this->orderby_dir, true ) ), 'in_array', array( 'ASC', 'DESC' ) ); |
|
871
|
|
|
|
|
872
|
|
|
$orderby = $this->orderby; |
|
873
|
|
|
|
|
874
|
|
|
// Enforce strict DB column name usage |
|
875
|
|
|
if ( ! empty( $_GET[ 'orderby' . $options->num ] ) ) { |
|
|
|
|
|
|
876
|
|
|
$orderby = pods_clean_name( $_GET[ 'orderby' . $options->num ], true, false ); |
|
|
|
|
|
|
877
|
|
|
} |
|
878
|
|
|
|
|
879
|
|
|
if ( !empty( $orderby ) ) { |
|
880
|
|
|
$orderby = array( |
|
881
|
|
|
'default' => $orderby |
|
882
|
|
|
); |
|
883
|
|
|
} |
|
884
|
|
|
else |
|
885
|
|
|
$orderby = array(); |
|
886
|
|
|
|
|
887
|
|
|
$options->validate( 'orderby', $orderby, 'array_merge' ); |
|
888
|
|
|
$options->validate( 'sortable', $this->sortable, 'boolean' ); |
|
889
|
|
|
|
|
890
|
|
|
$options->validate( 'params', $this->params, 'array' ); |
|
891
|
|
|
|
|
892
|
|
|
$options->validate( 'restrict', $this->restrict, 'array_merge' ); |
|
893
|
|
|
|
|
894
|
|
|
// handle author restrictions |
|
895
|
|
|
if ( !empty( $options[ 'restrict' ][ 'author_restrict' ] ) ) { |
|
896
|
|
|
$restrict = $options[ 'restrict' ]; |
|
897
|
|
|
|
|
898
|
|
|
if ( !is_array( $restrict[ 'author_restrict' ] ) ) |
|
899
|
|
|
$restrict[ 'author_restrict' ] = array( $restrict[ 'author_restrict' ] => get_current_user_id() ); |
|
900
|
|
|
|
|
901
|
|
|
if ( null === $restrict[ 'edit' ] ) |
|
902
|
|
|
$restrict[ 'edit' ] = $restrict[ 'author_restrict' ]; |
|
903
|
|
|
|
|
904
|
|
|
$options->restrict = $restrict; |
|
|
|
|
|
|
905
|
|
|
} |
|
906
|
|
|
|
|
907
|
|
|
if ( null !== $options[ 'restrict' ][ 'edit' ] ) { |
|
908
|
|
|
$restrict = $options[ 'restrict' ]; |
|
909
|
|
|
|
|
910
|
|
|
if ( null === $restrict[ 'duplicate' ] ) |
|
911
|
|
|
$restrict[ 'duplicate' ] = $restrict[ 'edit' ]; |
|
912
|
|
|
|
|
913
|
|
|
if ( null === $restrict[ 'delete' ] ) |
|
914
|
|
|
$restrict[ 'delete' ] = $restrict[ 'edit' ]; |
|
915
|
|
|
|
|
916
|
|
|
if ( null === $restrict[ 'manage' ] ) |
|
917
|
|
|
$restrict[ 'manage' ] = $restrict[ 'edit' ]; |
|
918
|
|
|
|
|
919
|
|
|
if ( null === $restrict[ 'reorder' ] ) |
|
920
|
|
|
$restrict[ 'reorder' ] = $restrict[ 'edit' ]; |
|
921
|
|
|
|
|
922
|
|
|
$options->restrict = $restrict; |
|
|
|
|
|
|
923
|
|
|
} |
|
924
|
|
|
|
|
925
|
|
|
$item = __( 'Item', 'pods' ); |
|
926
|
|
|
$items = __( 'Items', 'pods' ); |
|
927
|
|
|
|
|
928
|
|
|
if ( ! is_array( $this->label ) ) { |
|
929
|
|
|
$this->label = (array) $this->label; |
|
930
|
|
|
} |
|
931
|
|
|
|
|
932
|
|
|
if ( is_object( $this->pod ) ) { |
|
933
|
|
|
$pod_data = $this->pod->pod_data; |
|
934
|
|
|
$pod_data = apply_filters( 'pods_advanced_content_type_pod_data_' . $this->pod->pod_data[ 'name' ], $pod_data, $this->pod->pod_data[ 'name' ] ); |
|
935
|
|
|
$pod_data = apply_filters( 'pods_advanced_content_type_pod_data', $pod_data, $this->pod->pod_data[ 'name' ] ); |
|
936
|
|
|
|
|
937
|
|
|
$this->label = array_merge( $this->label, $pod_data['options'] ); |
|
938
|
|
|
|
|
939
|
|
|
$item = pods_v( 'label_singular', $pod_data['options'], pods_v( 'label', $pod_data, $item, true ), true ); |
|
940
|
|
|
$items = pods_v( 'label', $pod_data, $items, true ); |
|
941
|
|
|
} |
|
942
|
|
|
|
|
943
|
|
|
$options->validate( 'item', $item ); |
|
944
|
|
|
$options->validate( 'items', $items ); |
|
945
|
|
|
|
|
946
|
|
|
$options->validate( 'heading', array( |
|
947
|
|
|
'manage' => pods_v( 'label_manage', $this->label, __( 'Manage', 'pods' ) ), |
|
948
|
|
|
'add' => pods_v( 'label_add_new', $this->label, __( 'Add New', 'pods' ) ), |
|
949
|
|
|
'edit' => pods_v( 'label_edit', $this->label, __( 'Edit', 'pods' ) ), |
|
950
|
|
|
'duplicate' => pods_v( 'label_duplicate', $this->label, __( 'Duplicate', 'pods' ) ), |
|
951
|
|
|
'view' => pods_v( 'label_view', $this->label, __( 'View', 'pods' ) ), |
|
952
|
|
|
'reorder' => pods_v( 'label_reorder', $this->label, __( 'Reorder', 'pods' ) ), |
|
953
|
|
|
'search' => pods_v( 'label_search', $this->label, __( 'Search', 'pods' ) ), |
|
954
|
|
|
'views' => pods_v( 'label_view', $this->label, __( 'View', 'pods' ) ) |
|
955
|
|
|
), 'array_merge' ); |
|
956
|
|
|
|
|
957
|
|
|
$options->validate( 'header', array( |
|
958
|
|
|
'manage' => pods_v( 'label_manage_items', $this->label, sprintf( __( 'Manage %s', 'pods' ), $options->items ) ), |
|
|
|
|
|
|
959
|
|
|
'add' => pods_v( 'label_add_new_item', $this->label, sprintf( __( 'Add New %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
960
|
|
|
'edit' => pods_v( 'label_edit_item', $this->label, sprintf( __( 'Edit %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
961
|
|
|
'duplicate' => pods_v( 'label_duplicate_item', $this->label, sprintf( __( 'Duplicate %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
962
|
|
|
'view' => pods_v( 'label_view_item', $this->label, sprintf( __( 'View %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
963
|
|
|
'reorder' => pods_v( 'label_reorder_items', $this->label, sprintf( __( 'Reorder %s', 'pods' ), $options->items ) ), |
|
|
|
|
|
|
964
|
|
|
'search' => pods_v( 'label_search_items', $this->label, sprintf( __( 'Search %s', 'pods' ), $options->items ) ) |
|
|
|
|
|
|
965
|
|
|
), 'array_merge' ); |
|
966
|
|
|
|
|
967
|
|
|
$options->validate( 'label', array( |
|
968
|
|
|
'add' => pods_v( 'label_add_new_item', $this->label, sprintf( __( 'Add New %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
969
|
|
|
'add_new' => pods_v( 'label_add_new', $this->label, __( 'Add New', 'pods' ) ), |
|
970
|
|
|
'edit' => pods_v( 'label_update_item', $this->label, sprintf( __( 'Update %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
971
|
|
|
'duplicate' => pods_v( 'label_duplicate_item', $this->label, sprintf( __( 'Duplicate %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
972
|
|
|
'delete' => pods_v( 'label_delete_item', $this->label, sprintf( __( 'Delete this %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
973
|
|
|
'view' => pods_v( 'label_view_item', $this->label, sprintf( __( 'View %s', 'pods' ), $options->item ) ), |
|
|
|
|
|
|
974
|
|
|
'reorder' => pods_v( 'label_reorder_items', $this->label, sprintf( __( 'Reorder %s', 'pods' ), $options->items ) ) |
|
|
|
|
|
|
975
|
|
|
), 'array_merge' ); |
|
976
|
|
|
|
|
977
|
|
|
$options->validate( 'fields', array( |
|
978
|
|
|
'manage' => array( |
|
979
|
|
|
$options->sql[ 'field_index' ] => array( 'label' => __( 'Name', 'pods' ) ) |
|
|
|
|
|
|
980
|
|
|
) |
|
981
|
|
|
), 'array' ); |
|
982
|
|
|
|
|
983
|
|
|
$options->validate( 'export', $this->export, 'array_merge' ); |
|
984
|
|
|
$options->validate( 'reorder', $this->reorder, 'array_merge' ); |
|
985
|
|
|
$options->validate( 'screen_options', $this->screen_options, 'array_merge' ); |
|
986
|
|
|
|
|
987
|
|
|
$options->validate( 'session', $this->session, 'in_array', array( |
|
988
|
|
|
'search', |
|
989
|
|
|
'filters', |
|
990
|
|
|
'show_per_page', |
|
991
|
|
|
'orderby' |
|
992
|
|
|
) ); |
|
993
|
|
|
$options->validate( 'user', $this->user, 'in_array', array( |
|
994
|
|
|
'search', |
|
995
|
|
|
'filters', |
|
996
|
|
|
'show_per_page', |
|
997
|
|
|
'orderby' |
|
998
|
|
|
) ); |
|
999
|
|
|
|
|
1000
|
|
|
$options->validate( 'action_after', $this->action_after, 'array_merge' ); |
|
1001
|
|
|
$options->validate( 'action_links', $this->action_links, 'array_merge' ); |
|
1002
|
|
|
$options->validate( 'actions_disabled', $this->actions_disabled, 'array' ); |
|
1003
|
|
|
$options->validate( 'actions_hidden', $this->actions_hidden, 'array_merge' ); |
|
1004
|
|
|
$options->validate( 'actions_custom', $this->actions_custom, 'array_merge' ); |
|
1005
|
|
|
|
|
1006
|
|
|
if ( !empty( $options->actions_disabled ) ) { |
|
|
|
|
|
|
1007
|
|
View Code Duplication |
if ( !empty( $options->actions_bulk ) ) { |
|
|
|
|
|
|
1008
|
|
|
$actions_bulk = $options->actions_bulk; |
|
|
|
|
|
|
1009
|
|
|
|
|
1010
|
|
|
foreach ( $actions_bulk as $action => $action_opt ) { |
|
1011
|
|
|
if ( in_array( $action, $options->actions_disabled ) ) { |
|
|
|
|
|
|
1012
|
|
|
unset( $actions_bulk[ $action ] ); |
|
1013
|
|
|
} |
|
1014
|
|
|
} |
|
1015
|
|
|
|
|
1016
|
|
|
$options->actions_bulk = $actions_bulk; |
|
|
|
|
|
|
1017
|
|
|
} |
|
1018
|
|
|
|
|
1019
|
|
View Code Duplication |
if ( !empty( $options->actions_custom ) ) { |
|
|
|
|
|
|
1020
|
|
|
$actions_custom = $options->actions_custom; |
|
|
|
|
|
|
1021
|
|
|
|
|
1022
|
|
|
foreach ( $actions_custom as $action => $action_opt ) { |
|
1023
|
|
|
if ( in_array( $action, $options->actions_disabled ) ) { |
|
|
|
|
|
|
1024
|
|
|
unset( $actions_custom[ $action ] ); |
|
1025
|
|
|
} |
|
1026
|
|
|
} |
|
1027
|
|
|
|
|
1028
|
|
|
$options->actions_custom = $actions_custom; |
|
|
|
|
|
|
1029
|
|
|
} |
|
1030
|
|
|
} |
|
1031
|
|
|
|
|
1032
|
|
|
$options->validate( 'extra', $this->extra, 'array_merge' ); |
|
1033
|
|
|
|
|
1034
|
|
|
$options->validate( 'style', $this->style ); |
|
1035
|
|
|
$options->validate( 'icon', $this->icon ); |
|
1036
|
|
|
$options->validate( 'css', $this->css ); |
|
1037
|
|
|
$options->validate( 'wpcss', $this->wpcss, 'boolean' ); |
|
1038
|
|
|
|
|
1039
|
|
|
if ( true === $options[ 'wpcss' ] ) { |
|
1040
|
|
|
global $user_ID; |
|
|
|
|
|
|
1041
|
|
|
wp_get_current_user(); |
|
1042
|
|
|
|
|
1043
|
|
|
$color = get_user_meta( $user_ID, 'admin_color', true ); |
|
1044
|
|
|
if ( strlen( $color ) < 1 ) |
|
1045
|
|
|
$color = 'fresh'; |
|
1046
|
|
|
|
|
1047
|
|
|
$this->wpcss = "colors-{$color}"; |
|
1048
|
|
|
} |
|
1049
|
|
|
|
|
1050
|
|
|
$options = $options->dump(); |
|
1051
|
|
|
|
|
1052
|
|
|
if ( is_object( $this->pod ) ) |
|
1053
|
|
|
$options = $this->do_hook( $this->pod->pod . '_setup_options', $options ); |
|
1054
|
|
|
|
|
1055
|
|
|
$options = $this->do_hook( 'setup_options', $options ); |
|
1056
|
|
|
|
|
1057
|
|
|
if ( false !== $options && !empty( $options ) ) { |
|
1058
|
|
|
foreach ( $options as $option => $value ) { |
|
1059
|
|
|
if ( isset( $this->{$option} ) ) |
|
1060
|
|
|
$this->{$option} = $value; |
|
1061
|
|
|
else |
|
1062
|
|
|
$this->x[ $option ] = $value; |
|
1063
|
|
|
} |
|
1064
|
|
|
} |
|
1065
|
|
|
|
|
1066
|
|
|
$unique_identifier = pods_var( 'page', 'get' ); // wp-admin page |
|
1067
|
|
|
if ( is_object( $this->pod ) && isset( $this->pod->pod ) ) |
|
1068
|
|
|
$unique_identifier = '_' . $this->pod->pod; |
|
1069
|
|
|
elseif ( 0 < strlen( $this->sql[ 'table' ] ) ) |
|
1070
|
|
|
$unique_identifier = '_' . $this->sql[ 'table' ]; |
|
1071
|
|
|
|
|
1072
|
|
|
$unique_identifier .= '_' . $this->page; |
|
1073
|
|
|
if ( 0 < strlen( $this->num ) ) |
|
1074
|
|
|
$unique_identifier .= '_' . $this->num; |
|
1075
|
|
|
|
|
1076
|
|
|
$this->unique_identifier = 'pods_ui_' . md5( $unique_identifier ); |
|
1077
|
|
|
|
|
1078
|
|
|
$this->setup_fields(); |
|
1079
|
|
|
|
|
1080
|
|
|
return $options; |
|
1081
|
|
|
} |
|
1082
|
|
|
|
|
1083
|
|
|
/** |
|
1084
|
|
|
* @param null $fields |
|
1085
|
|
|
* @param string $which |
|
1086
|
|
|
* |
|
1087
|
|
|
* @return array|bool|mixed|null |
|
1088
|
|
|
*/ |
|
1089
|
|
|
public function setup_fields ( $fields = null, $which = 'fields' ) { |
|
1090
|
|
|
$init = false; |
|
1091
|
|
|
if ( null === $fields ) { |
|
1092
|
|
|
if ( isset( $this->fields[ $which ] ) ) |
|
1093
|
|
|
$fields = (array) $this->fields[ $which ]; |
|
1094
|
|
|
elseif ( isset( $this->fields[ 'manage' ] ) ) |
|
1095
|
|
|
$fields = (array) $this->fields[ 'manage' ]; |
|
1096
|
|
|
else |
|
1097
|
|
|
$fields = array(); |
|
1098
|
|
|
if ( 'fields' == $which ) |
|
1099
|
|
|
$init = true; |
|
1100
|
|
|
} |
|
1101
|
|
|
if ( !empty( $fields ) ) { |
|
1102
|
|
|
// Available Attributes |
|
1103
|
|
|
// type = field type |
|
1104
|
|
|
// type = date (data validation as date) |
|
1105
|
|
|
// type = time (data validation as time) |
|
1106
|
|
|
// type = datetime (data validation as datetime) |
|
1107
|
|
|
// date_touch = use current timestamp when saving (even if readonly, if type is date-related) |
|
1108
|
|
|
// date_touch_on_create = use current timestamp when saving ONLY on create (even if readonly, if type is date-related) |
|
1109
|
|
|
// date_ongoing = use this additional field to search between as if the first is the "start" and the date_ongoing is the "end" for filter |
|
1110
|
|
|
// type = text / other (single line text box) |
|
1111
|
|
|
// type = desc (textarea) |
|
1112
|
|
|
// type = number (data validation as int float) |
|
1113
|
|
|
// type = decimal (data validation as decimal) |
|
1114
|
|
|
// type = password (single line password box) |
|
1115
|
|
|
// type = bool (checkbox) |
|
1116
|
|
|
// type = related (select box) |
|
1117
|
|
|
// related = table to relate to (if type=related) OR custom array of (key => label or comma separated values) items |
|
1118
|
|
|
// related_field = field name on table to show (if type=related) - default "name" |
|
1119
|
|
|
// related_multiple = true (ability to select multiple values if type=related) |
|
1120
|
|
|
// related_sql = custom where / order by SQL (if type=related) |
|
1121
|
|
|
// readonly = true (shows as text) |
|
1122
|
|
|
// display = false (doesn't show on form, but can be saved) |
|
1123
|
|
|
// search = this field is searchable |
|
1124
|
|
|
// filter = this field will be independently searchable (by default, searchable fields are searched by the primary search box) |
|
1125
|
|
|
// comments = comments to show for field |
|
1126
|
|
|
// comments_top = true (shows comments above field instead of below) |
|
1127
|
|
|
// real_name = the real name of the field (if using an alias for 'name') |
|
1128
|
|
|
// group_related = true (uses HAVING instead of WHERE for filtering field) |
|
1129
|
|
|
$new_fields = array(); |
|
1130
|
|
|
$filterable = false; |
|
1131
|
|
|
if ( empty( $this->filters ) && ( empty( $this->fields[ 'search' ] ) || 'search' == $which ) && false !== $this->searchable ) { |
|
1132
|
|
|
$filterable = true; |
|
1133
|
|
|
$this->filters = array(); |
|
1134
|
|
|
} |
|
1135
|
|
|
|
|
1136
|
|
|
foreach ( $fields as $field => $attributes ) { |
|
1137
|
|
|
if ( !is_array( $attributes ) ) { |
|
1138
|
|
|
if ( is_int( $field ) ) { |
|
1139
|
|
|
$field = $attributes; |
|
1140
|
|
|
$attributes = array(); |
|
1141
|
|
|
} |
|
1142
|
|
|
else |
|
1143
|
|
|
$attributes = array( 'label' => $attributes ); |
|
1144
|
|
|
} |
|
1145
|
|
|
|
|
1146
|
|
|
if ( !isset( $attributes[ 'real_name' ] ) ) |
|
1147
|
|
|
$attributes[ 'real_name' ] = pods_var( 'name', $attributes, $field ); |
|
1148
|
|
|
|
|
1149
|
|
|
if ( is_object( $this->pod ) && isset( $this->pod->fields ) && isset( $this->pod->fields[ $attributes[ 'real_name' ] ] ) ) |
|
1150
|
|
|
$attributes = array_merge( $this->pod->fields[ $attributes[ 'real_name' ] ], $attributes ); |
|
1151
|
|
|
|
|
1152
|
|
|
if ( !isset( $attributes[ 'options' ] ) ) |
|
1153
|
|
|
$attributes[ 'options' ] = array(); |
|
1154
|
|
|
if ( !isset( $attributes[ 'id' ] ) ) |
|
1155
|
|
|
$attributes[ 'id' ] = ''; |
|
1156
|
|
|
if ( !isset( $attributes[ 'label' ] ) ) |
|
1157
|
|
|
$attributes[ 'label' ] = ucwords( str_replace( '_', ' ', $field ) ); |
|
1158
|
|
|
if ( !isset( $attributes[ 'type' ] ) ) |
|
1159
|
|
|
$attributes[ 'type' ] = 'text'; |
|
1160
|
|
|
if ( !isset( $attributes[ 'options' ][ 'date_format_type' ] ) ) |
|
1161
|
|
|
$attributes[ 'options' ][ 'date_format_type' ] = 'date'; |
|
1162
|
|
View Code Duplication |
if ( 'related' != $attributes[ 'type' ] || !isset( $attributes[ 'related' ] ) ) |
|
1163
|
|
|
$attributes[ 'related' ] = false; |
|
1164
|
|
View Code Duplication |
if ( 'related' != $attributes[ 'type' ] || !isset( $attributes[ 'related_id' ] ) ) |
|
1165
|
|
|
$attributes[ 'related_id' ] = 'id'; |
|
1166
|
|
View Code Duplication |
if ( 'related' != $attributes[ 'type' ] || !isset( $attributes[ 'related_field' ] ) ) |
|
1167
|
|
|
$attributes[ 'related_field' ] = 'name'; |
|
1168
|
|
View Code Duplication |
if ( 'related' != $attributes[ 'type' ] || !isset( $attributes[ 'related_multiple' ] ) ) |
|
1169
|
|
|
$attributes[ 'related_multiple' ] = false; |
|
1170
|
|
View Code Duplication |
if ( 'related' != $attributes[ 'type' ] || !isset( $attributes[ 'related_sql' ] ) ) |
|
1171
|
|
|
$attributes[ 'related_sql' ] = false; |
|
1172
|
|
|
if ( 'related' == $attributes[ 'type' ] && ( is_array( $attributes[ 'related' ] ) || strpos( $attributes[ 'related' ], ',' ) ) ) { |
|
1173
|
|
|
if ( !is_array( $attributes[ 'related' ] ) ) { |
|
1174
|
|
|
$attributes[ 'related' ] = @explode( ',', $attributes[ 'related' ] ); |
|
1175
|
|
|
$related_items = array(); |
|
1176
|
|
|
foreach ( $attributes[ 'related' ] as $key => $label ) { |
|
1177
|
|
|
if ( is_numeric( $key ) ) { |
|
1178
|
|
|
$key = $label; |
|
1179
|
|
|
$label = ucwords( str_replace( '_', ' ', $label ) ); |
|
1180
|
|
|
} |
|
1181
|
|
|
$related_items[ $key ] = $label; |
|
1182
|
|
|
} |
|
1183
|
|
|
$attributes[ 'related' ] = $related_items; |
|
1184
|
|
|
} |
|
1185
|
|
|
if ( empty( $attributes[ 'related' ] ) ) |
|
1186
|
|
|
$attributes[ 'related' ] = false; |
|
1187
|
|
|
} |
|
1188
|
|
|
if ( !isset( $attributes[ 'readonly' ] ) ) |
|
1189
|
|
|
$attributes[ 'readonly' ] = false; |
|
1190
|
|
|
if ( !isset( $attributes[ 'date_touch' ] ) || 'date' != $attributes[ 'type' ] ) |
|
1191
|
|
|
$attributes[ 'date_touch' ] = false; |
|
1192
|
|
|
if ( !isset( $attributes[ 'date_touch_on_create' ] ) || 'date' != $attributes[ 'type' ] ) |
|
1193
|
|
|
$attributes[ 'date_touch_on_create' ] = false; |
|
1194
|
|
|
if ( !isset( $attributes[ 'display' ] ) ) |
|
1195
|
|
|
$attributes[ 'display' ] = true; |
|
1196
|
|
|
if ( !isset( $attributes[ 'hidden' ] ) ) |
|
1197
|
|
|
$attributes[ 'hidden' ] = false; |
|
1198
|
|
|
if ( !isset( $attributes[ 'sortable' ] ) || false === $this->sortable ) |
|
1199
|
|
|
$attributes[ 'sortable' ] = $this->sortable; |
|
1200
|
|
View Code Duplication |
if ( !isset( $attributes[ 'options' ][ 'search' ] ) || false === $this->searchable ) |
|
1201
|
|
|
$attributes[ 'options' ][ 'search' ] = $this->searchable; |
|
1202
|
|
View Code Duplication |
if ( !isset( $attributes[ 'options' ][ 'filter' ] ) || false === $this->searchable ) |
|
1203
|
|
|
$attributes[ 'options' ][ 'filter' ] = $this->searchable; |
|
1204
|
|
|
/*if ( false !== $attributes[ 'options' ][ 'filter' ] && false !== $filterable ) |
|
|
|
|
|
|
1205
|
|
|
$this->filters[] = $field;*/ |
|
1206
|
|
|
if ( false === $attributes[ 'options' ][ 'filter' ] || !isset( $attributes[ 'filter_label' ] ) || !in_array( $field, $this->filters ) ) |
|
1207
|
|
|
$attributes[ 'filter_label' ] = $attributes[ 'label' ]; |
|
1208
|
|
|
if ( false === $attributes[ 'options' ][ 'filter' ] || !isset( $attributes[ 'filter_default' ] ) || !in_array( $field, $this->filters ) ) |
|
1209
|
|
|
$attributes[ 'filter_default' ] = false; |
|
1210
|
|
View Code Duplication |
if ( false === $attributes[ 'options' ][ 'filter' ] || !isset( $attributes[ 'date_ongoing' ] ) || 'date' != $attributes[ 'type' ] || !in_array( $field, $this->filters ) ) |
|
1211
|
|
|
$attributes[ 'date_ongoing' ] = false; |
|
1212
|
|
View Code Duplication |
if ( false === $attributes[ 'options' ][ 'filter' ] || !isset( $attributes[ 'date_ongoing' ] ) || 'date' != $attributes[ 'type' ] || !isset( $attributes[ 'date_ongoing_default' ] ) || !in_array( $field, $this->filters ) ) |
|
1213
|
|
|
$attributes[ 'date_ongoing_default' ] = false; |
|
1214
|
|
|
if ( !isset( $attributes[ 'export' ] ) ) |
|
1215
|
|
|
$attributes[ 'export' ] = true; |
|
1216
|
|
|
if ( !isset( $attributes[ 'group_related' ] ) ) |
|
1217
|
|
|
$attributes[ 'group_related' ] = false; |
|
1218
|
|
|
if ( !isset( $attributes[ 'comments' ] ) ) |
|
1219
|
|
|
$attributes[ 'comments' ] = ''; |
|
1220
|
|
|
if ( !isset( $attributes[ 'comments_top' ] ) ) |
|
1221
|
|
|
$attributes[ 'comments_top' ] = false; |
|
1222
|
|
|
if ( !isset( $attributes[ 'custom_view' ] ) ) |
|
1223
|
|
|
$attributes[ 'custom_view' ] = false; |
|
1224
|
|
|
if ( !isset( $attributes[ 'custom_input' ] ) ) |
|
1225
|
|
|
$attributes[ 'custom_input' ] = false; |
|
1226
|
|
|
if ( isset( $attributes[ 'display_helper' ] ) ) // pods ui backward compatibility |
|
1227
|
|
|
$attributes[ 'custom_display' ] = $attributes[ 'display_helper' ]; |
|
1228
|
|
|
if ( !isset( $attributes[ 'custom_display' ] ) ) |
|
1229
|
|
|
$attributes[ 'custom_display' ] = false; |
|
1230
|
|
|
if ( !isset( $attributes[ 'custom_relate' ] ) ) |
|
1231
|
|
|
$attributes[ 'custom_relate' ] = false; |
|
1232
|
|
|
if ( !isset( $attributes[ 'custom_form_display' ] ) ) |
|
1233
|
|
|
$attributes[ 'custom_form_display' ] = false; |
|
1234
|
|
|
if ( !isset( $attributes[ 'css_values' ] ) ) |
|
1235
|
|
|
$attributes[ 'css_values' ] = true; |
|
1236
|
|
|
if ( 'search_columns' == $which && !$attributes[ 'options' ][ 'search' ] ) |
|
1237
|
|
|
continue; |
|
1238
|
|
|
|
|
1239
|
|
|
$attributes = PodsForm::field_setup( $attributes, null, $attributes[ 'type' ] ); |
|
1240
|
|
|
|
|
1241
|
|
|
$new_fields[ $field ] = $attributes; |
|
1242
|
|
|
} |
|
1243
|
|
|
$fields = $new_fields; |
|
1244
|
|
|
} |
|
1245
|
|
|
if ( false !== $init ) { |
|
1246
|
|
|
if ( 'fields' != $which && !empty( $this->fields ) ) |
|
1247
|
|
|
$this->fields = $this->setup_fields( $this->fields, 'fields' ); |
|
1248
|
|
|
else |
|
1249
|
|
|
$this->fields[ 'manage' ] = $fields; |
|
1250
|
|
|
|
|
1251
|
|
|
if ( !in_array( 'add', $this->actions_disabled ) || !in_array( 'edit', $this->actions_disabled ) || !in_array( 'duplicate', $this->actions_disabled ) ) { |
|
1252
|
|
|
if ( 'form' != $which && isset( $this->fields[ 'form' ] ) && is_array( $this->fields[ 'form' ] ) ) |
|
1253
|
|
|
$this->fields[ 'form' ] = $this->setup_fields( $this->fields[ 'form' ], 'form' ); |
|
1254
|
|
|
else |
|
1255
|
|
|
$this->fields[ 'form' ] = $fields; |
|
1256
|
|
|
|
|
1257
|
|
|
if ( !in_array( 'add', $this->actions_disabled ) ) { |
|
1258
|
|
|
if ( 'add' != $which && isset( $this->fields[ 'add' ] ) && is_array( $this->fields[ 'add' ] ) ) |
|
1259
|
|
|
$this->fields[ 'add' ] = $this->setup_fields( $this->fields[ 'add' ], 'add' ); |
|
1260
|
|
|
} |
|
1261
|
|
|
if ( !in_array( 'edit', $this->actions_disabled ) ) { |
|
1262
|
|
|
if ( 'edit' != $which && isset( $this->fields[ 'edit' ] ) && is_array( $this->fields[ 'edit' ] ) ) |
|
1263
|
|
|
$this->fields[ 'edit' ] = $this->setup_fields( $this->fields[ 'edit' ], 'edit' ); |
|
1264
|
|
|
} |
|
1265
|
|
|
if ( !in_array( 'duplicate', $this->actions_disabled ) ) { |
|
1266
|
|
|
if ( 'duplicate' != $which && isset( $this->fields[ 'duplicate' ] ) && is_array( $this->fields[ 'duplicate' ] ) ) |
|
1267
|
|
|
$this->fields[ 'duplicate' ] = $this->setup_fields( $this->fields[ 'duplicate' ], 'duplicate' ); |
|
1268
|
|
|
} |
|
1269
|
|
|
} |
|
1270
|
|
|
|
|
1271
|
|
View Code Duplication |
if ( false !== $this->searchable ) { |
|
1272
|
|
|
if ( 'search' != $which && isset( $this->fields[ 'search' ] ) &&!empty( $this->fields[ 'search' ] ) ) |
|
1273
|
|
|
$this->fields[ 'search' ] = $this->setup_fields( $this->fields[ 'search' ], 'search' ); |
|
1274
|
|
|
else |
|
1275
|
|
|
$this->fields[ 'search' ] = $fields; |
|
1276
|
|
|
} |
|
1277
|
|
|
else |
|
1278
|
|
|
$this->fields[ 'search' ] = false; |
|
1279
|
|
|
|
|
1280
|
|
|
if ( !in_array( 'export', $this->actions_disabled ) ) { |
|
1281
|
|
|
if ( 'export' != $which && isset( $this->fields[ 'export' ] ) &&!empty( $this->fields[ 'export' ] ) ) |
|
1282
|
|
|
$this->fields[ 'export' ] = $this->setup_fields( $this->fields[ 'export' ], 'export' ); |
|
1283
|
|
|
} |
|
1284
|
|
|
|
|
1285
|
|
View Code Duplication |
if ( !in_array( 'reorder', $this->actions_disabled ) && false !== $this->reorder[ 'on' ] ) { |
|
1286
|
|
|
if ( 'reorder' != $which && isset( $this->fields[ 'reorder' ] ) &&!empty( $this->fields[ 'reorder' ] ) ) |
|
1287
|
|
|
$this->fields[ 'reorder' ] = $this->setup_fields( $this->fields[ 'reorder' ], 'reorder' ); |
|
1288
|
|
|
else |
|
1289
|
|
|
$this->fields[ 'reorder' ] = $fields; |
|
1290
|
|
|
} |
|
1291
|
|
|
} |
|
1292
|
|
|
return $this->do_hook( 'setup_fields', $fields, $which, $init ); |
|
1293
|
|
|
} |
|
1294
|
|
|
|
|
1295
|
|
|
/** |
|
1296
|
|
|
* @param $msg |
|
1297
|
|
|
* @param bool $error |
|
1298
|
|
|
*/ |
|
1299
|
|
|
public function message ( $msg, $error = false ) { |
|
1300
|
|
|
$msg = $this->do_hook( ( $error ) ? 'error' : 'message', $msg ); |
|
1301
|
|
|
?> |
|
1302
|
|
|
<div id="message" class="<?php echo esc_attr( ( $error ) ? 'error' : 'updated' ); ?> fade"><p><?php echo $msg; ?></p></div> |
|
1303
|
|
|
<?php |
|
1304
|
|
|
} |
|
1305
|
|
|
|
|
1306
|
|
|
/** |
|
1307
|
|
|
* @param $msg |
|
1308
|
|
|
* |
|
1309
|
|
|
* @return bool |
|
1310
|
|
|
*/ |
|
1311
|
|
|
public function error ( $msg ) { |
|
1312
|
|
|
$this->message( $msg, true ); |
|
1313
|
|
|
|
|
1314
|
|
|
return false; |
|
1315
|
|
|
} |
|
1316
|
|
|
|
|
1317
|
|
|
/** |
|
1318
|
|
|
* @return mixed |
|
1319
|
|
|
*/ |
|
1320
|
|
|
public function go () { |
|
1321
|
|
|
$this->do_hook( 'go' ); |
|
1322
|
|
|
$_GET = pods_unsanitize( $_GET ); // fix wp sanitization |
|
1323
|
|
|
$_POST = pods_unsanitize( $_POST ); // fix wp sanitization |
|
1324
|
|
|
|
|
1325
|
|
|
if ( false !== $this->css ) { |
|
1326
|
|
|
?> |
|
1327
|
|
|
<link type="text/css" rel="stylesheet" href="<?php echo esc_url( $this->css ); ?>" /> |
|
1328
|
|
|
<?php |
|
1329
|
|
|
} |
|
1330
|
|
|
if ( false !== $this->wpcss ) { |
|
1331
|
|
|
$stylesheets = array( 'global', 'wp-admin', $this->wpcss ); |
|
1332
|
|
|
foreach ( $stylesheets as $style ) { |
|
1333
|
|
|
if ( !wp_style_is( $style, 'queue' ) && !wp_style_is( $style, 'to_do' ) && !wp_style_is( $style, 'done' ) ) |
|
1334
|
|
|
wp_enqueue_style( $style ); |
|
1335
|
|
|
} |
|
1336
|
|
|
} |
|
1337
|
|
|
|
|
1338
|
|
|
$this->ui_page = array( $this->action ); |
|
1339
|
|
|
if ( 'add' == $this->action && !in_array( $this->action, $this->actions_disabled ) ) { |
|
1340
|
|
|
$this->ui_page[] = 'form'; |
|
1341
|
|
View Code Duplication |
if ( 'create' == $this->do && $this->save && !in_array( $this->do, $this->actions_disabled ) && !empty( $_POST ) ) { |
|
1342
|
|
|
$this->ui_page[] = $this->do; |
|
1343
|
|
|
$this->save( true ); |
|
1344
|
|
|
$this->manage(); |
|
1345
|
|
|
} |
|
1346
|
|
|
else |
|
1347
|
|
|
$this->add(); |
|
1348
|
|
|
} |
|
1349
|
|
|
elseif ( ( 'edit' == $this->action && !in_array( $this->action, $this->actions_disabled ) ) || ( 'duplicate' == $this->action && !in_array( $this->action, $this->actions_disabled ) ) ) { |
|
1350
|
|
|
$this->ui_page[] = 'form'; |
|
1351
|
|
|
if ( 'save' == $this->do && $this->save && !empty( $_POST ) ) |
|
1352
|
|
|
$this->save(); |
|
1353
|
|
|
$this->edit( ( 'duplicate' == $this->action && !in_array( $this->action, $this->actions_disabled ) ) ? true : false ); |
|
1354
|
|
|
} |
|
1355
|
|
|
elseif ( 'delete' == $this->action && !in_array( $this->action, $this->actions_disabled ) && false !== wp_verify_nonce( $this->_nonce, 'pods-ui-action-delete' ) ) { |
|
1356
|
|
|
$this->delete( $this->id ); |
|
1357
|
|
|
$this->manage(); |
|
1358
|
|
|
} |
|
1359
|
|
|
elseif ( 'reorder' == $this->action && !in_array( $this->action, $this->actions_disabled ) && false !== $this->reorder[ 'on' ] ) { |
|
1360
|
|
|
if ( 'save' == $this->do ) { |
|
1361
|
|
|
$this->ui_page[] = $this->do; |
|
1362
|
|
|
$this->reorder(); |
|
1363
|
|
|
} |
|
1364
|
|
|
$this->manage( true ); |
|
1365
|
|
|
} |
|
1366
|
|
|
elseif ( 'save' == $this->do && $this->save && !in_array( $this->do, $this->actions_disabled ) && !empty( $_POST ) ) { |
|
1367
|
|
|
$this->ui_page[] = $this->do; |
|
1368
|
|
|
$this->save(); |
|
1369
|
|
|
$this->manage(); |
|
1370
|
|
|
} |
|
1371
|
|
View Code Duplication |
elseif ( 'create' == $this->do && $this->save && !in_array( $this->do, $this->actions_disabled ) && !empty( $_POST ) ) { |
|
1372
|
|
|
$this->ui_page[] = $this->do; |
|
1373
|
|
|
$this->save( true ); |
|
1374
|
|
|
$this->manage(); |
|
1375
|
|
|
} |
|
1376
|
|
|
elseif ( 'view' == $this->action && !in_array( $this->action, $this->actions_disabled ) ) |
|
1377
|
|
|
$this->view(); |
|
1378
|
|
|
else { |
|
1379
|
|
|
if ( isset( $this->actions_custom[ $this->action ] ) ) { |
|
1380
|
|
|
$more_args = false; |
|
1381
|
|
|
|
|
1382
|
|
|
if ( is_array( $this->actions_custom[ $this->action ] ) && isset( $this->actions_custom[ $this->action ][ 'more_args' ] ) ) { |
|
1383
|
|
|
$more_args = $this->actions_custom[ $this->action ][ 'more_args' ]; |
|
1384
|
|
|
} |
|
1385
|
|
|
|
|
1386
|
|
|
$row = $this->row; |
|
1387
|
|
|
|
|
1388
|
|
|
if ( empty( $row ) ) { |
|
1389
|
|
|
$row = $this->get_row(); |
|
1390
|
|
|
} |
|
1391
|
|
|
|
|
1392
|
|
|
if ( $this->restricted( $this->action, $row ) || ( $more_args && ! empty( $more_args[ 'nonce' ] ) && false === wp_verify_nonce( $this->_nonce, 'pods-ui-action-' . $this->action ) ) ) { |
|
1393
|
|
|
return $this->error( sprintf( __( '<strong>Error:</strong> You do not have access to this %s.', 'pods' ), $this->item ) ); |
|
1394
|
|
|
} |
|
1395
|
|
|
elseif ( $more_args && false !== $this->callback_action( true, $this->action, $this->id, $row ) ) { |
|
1396
|
|
|
return null; |
|
1397
|
|
|
} |
|
1398
|
|
|
elseif ( false !== $this->callback_action( true, $this->action, $this->id ) ) { |
|
1399
|
|
|
return null; |
|
1400
|
|
|
} |
|
1401
|
|
|
} |
|
1402
|
|
|
|
|
1403
|
|
|
if ( !in_array( 'manage', $this->actions_disabled ) ) { |
|
1404
|
|
|
// handle session / user persistent settings for show_per_page, orderby, search, and filters |
|
1405
|
|
|
$methods = array( 'session', 'user' ); |
|
1406
|
|
|
|
|
1407
|
|
|
// @todo fix this to set ($this) AND save (setting) |
|
1408
|
|
|
foreach ( $methods as $method ) { |
|
1409
|
|
|
foreach ( $this->$method as $setting ) { |
|
1410
|
|
|
if ( 'show_per_page' == $setting ) |
|
1411
|
|
|
$value = $this->limit; |
|
1412
|
|
|
elseif ( 'orderby' == $setting ) { |
|
1413
|
|
|
if ( empty( $this->orderby ) ) |
|
1414
|
|
|
$value = ''; |
|
1415
|
|
|
// save this if we have a default index set |
|
1416
|
|
|
elseif ( isset( $this->orderby[ 'default' ] ) ) { |
|
1417
|
|
|
$value = $this->orderby[ 'default' ] . ' ' |
|
1418
|
|
|
. ( false === strpos( $this->orderby[ 'default' ], ' ' ) ? $this->orderby_dir : '' ); |
|
1419
|
|
|
} |
|
1420
|
|
|
else |
|
1421
|
|
|
$value = ''; |
|
1422
|
|
|
} |
|
1423
|
|
|
else |
|
1424
|
|
|
$value = $this->$setting; |
|
1425
|
|
|
|
|
1426
|
|
|
pods_v_set( $value, $setting, $method ); |
|
1427
|
|
|
} |
|
1428
|
|
|
} |
|
1429
|
|
|
|
|
1430
|
|
|
$this->manage(); |
|
1431
|
|
|
} |
|
1432
|
|
|
} |
|
1433
|
|
|
} |
|
1434
|
|
|
|
|
1435
|
|
|
/** |
|
1436
|
|
|
* @return mixed |
|
1437
|
|
|
*/ |
|
1438
|
|
|
public function add () { |
|
1439
|
|
|
if ( false !== $this->callback_action( 'add' ) ) { |
|
1440
|
|
|
return null; |
|
1441
|
|
|
} |
|
1442
|
|
|
?> |
|
1443
|
|
|
<div class="wrap pods-ui"> |
|
1444
|
|
|
<div id="icon-edit-pages" class="icon32"<?php if ( false !== $this->icon ) { ?> style="background-position:0 0;background-size:100%;background-image:url(<?php echo esc_url( $this->icon ); ?>);"<?php } ?>><br /></div> |
|
1445
|
|
|
<h2> |
|
1446
|
|
|
<?php |
|
1447
|
|
|
echo wp_kses_post( $this->header[ 'add' ] ); |
|
1448
|
|
|
|
|
1449
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'manage', 'id' . $this->num => '' ), self::$allowed, $this->exclusion() ); |
|
1450
|
|
|
|
|
1451
|
|
|
if ( !empty( $this->action_links[ 'manage' ] ) ) { |
|
1452
|
|
|
$link = $this->action_links[ 'manage' ]; |
|
1453
|
|
|
} |
|
1454
|
|
|
?> |
|
1455
|
|
|
<a href="<?php echo esc_url( $link ); ?>" class="add-new-h2">« <?php echo pods_v( 'label_back_to_manage', $this->label, sprintf( __( 'Back to %s', 'pods' ), $this->heading[ 'manage' ] ) ); ?></a> |
|
1456
|
|
|
</h2> |
|
1457
|
|
|
|
|
1458
|
|
|
<?php $this->form( true ); ?> |
|
1459
|
|
|
</div> |
|
1460
|
|
|
<?php |
|
1461
|
|
|
} |
|
1462
|
|
|
|
|
1463
|
|
|
/** |
|
1464
|
|
|
* @param bool $duplicate |
|
1465
|
|
|
* |
|
1466
|
|
|
* @return mixed |
|
1467
|
|
|
*/ |
|
1468
|
|
|
public function edit ( $duplicate = false ) { |
|
1469
|
|
|
if ( in_array( 'duplicate', $this->actions_disabled ) ) |
|
1470
|
|
|
$duplicate = false; |
|
1471
|
|
|
|
|
1472
|
|
|
if ( empty( $this->row ) ) |
|
1473
|
|
|
$this->get_row(); |
|
1474
|
|
|
|
|
1475
|
|
|
if ( $duplicate && false !== $this->callback_action( 'duplicate' ) ) { |
|
1476
|
|
|
return null; |
|
1477
|
|
|
} |
|
1478
|
|
|
elseif ( false !== $this->callback_action( 'edit', $duplicate ) ) { |
|
1479
|
|
|
return null; |
|
1480
|
|
|
} |
|
1481
|
|
|
?> |
|
1482
|
|
|
<div class="wrap pods-ui"> |
|
1483
|
|
|
<div id="icon-edit-pages" class="icon32"<?php if ( false !== $this->icon ) { ?> style="background-position:0 0;background-size:100%;background-image:url(<?php echo esc_url( $this->icon ); ?>);"<?php } ?>><br /></div> |
|
1484
|
|
|
<h2> |
|
1485
|
|
|
<?php |
|
1486
|
|
|
echo wp_kses_post( $this->do_template( $duplicate ? $this->header[ 'duplicate' ] : $this->header[ 'edit' ] ) ); |
|
1487
|
|
|
|
|
1488
|
|
View Code Duplication |
if ( !in_array( 'add', $this->actions_disabled ) && !in_array( 'add', $this->actions_hidden ) ) { |
|
1489
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'add', 'id' . $this->num => '', 'do' . $this->num = '' ), self::$allowed, $this->exclusion() ); |
|
1490
|
|
|
|
|
1491
|
|
|
if ( !empty( $this->action_links[ 'add' ] ) ) |
|
1492
|
|
|
$link = $this->action_links[ 'add' ]; |
|
1493
|
|
|
?> |
|
1494
|
|
|
<a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->heading[ 'add' ] ); ?></a> |
|
1495
|
|
|
<?php |
|
1496
|
|
|
} |
|
1497
|
|
|
elseif ( !in_array( 'manage', $this->actions_disabled ) && !in_array( 'manage', $this->actions_hidden ) ) { |
|
1498
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'manage', 'id' . $this->num => '' ), self::$allowed, $this->exclusion() ); |
|
1499
|
|
|
|
|
1500
|
|
|
if ( !empty( $this->action_links[ 'manage' ] ) ) |
|
1501
|
|
|
$link = $this->action_links[ 'manage' ]; |
|
1502
|
|
|
?> |
|
1503
|
|
|
<a href="<?php echo esc_url( $link ); ?>" class="add-new-h2">« <?php echo pods_v( 'label_back_to_manage', $this->label, sprintf( __( 'Back to %s', 'pods' ), $this->heading[ 'manage' ] ) ); ?></a> |
|
1504
|
|
|
<?php |
|
1505
|
|
|
} |
|
1506
|
|
|
?> |
|
1507
|
|
|
</h2> |
|
1508
|
|
|
|
|
1509
|
|
|
<?php $this->form( false, $duplicate ); ?> |
|
1510
|
|
|
</div> |
|
1511
|
|
|
<?php |
|
1512
|
|
|
} |
|
1513
|
|
|
|
|
1514
|
|
|
/** |
|
1515
|
|
|
* @param bool $create |
|
1516
|
|
|
* @param bool $duplicate |
|
1517
|
|
|
* |
|
1518
|
|
|
* @return bool|mixed |
|
1519
|
|
|
*/ |
|
1520
|
|
|
public function form ( $create = false, $duplicate = false ) { |
|
1521
|
|
|
if ( in_array( 'duplicate', $this->actions_disabled ) ) |
|
1522
|
|
|
$duplicate = false; |
|
1523
|
|
|
|
|
1524
|
|
|
if ( false !== $this->callback( 'form' ) ) { |
|
1525
|
|
|
return null; |
|
1526
|
|
|
} |
|
1527
|
|
|
|
|
1528
|
|
|
$label = $this->label[ 'add' ]; |
|
1529
|
|
|
$id = null; |
|
1530
|
|
|
$vars = array( |
|
1531
|
|
|
'action' . $this->num => $this->action_after[ 'add' ], |
|
1532
|
|
|
'do' . $this->num => 'create', |
|
1533
|
|
|
'id' . $this->num => 'X_ID_X' |
|
1534
|
|
|
); |
|
1535
|
|
|
|
|
1536
|
|
|
$alt_vars = $vars; |
|
1537
|
|
|
$alt_vars[ 'action' ] = 'manage'; |
|
1538
|
|
|
unset( $alt_vars[ 'id' ] ); |
|
1539
|
|
|
|
|
1540
|
|
|
if ( false === $create ) { |
|
1541
|
|
|
if ( empty( $this->row ) ) |
|
1542
|
|
|
$this->get_row(); |
|
1543
|
|
|
|
|
1544
|
|
|
if ( empty( $this->row ) && ( !is_object( $this->pod ) || 'settings' != $this->pod->pod_data[ 'type' ] ) ) |
|
1545
|
|
|
return $this->error( sprintf( __( '<strong>Error:</strong> %s not found.', 'pods' ), $this->item ) ); |
|
1546
|
|
|
|
|
1547
|
|
|
if ( $this->restricted( $this->action, $this->row ) ) |
|
1548
|
|
|
return $this->error( sprintf( __( '<strong>Error:</strong> You do not have access to this %s.', 'pods' ), $this->item ) ); |
|
1549
|
|
|
|
|
1550
|
|
|
$label = $this->do_template( $this->label[ 'edit' ] ); |
|
1551
|
|
|
$id = $this->row[ $this->sql[ 'field_id' ] ]; |
|
1552
|
|
|
$vars = array( |
|
1553
|
|
|
'action' . $this->num => $this->action_after[ 'edit' ], |
|
1554
|
|
|
'do' . $this->num => 'save', |
|
1555
|
|
|
'id' . $this->num => $id |
|
1556
|
|
|
); |
|
1557
|
|
|
|
|
1558
|
|
|
$alt_vars = $vars; |
|
1559
|
|
|
$alt_vars[ 'action' ] = 'manage'; |
|
1560
|
|
|
unset( $alt_vars[ 'id' ] ); |
|
1561
|
|
|
|
|
1562
|
|
|
if ( $duplicate ) { |
|
1563
|
|
|
$label = $this->do_template( $this->label[ 'duplicate' ] ); |
|
1564
|
|
|
$id = null; |
|
1565
|
|
|
$vars = array( |
|
1566
|
|
|
'action' . $this->num => $this->action_after[ 'duplicate' ], |
|
1567
|
|
|
'do' . $this->num => 'create', |
|
1568
|
|
|
'id' . $this->num => 'X_ID_X' |
|
1569
|
|
|
); |
|
1570
|
|
|
|
|
1571
|
|
|
$alt_vars = $vars; |
|
1572
|
|
|
$alt_vars[ 'action' ] = 'manage'; |
|
1573
|
|
|
unset( $alt_vars[ 'id' ] ); |
|
1574
|
|
|
} |
|
1575
|
|
|
} |
|
1576
|
|
|
|
|
1577
|
|
|
$fields = array(); |
|
1578
|
|
|
|
|
1579
|
|
|
if ( isset( $this->fields[ $this->action ] ) ) |
|
1580
|
|
|
$fields = $this->fields[ $this->action ]; |
|
1581
|
|
|
|
|
1582
|
|
View Code Duplication |
if ( is_object( $this->pod ) ) { |
|
1583
|
|
|
$object_fields = (array) pods_var_raw( 'object_fields', $this->pod->pod_data, array(), null, true ); |
|
1584
|
|
|
|
|
1585
|
|
|
if ( empty( $object_fields ) && in_array( $this->pod->pod_data[ 'type' ], array( 'post_type', 'taxonomy', 'media', 'user', 'comment' ) ) ) |
|
1586
|
|
|
$object_fields = $this->pod->api->get_wp_object_fields( $this->pod->pod_data[ 'type' ], $this->pod->pod_data ); |
|
1587
|
|
|
|
|
1588
|
|
|
if ( empty( $fields ) ) { |
|
1589
|
|
|
// Add core object fields if $fields is empty |
|
1590
|
|
|
$fields = array_merge( $object_fields, $this->pod->fields ); |
|
1591
|
|
|
} |
|
1592
|
|
|
} |
|
1593
|
|
|
|
|
1594
|
|
|
$form_fields = $fields; // Temporary |
|
1595
|
|
|
|
|
1596
|
|
|
$fields = array(); |
|
1597
|
|
|
|
|
1598
|
|
|
foreach ( $form_fields as $k => $field ) { |
|
1599
|
|
|
$name = $k; |
|
1600
|
|
|
|
|
1601
|
|
|
$defaults = array( |
|
1602
|
|
|
'name' => $name |
|
1603
|
|
|
); |
|
1604
|
|
|
|
|
1605
|
|
|
if ( !is_array( $field ) ) { |
|
1606
|
|
|
$name = $field; |
|
1607
|
|
|
|
|
1608
|
|
|
$field = array( |
|
1609
|
|
|
'name' => $name |
|
1610
|
|
|
); |
|
1611
|
|
|
} |
|
1612
|
|
|
|
|
1613
|
|
|
$field = array_merge( $defaults, $field ); |
|
1614
|
|
|
|
|
1615
|
|
|
$field[ 'name' ] = trim( $field[ 'name' ] ); |
|
1616
|
|
|
|
|
1617
|
|
|
$default_value = pods_var_raw( 'default', $field ); |
|
1618
|
|
|
$value = pods_var_raw( 'value', $field ); |
|
1619
|
|
|
|
|
1620
|
|
|
if ( empty( $field[ 'name' ] ) ) |
|
1621
|
|
|
$field[ 'name' ] = trim( $name ); |
|
1622
|
|
|
|
|
1623
|
|
View Code Duplication |
if ( isset( $object_fields[ $field[ 'name' ] ] ) ) |
|
1624
|
|
|
$field = array_merge( $field, $object_fields[ $field[ 'name' ] ] ); |
|
1625
|
|
|
elseif ( isset( $this->pod->fields[ $field[ 'name' ] ] ) ) |
|
1626
|
|
|
$field = array_merge( $this->pod->fields[ $field[ 'name' ] ], $field ); |
|
1627
|
|
|
|
|
1628
|
|
View Code Duplication |
if ( pods_var_raw( 'hidden', $field, false, null, true ) ) |
|
1629
|
|
|
$field[ 'type' ] = 'hidden'; |
|
1630
|
|
|
|
|
1631
|
|
|
$fields[ $field[ 'name' ] ] = $field; |
|
1632
|
|
|
|
|
1633
|
|
View Code Duplication |
if ( empty( $this->id ) && null !== $default_value ) { |
|
1634
|
|
|
$this->pod->row_override[ $field[ 'name' ] ] = $default_value; |
|
1635
|
|
|
} |
|
1636
|
|
|
elseif ( !empty( $this->id ) && null !== $value ) { |
|
1637
|
|
|
$this->pod->row[ $field[ 'name' ] ] = $value; |
|
1638
|
|
|
} |
|
1639
|
|
|
} |
|
1640
|
|
|
|
|
1641
|
|
|
unset( $form_fields ); // Cleanup |
|
1642
|
|
|
|
|
1643
|
|
|
$fields = $this->do_hook( 'form_fields', $fields, $this->pod ); |
|
1644
|
|
|
|
|
1645
|
|
|
$pod =& $this->pod; |
|
1646
|
|
|
$thank_you = pods_query_arg( $vars, self::$allowed, $this->exclusion() ); |
|
1647
|
|
|
$thank_you_alt = pods_query_arg( $alt_vars, self::$allowed, $this->exclusion() ); |
|
1648
|
|
|
$obj =& $this; |
|
1649
|
|
|
$singular_label = $this->item; |
|
1650
|
|
|
$plural_label = $this->items; |
|
1651
|
|
|
|
|
1652
|
|
|
if ( is_object( $this->pod ) && 'settings' == $this->pod->pod_data[ 'type' ] && 'settings' == $this->style ) |
|
1653
|
|
|
pods_view( PODS_DIR . 'ui/admin/form-settings.php', compact( array_keys( get_defined_vars() ) ) ); |
|
1654
|
|
|
else |
|
1655
|
|
|
pods_view( PODS_DIR . 'ui/admin/form.php', compact( array_keys( get_defined_vars() ) ) ); |
|
1656
|
|
|
} |
|
1657
|
|
|
|
|
1658
|
|
|
/** |
|
1659
|
|
|
* @return bool|mixed |
|
1660
|
|
|
* @since 2.3.10 |
|
1661
|
|
|
*/ |
|
1662
|
|
|
public function view () { |
|
1663
|
|
|
|
|
1664
|
|
|
if ( false !== $this->callback_action( 'view' ) ) { |
|
1665
|
|
|
return null; |
|
1666
|
|
|
} |
|
1667
|
|
|
|
|
1668
|
|
|
if ( empty( $this->row ) ) { |
|
1669
|
|
|
$this->get_row(); |
|
1670
|
|
|
} |
|
1671
|
|
|
|
|
1672
|
|
|
if ( empty( $this->row ) ) { |
|
1673
|
|
|
return $this->error( sprintf( __( '<strong>Error:</strong> %s not found.', 'pods' ), $this->item ) ); |
|
1674
|
|
|
} |
|
1675
|
|
|
|
|
1676
|
|
|
$pod =& $this->pod; |
|
1677
|
|
|
$obj =& $this; |
|
1678
|
|
|
|
|
1679
|
|
|
$fields = array(); |
|
1680
|
|
|
|
|
1681
|
|
|
if ( isset( $this->fields[ $this->action ] ) ) { |
|
1682
|
|
|
$fields = $this->fields[ $this->action ]; |
|
1683
|
|
|
} |
|
1684
|
|
|
|
|
1685
|
|
View Code Duplication |
if ( is_object( $this->pod ) ) { |
|
1686
|
|
|
$object_fields = (array) pods_var_raw( 'object_fields', $this->pod->pod_data, array(), null, true ); |
|
1687
|
|
|
|
|
1688
|
|
|
$object_field_objects = array( |
|
1689
|
|
|
'post_type', |
|
1690
|
|
|
'taxonomy', |
|
1691
|
|
|
'media', |
|
1692
|
|
|
'user', |
|
1693
|
|
|
'comment' |
|
1694
|
|
|
); |
|
1695
|
|
|
|
|
1696
|
|
|
if ( empty( $object_fields ) && in_array( $this->pod->pod_data[ 'type' ], $object_field_objects ) ) { |
|
1697
|
|
|
$object_fields = $this->pod->api->get_wp_object_fields( $this->pod->pod_data[ 'type' ], $this->pod->pod_data ); |
|
1698
|
|
|
} |
|
1699
|
|
|
|
|
1700
|
|
|
if ( empty( $fields ) ) { |
|
1701
|
|
|
// Add core object fields if $fields is empty |
|
1702
|
|
|
$fields = array_merge( $object_fields, $this->pod->fields ); |
|
1703
|
|
|
} |
|
1704
|
|
|
} |
|
1705
|
|
|
|
|
1706
|
|
|
$view_fields = $fields; // Temporary |
|
1707
|
|
|
|
|
1708
|
|
|
$fields = array(); |
|
1709
|
|
|
|
|
1710
|
|
|
foreach ( $view_fields as $k => $field ) { |
|
1711
|
|
|
$name = $k; |
|
1712
|
|
|
|
|
1713
|
|
|
$defaults = array( |
|
1714
|
|
|
'name' => $name, |
|
1715
|
|
|
'type' => 'text', |
|
1716
|
|
|
'options' => 'text' |
|
1717
|
|
|
); |
|
1718
|
|
|
|
|
1719
|
|
|
if ( !is_array( $field ) ) { |
|
1720
|
|
|
$name = $field; |
|
1721
|
|
|
|
|
1722
|
|
|
$field = array( |
|
1723
|
|
|
'name' => $name |
|
1724
|
|
|
); |
|
1725
|
|
|
} |
|
1726
|
|
|
|
|
1727
|
|
|
$field = array_merge( $defaults, $field ); |
|
1728
|
|
|
|
|
1729
|
|
|
$field[ 'name' ] = trim( $field[ 'name' ] ); |
|
1730
|
|
|
|
|
1731
|
|
|
$value = pods_var_raw( 'default', $field ); |
|
1732
|
|
|
|
|
1733
|
|
|
if ( empty( $field[ 'name' ] ) ) { |
|
1734
|
|
|
$field[ 'name' ] = trim( $name ); |
|
1735
|
|
|
} |
|
1736
|
|
|
|
|
1737
|
|
View Code Duplication |
if ( isset( $object_fields[ $field[ 'name' ] ] ) ) { |
|
1738
|
|
|
$field = array_merge( $field, $object_fields[ $field[ 'name' ] ] ); |
|
1739
|
|
|
} |
|
1740
|
|
|
elseif ( isset( $this->pod->fields[ $field[ 'name' ] ] ) ) { |
|
1741
|
|
|
$field = array_merge( $this->pod->fields[ $field[ 'name' ] ], $field ); |
|
1742
|
|
|
} |
|
1743
|
|
|
|
|
1744
|
|
View Code Duplication |
if ( pods_v( 'hidden', $field, false, null, true ) || 'hidden' == $field[ 'type' ] ) { |
|
1745
|
|
|
continue; |
|
1746
|
|
|
} |
|
1747
|
|
|
elseif ( !PodsForm::permission( $field[ 'type' ], $field[ 'name' ], $field[ 'options' ], $fields, $pod, $pod->id() ) ) { |
|
1748
|
|
|
continue; |
|
1749
|
|
|
} |
|
1750
|
|
|
|
|
1751
|
|
|
$fields[ $field[ 'name' ] ] = $field; |
|
1752
|
|
|
|
|
1753
|
|
|
if ( empty( $this->id ) && null !== $value ) { |
|
1754
|
|
|
$this->pod->row_override[ $field[ 'name' ] ] = $value; |
|
1755
|
|
|
} |
|
1756
|
|
|
} |
|
1757
|
|
|
|
|
1758
|
|
|
unset( $view_fields ); // Cleanup |
|
1759
|
|
|
?> |
|
1760
|
|
|
<div class="wrap pods-ui"> |
|
1761
|
|
|
<div id="icon-edit-pages" class="icon32"<?php if ( false !== $this->icon ) { ?> style="background-position:0 0;background-size:100%;background-image:url(<?php echo esc_url( $this->icon ); ?>);"<?php } ?>><br /></div> |
|
1762
|
|
|
<h2> |
|
1763
|
|
|
<?php |
|
1764
|
|
|
echo wp_kses_post( $this->do_template( $this->header[ 'view' ] ) ); |
|
1765
|
|
|
|
|
1766
|
|
View Code Duplication |
if ( !in_array( 'add', $this->actions_disabled ) && !in_array( 'add', $this->actions_hidden ) ) { |
|
1767
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'add', 'id' . $this->num => '', 'do' . $this->num = '' ), self::$allowed, $this->exclusion() ); |
|
1768
|
|
|
|
|
1769
|
|
|
if ( !empty( $this->action_links[ 'add' ] ) ) { |
|
1770
|
|
|
$link = $this->action_links[ 'add' ]; |
|
1771
|
|
|
} |
|
1772
|
|
|
?> |
|
1773
|
|
|
<a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->heading[ 'add' ] ); ?></a> |
|
1774
|
|
|
<?php |
|
1775
|
|
|
} |
|
1776
|
|
|
elseif ( !in_array( 'manage', $this->actions_disabled ) && !in_array( 'manage', $this->actions_hidden ) ) { |
|
1777
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'manage', 'id' . $this->num => '' ), self::$allowed, $this->exclusion() ); |
|
1778
|
|
|
|
|
1779
|
|
|
if ( !empty( $this->action_links[ 'manage' ] ) ) { |
|
1780
|
|
|
$link = $this->action_links[ 'manage' ]; |
|
1781
|
|
|
} |
|
1782
|
|
|
?> |
|
1783
|
|
|
<a href="<?php echo esc_url( $link ); ?>" class="add-new-h2">« <?php echo pods_v( 'label_back_to_manage', $this->label, sprintf( __( 'Back to %s', 'pods' ), $this->heading[ 'manage' ] ) ); ?></a> |
|
1784
|
|
|
<?php |
|
1785
|
|
|
} |
|
1786
|
|
|
|
|
1787
|
|
|
pods_view( PODS_DIR . 'ui/admin/view.php', compact( array_keys( get_defined_vars() ) ) ); |
|
1788
|
|
|
?> |
|
1789
|
|
|
|
|
1790
|
|
|
</h2> |
|
1791
|
|
|
</div> |
|
1792
|
|
|
<?php |
|
1793
|
|
|
} |
|
1794
|
|
|
|
|
1795
|
|
|
|
|
1796
|
|
|
/** |
|
1797
|
|
|
* Reorder data |
|
1798
|
|
|
*/ |
|
1799
|
|
|
public function reorder () { |
|
1800
|
|
|
// loop through order |
|
1801
|
|
|
$order = (array) pods_var_raw( 'order', 'post', array(), null, true ); |
|
1802
|
|
|
|
|
1803
|
|
|
$params = array( |
|
1804
|
|
|
'pod' => $this->pod->pod, |
|
1805
|
|
|
'field' => $this->reorder[ 'on' ], |
|
1806
|
|
|
'order' => $order |
|
1807
|
|
|
); |
|
1808
|
|
|
|
|
1809
|
|
|
$reorder = pods_api()->reorder_pod_item( $params ); |
|
1810
|
|
|
|
|
1811
|
|
|
if ( $reorder ) |
|
1812
|
|
|
$this->message( sprintf( __( "<strong>Success!</strong> %s reordered successfully.", 'pods' ), $this->items ) ); |
|
1813
|
|
|
else |
|
1814
|
|
|
$this->error( sprintf( __( "<strong>Error:</strong> %s has not been reordered.", 'pods' ), $this->items ) ); |
|
1815
|
|
|
} |
|
1816
|
|
|
|
|
1817
|
|
|
/** |
|
1818
|
|
|
* @param bool $insert |
|
1819
|
|
|
* |
|
1820
|
|
|
* @return mixed |
|
1821
|
|
|
*/ |
|
1822
|
|
|
public function save ( $insert = false ) { |
|
1823
|
|
|
$this->do_hook( 'pre_save', $insert ); |
|
1824
|
|
|
|
|
1825
|
|
|
if ( $this->callback( 'save', $insert ) ) { |
|
1826
|
|
|
return null; |
|
1827
|
|
|
} |
|
1828
|
|
|
|
|
1829
|
|
|
global $wpdb; |
|
|
|
|
|
|
1830
|
|
|
$action = __( 'saved', 'pods' ); |
|
1831
|
|
|
if ( true === $insert ) |
|
1832
|
|
|
$action = __( 'created', 'pods' ); |
|
1833
|
|
|
$field_sql = array(); |
|
1834
|
|
|
$values = array(); |
|
1835
|
|
|
$data = array(); |
|
1836
|
|
|
foreach ( $this->fields[ 'form' ] as $field => $attributes ) { |
|
1837
|
|
|
$vartype = '%s'; |
|
1838
|
|
|
if ( 'bool' == $attributes[ 'type' ] ) |
|
1839
|
|
|
$selected = ( 1 == pods_var( $field, 'post', 0 ) ) ? 1 : 0; |
|
1840
|
|
|
elseif ( '' == pods_var( $field, 'post', '' ) ) |
|
1841
|
|
|
continue; |
|
1842
|
|
|
if ( false === $attributes[ 'display' ] || false !== $attributes[ 'readonly' ] ) { |
|
1843
|
|
|
if ( !in_array( $attributes[ 'type' ], array( 'date', 'time', 'datetime' ) ) ) |
|
1844
|
|
|
continue; |
|
1845
|
|
|
if ( false === $attributes[ 'date_touch' ] && ( false === $attributes[ 'date_touch_on_create' ] || false === $insert || 0 < $this->id ) ) |
|
1846
|
|
|
continue; |
|
1847
|
|
|
} |
|
1848
|
|
|
if ( in_array( $attributes[ 'type' ], array( 'date', 'time', 'datetime' ) ) ) { |
|
1849
|
|
|
$format = "Y-m-d H:i:s"; |
|
1850
|
|
|
if ( 'date' == $attributes[ 'type' ] ) |
|
1851
|
|
|
$format = "Y-m-d"; |
|
1852
|
|
|
if ( 'time' == $attributes[ 'type' ] ) |
|
1853
|
|
|
$format = "H:i:s"; |
|
1854
|
|
|
if ( false !== $attributes[ 'date_touch' ] || ( false !== $attributes[ 'date_touch_on_create' ] && true === $insert && $this->id < 1 ) ) |
|
1855
|
|
|
$value = date_i18n( $format ); |
|
1856
|
|
|
else |
|
1857
|
|
|
$value = date_i18n( $format, strtotime( ( 'time' == $attributes[ 'type' ] ) ? date_i18n( 'Y-m-d ' ) : pods_var( $field, 'post', '' ) ) ); |
|
1858
|
|
|
} |
|
1859
|
|
|
else { |
|
1860
|
|
|
if ( 'bool' == $attributes[ 'type' ] ) { |
|
1861
|
|
|
$vartype = '%d'; |
|
1862
|
|
|
$value = 0; |
|
1863
|
|
|
if ( '' != pods_var( $field, 'post', '' ) ) |
|
1864
|
|
|
$value = 1; |
|
1865
|
|
|
} |
|
1866
|
|
View Code Duplication |
elseif ( 'number' == $attributes[ 'type' ] ) { |
|
1867
|
|
|
$vartype = '%d'; |
|
1868
|
|
|
$value = number_format( pods_var( $field, 'post', 0 ), 0, '', '' ); |
|
1869
|
|
|
} |
|
1870
|
|
View Code Duplication |
elseif ( 'decimal' == $attributes[ 'type' ] ) { |
|
1871
|
|
|
$vartype = '%d'; |
|
1872
|
|
|
$value = number_format( pods_var( $field, 'post', 0 ), 2, '.', '' ); |
|
1873
|
|
|
} |
|
1874
|
|
|
elseif ( 'related' == $attributes[ 'type' ] ) { |
|
1875
|
|
|
if ( is_array( pods_var( $field, 'post', '' ) ) ) |
|
1876
|
|
|
$value = implode( ',', pods_var( $field, 'post', '' ) ); |
|
1877
|
|
|
else |
|
1878
|
|
|
$value = pods_var( $field, 'post', '' ); |
|
1879
|
|
|
} |
|
1880
|
|
|
else |
|
1881
|
|
|
$value = pods_var( $field, 'post', '' ); |
|
1882
|
|
|
} |
|
1883
|
|
|
|
|
1884
|
|
View Code Duplication |
if ( isset( $attributes[ 'custom_save' ] ) && false !== $attributes[ 'custom_save' ] && is_callable( $attributes[ 'custom_save' ] ) ) |
|
1885
|
|
|
$value = call_user_func_array( $attributes[ 'custom_save' ], array( $value, $field, $attributes, &$this ) ); |
|
1886
|
|
|
|
|
1887
|
|
|
$field_sql[] = "`$field`=$vartype"; |
|
1888
|
|
|
$values[] = $value; |
|
1889
|
|
|
$data[ $field ] = $value; |
|
1890
|
|
|
} |
|
1891
|
|
|
$field_sql = implode( ',', $field_sql ); |
|
1892
|
|
|
if ( false === $insert && 0 < $this->id ) { |
|
1893
|
|
|
$this->insert_id = $this->id; |
|
|
|
|
|
|
1894
|
|
|
$values[] = $this->id; |
|
1895
|
|
|
$check = $wpdb->query( $wpdb->prepare( "UPDATE $this->sql['table'] SET $field_sql WHERE id=%d", $values ) ); |
|
1896
|
|
|
} |
|
1897
|
|
|
else |
|
1898
|
|
|
$check = $wpdb->query( $wpdb->prepare( "INSERT INTO $this->sql['table'] SET $field_sql", $values ) ); |
|
1899
|
|
|
if ( $check ) { |
|
1900
|
|
|
if ( 0 == $this->insert_id ) |
|
1901
|
|
|
$this->insert_id = $wpdb->insert_id; |
|
1902
|
|
|
$this->message( sprintf( __( "<strong>Success!</strong> %s %s successfully.", 'pods' ), $this->item, $action ) ); |
|
1903
|
|
|
} |
|
1904
|
|
|
else |
|
1905
|
|
|
$this->error( sprintf( __( "<strong>Error:</strong> %s has not been %s.", 'pods' ), $this->item, $action ) ); |
|
1906
|
|
|
$this->do_hook( 'post_save', $this->insert_id, $data, $insert ); |
|
1907
|
|
|
} |
|
1908
|
|
|
|
|
1909
|
|
|
/** |
|
1910
|
|
|
* @param null $id |
|
1911
|
|
|
* |
|
1912
|
|
|
* @return bool|mixed |
|
1913
|
|
|
*/ |
|
1914
|
|
|
public function delete ( $id = null ) { |
|
1915
|
|
|
$this->do_hook( 'pre_delete', $id ); |
|
1916
|
|
|
|
|
1917
|
|
|
if ( false !== $this->callback_action( 'delete', $id ) ) { |
|
1918
|
|
|
return null; |
|
1919
|
|
|
} |
|
1920
|
|
|
|
|
1921
|
|
|
$id = pods_absint( $id ); |
|
1922
|
|
|
|
|
1923
|
|
|
if ( empty( $id ) ) |
|
1924
|
|
|
$id = pods_absint( $this->id ); |
|
1925
|
|
|
|
|
1926
|
|
|
if ( $id < 1 ) |
|
1927
|
|
|
return $this->error( __( '<strong>Error:</strong> Invalid Configuration - Missing "id" definition.', 'pods' ) ); |
|
1928
|
|
|
|
|
1929
|
|
|
if ( false === $id ) |
|
1930
|
|
|
$id = $this->id; |
|
1931
|
|
|
|
|
1932
|
|
|
if ( is_object( $this->pod ) ) |
|
1933
|
|
|
$check = $this->pod->delete( $id ); |
|
1934
|
|
View Code Duplication |
else |
|
1935
|
|
|
$check = $this->pods_data->delete( $this->sql[ 'table' ], array( $this->sql[ 'field_id' ] => $id ) ); |
|
1936
|
|
|
|
|
1937
|
|
|
if ( $check ) |
|
1938
|
|
|
$this->message( sprintf( __( "<strong>Deleted:</strong> %s has been deleted.", 'pods' ), $this->item ) ); |
|
1939
|
|
|
else |
|
1940
|
|
|
$this->error( sprintf( __( "<strong>Error:</strong> %s has not been deleted.", 'pods' ), $this->item ) ); |
|
1941
|
|
|
|
|
1942
|
|
|
$this->do_hook( 'post_delete', $id ); |
|
1943
|
|
|
} |
|
1944
|
|
|
|
|
1945
|
|
|
/** |
|
1946
|
|
|
* Callback for deleting items in bulk |
|
1947
|
|
|
*/ |
|
1948
|
|
|
public function delete_bulk () { |
|
1949
|
|
|
$this->do_hook( 'pre_delete_bulk' ); |
|
1950
|
|
|
|
|
1951
|
|
|
if ( 1 != pods_var( 'deleted_bulk', 'get', 0 ) ) { |
|
1952
|
|
|
$ids = $this->bulk; |
|
1953
|
|
|
|
|
1954
|
|
|
$success = false; |
|
1955
|
|
|
|
|
1956
|
|
|
if ( !empty( $ids ) ) { |
|
1957
|
|
|
$ids = (array) $ids; |
|
1958
|
|
|
|
|
1959
|
|
|
foreach ( $ids as $id ) { |
|
1960
|
|
|
$id = pods_absint( $id ); |
|
1961
|
|
|
|
|
1962
|
|
|
if ( empty( $id ) ) |
|
1963
|
|
|
continue; |
|
1964
|
|
|
|
|
1965
|
|
|
if ( $callback = $this->callback( 'delete', $id ) ) { |
|
1966
|
|
|
$check = $callback; |
|
1967
|
|
|
} |
|
1968
|
|
|
elseif ( is_object( $this->pod ) ) |
|
1969
|
|
|
$check = $this->pod->delete( $id ); |
|
1970
|
|
View Code Duplication |
else |
|
1971
|
|
|
$check = $this->pods_data->delete( $this->sql[ 'table' ], array( $this->sql[ 'field_id' ] => $id ) ); |
|
1972
|
|
|
|
|
1973
|
|
|
if ( $check ) |
|
1974
|
|
|
$success = true; |
|
1975
|
|
|
} |
|
1976
|
|
|
} |
|
1977
|
|
|
|
|
1978
|
|
|
if ( $success ) |
|
1979
|
|
|
pods_redirect( pods_query_arg( array( 'action_bulk' => 'delete', 'deleted_bulk' => 1 ), array( 'page', 'lang', 'action', 'id' ) ) ); |
|
1980
|
|
|
else |
|
1981
|
|
|
$this->error( sprintf( __( "<strong>Error:</strong> %s has not been deleted.", 'pods' ), $this->item ) ); |
|
1982
|
|
|
} |
|
1983
|
|
|
else { |
|
1984
|
|
|
$this->message( sprintf( __( "<strong>Deleted:</strong> %s have been deleted.", 'pods' ), $this->items ) ); |
|
1985
|
|
|
|
|
1986
|
|
|
unset( $_GET[ 'deleted_bulk' ] ); |
|
1987
|
|
|
} |
|
1988
|
|
|
|
|
1989
|
|
|
$this->action_bulk = false; |
|
1990
|
|
|
unset( $_GET[ 'action_bulk' ] ); |
|
1991
|
|
|
|
|
1992
|
|
|
$this->do_hook( 'post_delete_bulk' ); |
|
1993
|
|
|
|
|
1994
|
|
|
$this->manage(); |
|
1995
|
|
|
} |
|
1996
|
|
|
|
|
1997
|
|
|
/** |
|
1998
|
|
|
* Callback for exporting items in bulk |
|
1999
|
|
|
*/ |
|
2000
|
|
|
public function export_bulk() { |
|
2001
|
|
|
|
|
2002
|
|
|
if ( ! empty( $_POST['bulk_export_type'] ) ) { |
|
2003
|
|
|
if ( ! empty( $_POST['bulk_export_fields'] ) ) { |
|
2004
|
|
|
$export_fields = $_POST['bulk_export_fields']; |
|
2005
|
|
|
|
|
2006
|
|
|
$this->fields['export'] = array(); |
|
2007
|
|
|
|
|
2008
|
|
|
if ( $this->pod ) { |
|
2009
|
|
|
$fields = $this->pod->fields(); |
|
2010
|
|
|
|
|
2011
|
|
|
foreach ( $fields as $field ) { |
|
2012
|
|
|
if ( in_array( $field['name'], $export_fields ) ) { |
|
2013
|
|
|
$this->fields['export'][] = $field; |
|
2014
|
|
|
} |
|
2015
|
|
|
} |
|
2016
|
|
|
} |
|
2017
|
|
|
} |
|
2018
|
|
|
|
|
2019
|
|
|
// Set up where clause so that export function finds it |
|
2020
|
|
|
if ( ! empty( $_POST['action_bulk_ids'] ) ) { |
|
2021
|
|
|
$ids = (array) explode(',', $_POST['action_bulk_ids']); |
|
2022
|
|
|
$ids = array_map( 'absint', $ids ); |
|
2023
|
|
|
$ids = array_filter( $ids ); |
|
2024
|
|
|
|
|
2025
|
|
|
if ( ! empty( $ids ) ) { |
|
2026
|
|
|
$ids = implode( ', ', $ids ); |
|
2027
|
|
|
|
|
2028
|
|
|
$this->where = array( |
|
2029
|
|
|
'manage' => '`' . pods_sanitize( $this->sql['field_id'] ) . '` IN ( ' . $ids . ' )', |
|
2030
|
|
|
); |
|
2031
|
|
|
} |
|
2032
|
|
|
} |
|
2033
|
|
|
|
|
2034
|
|
|
$this->export( $_POST['bulk_export_type'] ); |
|
2035
|
|
|
|
|
2036
|
|
|
// Cleanup since export function calls get_data before returning |
|
2037
|
|
|
$this->action_bulk = ''; |
|
2038
|
|
|
$this->where = array(); |
|
2039
|
|
|
$this->data = false; |
|
2040
|
|
|
$_GET['action_bulk_ids'] = ''; |
|
2041
|
|
|
|
|
2042
|
|
|
$this->manage(); |
|
2043
|
|
|
} else { |
|
2044
|
|
|
$this->export_fields_form(); |
|
2045
|
|
|
} |
|
2046
|
|
|
|
|
2047
|
|
|
} |
|
2048
|
|
|
|
|
2049
|
|
|
/** |
|
2050
|
|
|
* Select the pods fields to be exported |
|
2051
|
|
|
*/ |
|
2052
|
|
|
public function export_fields_form() { |
|
2053
|
|
|
|
|
2054
|
|
|
?> |
|
2055
|
|
|
<div class="wrap pods-admin pods-ui"> |
|
2056
|
|
|
<h2><?php echo __( 'Choose Export Fields', 'pods' ); ?></h2> |
|
2057
|
|
|
|
|
2058
|
|
|
<form method="post" id="pods_admin_ui_export_form"> |
|
2059
|
|
|
<?php |
|
2060
|
|
|
// Avoid a bunch of inputs if there's a lot selected |
|
2061
|
|
|
if ( ! empty( $_REQUEST['action_bulk_ids'] ) ) { |
|
2062
|
|
|
$_GET['action_bulk_ids'] = implode( ',', (array) $_REQUEST['action_bulk_ids'] ); |
|
2063
|
|
|
} |
|
2064
|
|
|
|
|
2065
|
|
|
$this->hidden_vars(); |
|
2066
|
|
|
?> |
|
2067
|
|
|
|
|
2068
|
|
|
<ul> |
|
2069
|
|
|
<?php foreach ( $this->pod->fields() as $field_name => $field ) { ?> |
|
2070
|
|
|
<li> |
|
2071
|
|
|
<label for="bulk_export_fields_<?php echo esc_attr( $field['name'] ); ?>"> |
|
2072
|
|
|
<input type="checkbox" name="bulk_export_fields[]" id="bulk_export_fields_<?php echo esc_attr( $field['name'] ); ?>" value="<?php echo esc_attr( $field['name'] ); ?>" /> |
|
2073
|
|
|
<?php echo esc_html( $field['label'] ); ?> |
|
2074
|
|
|
</label> |
|
2075
|
|
|
</li> |
|
2076
|
|
|
<?php } ?> |
|
2077
|
|
|
</ul> |
|
2078
|
|
|
|
|
2079
|
|
|
<p class="submit"> |
|
2080
|
|
|
<?php _e( 'Export as:', 'pods' ); ?> |
|
2081
|
|
|
<?php foreach ( $this->export[ 'formats' ] as $format => $separator ) { ?> |
|
2082
|
|
|
<input type="submit" id="export_type_<?php echo esc_attr( strtoupper( $format ) ); ?>" value=" <?php echo esc_attr( strtoupper( $format ) ); ?> " name="bulk_export_type" class="button-primary" /> |
|
2083
|
|
|
<?php } ?> |
|
2084
|
|
|
</p> |
|
2085
|
|
|
</form> |
|
2086
|
|
|
</div> |
|
2087
|
|
|
<?php |
|
2088
|
|
|
|
|
2089
|
|
|
} |
|
2090
|
|
|
|
|
2091
|
|
|
public function export( $export_type = null ) { |
|
2092
|
|
|
|
|
2093
|
|
|
if ( empty( $export_type ) ) { |
|
2094
|
|
|
$export_type = pods_var( 'export_type', 'get', 'csv' ); |
|
2095
|
|
|
} |
|
2096
|
|
|
|
|
2097
|
|
|
$export_type = trim( strtolower( $export_type ) ); |
|
2098
|
|
|
|
|
2099
|
|
|
$type = 'sv'; // covers csv + tsv |
|
2100
|
|
|
|
|
2101
|
|
|
if ( in_array( $export_type, array( 'xml', 'json' ) ) ) |
|
2102
|
|
|
$type = $export_type; |
|
2103
|
|
|
|
|
2104
|
|
|
$delimiter = ','; |
|
2105
|
|
|
|
|
2106
|
|
|
if ( ! empty( $this->export['formats'][ $export_type ] ) ) { |
|
2107
|
|
|
$delimiter = $this->export['formats'][ $export_type ]; |
|
2108
|
|
|
} |
|
2109
|
|
|
|
|
2110
|
|
|
$columns = array( |
|
2111
|
|
|
$this->sql['field_id'] => 'ID', |
|
2112
|
|
|
); |
|
2113
|
|
|
|
|
2114
|
|
|
if ( empty( $this->fields['export'] ) && $this->pod && ! empty( $this->pod->fields ) ) { |
|
2115
|
|
|
$this->fields['export'] = $this->pod->fields; |
|
2116
|
|
|
} |
|
2117
|
|
|
|
|
2118
|
|
|
if ( ! empty( $this->fields['export'] ) ) { |
|
2119
|
|
|
foreach ( $this->fields['export'] as $field ) { |
|
2120
|
|
|
$columns[ $field['name'] ] = $field['label']; |
|
2121
|
|
|
} |
|
2122
|
|
|
} |
|
2123
|
|
|
|
|
2124
|
|
|
$params = array( |
|
2125
|
|
|
'full' => true, |
|
2126
|
|
|
'flatten' => true, |
|
2127
|
|
|
'fields' => array_keys( $columns ), |
|
2128
|
|
|
'type' => $type, |
|
2129
|
|
|
'delimiter' => $delimiter, |
|
2130
|
|
|
'columns' => $columns |
|
2131
|
|
|
); |
|
2132
|
|
|
|
|
2133
|
|
|
$items = $this->get_data( $params ); |
|
2134
|
|
|
|
|
2135
|
|
|
$data = array( |
|
2136
|
|
|
'columns' => $columns, |
|
2137
|
|
|
'items' => $items, |
|
2138
|
|
|
'fields' => $this->fields[ 'export' ] |
|
2139
|
|
|
); |
|
2140
|
|
|
|
|
2141
|
|
|
$migrate = pods_migrate( $type, $delimiter, $data ); |
|
2142
|
|
|
|
|
2143
|
|
|
$migrate->export(); |
|
2144
|
|
|
|
|
2145
|
|
|
$export_file = $migrate->save(); |
|
2146
|
|
|
|
|
2147
|
|
|
$this->message( sprintf( __( '<strong>Success:</strong> Your export is ready, you can download it <a href="%s" target="_blank">here</a>', 'pods' ), $export_file ) ); |
|
2148
|
|
|
|
|
2149
|
|
|
//echo '<script type="text/javascript">window.open("' . esc_js( $export_file ) . '");</script>'; |
|
|
|
|
|
|
2150
|
|
|
|
|
2151
|
|
|
$this->get_data(); |
|
2152
|
|
|
} |
|
2153
|
|
|
|
|
2154
|
|
|
/** |
|
2155
|
|
|
* @param $field |
|
2156
|
|
|
* |
|
2157
|
|
|
* @return array|bool|mixed|null |
|
2158
|
|
|
*/ |
|
2159
|
|
|
public function get_field ( $field ) { |
|
2160
|
|
|
$value = null; |
|
2161
|
|
|
|
|
2162
|
|
|
// use PodsData to get field |
|
2163
|
|
|
|
|
2164
|
|
|
if ( $callback = $this->callback( 'get_field', $field ) ) { |
|
2165
|
|
|
return $callback; |
|
2166
|
|
|
} |
|
2167
|
|
|
|
|
2168
|
|
|
if ( isset( $this->row[ $field ] ) ) { |
|
2169
|
|
|
$value = $this->row[ $field ]; |
|
2170
|
|
|
} |
|
2171
|
|
|
elseif ( false !== $this->pod && is_object( $this->pod ) && ( 'Pods' == get_class( $this->pod ) || 'Pod' == get_class( $this->pod ) ) ) { |
|
2172
|
|
|
if ( 'Pod' == get_class( $this->pod ) ) |
|
2173
|
|
|
$value = $this->pod->get_field( $field ); |
|
|
|
|
|
|
2174
|
|
|
else |
|
2175
|
|
|
$value = $this->pod->field( $field ); |
|
2176
|
|
|
} |
|
2177
|
|
|
|
|
2178
|
|
|
return $this->do_hook( 'get_field', $value, $field ); |
|
2179
|
|
|
} |
|
2180
|
|
|
|
|
2181
|
|
|
/** |
|
2182
|
|
|
* Get find() params based on current UI action |
|
2183
|
|
|
* |
|
2184
|
|
|
* @param null|array $params |
|
2185
|
|
|
* @param null|string $action |
|
2186
|
|
|
*/ |
|
2187
|
|
|
public function get_params( $params = null, $action = null ) { |
|
2188
|
|
|
|
|
2189
|
|
|
if ( null === $action ) { |
|
2190
|
|
|
$action = $this->action; |
|
2191
|
|
|
} |
|
2192
|
|
|
|
|
2193
|
|
|
$defaults = array( |
|
2194
|
|
|
'full' => false, |
|
2195
|
|
|
'flatten' => true, |
|
2196
|
|
|
'fields' => null, |
|
2197
|
|
|
'type' => '' |
|
2198
|
|
|
); |
|
2199
|
|
|
|
|
2200
|
|
View Code Duplication |
if ( !empty( $params ) && is_array( $params ) ) |
|
2201
|
|
|
$params = (object) array_merge( $defaults, $params ); |
|
2202
|
|
|
else |
|
2203
|
|
|
$params = (object) $defaults; |
|
2204
|
|
|
|
|
2205
|
|
|
if ( !in_array( $action, array( 'manage', 'reorder' ) ) ) |
|
2206
|
|
|
$action = 'manage'; |
|
2207
|
|
|
|
|
2208
|
|
|
$params_override = false; |
|
2209
|
|
|
|
|
2210
|
|
|
$orderby = array(); |
|
2211
|
|
|
|
|
2212
|
|
|
$limit = $this->limit; |
|
2213
|
|
|
|
|
2214
|
|
|
$sql = null; |
|
2215
|
|
|
|
|
2216
|
|
|
if ( 'reorder' == $this->action ) { |
|
2217
|
|
|
if ( ! empty( $this->reorder[ 'orderby' ] ) ) { |
|
2218
|
|
|
$orderby[ $this->reorder[ 'orderby' ] ] = $this->reorder[ 'orderby_dir' ]; |
|
2219
|
|
|
} else { |
|
2220
|
|
|
$orderby[ $this->reorder[ 'on' ] ] = $this->reorder[ 'orderby_dir' ]; |
|
2221
|
|
|
} |
|
2222
|
|
|
|
|
2223
|
|
|
if ( ! empty( $this->reorder[ 'limit' ] ) ) { |
|
2224
|
|
|
$limit = $this->reorder[ 'limit' ]; |
|
2225
|
|
|
} |
|
2226
|
|
|
|
|
2227
|
|
|
if ( ! empty( $this->reorder[ 'sql' ] ) ) { |
|
2228
|
|
|
$sql = $this->reorder[ 'sql' ]; |
|
2229
|
|
|
} |
|
2230
|
|
|
} |
|
2231
|
|
|
|
|
2232
|
|
|
if ( !empty( $this->orderby ) ) { |
|
2233
|
|
|
$this->orderby = (array) $this->orderby; |
|
2234
|
|
|
|
|
2235
|
|
|
foreach ( $this->orderby as $order ) { |
|
2236
|
|
|
if ( false !== strpos( $order, ' ' ) ) { |
|
2237
|
|
|
$orderby[] = $order; |
|
2238
|
|
|
} |
|
2239
|
|
|
elseif ( !isset( $orderby[ $order ] ) ) { |
|
2240
|
|
|
$orderby[ $order ] = $this->orderby_dir; |
|
2241
|
|
|
} |
|
2242
|
|
|
} |
|
2243
|
|
|
} |
|
2244
|
|
|
|
|
2245
|
|
|
if ( false !== $this->pod && is_object( $this->pod ) && ( 'Pods' == get_class( $this->pod ) || 'Pod' == get_class( $this->pod ) ) ) { |
|
2246
|
|
|
$find_params = array( |
|
2247
|
|
|
'where' => pods_v( $action, $this->where, null, true ), |
|
2248
|
|
|
'orderby' => $orderby, |
|
2249
|
|
|
'page' => (int) $this->page, |
|
2250
|
|
|
'pagination' => true, |
|
2251
|
|
|
'limit' => (int) $limit, |
|
2252
|
|
|
'search' => $this->searchable, |
|
2253
|
|
|
'search_query' => $this->search, |
|
2254
|
|
|
'search_across' => $this->search_across, |
|
2255
|
|
|
'search_across_picks' => $this->search_across_picks, |
|
2256
|
|
|
'filters' => $this->filters, |
|
2257
|
|
|
'sql' => $sql |
|
2258
|
|
|
); |
|
2259
|
|
|
|
|
2260
|
|
|
$params_override = true; |
|
2261
|
|
|
} |
|
2262
|
|
|
else { |
|
2263
|
|
|
$find_params = array( |
|
2264
|
|
|
'table' => $this->sql[ 'table' ], |
|
2265
|
|
|
'id' => $this->sql[ 'field_id' ], |
|
2266
|
|
|
'index' => $this->sql[ 'field_index' ], |
|
2267
|
|
|
'where' => pods_v( $action, $this->where, null, true ), |
|
2268
|
|
|
'orderby' => $orderby, |
|
2269
|
|
|
'page' => (int) $this->page, |
|
2270
|
|
|
'pagination' => true, |
|
2271
|
|
|
'limit' => (int) $limit, |
|
2272
|
|
|
'search' => $this->searchable, |
|
2273
|
|
|
'search_query' => $this->search, |
|
2274
|
|
|
'fields' => $this->fields[ 'search' ], |
|
2275
|
|
|
'sql' => $sql |
|
2276
|
|
|
); |
|
2277
|
|
|
|
|
2278
|
|
|
if ( ! empty( $this->sql['select'] ) ) { |
|
2279
|
|
|
$find_params['select'] = $this->sql['select']; |
|
2280
|
|
|
} |
|
2281
|
|
|
} |
|
2282
|
|
|
|
|
2283
|
|
|
if ( empty( $find_params[ 'where' ] ) && $this->restricted( $this->action ) ) |
|
2284
|
|
|
$find_params[ 'where' ] = $this->pods_data->query_fields( $this->restrict[ $this->action ], ( is_object( $this->pod ) ? $this->pod->pod_data : null ) ); |
|
2285
|
|
|
|
|
2286
|
|
|
if ( $params_override ) { |
|
2287
|
|
|
$find_params = array_merge( $find_params, (array) $this->params ); |
|
2288
|
|
|
} |
|
2289
|
|
|
|
|
2290
|
|
|
if ( $params->full ) |
|
2291
|
|
|
$find_params[ 'limit' ] = -1; |
|
2292
|
|
|
|
|
2293
|
|
|
$find_params = apply_filters('pods_ui_get_params', $find_params, $this->pod->pod, $this); |
|
2294
|
|
|
|
|
2295
|
|
|
/** |
|
2296
|
|
|
* Filter Pods::find() parameters to make it more easily extended by plugins and developers. |
|
2297
|
|
|
* |
|
2298
|
|
|
* @param array $find_params Parameters used with Pods::find() |
|
2299
|
|
|
* @param string $action Current action |
|
2300
|
|
|
* @param PodsUI $this PodsUI instance |
|
2301
|
|
|
* |
|
2302
|
|
|
* @since 2.6.8 |
|
2303
|
|
|
*/ |
|
2304
|
|
|
$find_params = apply_filters( 'pods_ui_get_find_params', $find_params, $action, $this ); |
|
2305
|
|
|
|
|
2306
|
|
|
// Debug purposes |
|
2307
|
|
View Code Duplication |
if ( 1 == pods_v( 'pods_debug_params', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) |
|
2308
|
|
|
pods_debug( $find_params ); |
|
2309
|
|
|
|
|
2310
|
|
|
return $find_params; |
|
2311
|
|
|
} |
|
2312
|
|
|
|
|
2313
|
|
|
/** |
|
2314
|
|
|
* @param bool $full Whether to get ALL data or use pagination |
|
|
|
|
|
|
2315
|
|
|
* |
|
2316
|
|
|
* @return bool |
|
2317
|
|
|
*/ |
|
2318
|
|
|
public function get_data ( $params = null ) { |
|
2319
|
|
|
$action = $this->action; |
|
2320
|
|
|
|
|
2321
|
|
|
$defaults = array( |
|
2322
|
|
|
'full' => false, |
|
2323
|
|
|
'flatten' => true, |
|
2324
|
|
|
'fields' => null, |
|
2325
|
|
|
'type' => '' |
|
2326
|
|
|
); |
|
2327
|
|
|
|
|
2328
|
|
View Code Duplication |
if ( !empty( $params ) && is_array( $params ) ) |
|
2329
|
|
|
$params = (object) array_merge( $defaults, $params ); |
|
2330
|
|
|
else |
|
2331
|
|
|
$params = (object) $defaults; |
|
2332
|
|
|
|
|
2333
|
|
|
if ( !in_array( $action, array( 'manage', 'reorder' ) ) ) |
|
2334
|
|
|
$action = 'manage'; |
|
2335
|
|
|
|
|
2336
|
|
|
$find_params = $this->get_params( $params, $action ); |
|
2337
|
|
|
|
|
2338
|
|
|
if ( false !== $this->pod && is_object( $this->pod ) && ( 'Pods' == get_class( $this->pod ) || 'Pod' == get_class( $this->pod ) ) ) { |
|
2339
|
|
|
$this->pod->find( $find_params ); |
|
|
|
|
|
|
2340
|
|
|
|
|
2341
|
|
|
if ( !$params->full ) { |
|
2342
|
|
|
$data = $this->pod->data(); |
|
|
|
|
|
|
2343
|
|
|
|
|
2344
|
|
|
$this->data = $data; |
|
2345
|
|
|
|
|
2346
|
|
|
if ( !empty( $this->data ) ) { |
|
2347
|
|
|
$this->data_keys = array_keys( $this->data ); |
|
2348
|
|
|
} |
|
2349
|
|
|
|
|
2350
|
|
|
$this->total = $this->pod->total(); |
|
|
|
|
|
|
2351
|
|
|
$this->total_found = $this->pod->total_found(); |
|
|
|
|
|
|
2352
|
|
|
} |
|
2353
|
|
|
else { |
|
2354
|
|
|
$this->data_full = array(); |
|
2355
|
|
|
|
|
2356
|
|
|
$export_params = array( |
|
2357
|
|
|
'fields' => $params->fields, |
|
2358
|
|
|
'flatten' => true |
|
2359
|
|
|
); |
|
2360
|
|
|
|
|
2361
|
|
|
if ( in_array( $params->type, array( 'json', 'xml' ) ) ) |
|
2362
|
|
|
$export_params[ 'flatten' ] = false; |
|
2363
|
|
|
|
|
2364
|
|
|
$export_params = $this->do_hook( 'export_options', $export_params, $params ); |
|
2365
|
|
|
|
|
2366
|
|
|
while ( $this->pod->fetch() ) { |
|
|
|
|
|
|
2367
|
|
|
$this->data_full[ $this->pod->id() ] = $this->pod->export( $export_params ); |
|
|
|
|
|
|
2368
|
|
|
} |
|
2369
|
|
|
|
|
2370
|
|
|
$this->pod->reset(); |
|
|
|
|
|
|
2371
|
|
|
|
|
2372
|
|
|
return $this->data_full; |
|
2373
|
|
|
} |
|
2374
|
|
|
} |
|
2375
|
|
|
else { |
|
2376
|
|
|
if ( !empty( $this->data ) ) |
|
2377
|
|
|
return $this->data; |
|
2378
|
|
|
|
|
2379
|
|
|
if ( empty( $this->sql[ 'table' ] ) ) |
|
2380
|
|
|
return $this->data; |
|
2381
|
|
|
|
|
2382
|
|
|
$this->pods_data->select( $find_params ); |
|
2383
|
|
|
|
|
2384
|
|
|
if ( !$params->full ) { |
|
2385
|
|
|
$this->data = $this->pods_data->data; |
|
2386
|
|
|
|
|
2387
|
|
|
if ( !empty( $this->data ) ) { |
|
2388
|
|
|
$this->data_keys = array_keys( $this->data ); |
|
2389
|
|
|
} |
|
2390
|
|
|
|
|
2391
|
|
|
$this->total = $this->pods_data->total(); |
|
2392
|
|
|
$this->total_found = $this->pods_data->total_found(); |
|
2393
|
|
|
} |
|
2394
|
|
|
else { |
|
2395
|
|
|
$this->data_full = $this->pods_data->data; |
|
2396
|
|
|
|
|
2397
|
|
|
if ( !empty( $this->data_full ) ) { |
|
2398
|
|
|
$this->data_keys = array_keys( $this->data_full ); |
|
2399
|
|
|
} |
|
2400
|
|
|
|
|
2401
|
|
|
return $this->data_full; |
|
2402
|
|
|
} |
|
2403
|
|
|
} |
|
2404
|
|
|
|
|
2405
|
|
|
return $this->data; |
|
2406
|
|
|
} |
|
2407
|
|
|
|
|
2408
|
|
|
/** |
|
2409
|
|
|
* Sort out data alphabetically by a key |
|
2410
|
|
|
*/ |
|
2411
|
|
|
public function sort_data () { |
|
2412
|
|
|
// only do this if we have a default orderby |
|
2413
|
|
|
if ( isset( $this->orderby[ 'default' ] ) ) { |
|
2414
|
|
|
$orderby = $this->orderby[ 'default' ]; |
|
2415
|
|
|
foreach ( $this->data as $k => $v ) { |
|
|
|
|
|
|
2416
|
|
|
$sorter[ $k ] = strtolower( $v[ $orderby ] ); |
|
|
|
|
|
|
2417
|
|
|
} |
|
2418
|
|
|
if ( $this->orderby_dir == 'ASC' ) |
|
2419
|
|
|
asort( $sorter ); |
|
2420
|
|
|
else |
|
2421
|
|
|
arsort( $sorter ); |
|
2422
|
|
|
foreach ( $sorter as $key => $val ) { |
|
2423
|
|
|
$intermediary[] = $this->data[ $key ]; |
|
|
|
|
|
|
2424
|
|
|
} |
|
2425
|
|
|
if ( isset( $intermediary ) ) { |
|
2426
|
|
|
$this->data = $intermediary; |
|
2427
|
|
|
$this->data_keys = array_keys( $this->data ); |
|
2428
|
|
|
} |
|
2429
|
|
|
} |
|
2430
|
|
|
} |
|
2431
|
|
|
|
|
2432
|
|
|
/** |
|
2433
|
|
|
* @return array |
|
2434
|
|
|
*/ |
|
2435
|
|
|
public function get_row ( &$counter = 0, $method = null ) { |
|
2436
|
|
|
if ( !empty( $this->row ) && 0 < (int) $this->id && 'table' != $method ) |
|
2437
|
|
|
return $this->row; |
|
2438
|
|
|
|
|
2439
|
|
|
if ( is_object( $this->pod ) && ( 'Pods' == get_class( $this->pod ) || 'Pod' == get_class( $this->pod ) ) ) |
|
2440
|
|
|
$this->row = $this->pod->fetch(); |
|
|
|
|
|
|
2441
|
|
|
else { |
|
2442
|
|
|
$this->row = false; |
|
2443
|
|
|
|
|
2444
|
|
|
if ( !empty( $this->data ) ) { |
|
2445
|
|
|
if ( empty( $this->data_keys ) || count( $this->data ) != count( $this->data_keys ) ) { |
|
2446
|
|
|
$this->data_keys = array_keys( $this->data ); |
|
2447
|
|
|
} |
|
2448
|
|
|
|
|
2449
|
|
|
if ( count( $this->data ) == $this->total && isset( $this->data_keys[ $counter ] ) && isset( $this->data[ $this->data_keys[ $counter ] ] ) ) { |
|
2450
|
|
|
$this->row = $this->data[ $this->data_keys[ $counter ] ]; |
|
2451
|
|
|
|
|
2452
|
|
|
$counter++; |
|
2453
|
|
|
} |
|
2454
|
|
|
} |
|
2455
|
|
|
|
|
2456
|
|
|
if ( false === $this->row && 0 < (int) $this->id && !empty( $this->sql[ 'table' ] ) ) { |
|
2457
|
|
|
$this->pods_data->select( |
|
2458
|
|
|
array( |
|
2459
|
|
|
'table' => $this->sql[ 'table' ], |
|
2460
|
|
|
'where' => '`' . pods_sanitize( $this->sql['field_id'] ) . '` = ' . (int) $this->id, |
|
2461
|
|
|
'limit' => 1 |
|
2462
|
|
|
) |
|
2463
|
|
|
); |
|
2464
|
|
|
|
|
2465
|
|
|
$this->row = $this->pods_data->fetch(); |
|
2466
|
|
|
} |
|
2467
|
|
|
} |
|
2468
|
|
|
|
|
2469
|
|
|
return $this->row; |
|
2470
|
|
|
} |
|
2471
|
|
|
|
|
2472
|
|
|
/** |
|
2473
|
|
|
* @param bool $reorder |
|
2474
|
|
|
* |
|
2475
|
|
|
* @return mixed|null |
|
2476
|
|
|
*/ |
|
2477
|
|
|
public function manage ( $reorder = false ) { |
|
2478
|
|
|
if ( false !== $this->callback_action( 'manage', $reorder ) ) { |
|
2479
|
|
|
return null; |
|
2480
|
|
|
} |
|
2481
|
|
|
|
|
2482
|
|
|
if ( !empty( $this->action_bulk ) && !empty( $this->actions_bulk ) && isset( $this->actions_bulk[ $this->action_bulk ] ) && !in_array( $this->action_bulk, $this->actions_disabled ) && ( ! empty( $this->bulk ) || 'export' == $this->action_bulk ) ) { |
|
2483
|
|
|
if ( empty( $_REQUEST[ '_wpnonce' . $this->num ] ) || false === wp_verify_nonce( $_REQUEST[ '_wpnonce' . $this->num ], 'pods-ui-action-bulk' ) ) { |
|
2484
|
|
|
pods_message( __( 'Invalid bulk request, please try again.', 'pods' ) ); |
|
2485
|
|
|
} |
|
2486
|
|
|
elseif ( false !== $this->callback_bulk( $this->action_bulk, $this->bulk ) ) { |
|
2487
|
|
|
return null; |
|
2488
|
|
|
} |
|
2489
|
|
|
elseif ( 'delete' == $this->action_bulk ) { |
|
2490
|
|
|
$this->delete_bulk(); |
|
2491
|
|
|
|
|
2492
|
|
|
return; |
|
2493
|
|
|
} |
|
2494
|
|
|
elseif ( 'export' == $this->action_bulk ) { |
|
2495
|
|
|
$this->export_bulk(); |
|
2496
|
|
|
|
|
2497
|
|
|
return; |
|
2498
|
|
|
} |
|
2499
|
|
|
} |
|
2500
|
|
|
|
|
2501
|
|
|
$this->screen_meta(); |
|
2502
|
|
|
|
|
2503
|
|
|
if ( true === $reorder ) |
|
2504
|
|
|
wp_enqueue_script( 'jquery-ui-sortable' ); |
|
2505
|
|
|
?> |
|
2506
|
|
|
<div class="wrap pods-admin pods-ui"> |
|
2507
|
|
|
<div id="icon-edit-pages" class="icon32"<?php if ( false !== $this->icon ) { ?> style="background-position:0 0;background-size:100%;background-image:url(<?php echo esc_url( $this->icon ); ?>);"<?php } ?>><br /></div> |
|
2508
|
|
|
<h2> |
|
2509
|
|
|
<?php |
|
2510
|
|
|
if ( true === $reorder ) { |
|
2511
|
|
|
echo wp_kses_post( $this->header[ 'reorder' ] ); |
|
2512
|
|
|
|
|
2513
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'manage', 'id' . $this->num => '' ), self::$allowed, $this->exclusion() ); |
|
2514
|
|
|
|
|
2515
|
|
|
if ( !empty( $this->action_links[ 'manage' ] ) ) |
|
2516
|
|
|
$link = $this->action_links[ 'manage' ]; |
|
2517
|
|
|
?> |
|
2518
|
|
|
<small>(<a href="<?php echo esc_url( $link ); ?>">« <?php echo sprintf( __( 'Back to %s', 'pods' ), $this->heading[ 'manage' ] ); ?></a>)</small> |
|
2519
|
|
|
<?php |
|
2520
|
|
|
} |
|
2521
|
|
|
else |
|
2522
|
|
|
echo wp_kses_post( $this->header[ 'manage' ] ); |
|
2523
|
|
|
|
|
2524
|
|
|
if ( !in_array( 'add', $this->actions_disabled ) && !in_array( 'add', $this->actions_hidden ) ) { |
|
2525
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'add', 'id' . $this->num => '', 'do' . $this->num => '' ), self::$allowed, $this->exclusion() ); |
|
2526
|
|
|
|
|
2527
|
|
|
if ( !empty( $this->action_links[ 'add' ] ) ) |
|
2528
|
|
|
$link = $this->action_links[ 'add' ]; |
|
2529
|
|
|
?> |
|
2530
|
|
|
<a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->label[ 'add_new' ] ); ?></a> |
|
2531
|
|
|
<?php |
|
2532
|
|
|
} |
|
2533
|
|
|
if ( !in_array( 'reorder', $this->actions_disabled ) && !in_array( 'reorder', $this->actions_hidden ) && false !== $this->reorder[ 'on' ] ) { |
|
2534
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'reorder' ), self::$allowed, $this->exclusion() ); |
|
2535
|
|
|
|
|
2536
|
|
|
if ( !empty( $this->action_links[ 'reorder' ] ) ) |
|
2537
|
|
|
$link = $this->action_links[ 'reorder' ]; |
|
2538
|
|
|
?> |
|
2539
|
|
|
<a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->label[ 'reorder' ] ); ?></a> |
|
2540
|
|
|
<?php |
|
2541
|
|
|
} |
|
2542
|
|
|
?> |
|
2543
|
|
|
</h2> |
|
2544
|
|
|
|
|
2545
|
|
|
<form id="posts-filter" action="" method="get"> |
|
2546
|
|
|
<?php |
|
2547
|
|
|
$excluded_filters = array( |
|
2548
|
|
|
'search' . $this->num, |
|
2549
|
|
|
'pg' . $this->num, |
|
2550
|
|
|
'action' . $this->num, |
|
2551
|
|
|
'action_bulk' . $this->num, |
|
2552
|
|
|
'action_bulk_ids' . $this->num, |
|
2553
|
|
|
'_wpnonce' . $this->num |
|
2554
|
|
|
); |
|
2555
|
|
|
|
|
2556
|
|
|
$filters = $this->filters; |
|
2557
|
|
|
|
|
2558
|
|
|
foreach ( $filters as $k => $filter ) { |
|
2559
|
|
View Code Duplication |
if ( isset( $this->pod->fields[ $filter ] ) ) { |
|
2560
|
|
|
$filter_field = $this->pod->fields[ $filter ]; |
|
2561
|
|
|
} |
|
2562
|
|
|
elseif ( isset( $this->fields[ 'manage' ][ $filter ] ) ) { |
|
2563
|
|
|
$filter_field = $this->fields[ 'manage' ][ $filter ]; |
|
2564
|
|
|
} |
|
2565
|
|
|
else { |
|
2566
|
|
|
unset( $filters[ $k ] ); |
|
2567
|
|
|
continue; |
|
2568
|
|
|
} |
|
2569
|
|
|
|
|
2570
|
|
View Code Duplication |
if ( in_array( $filter_field[ 'type' ], array( 'date', 'datetime', 'time' ) ) ) { |
|
2571
|
|
|
if ( '' == pods_var_raw( 'filter_' . $filter . '_start', 'get', '', null, true ) && '' == pods_var_raw( 'filter_' . $filter . '_end', 'get', '', null, true ) ) { |
|
2572
|
|
|
unset( $filters[ $k ] ); |
|
2573
|
|
|
continue; |
|
2574
|
|
|
} |
|
2575
|
|
|
} |
|
2576
|
|
|
elseif ( '' === pods_var_raw( 'filter_' . $filter, 'get', '' ) ) { |
|
2577
|
|
|
unset( $filters[ $k ] ); |
|
2578
|
|
|
continue; |
|
2579
|
|
|
} |
|
2580
|
|
|
|
|
2581
|
|
|
$excluded_filters[] = 'filter_' . $filter . '_start'; |
|
2582
|
|
|
$excluded_filters[] = 'filter_' . $filter . '_end'; |
|
2583
|
|
|
$excluded_filters[] = 'filter_' . $filter; |
|
2584
|
|
|
} |
|
2585
|
|
|
|
|
2586
|
|
|
$get = $_GET; |
|
2587
|
|
|
|
|
2588
|
|
View Code Duplication |
foreach ( $get as $k => $v ) { |
|
2589
|
|
|
if ( is_array( $v ) || in_array( $k, $excluded_filters ) || strlen( $v ) < 1 ) |
|
2590
|
|
|
continue; |
|
2591
|
|
|
?> |
|
2592
|
|
|
<input type="hidden" name="<?php echo esc_attr( $k ); ?>" value="<?php echo esc_attr( $v ); ?>" /> |
|
2593
|
|
|
<?php |
|
2594
|
|
|
} |
|
2595
|
|
|
|
|
2596
|
|
|
if ( false !== $this->callback( 'header', $reorder ) ) { |
|
2597
|
|
|
return null; |
|
2598
|
|
|
} |
|
2599
|
|
|
|
|
2600
|
|
|
if ( false === $this->data ) |
|
2601
|
|
|
$this->get_data(); |
|
2602
|
|
|
elseif ( $this->sortable ) // we have the data already as an array |
|
2603
|
|
|
$this->sort_data(); |
|
2604
|
|
|
|
|
2605
|
|
|
if ( !in_array( 'export', $this->actions_disabled ) && 'export' == $this->action ) |
|
2606
|
|
|
$this->export(); |
|
2607
|
|
|
|
|
2608
|
|
|
if ( ( !empty( $this->data ) || false !== $this->search || ( $this->filters_enhanced && !empty( $this->views ) ) ) && ( ( $this->filters_enhanced && !empty( $this->views ) ) || false !== $this->searchable ) ) { |
|
2609
|
|
|
if ( $this->filters_enhanced ) |
|
2610
|
|
|
$this->filters(); |
|
2611
|
|
|
else { |
|
2612
|
|
|
?> |
|
2613
|
|
|
<p class="search-box" align="right"> |
|
2614
|
|
|
<?php |
|
2615
|
|
|
$excluded_filters = array( 'search' . $this->num, 'pg' . $this->num ); |
|
2616
|
|
|
|
|
2617
|
|
|
foreach ( $this->filters as $filter ) { |
|
2618
|
|
|
$excluded_filters[] = 'filter_' . $filter . '_start'; |
|
2619
|
|
|
$excluded_filters[] = 'filter_' . $filter . '_end'; |
|
2620
|
|
|
$excluded_filters[] = 'filter_' . $filter; |
|
2621
|
|
|
} |
|
2622
|
|
|
|
|
2623
|
|
|
$this->hidden_vars( $excluded_filters ); |
|
2624
|
|
|
|
|
2625
|
|
|
foreach ( $this->filters as $filter ) { |
|
2626
|
|
View Code Duplication |
if ( isset( $this->pod->fields[ $filter ] ) ) { |
|
2627
|
|
|
$filter_field = $this->pod->fields[ $filter ]; |
|
2628
|
|
|
} |
|
2629
|
|
|
elseif ( isset( $this->fields[ 'manage' ][ $filter ] ) ) { |
|
2630
|
|
|
$filter_field = $this->fields[ 'manage' ][ $filter ]; |
|
2631
|
|
|
} |
|
2632
|
|
|
else { |
|
2633
|
|
|
continue; |
|
2634
|
|
|
} |
|
2635
|
|
|
|
|
2636
|
|
|
if ( in_array( $filter_field[ 'type' ], array( 'date', 'datetime', 'time' ) ) ) { |
|
2637
|
|
|
$start = pods_var_raw( 'filter_' . $filter . '_start', 'get', pods_var_raw( 'filter_default', $filter_field, '', null, true ), null, true ); |
|
2638
|
|
|
$end = pods_var_raw( 'filter_' . $filter . '_end', 'get', pods_var_raw( 'filter_ongoing_default', $filter_field, '', null, true ), null, true ); |
|
2639
|
|
|
|
|
2640
|
|
|
// override default value |
|
2641
|
|
|
$filter_field[ 'options' ][ 'default_value' ] = ''; |
|
2642
|
|
|
$filter_field[ 'options' ][ $filter_field[ 'type' ] . '_allow_empty' ] = 1; |
|
2643
|
|
|
|
|
2644
|
|
|
|
|
2645
|
|
View Code Duplication |
if ( !empty( $start ) && !in_array( $start, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) |
|
2646
|
|
|
$start = PodsForm::field_method( $filter_field[ 'type' ], 'convert_date', $start, 'n/j/Y' ); |
|
2647
|
|
|
|
|
2648
|
|
View Code Duplication |
if ( !empty( $end ) && !in_array( $end, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) |
|
2649
|
|
|
$end = PodsForm::field_method( $filter_field[ 'type' ], 'convert_date', $end, 'n/j/Y' ); |
|
2650
|
|
|
?> |
|
2651
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_start"> |
|
2652
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
2653
|
|
|
</label> |
|
2654
|
|
|
<?php echo PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field[ 'type' ], $filter_field ); ?> |
|
2655
|
|
|
|
|
2656
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_end"> |
|
2657
|
|
|
to |
|
2658
|
|
|
</label> |
|
2659
|
|
|
<?php |
|
2660
|
|
|
echo PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field[ 'type' ], $filter_field ); |
|
2661
|
|
|
} |
|
2662
|
|
|
elseif ( 'pick' == $filter_field[ 'type' ] ) { |
|
2663
|
|
|
$value = pods_var_raw( 'filter_' . $filter, 'get' ); |
|
2664
|
|
|
|
|
2665
|
|
|
if ( strlen( $value ) < 1 ) |
|
2666
|
|
|
$value = pods_var_raw( 'filter_default', $filter_field ); |
|
2667
|
|
|
|
|
2668
|
|
|
// override default value |
|
2669
|
|
|
$filter_field[ 'options' ][ 'default_value' ] = ''; |
|
2670
|
|
|
|
|
2671
|
|
|
$filter_field[ 'options' ][ 'pick_format_type' ] = 'single'; |
|
2672
|
|
|
$filter_field[ 'options' ][ 'pick_format_single' ] = 'dropdown'; |
|
2673
|
|
|
|
|
2674
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields[ 'search' ], array(), null, true ), array(), null, true ), '', null, true ); |
|
2675
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', $filter_field[ 'options' ], $filter_field[ 'options' ][ 'input_helper' ], null, true ); |
|
2676
|
|
|
|
|
2677
|
|
|
$options = array_merge( $filter_field, $filter_field[ 'options' ] ); |
|
2678
|
|
|
?> |
|
2679
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>"> |
|
2680
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
2681
|
|
|
</label> |
|
2682
|
|
|
<?php |
|
2683
|
|
|
echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); |
|
2684
|
|
|
} |
|
2685
|
|
|
elseif ( 'boolean' == $filter_field[ 'type' ] ) { |
|
2686
|
|
|
$value = pods_var_raw( 'filter_' . $filter, 'get', '' ); |
|
2687
|
|
|
|
|
2688
|
|
|
if ( strlen( $value ) < 1 ) |
|
2689
|
|
|
$value = pods_var_raw( 'filter_default', $filter_field ); |
|
2690
|
|
|
|
|
2691
|
|
|
// override default value |
|
2692
|
|
|
$filter_field[ 'options' ][ 'default_value' ] = ''; |
|
2693
|
|
|
|
|
2694
|
|
|
$filter_field[ 'options' ][ 'pick_format_type' ] = 'single'; |
|
2695
|
|
|
$filter_field[ 'options' ][ 'pick_format_single' ] = 'dropdown'; |
|
2696
|
|
|
|
|
2697
|
|
|
$filter_field[ 'options' ][ 'pick_object' ] = 'custom-simple'; |
|
2698
|
|
|
$filter_field[ 'options' ][ 'pick_custom' ] = array( |
|
2699
|
|
|
'1' => pods_var_raw( 'boolean_yes_label', $filter_field[ 'options' ], __( 'Yes', 'pods' ), null, true ), |
|
2700
|
|
|
'0' => pods_var_raw( 'boolean_no_label', $filter_field[ 'options' ], __( 'No', 'pods' ), null, true ) |
|
2701
|
|
|
); |
|
2702
|
|
|
|
|
2703
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields[ 'search' ], array(), null, true ), array(), null, true ), '', null, true ); |
|
2704
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', $filter_field[ 'options' ], $filter_field[ 'options' ][ 'input_helper' ], null, true ); |
|
2705
|
|
|
|
|
2706
|
|
|
$options = array_merge( $filter_field, $filter_field[ 'options' ] ); |
|
2707
|
|
|
?> |
|
2708
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>"> |
|
2709
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
2710
|
|
|
</label> |
|
2711
|
|
|
<?php |
|
2712
|
|
|
echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); |
|
2713
|
|
|
} |
|
2714
|
|
|
else { |
|
2715
|
|
|
$value = pods_var_raw( 'filter_' . $filter, 'get' ); |
|
2716
|
|
|
|
|
2717
|
|
|
if ( strlen( $value ) < 1 ) |
|
2718
|
|
|
$value = pods_var_raw( 'filter_default', $filter_field ); |
|
2719
|
|
|
|
|
2720
|
|
|
// override default value |
|
2721
|
|
|
$filter_field[ 'options' ][ 'default_value' ] = ''; |
|
2722
|
|
|
|
|
2723
|
|
|
$options = array(); |
|
2724
|
|
|
$options[ 'input_helper' ] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields[ 'search' ], array(), null, true ), array(), null, true ), '', null, true ); |
|
2725
|
|
|
$options[ 'input_helper' ] = pods_var_raw( 'ui_input_helper', $options, $options[ 'input_helper' ], null, true ); |
|
2726
|
|
|
?> |
|
2727
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>"> |
|
2728
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
2729
|
|
|
</label> |
|
2730
|
|
|
<?php |
|
2731
|
|
|
echo PodsForm::field( 'filter_' . $filter, $value, 'text', $options ); |
|
2732
|
|
|
} |
|
2733
|
|
|
} |
|
2734
|
|
|
|
|
2735
|
|
|
if ( false !== $this->do_hook( 'filters_show_search', true ) ) { |
|
2736
|
|
|
?> |
|
2737
|
|
|
<label<?php echo ( empty( $this->filters ) ) ? ' class="screen-reader-text"' : ''; ?> for="page-search<?php echo esc_attr( $this->num ); ?>-input"><?php _e( 'Search', 'pods' ); ?>:</label> |
|
2738
|
|
|
<?php echo PodsForm::field( 'search' . $this->num, $this->search, 'text', array( 'attributes' => array( 'id' => 'page-search' . $this->num . '-input' ) ) ); ?> |
|
2739
|
|
|
<?php |
|
2740
|
|
|
} |
|
2741
|
|
|
else { |
|
2742
|
|
|
echo PodsForm::field( 'search' . $this->num, '', 'hidden' ); |
|
2743
|
|
|
} |
|
2744
|
|
|
?> |
|
2745
|
|
|
<?php echo PodsForm::submit_button( $this->header[ 'search' ], 'button', false, false, array('id' => 'search' . $this->num . '-submit') ); ?> |
|
2746
|
|
|
<?php |
|
2747
|
|
|
if ( 0 < strlen( $this->search ) ) { |
|
2748
|
|
|
$clear_filters = array( |
|
2749
|
|
|
'search' . $this->num => false |
|
2750
|
|
|
); |
|
2751
|
|
|
|
|
2752
|
|
View Code Duplication |
foreach ( $this->filters as $filter ) { |
|
2753
|
|
|
$clear_filters[ 'filter_' . $filter . '_start' ] = false; |
|
2754
|
|
|
$clear_filters[ 'filter_' . $filter . '_end' ] = false; |
|
2755
|
|
|
$clear_filters[ 'filter_' . $filter ] = false; |
|
2756
|
|
|
} |
|
2757
|
|
|
?> |
|
2758
|
|
|
<br class="clear" /> |
|
2759
|
|
|
<small>[<a href="<?php echo esc_url( pods_query_arg( $clear_filters, array( 'orderby' . $this->num, 'orderby_dir' . $this->num, 'limit' . $this->num, 'page' ), $this->exclusion() ) ); ?>"><?php _e( 'Reset Filters', 'pods' ); ?></a>]</small> |
|
2760
|
|
|
<br class="clear" /> |
|
2761
|
|
|
<?php |
|
2762
|
|
|
} |
|
2763
|
|
|
?> |
|
2764
|
|
|
</p> |
|
2765
|
|
|
<?php |
|
2766
|
|
|
} |
|
2767
|
|
|
} |
|
2768
|
|
|
else { |
|
2769
|
|
|
?> |
|
2770
|
|
|
<br class="clear" /> |
|
2771
|
|
|
<?php |
|
2772
|
|
|
} |
|
2773
|
|
|
|
|
2774
|
|
|
if ( !empty( $this->data ) && ( false !== $this->pagination_total || false !== $this->pagination || true === $reorder ) || ( !in_array( 'export', $this->actions_disabled ) && !in_array( 'export', $this->actions_hidden ) ) || !empty( $this->actions_disabled ) ) { |
|
2775
|
|
|
?> |
|
2776
|
|
|
<div class="tablenav"> |
|
2777
|
|
|
<?php |
|
2778
|
|
|
if ( !empty( $this->data ) && !empty( $this->actions_bulk ) ) { |
|
2779
|
|
|
?> |
|
2780
|
|
|
<div class="alignleft actions"> |
|
2781
|
|
|
<?php wp_nonce_field( 'pods-ui-action-bulk', '_wpnonce' . $this->num, false ); ?> |
|
2782
|
|
|
|
|
2783
|
|
|
<select name="action_bulk<?php echo esc_attr( $this->num ); ?>"> |
|
2784
|
|
|
<option value="-1" selected="selected"><?php _e( 'Bulk Actions', 'pods' ); ?></option> |
|
2785
|
|
|
|
|
2786
|
|
|
<?php |
|
2787
|
|
|
foreach ( $this->actions_bulk as $action => $action_data ) { |
|
2788
|
|
|
if ( in_array( $action, $this->actions_hidden ) || in_array( $action, $this->actions_hidden ) ) |
|
2789
|
|
|
continue; |
|
2790
|
|
|
|
|
2791
|
|
View Code Duplication |
if ( !isset( $action_data[ 'label' ] ) ) |
|
2792
|
|
|
$action_data[ 'label' ] = ucwords( str_replace( '_', ' ', $action ) ); |
|
2793
|
|
|
?> |
|
2794
|
|
|
<option value="<?php echo esc_attr( $action ); ?>"><?php echo esc_html( $action_data[ 'label' ] ); ?></option> |
|
2795
|
|
|
<?php |
|
2796
|
|
|
} |
|
2797
|
|
|
?> |
|
2798
|
|
|
</select> |
|
2799
|
|
|
|
|
2800
|
|
|
<input type="submit" id="doaction_bulk<?php echo esc_attr( $this->num ); ?>" class="button-secondary action" value="<?php esc_attr_e( 'Apply', 'pods' ); ?>"> |
|
2801
|
|
|
</div> |
|
2802
|
|
|
<?php |
|
2803
|
|
|
} |
|
2804
|
|
|
|
|
2805
|
|
View Code Duplication |
if ( true !== $reorder && ( false !== $this->pagination_total || false !== $this->pagination ) ) { |
|
2806
|
|
|
?> |
|
2807
|
|
|
<div class="tablenav-pages<?php echo esc_attr( ( $this->limit < $this->total_found || 1 < $this->page ) ? '' : ' one-page' ); ?>"> |
|
2808
|
|
|
<?php $this->pagination( 1 ); ?> |
|
2809
|
|
|
</div> |
|
2810
|
|
|
<?php |
|
2811
|
|
|
} |
|
2812
|
|
|
|
|
2813
|
|
|
if ( true === $reorder ) { |
|
2814
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'manage', 'id' . $this->num => '' ), self::$allowed, $this->exclusion() ); |
|
2815
|
|
|
|
|
2816
|
|
|
if ( !empty( $this->action_links[ 'manage' ] ) ) { |
|
2817
|
|
|
$link = $this->action_links[ 'manage' ]; |
|
2818
|
|
|
} |
|
2819
|
|
|
?> |
|
2820
|
|
|
<input type="button" value="<?php esc_attr_e( 'Update Order', 'pods' ); ?>" class="button" onclick="jQuery('form.admin_ui_reorder_form').submit();" /> |
|
2821
|
|
|
<input type="button" value="<?php esc_attr_e( 'Cancel', 'pods' ); ?>" class="button" onclick="document.location='<?php echo esc_js( $link ); ?>';" /> |
|
2822
|
|
|
</form> |
|
2823
|
|
|
<?php |
|
2824
|
|
|
} |
|
2825
|
|
|
elseif ( !in_array( 'export', $this->actions_disabled ) && !in_array( 'export', $this->actions_hidden ) ) { |
|
2826
|
|
|
?> |
|
2827
|
|
|
<div class="alignleft actions"> |
|
2828
|
|
|
<input type="button" value="<?php echo esc_attr( sprintf( __( 'Export all %s', 'pods' ), $this->items ) ); ?>" class="button" onclick="document.location='<?php echo pods_slash( pods_query_arg( array( 'action_bulk' . $this->num => 'export', '_wpnonce' => wp_create_nonce( 'pods-ui-action-bulk' ) ), self::$allowed, $this->exclusion() ) ); ?>';" /> |
|
2829
|
|
|
</div> |
|
2830
|
|
|
<?php |
|
2831
|
|
|
} |
|
2832
|
|
|
?> |
|
2833
|
|
|
<br class="clear" /> |
|
2834
|
|
|
</div> |
|
2835
|
|
|
<?php |
|
2836
|
|
|
} |
|
2837
|
|
|
else { |
|
2838
|
|
|
?> |
|
2839
|
|
|
<br class="clear" /> |
|
2840
|
|
|
<?php |
|
2841
|
|
|
} |
|
2842
|
|
|
?> |
|
2843
|
|
|
<div class="clear"></div> |
|
2844
|
|
|
<?php |
|
2845
|
|
|
if ( empty( $this->data ) && false !== $this->default_none && false === $this->search ) { |
|
2846
|
|
|
?> |
|
2847
|
|
|
<p><?php _e( 'Please use the search filter(s) above to display data', 'pods' ); ?><?php if ( $this->export ) { ?>, <?php _e( 'or click on an Export to download a full copy of the data', 'pods' ); ?><?php } ?>.</p> |
|
|
|
|
|
|
2848
|
|
|
<?php |
|
2849
|
|
|
} |
|
2850
|
|
|
else |
|
2851
|
|
|
$this->table( $reorder ); |
|
2852
|
|
View Code Duplication |
if ( !empty( $this->data ) ) { |
|
2853
|
|
|
if ( true !== $reorder && ( false !== $this->pagination_total || false !== $this->pagination ) ) { |
|
2854
|
|
|
?> |
|
2855
|
|
|
<div class="tablenav"> |
|
2856
|
|
|
<div class="tablenav-pages<?php echo esc_attr( ( $this->limit < $this->total_found || 1 < $this->page ) ? '' : ' one-page' ); ?>"> |
|
2857
|
|
|
<?php $this->pagination( 0 ); ?> |
|
2858
|
|
|
<br class="clear" /> |
|
2859
|
|
|
</div> |
|
2860
|
|
|
</div> |
|
2861
|
|
|
<?php |
|
2862
|
|
|
} |
|
2863
|
|
|
} |
|
2864
|
|
|
|
|
2865
|
|
|
?> |
|
2866
|
|
|
</form> |
|
2867
|
|
|
</div> |
|
2868
|
|
|
<?php |
|
2869
|
|
|
if ( $this->filters_enhanced ) |
|
2870
|
|
|
$this->filters_popup(); |
|
2871
|
|
|
} |
|
2872
|
|
|
|
|
2873
|
|
|
public function filters () { |
|
2874
|
|
|
include_once ABSPATH . 'wp-admin/includes/template.php'; |
|
2875
|
|
|
|
|
2876
|
|
|
wp_enqueue_script( 'thickbox' ); |
|
2877
|
|
|
wp_enqueue_style( 'pods-ui-list-table', PODS_URL . 'ui/css/pods-ui-list-table.css', array( 'thickbox' ), PODS_VERSION ); |
|
2878
|
|
|
|
|
2879
|
|
|
$filters = $this->filters; |
|
2880
|
|
|
|
|
2881
|
|
|
foreach ( $filters as $k => $filter ) { |
|
2882
|
|
View Code Duplication |
if ( isset( $this->pod->fields[ $filter ] ) ) { |
|
2883
|
|
|
$filter_field = $this->pod->fields[ $filter ]; |
|
2884
|
|
|
} |
|
2885
|
|
|
elseif ( isset( $this->fields[ 'manage' ][ $filter ] ) ) { |
|
2886
|
|
|
$filter_field = $this->fields[ 'manage' ][ $filter ]; |
|
2887
|
|
|
} |
|
2888
|
|
|
else { |
|
2889
|
|
|
continue; |
|
2890
|
|
|
} |
|
2891
|
|
|
|
|
2892
|
|
View Code Duplication |
if ( isset( $filter_field ) && in_array( $filter_field[ 'type' ], array( 'date', 'datetime', 'time' ) ) ) { |
|
2893
|
|
|
if ( '' == pods_var_raw( 'filter_' . $filter . '_start', 'get', '', null, true ) && '' == pods_var_raw( 'filter_' . $filter . '_end', 'get', '', null, true ) ) |
|
2894
|
|
|
unset( $filters[ $k ] ); |
|
2895
|
|
|
} |
|
2896
|
|
|
elseif ( '' === pods_var_raw( 'filter_' . $filter, 'get', '' ) ) |
|
2897
|
|
|
unset( $filters[ $k ] ); |
|
2898
|
|
|
} |
|
2899
|
|
|
|
|
2900
|
|
|
$filtered = false; |
|
2901
|
|
|
|
|
2902
|
|
|
if ( !empty( $filters ) ) |
|
2903
|
|
|
$filtered = true; |
|
2904
|
|
|
?> |
|
2905
|
|
|
<div class="pods-ui-filter-bar"> |
|
2906
|
|
|
<div class="pods-ui-filter-bar-primary"> |
|
2907
|
|
|
<?php |
|
2908
|
|
|
if ( !empty( $this->views ) ) { |
|
2909
|
|
|
?> |
|
2910
|
|
|
<ul class="subsubsub"> |
|
2911
|
|
|
<li class="pods-ui-filter-view-label"><strong><?php echo wp_kses_post( $this->heading[ 'views' ] ); ?></strong></li> |
|
2912
|
|
|
|
|
2913
|
|
|
<?php |
|
2914
|
|
|
foreach ( $this->views as $view => $label ) { |
|
2915
|
|
|
if ( false === strpos( $label, '<a' ) ) { |
|
2916
|
|
|
$link = pods_query_arg( array( 'view' . $this->num => $view, 'pg' . $this->num => '' ), self::$allowed, $this->exclusion() ); |
|
2917
|
|
|
|
|
2918
|
|
|
if ( $this->view == $view ) |
|
2919
|
|
|
$label = '<a href="' . esc_url( $link ) . '" class="current">' . esc_html( $label ) . '</a>'; |
|
2920
|
|
|
else |
|
2921
|
|
|
$label = '<a href="' . esc_url( $link ) . '">' . esc_html( $label ) . '</a>'; |
|
2922
|
|
|
} |
|
2923
|
|
|
?> |
|
2924
|
|
|
<li class="<?php echo esc_attr( $view ); ?>"><?php echo esc_html( $label ); ?></li> |
|
2925
|
|
|
<?php |
|
2926
|
|
|
} |
|
2927
|
|
|
?> |
|
2928
|
|
|
</ul> |
|
2929
|
|
|
<?php |
|
2930
|
|
|
} |
|
2931
|
|
|
?> |
|
2932
|
|
|
|
|
2933
|
|
|
<?php |
|
2934
|
|
|
if ( false !== $this->search && false !== $this->searchable ) { |
|
2935
|
|
|
?> |
|
2936
|
|
|
<p class="search-box"> |
|
2937
|
|
|
<?php |
|
2938
|
|
|
if ( $filtered || '' != pods_var_raw( 'search' . $this->num, 'get', '', null, true ) ) { |
|
2939
|
|
|
$clear_filters = array( |
|
2940
|
|
|
'search' . $this->num => false |
|
2941
|
|
|
); |
|
2942
|
|
|
|
|
2943
|
|
View Code Duplication |
foreach ( $this->filters as $filter ) { |
|
2944
|
|
|
$clear_filters[ 'filter_' . $filter . '_start' ] = false; |
|
2945
|
|
|
$clear_filters[ 'filter_' . $filter . '_end' ] = false; |
|
2946
|
|
|
$clear_filters[ 'filter_' . $filter ] = false; |
|
2947
|
|
|
} |
|
2948
|
|
|
?> |
|
2949
|
|
|
<a href="<?php echo esc_url( pods_query_arg( $clear_filters, array( 'orderby' . $this->num, 'orderby_dir' . $this->num, 'limit' . $this->num, 'page' ), $this->exclusion() ) ); ?>" class="pods-ui-filter-reset">[<?php _e( 'Reset', 'pods' ); ?>]</a> |
|
2950
|
|
|
<?php |
|
2951
|
|
|
} |
|
2952
|
|
|
|
|
2953
|
|
|
if ( false !== $this->do_hook( 'filters_show_search', true ) ) { |
|
2954
|
|
|
?> |
|
2955
|
|
|
<label class="screen-reader-text" for="page-search<?php echo esc_attr( $this->num ); ?>-input"><?php _e( 'Search', 'pods' ); ?>:</label> |
|
2956
|
|
|
<?php echo PodsForm::field( 'search' . $this->num, $this->search, 'text', array( 'attributes' => array( 'id' => 'page-search' . $this->num . '-input' ) ) ); ?> |
|
2957
|
|
|
<?php |
|
2958
|
|
|
} |
|
2959
|
|
|
else { |
|
2960
|
|
|
echo PodsForm::field( 'search' . $this->num, '', 'hidden' ); |
|
2961
|
|
|
} |
|
2962
|
|
|
?> |
|
2963
|
|
|
|
|
2964
|
|
|
<?php echo PodsForm::submit_button( $this->header[ 'search' ], 'button', false, false, array('id' => 'search' . $this->num . '-submit') ); ?> |
|
2965
|
|
|
</p> |
|
2966
|
|
|
<?php |
|
2967
|
|
|
} |
|
2968
|
|
|
?> |
|
2969
|
|
|
</div> |
|
2970
|
|
|
|
|
2971
|
|
|
<?php |
|
2972
|
|
|
if ( !empty( $this->filters ) ) { |
|
2973
|
|
|
?> |
|
2974
|
|
|
<div class="pods-ui-filter-bar-secondary"> |
|
2975
|
|
|
<ul class="subsubsub"> |
|
2976
|
|
|
<?php |
|
2977
|
|
|
if ( !$filtered ) { |
|
2978
|
|
|
?> |
|
2979
|
|
|
<li class="pods-ui-filter-bar-add-filter"> |
|
2980
|
|
|
<a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e( 'Advanced Filters', 'pods' ); ?>"> |
|
2981
|
|
|
<?php _e( 'Advanced Filters', 'pods' ); ?> |
|
2982
|
|
|
</a> |
|
2983
|
|
|
</li> |
|
2984
|
|
|
<?php |
|
2985
|
|
|
} |
|
2986
|
|
|
else { |
|
2987
|
|
|
?> |
|
2988
|
|
|
<li class="pods-ui-filter-bar-add-filter"> |
|
2989
|
|
|
<a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e( 'Advanced Filters', 'pods' ); ?>"> |
|
2990
|
|
|
+ <?php _e( 'Add Filter', 'pods' ); ?> |
|
2991
|
|
|
</a> |
|
2992
|
|
|
</li> |
|
2993
|
|
|
<?php |
|
2994
|
|
|
} |
|
2995
|
|
|
|
|
2996
|
|
|
foreach ( $filters as $filter ) { |
|
2997
|
|
|
$value = pods_var_raw( 'filter_' . $filter, 'get' ); |
|
2998
|
|
|
|
|
2999
|
|
View Code Duplication |
if ( isset( $this->pod->fields[ $filter ] ) ) { |
|
3000
|
|
|
$filter_field = $this->pod->fields[ $filter ]; |
|
3001
|
|
|
} |
|
3002
|
|
|
elseif ( isset( $this->fields[ 'manage' ][ $filter ] ) ) { |
|
3003
|
|
|
$filter_field = $this->fields[ 'manage' ][ $filter ]; |
|
3004
|
|
|
} |
|
3005
|
|
|
else { |
|
3006
|
|
|
continue; |
|
3007
|
|
|
} |
|
3008
|
|
|
|
|
3009
|
|
|
$data_filter = 'filter_' . $filter; |
|
3010
|
|
|
|
|
3011
|
|
|
$start = $end = $value_label = ''; |
|
3012
|
|
|
|
|
3013
|
|
|
if ( in_array( $filter_field[ 'type' ], array( 'date', 'datetime', 'time' ) ) ) { |
|
3014
|
|
|
$start = pods_var_raw( 'filter_' . $filter . '_start', 'get', '', null, true ); |
|
3015
|
|
|
$end = pods_var_raw( 'filter_' . $filter . '_end', 'get', '', null, true ); |
|
3016
|
|
|
|
|
3017
|
|
View Code Duplication |
if ( !empty( $start ) && !in_array( $start, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) |
|
3018
|
|
|
$start = PodsForm::field_method( $filter_field[ 'type' ], 'convert_date', $start, 'n/j/Y' ); |
|
3019
|
|
|
|
|
3020
|
|
View Code Duplication |
if ( !empty( $end ) && !in_array( $end, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) |
|
3021
|
|
|
$end = PodsForm::field_method( $filter_field[ 'type' ], 'convert_date', $end, 'n/j/Y' ); |
|
3022
|
|
|
|
|
3023
|
|
|
$value = trim( $start . ' - ' . $end, ' -' ); |
|
3024
|
|
|
|
|
3025
|
|
|
$data_filter = 'filter_' . $filter . '_start'; |
|
3026
|
|
|
} |
|
3027
|
|
|
elseif ( 'pick' == $filter_field[ 'type' ] ) |
|
3028
|
|
|
$value_label = trim( PodsForm::field_method( 'pick', 'value_to_label', $filter, $value, $filter_field, $this->pod->pod_data, null ) ); |
|
3029
|
|
|
elseif ( 'boolean' == $filter_field[ 'type' ] ) { |
|
3030
|
|
|
$yesno_options = array( |
|
3031
|
|
|
'1' => pods_var_raw( 'boolean_yes_label', $filter_field[ 'options' ], __( 'Yes', 'pods' ), null, true ), |
|
3032
|
|
|
'0' => pods_var_raw( 'boolean_no_label', $filter_field[ 'options' ], __( 'No', 'pods' ), null, true ) |
|
3033
|
|
|
); |
|
3034
|
|
|
|
|
3035
|
|
|
if ( isset( $yesno_options[ (string) $value ] ) ) |
|
3036
|
|
|
$value_label = $yesno_options[ (string) $value ]; |
|
3037
|
|
|
} |
|
3038
|
|
|
|
|
3039
|
|
|
if ( strlen( $value_label ) < 1 ) |
|
3040
|
|
|
$value_label = $value; |
|
3041
|
|
|
?> |
|
3042
|
|
|
<li class="pods-ui-filter-bar-filter" data-filter="<?php echo esc_attr( $data_filter ); ?>"> |
|
3043
|
|
|
<a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e( 'Advanced Filters', 'pods' ); ?>"> |
|
3044
|
|
|
<strong><?php echo esc_html( $filter_field[ 'label' ] ); ?>:</strong> |
|
3045
|
|
|
<?php echo esc_html( $value_label ); ?> |
|
3046
|
|
|
</a> |
|
3047
|
|
|
|
|
3048
|
|
|
<a href="#remove-filter" class="remove-filter" title="<?php esc_attr_e( 'Remove Filter', 'pods' ); ?>">x</a> |
|
3049
|
|
|
|
|
3050
|
|
|
<?php |
|
3051
|
|
|
if ( in_array( $filter_field[ 'type' ], array( 'date', 'datetime', 'time' ) ) ) { |
|
3052
|
|
|
echo PodsForm::field( 'filter_' . $filter . '_start', $start, 'hidden' ); |
|
3053
|
|
|
echo PodsForm::field( 'filter_' . $filter . '_end', $end, 'hidden' ); |
|
3054
|
|
|
} |
|
3055
|
|
|
else |
|
3056
|
|
|
echo PodsForm::field( $data_filter, $value, 'hidden' ); |
|
3057
|
|
|
?> |
|
3058
|
|
|
</li> |
|
3059
|
|
|
<?php |
|
3060
|
|
|
} |
|
3061
|
|
|
?> |
|
3062
|
|
|
</ul> |
|
3063
|
|
|
</div> |
|
3064
|
|
|
<?php |
|
3065
|
|
|
} |
|
3066
|
|
|
?> |
|
3067
|
|
|
</div> |
|
3068
|
|
|
|
|
3069
|
|
|
<script type="text/javascript"> |
|
3070
|
|
|
jQuery( function() { |
|
3071
|
|
|
jQuery( '.pods-ui-filter-bar-secondary' ).on( 'click', '.remove-filter', function ( e ) { |
|
3072
|
|
|
jQuery( '.pods-ui-filter-popup #' + jQuery( this ).parent().data( 'filter' ) ).remove(); |
|
3073
|
|
|
|
|
3074
|
|
|
jQuery( this ).parent().find( 'input' ).each( function () { |
|
3075
|
|
|
jQuery( this ).remove(); |
|
3076
|
|
|
} ); |
|
3077
|
|
|
|
|
3078
|
|
|
jQuery( 'form#posts-filter [name="pg<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true ); |
|
3079
|
|
|
jQuery( 'form#posts-filter [name="action<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true ); |
|
3080
|
|
|
jQuery( 'form#posts-filter [name="action_bulk<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true ); |
|
3081
|
|
|
jQuery( 'form#posts-filter [name="_wpnonce<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true ); |
|
3082
|
|
|
|
|
3083
|
|
|
jQuery( 'form#posts-filter' ).submit(); |
|
3084
|
|
|
|
|
3085
|
|
|
e.preventDefault(); |
|
3086
|
|
|
} ); |
|
3087
|
|
|
} ); |
|
3088
|
|
|
</script> |
|
3089
|
|
|
<?php |
|
3090
|
|
|
} |
|
3091
|
|
|
|
|
3092
|
|
|
public function filters_popup () { |
|
3093
|
|
|
$filters = $this->filters; |
|
3094
|
|
|
?> |
|
3095
|
|
|
<div id="pods-ui-posts-filter-popup" class="hidden"> |
|
3096
|
|
|
<form action="" method="get" class="pods-ui-posts-filter-popup"> |
|
3097
|
|
|
<h2><?php _e( 'Advanced Filters', 'pods' ); ?></h2> |
|
3098
|
|
|
|
|
3099
|
|
|
<div class="pods-ui-posts-filters"> |
|
3100
|
|
|
<?php |
|
3101
|
|
|
$excluded_filters = array( |
|
3102
|
|
|
'search' . $this->num, |
|
3103
|
|
|
'pg' . $this->num, |
|
3104
|
|
|
'action' . $this->num, |
|
3105
|
|
|
'action_bulk' . $this->num, |
|
3106
|
|
|
'action_bulk_ids' . $this->num, |
|
3107
|
|
|
'_wpnonce' . $this->num |
|
3108
|
|
|
); |
|
3109
|
|
|
|
|
3110
|
|
|
foreach ( $filters as $filter ) { |
|
3111
|
|
|
$excluded_filters[] = 'filters_relation'; |
|
3112
|
|
|
$excluded_filters[] = 'filters_compare_' . $filter; |
|
3113
|
|
|
$excluded_filters[] = 'filter_' . $filter . '_start'; |
|
3114
|
|
|
$excluded_filters[] = 'filter_' . $filter . '_end'; |
|
3115
|
|
|
$excluded_filters[] = 'filter_' . $filter; |
|
3116
|
|
|
} |
|
3117
|
|
|
|
|
3118
|
|
|
$get = $_GET; |
|
3119
|
|
|
|
|
3120
|
|
View Code Duplication |
foreach ( $get as $k => $v ) { |
|
3121
|
|
|
if ( in_array( $k, $excluded_filters ) || strlen( $v ) < 1 ) |
|
3122
|
|
|
continue; |
|
3123
|
|
|
?> |
|
3124
|
|
|
<input type="hidden" name="<?php echo esc_attr( $k ); ?>" value="<?php echo esc_attr( $v ); ?>" /> |
|
3125
|
|
|
<?php |
|
3126
|
|
|
} |
|
3127
|
|
|
|
|
3128
|
|
|
$zebra = true; |
|
3129
|
|
|
|
|
3130
|
|
|
foreach ( $filters as $filter ) { |
|
3131
|
|
|
if ( empty( $filter ) ) |
|
3132
|
|
|
continue; |
|
3133
|
|
|
|
|
3134
|
|
View Code Duplication |
if ( isset( $this->pod->fields[ $filter ] ) ) { |
|
3135
|
|
|
$filter_field = $this->pod->fields[ $filter ]; |
|
3136
|
|
|
} |
|
3137
|
|
|
elseif ( isset( $this->fields[ 'manage' ][ $filter ] ) ) { |
|
3138
|
|
|
$filter_field = $this->fields[ 'manage' ][ $filter ]; |
|
3139
|
|
|
} |
|
3140
|
|
|
else { |
|
3141
|
|
|
continue; |
|
3142
|
|
|
} |
|
3143
|
|
|
?> |
|
3144
|
|
|
<p class="pods-ui-posts-filter-toggled pods-ui-posts-filter-<?php echo esc_attr( $filter . ( $zebra ? ' clear' : '' ) ); ?>"> |
|
3145
|
|
|
<?php |
|
3146
|
|
|
if ( in_array( $filter_field[ 'type' ], array( 'date', 'datetime', 'time' ) ) ) { |
|
3147
|
|
|
$start = pods_var_raw( 'filter_' . $filter . '_start', 'get', pods_var_raw( 'filter_default', $filter_field, '', null, true ), null, true ); |
|
3148
|
|
|
$end = pods_var_raw( 'filter_' . $filter . '_end', 'get', pods_var_raw( 'filter_ongoing_default', $filter_field, '', null, true ), null, true ); |
|
3149
|
|
|
|
|
3150
|
|
|
// override default value |
|
3151
|
|
|
$filter_field[ 'options' ][ 'default_value' ] = ''; |
|
3152
|
|
|
$filter_field[ 'options' ][ $filter_field[ 'type' ] . '_allow_empty' ] = 1; |
|
3153
|
|
|
|
|
3154
|
|
View Code Duplication |
if ( !empty( $start ) && !in_array( $start, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) |
|
3155
|
|
|
$start = PodsForm::field_method( $filter_field[ 'type' ], 'convert_date', $start, 'n/j/Y' ); |
|
3156
|
|
|
|
|
3157
|
|
View Code Duplication |
if ( !empty( $end ) && !in_array( $end, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) |
|
3158
|
|
|
$end = PodsForm::field_method( $filter_field[ 'type' ], 'convert_date', $end, 'n/j/Y' ); |
|
3159
|
|
|
?> |
|
3160
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( ( empty( $start ) && empty( $end ) ) ? '' : ' hidden' ); ?>">+</span> |
|
3161
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( ( empty( $start ) && empty( $end ) ) ? ' hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span> |
|
3162
|
|
|
|
|
3163
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_start"> |
|
3164
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
3165
|
|
|
</label> |
|
3166
|
|
|
|
|
3167
|
|
|
<span class="pods-ui-posts-filter<?php echo esc_attr( ( empty( $start ) && empty( $end ) ) ? ' hidden' : '' ); ?>"> |
|
3168
|
|
|
<?php echo PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field[ 'type' ], $filter_field ); ?> |
|
3169
|
|
|
|
|
3170
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_end">to</label> |
|
3171
|
|
|
<?php echo PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field[ 'type' ], $filter_field ); ?> |
|
3172
|
|
|
</span> |
|
3173
|
|
|
<?php |
|
3174
|
|
|
} |
|
3175
|
|
|
elseif ( 'pick' == $filter_field[ 'type' ] ) { |
|
3176
|
|
|
$value = pods_var_raw( 'filter_' . $filter, 'get', '' ); |
|
3177
|
|
|
|
|
3178
|
|
|
if ( strlen( $value ) < 1 ) |
|
3179
|
|
|
$value = pods_var_raw( 'filter_default', $filter_field ); |
|
3180
|
|
|
|
|
3181
|
|
|
// override default value |
|
3182
|
|
|
$filter_field[ 'options' ][ 'default_value' ] = ''; |
|
3183
|
|
|
|
|
3184
|
|
|
$filter_field[ 'options' ][ 'pick_format_type' ] = 'single'; |
|
3185
|
|
|
$filter_field[ 'options' ][ 'pick_format_single' ] = 'dropdown'; |
|
3186
|
|
|
|
|
3187
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields[ 'search' ], array(), null, true ), array(), null, true ), '', null, true ); |
|
3188
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', $filter_field[ 'options' ], $filter_field[ 'options' ][ 'input_helper' ], null, true ); |
|
3189
|
|
|
|
|
3190
|
|
|
$options = array_merge( $filter_field, $filter_field[ 'options' ] ); |
|
3191
|
|
|
?> |
|
3192
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( empty( $value ) ? '' : ' hidden' ); ?>">+</span> |
|
3193
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( empty( $value ) ? ' hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span> |
|
3194
|
|
|
|
|
3195
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>"> |
|
3196
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
3197
|
|
|
</label> |
|
3198
|
|
|
|
|
3199
|
|
|
<span class="pods-ui-posts-filter<?php echo esc_attr( strlen( $value ) < 1 ? ' hidden' : '' ); ?>"> |
|
3200
|
|
|
<?php echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); ?> |
|
3201
|
|
|
</span> |
|
3202
|
|
|
<?php |
|
3203
|
|
|
} |
|
3204
|
|
|
elseif ( 'boolean' == $filter_field[ 'type' ] ) { |
|
3205
|
|
|
$value = pods_var_raw( 'filter_' . $filter, 'get', '' ); |
|
3206
|
|
|
|
|
3207
|
|
|
if ( strlen( $value ) < 1 ) |
|
3208
|
|
|
$value = pods_var_raw( 'filter_default', $filter_field ); |
|
3209
|
|
|
|
|
3210
|
|
|
// override default value |
|
3211
|
|
|
$filter_field[ 'options' ][ 'default_value' ] = ''; |
|
3212
|
|
|
|
|
3213
|
|
|
$filter_field[ 'options' ][ 'pick_format_type' ] = 'single'; |
|
3214
|
|
|
$filter_field[ 'options' ][ 'pick_format_single' ] = 'dropdown'; |
|
3215
|
|
|
|
|
3216
|
|
|
$filter_field[ 'options' ][ 'pick_object' ] = 'custom-simple'; |
|
3217
|
|
|
$filter_field[ 'options' ][ 'pick_custom' ] = array( |
|
3218
|
|
|
'1' => pods_var_raw( 'boolean_yes_label', $filter_field[ 'options' ], __( 'Yes', 'pods' ), null, true ), |
|
3219
|
|
|
'0' => pods_var_raw( 'boolean_no_label', $filter_field[ 'options' ], __( 'No', 'pods' ), null, true ) |
|
3220
|
|
|
); |
|
3221
|
|
|
|
|
3222
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields[ 'search' ], array(), null, true ), array(), null, true ), '', null, true ); |
|
3223
|
|
|
$filter_field[ 'options' ][ 'input_helper' ] = pods_var_raw( 'ui_input_helper', $filter_field[ 'options' ], $filter_field[ 'options' ][ 'input_helper' ], null, true ); |
|
3224
|
|
|
|
|
3225
|
|
|
$options = array_merge( $filter_field, $filter_field[ 'options' ] ); |
|
3226
|
|
|
?> |
|
3227
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( empty( $value ) ? '' : ' hidden' ); ?>">+</span> |
|
3228
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( empty( $value ) ? ' hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span> |
|
3229
|
|
|
|
|
3230
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>"> |
|
3231
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
3232
|
|
|
</label> |
|
3233
|
|
|
|
|
3234
|
|
|
<span class="pods-ui-posts-filter<?php echo esc_attr( strlen( $value ) < 1 ? ' hidden' : '' ); ?>"> |
|
3235
|
|
|
<?php echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); ?> |
|
3236
|
|
|
</span> |
|
3237
|
|
|
<?php |
|
3238
|
|
|
} |
|
3239
|
|
|
else { |
|
3240
|
|
|
$value = pods_var_raw( 'filter_' . $filter, 'get' ); |
|
3241
|
|
|
|
|
3242
|
|
|
if ( strlen( $value ) < 1 ) |
|
3243
|
|
|
$value = pods_var_raw( 'filter_default', $filter_field ); |
|
3244
|
|
|
|
|
3245
|
|
|
$options = array( |
|
3246
|
|
|
'input_helper' => pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields[ 'search' ], array(), null, true ), array(), null, true ), '', null, true ) |
|
3247
|
|
|
); |
|
3248
|
|
|
|
|
3249
|
|
|
if ( empty( $options[ 'input_helper' ] ) && isset( $filter_field[ 'options' ] ) && isset( $filter_field[ 'options' ][ 'input_helper' ] ) ) |
|
3250
|
|
|
$options[ 'input_helper' ] = $filter_field[ 'options' ][ 'input_helper' ]; |
|
3251
|
|
|
?> |
|
3252
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( empty( $value ) ? '' : ' hidden' ); ?>">+</span> |
|
3253
|
|
|
<span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( empty( $value ) ? ' hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span> |
|
3254
|
|
|
|
|
3255
|
|
|
<label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>"> |
|
3256
|
|
|
<?php echo esc_html( $filter_field[ 'label' ] ); ?> |
|
3257
|
|
|
</label> |
|
3258
|
|
|
|
|
3259
|
|
|
<span class="pods-ui-posts-filter<?php echo esc_attr( empty( $value ) ? ' hidden' : '' ); ?>"> |
|
3260
|
|
|
<?php echo PodsForm::field( 'filter_' . $filter, $value, 'text', $options ); ?> |
|
3261
|
|
|
</span> |
|
3262
|
|
|
<?php |
|
3263
|
|
|
} |
|
3264
|
|
|
?> |
|
3265
|
|
|
</p> |
|
3266
|
|
|
<?php |
|
3267
|
|
|
$zebra = empty( $zebra ); |
|
3268
|
|
|
} |
|
3269
|
|
|
?> |
|
3270
|
|
|
|
|
3271
|
|
|
<p class="pods-ui-posts-filter-toggled pods-ui-posts-filter-search<?php echo esc_attr( $zebra ? ' clear' : '' ); ?>"> |
|
3272
|
|
|
<label for="pods-form-ui-search<?php echo esc_attr( $this->num ); ?>"><?php _e( 'Search Text', 'pods' ); ?></label> |
|
3273
|
|
|
<?php echo PodsForm::field( 'search' . $this->num, pods_var_raw( 'search' . $this->num, 'get' ), 'text' ); ?> |
|
3274
|
|
|
</p> |
|
3275
|
|
|
|
|
3276
|
|
|
<?php $zebra = empty( $zebra ); ?> |
|
3277
|
|
|
</div> |
|
3278
|
|
|
|
|
3279
|
|
|
<p class="submit<?php echo esc_attr( $zebra ? ' clear' : '' ); ?>"><input type="submit" value="<?php echo esc_attr( $this->header[ 'search' ] ); ?>" class="button button-primary" /></p> |
|
3280
|
|
|
</form> |
|
3281
|
|
|
</div> |
|
3282
|
|
|
|
|
3283
|
|
|
<script type="text/javascript"> |
|
3284
|
|
|
jQuery( function () { |
|
3285
|
|
|
jQuery( document ).on( 'click', '.pods-ui-posts-filter-toggle.toggle-on', function ( e ) { |
|
3286
|
|
|
jQuery( this ).parent().find( '.pods-ui-posts-filter' ).removeClass( 'hidden' ); |
|
3287
|
|
|
|
|
3288
|
|
|
jQuery( this ).hide(); |
|
3289
|
|
|
jQuery( this ).parent().find( '.toggle-off' ).show(); |
|
3290
|
|
|
} ); |
|
3291
|
|
|
|
|
3292
|
|
|
jQuery( document ).on( 'click', '.pods-ui-posts-filter-toggle.toggle-off', function ( e ) { |
|
3293
|
|
|
jQuery( this ).parent().find( '.pods-ui-posts-filter' ).addClass( 'hidden' ); |
|
3294
|
|
|
jQuery( this ).parent().find( 'select, input' ).val( '' ); |
|
3295
|
|
|
|
|
3296
|
|
|
jQuery( this ).hide(); |
|
3297
|
|
|
jQuery( this ).parent().find( '.toggle-on' ).show(); |
|
3298
|
|
|
} ); |
|
3299
|
|
|
|
|
3300
|
|
|
jQuery( document ).on( 'click', '.pods-ui-posts-filter-toggled label', function ( e ) { |
|
3301
|
|
|
if ( jQuery( this ).parent().find( '.pods-ui-posts-filter' ).hasClass( 'hidden' ) ) { |
|
3302
|
|
|
jQuery( this ).parent().find( '.pods-ui-posts-filter' ).removeClass( 'hidden' ); |
|
3303
|
|
|
|
|
3304
|
|
|
jQuery( this ).parent().find( '.toggle-on' ).hide(); |
|
3305
|
|
|
jQuery( this ).parent().find( '.toggle-off' ).show(); |
|
3306
|
|
|
} |
|
3307
|
|
|
else { |
|
3308
|
|
|
jQuery( this ).parent().find( '.pods-ui-posts-filter' ).addClass( 'hidden' ); |
|
3309
|
|
|
jQuery( this ).parent().find( 'select, input' ).val( '' ); |
|
3310
|
|
|
|
|
3311
|
|
|
jQuery( this ).parent().find( '.toggle-on' ).show(); |
|
3312
|
|
|
jQuery( this ).parent().find( '.toggle-off' ).hide(); |
|
3313
|
|
|
} |
|
3314
|
|
|
} ); |
|
3315
|
|
|
} ); |
|
3316
|
|
|
</script> |
|
3317
|
|
|
<?php |
|
3318
|
|
|
} |
|
3319
|
|
|
|
|
3320
|
|
|
/** |
|
3321
|
|
|
* @param bool $reorder |
|
3322
|
|
|
* |
|
3323
|
|
|
* @return bool|mixed |
|
3324
|
|
|
*/ |
|
3325
|
|
|
public function table ( $reorder = false ) { |
|
3326
|
|
|
if ( false !== $this->callback( 'table', $reorder ) ) { |
|
3327
|
|
|
return null; |
|
3328
|
|
|
} |
|
3329
|
|
|
|
|
3330
|
|
|
if ( empty( $this->data ) ) { |
|
3331
|
|
|
?> |
|
3332
|
|
|
<p><?php echo pods_v( 'label_no_items_found', $this->label, sprintf( __( 'No %s found', 'pods' ), $this->items ) ); ?></p> |
|
3333
|
|
|
<?php |
|
3334
|
|
|
return false; |
|
3335
|
|
|
} |
|
3336
|
|
|
if ( true === $reorder && !in_array( 'reorder', $this->actions_disabled ) && false !== $this->reorder[ 'on' ] ) { |
|
3337
|
|
|
?> |
|
3338
|
|
|
<style type="text/css"> |
|
3339
|
|
|
table.widefat.fixed tbody.reorderable tr { |
|
3340
|
|
|
height: 50px; |
|
3341
|
|
|
} |
|
3342
|
|
|
|
|
3343
|
|
|
.dragme { |
|
3344
|
|
|
background: url(<?php echo esc_url( PODS_URL ); ?>/ui/images/handle.gif) no-repeat; |
|
3345
|
|
|
background-position: 8px 8px; |
|
3346
|
|
|
cursor: pointer; |
|
3347
|
|
|
} |
|
3348
|
|
|
|
|
3349
|
|
|
.dragme strong { |
|
3350
|
|
|
margin-left: 30px; |
|
3351
|
|
|
} |
|
3352
|
|
|
</style> |
|
3353
|
|
|
<form action="<?php echo esc_url( pods_query_arg( array( 'action' . $this->num => 'reorder', 'do' . $this->num => 'save', 'page' => pods_var_raw( 'page' ) ), self::$allowed, $this->exclusion() ) ); ?>" method="post" class="admin_ui_reorder_form"> |
|
3354
|
|
|
<?php |
|
3355
|
|
|
} |
|
3356
|
|
|
$table_fields = $this->fields[ 'manage' ]; |
|
3357
|
|
View Code Duplication |
if ( true === $reorder && !in_array( 'reorder', $this->actions_disabled ) && false !== $this->reorder[ 'on' ] ) |
|
3358
|
|
|
$table_fields = $this->fields[ 'reorder' ]; |
|
3359
|
|
|
if ( false === $table_fields || empty( $table_fields ) ) |
|
3360
|
|
|
return $this->error( __( '<strong>Error:</strong> Invalid Configuration - Missing "fields" definition.', 'pods' ) ); |
|
3361
|
|
|
?> |
|
3362
|
|
|
<table class="widefat page fixed wp-list-table" cellspacing="0"<?php echo ( 1 == $reorder && $this->reorder ) ? ' id="admin_ui_reorder"' : ''; ?>> |
|
|
|
|
|
|
3363
|
|
|
<thead> |
|
3364
|
|
|
<tr> |
|
3365
|
|
|
<?php |
|
3366
|
|
|
if ( !empty( $this->actions_bulk ) ) { |
|
3367
|
|
|
?> |
|
3368
|
|
|
<th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" /></th> |
|
3369
|
|
|
<?php |
|
3370
|
|
|
} |
|
3371
|
|
|
|
|
3372
|
|
|
$name_field = false; |
|
3373
|
|
|
$fields = array(); |
|
3374
|
|
|
if ( !empty( $table_fields ) ) { |
|
3375
|
|
|
foreach ( $table_fields as $field => $attributes ) { |
|
3376
|
|
|
if ( false === $attributes[ 'display' ] ) |
|
3377
|
|
|
continue; |
|
3378
|
|
|
if ( false === $name_field ) |
|
3379
|
|
|
$id = 'title'; |
|
3380
|
|
|
else |
|
3381
|
|
|
$id = ''; |
|
3382
|
|
|
if ( 'other' == $attributes[ 'type' ] ) |
|
3383
|
|
|
$id = ''; |
|
3384
|
|
|
if ( in_array( $attributes[ 'type' ], array( 'date', 'datetime', 'time' ) ) ) |
|
3385
|
|
|
$id = 'date'; |
|
3386
|
|
|
if ( false === $name_field && 'title' == $id ) |
|
3387
|
|
|
$name_field = true; |
|
3388
|
|
|
$fields[ $field ] = $attributes; |
|
3389
|
|
|
$fields[ $field ][ 'field_id' ] = $id; |
|
3390
|
|
|
$dir = 'DESC'; |
|
3391
|
|
|
$current_sort = ' asc'; |
|
3392
|
|
|
if ( isset( $this->orderby[ 'default' ] ) && $field == $this->orderby[ 'default' ] ) { |
|
3393
|
|
|
if ( 'DESC' == $this->orderby_dir ) { |
|
3394
|
|
|
$dir = 'ASC'; |
|
3395
|
|
|
$current_sort = ' desc'; |
|
3396
|
|
|
} |
|
3397
|
|
|
} |
|
3398
|
|
|
|
|
3399
|
|
|
$att_id = ''; |
|
3400
|
|
|
if ( !empty( $id ) ) |
|
3401
|
|
|
$att_id = ' id="' . esc_attr( $id ) . '"'; |
|
3402
|
|
|
|
|
3403
|
|
|
$width = ''; |
|
3404
|
|
|
|
|
3405
|
|
|
$column_classes = array( |
|
3406
|
|
|
'manage-column', |
|
3407
|
|
|
'column-' . $id |
|
3408
|
|
|
); |
|
3409
|
|
|
|
|
3410
|
|
|
// Merge with the classes taken from the UI call |
|
3411
|
|
View Code Duplication |
if ( ! empty( $attributes['classes'] ) && is_array( $attributes['classes'] ) ) { |
|
3412
|
|
|
$column_classes = array_merge( $column_classes, $attributes['classes'] ); |
|
3413
|
|
|
} |
|
3414
|
|
|
if ( $id == 'title' ) { |
|
3415
|
|
|
$column_classes[] = 'column-primary'; |
|
3416
|
|
|
} |
|
3417
|
|
|
|
|
3418
|
|
View Code Duplication |
if ( isset( $attributes[ 'width' ] ) && !empty( $attributes[ 'width' ] ) ) |
|
3419
|
|
|
$width = ' style="width: ' . esc_attr( $attributes[ 'width' ] ) . '"'; |
|
3420
|
|
|
|
|
3421
|
|
|
if ( $fields[ $field ][ 'sortable' ] ) { |
|
3422
|
|
|
$column_classes[] = 'sortable' . $current_sort; |
|
3423
|
|
|
?> |
|
3424
|
|
|
<th scope="col"<?php echo $att_id; ?> class="<?php echo esc_attr( implode( ' ', $column_classes ) ); ?>"<?php echo $width; ?>> |
|
3425
|
|
|
<a href="<?php echo esc_url_raw( pods_query_arg( array( 'orderby' . $this->num => $field, 'orderby_dir' . $this->num => $dir ), array( 'limit' . $this->num, 'search' . $this->num, 'pg' . $this->num, 'page' ), $this->exclusion() ) ); ?>"> <span><?php echo esc_html( $attributes[ 'label' ] ); ?></span> <span class="sorting-indicator"></span> </a> |
|
3426
|
|
|
</th> |
|
3427
|
|
|
<?php |
|
3428
|
|
|
} |
|
3429
|
|
|
else { |
|
3430
|
|
|
?> |
|
3431
|
|
|
<th scope="col"<?php echo $att_id; ?> class="<?php echo esc_attr( implode( ' ', $column_classes ) ); ?>"<?php echo $width; ?>><?php echo esc_html( $attributes[ 'label' ] ); ?></th> |
|
3432
|
|
|
<?php |
|
3433
|
|
|
} |
|
3434
|
|
|
} |
|
3435
|
|
|
} |
|
3436
|
|
|
?> |
|
3437
|
|
|
</tr> |
|
3438
|
|
|
</thead> |
|
3439
|
|
|
<?php |
|
3440
|
|
|
if ( 6 < $this->total_found ) { |
|
3441
|
|
|
?> |
|
3442
|
|
|
<tfoot> |
|
3443
|
|
|
<tr> |
|
3444
|
|
|
<?php |
|
3445
|
|
|
if ( !empty( $this->actions_bulk ) ) { |
|
3446
|
|
|
?> |
|
3447
|
|
|
<th scope="col" class="manage-column column-cb check-column"><input type="checkbox" /></th> |
|
3448
|
|
|
<?php |
|
3449
|
|
|
} |
|
3450
|
|
|
|
|
3451
|
|
|
if ( !empty( $fields ) ) { |
|
3452
|
|
|
foreach ( $fields as $field => $attributes ) { |
|
3453
|
|
|
$dir = 'ASC'; |
|
3454
|
|
|
if ( $field == $this->orderby ) { |
|
3455
|
|
|
$current_sort = 'desc'; |
|
3456
|
|
|
if ( 'ASC' == $this->orderby_dir ) { |
|
3457
|
|
|
$dir = 'DESC'; |
|
3458
|
|
|
$current_sort = 'asc'; |
|
3459
|
|
|
} |
|
3460
|
|
|
} |
|
3461
|
|
|
|
|
3462
|
|
|
$width = ''; |
|
3463
|
|
|
|
|
3464
|
|
View Code Duplication |
if ( isset( $attributes[ 'width' ] ) && !empty( $attributes[ 'width' ] ) ) |
|
3465
|
|
|
$width = ' style="width: ' . esc_attr( $attributes[ 'width' ] ) . '"'; |
|
3466
|
|
|
|
|
3467
|
|
|
if ( $fields[ $field ][ 'sortable' ] ) { |
|
3468
|
|
|
?> |
|
3469
|
|
|
<th scope="col" class="manage-column column-<?php echo esc_attr( $id ); ?> sortable <?php echo esc_attr( $current_sort ); ?>"<?php echo $width; ?>><a href="<?php echo esc_url_raw( pods_query_arg( array( 'orderby' . $this->num => $field, 'orderby_dir' . $this->num => $dir ), array( 'limit' . $this->num, 'search' . $this->num, 'pg' . $this->num, 'page' ), $this->exclusion() ) ); ?>"><span><?php echo esc_html( $attributes[ 'label' ] ); ?></span><span class="sorting-indicator"></span></a></th> |
|
|
|
|
|
|
3470
|
|
|
<?php |
|
3471
|
|
|
} |
|
3472
|
|
|
else { |
|
3473
|
|
|
?> |
|
3474
|
|
|
<th scope="col" class="manage-column column-<?php echo esc_attr( $id ); ?>"<?php echo $width; ?>><?php echo esc_html( $attributes[ 'label' ] ); ?></th> |
|
3475
|
|
|
<?php |
|
3476
|
|
|
} |
|
3477
|
|
|
} |
|
3478
|
|
|
} |
|
3479
|
|
|
?> |
|
3480
|
|
|
</tr> |
|
3481
|
|
|
</tfoot> |
|
3482
|
|
|
<?php |
|
3483
|
|
|
} |
|
3484
|
|
|
?> |
|
3485
|
|
|
<tbody id="the-list"<?php echo ( true === $reorder && !in_array( 'reorder', $this->actions_disabled ) && false !== $this->reorder[ 'on' ] ) ? ' class="reorderable"' : ''; ?>> |
|
3486
|
|
|
<?php |
|
3487
|
|
|
if ( !empty( $this->data ) && is_array( $this->data ) ) { |
|
3488
|
|
|
$counter = 0; |
|
3489
|
|
|
|
|
3490
|
|
|
while ( $row = $this->get_row( $counter, 'table' ) ) { |
|
3491
|
|
|
if ( is_object( $row ) ) |
|
3492
|
|
|
$row = get_object_vars( (object) $row ); |
|
3493
|
|
|
|
|
3494
|
|
|
$toggle_class = ''; |
|
3495
|
|
|
|
|
3496
|
|
|
if ( is_array( $this->actions_custom ) && isset( $this->actions_custom[ 'toggle' ] ) ) { |
|
3497
|
|
|
$toggle_class = ' pods-toggled-on'; |
|
3498
|
|
|
|
|
3499
|
|
|
if ( !isset( $row[ 'toggle' ] ) || empty( $row[ 'toggle' ] ) ) |
|
3500
|
|
|
$toggle_class = ' pods-toggled-off'; |
|
3501
|
|
|
} |
|
3502
|
|
|
?> |
|
3503
|
|
|
<tr id="item-<?php echo esc_attr( $row[ $this->sql[ 'field_id' ] ] ); ?>" class="iedit<?php echo esc_attr( $toggle_class ); ?>"> |
|
3504
|
|
|
<?php |
|
3505
|
|
|
if ( !empty( $this->actions_bulk ) ) { |
|
3506
|
|
|
?> |
|
3507
|
|
|
<th scope="row" class="check-column"><input type="checkbox" name="action_bulk_ids<?php echo esc_attr( $this->num ); ?>[]" value="<?php echo esc_attr( $row[$this->sql['field_id']] ); ?>"></th> |
|
3508
|
|
|
<?php |
|
3509
|
|
|
} |
|
3510
|
|
|
// Boolean for the first field to output after the check-column |
|
3511
|
|
|
// will be set to false at the end of the first loop |
|
3512
|
|
|
$first_field = true; |
|
3513
|
|
|
foreach ( $fields as $field => $attributes ) { |
|
3514
|
|
|
if ( false === $attributes[ 'display' ] ) |
|
3515
|
|
|
continue; |
|
3516
|
|
|
|
|
3517
|
|
|
if ( !isset( $row[ $field ] ) ) { |
|
3518
|
|
|
$row[ $field ] = $this->get_field( $field ); |
|
3519
|
|
|
} |
|
3520
|
|
|
|
|
3521
|
|
|
$row_value = $row[ $field ]; |
|
3522
|
|
|
|
|
3523
|
|
|
if ( !empty( $attributes[ 'custom_display' ] ) ) { |
|
3524
|
|
|
if ( is_callable( $attributes[ 'custom_display' ] ) ) |
|
3525
|
|
|
$row_value = call_user_func_array( $attributes[ 'custom_display' ], array( $row, &$this, $row_value, $field, $attributes ) ); |
|
3526
|
|
|
elseif ( is_object( $this->pod ) && class_exists( 'Pods_Helpers' ) ) |
|
3527
|
|
|
$row_value = $this->pod->helper( $attributes[ 'custom_display' ], $row_value, $field ); |
|
3528
|
|
|
} |
|
3529
|
|
|
else { |
|
3530
|
|
|
ob_start(); |
|
3531
|
|
|
|
|
3532
|
|
|
$field_value = PodsForm::field_method( $attributes[ 'type' ], 'ui', $this->id, $row_value, $field, array_merge( $attributes, pods_var_raw( 'options', $attributes, array(), null, true ) ), $fields, $this->pod ); |
|
3533
|
|
|
|
|
3534
|
|
|
$field_output = trim( (string) ob_get_clean() ); |
|
3535
|
|
|
|
|
3536
|
|
|
if ( false === $field_value ) |
|
3537
|
|
|
$row_value = ''; |
|
3538
|
|
|
elseif ( 0 < strlen( trim( (string) $field_value ) ) ) |
|
3539
|
|
|
$row_value = trim( (string) $field_value ); |
|
3540
|
|
|
elseif ( 0 < strlen( $field_output ) ) |
|
3541
|
|
|
$row_value = $field_output; |
|
3542
|
|
|
} |
|
3543
|
|
|
|
|
3544
|
|
|
if ( false !== $attributes[ 'custom_relate' ] ) { |
|
3545
|
|
|
global $wpdb; |
|
|
|
|
|
|
3546
|
|
|
$table = $attributes[ 'custom_relate' ]; |
|
3547
|
|
|
$on = $this->sql[ 'field_id' ]; |
|
3548
|
|
|
$is = $row[ $this->sql[ 'field_id' ] ]; |
|
3549
|
|
|
$what = array( 'name' ); |
|
3550
|
|
|
if ( is_array( $table ) ) { |
|
3551
|
|
|
if ( isset( $table[ 'on' ] ) ) |
|
3552
|
|
|
$on = pods_sanitize( $table[ 'on' ] ); |
|
3553
|
|
|
if ( isset( $table[ 'is' ] ) && isset( $row[ $table[ 'is' ] ] ) ) |
|
3554
|
|
|
$is = pods_sanitize( $row[ $table[ 'is' ] ] ); |
|
3555
|
|
|
if ( isset( $table[ 'what' ] ) ) { |
|
3556
|
|
|
$what = array(); |
|
3557
|
|
|
if ( is_array( $table[ 'what' ] ) ) { |
|
3558
|
|
|
foreach ( $table[ 'what' ] as $wha ) { |
|
3559
|
|
|
$what[] = pods_sanitize( $wha ); |
|
3560
|
|
|
} |
|
3561
|
|
|
} |
|
3562
|
|
|
else |
|
3563
|
|
|
$what[] = pods_sanitize( $table[ 'what' ] ); |
|
3564
|
|
|
} |
|
3565
|
|
|
if ( isset( $table[ 'table' ] ) ) |
|
3566
|
|
|
$table = $table[ 'table' ]; |
|
3567
|
|
|
} |
|
3568
|
|
|
$table = pods_sanitize( $table ); |
|
3569
|
|
|
$wha = implode( ',', $what ); |
|
3570
|
|
|
$sql = "SELECT {$wha} FROM {$table} WHERE `{$on}`='{$is}'"; |
|
3571
|
|
|
$value = @current( $wpdb->get_results( $sql, ARRAY_A ) ); |
|
3572
|
|
|
if ( !empty( $value ) ) { |
|
3573
|
|
|
$val = array(); |
|
3574
|
|
|
foreach ( $what as $wha ) { |
|
3575
|
|
|
if ( isset( $value[ $wha ] ) ) |
|
3576
|
|
|
$val[] = $value[ $wha ]; |
|
3577
|
|
|
} |
|
3578
|
|
|
if ( !empty( $val ) ) |
|
3579
|
|
|
$row_value = implode( ' ', $val ); |
|
3580
|
|
|
} |
|
3581
|
|
|
} |
|
3582
|
|
|
|
|
3583
|
|
|
$css_classes = array( |
|
3584
|
|
|
'pods-ui-col-field-' . sanitize_title( $field ) |
|
3585
|
|
|
); |
|
3586
|
|
|
|
|
3587
|
|
|
// Merge with the classes taken from the UI call |
|
3588
|
|
View Code Duplication |
if ( ! empty( $attributes['classes'] ) && is_array( $attributes['classes'] ) ) { |
|
3589
|
|
|
$css_classes = array_merge( $css_classes, $attributes['classes'] ); |
|
3590
|
|
|
} |
|
3591
|
|
|
|
|
3592
|
|
|
if ( $attributes[ 'css_values' ] ) { |
|
3593
|
|
|
$css_field_value = $row[ $field ]; |
|
3594
|
|
|
|
|
3595
|
|
|
if ( is_object( $css_field_value ) ) { |
|
3596
|
|
|
$css_field_value = get_object_vars( $css_field_value ); |
|
3597
|
|
|
} |
|
3598
|
|
|
|
|
3599
|
|
|
if ( is_array( $css_field_value ) ) { |
|
3600
|
|
|
foreach ( $css_field_value as $css_field_val ) { |
|
3601
|
|
|
if ( is_object( $css_field_val ) ) { |
|
3602
|
|
|
$css_field_val = get_object_vars( $css_field_val ); |
|
3603
|
|
|
} |
|
3604
|
|
|
|
|
3605
|
|
|
if ( is_array( $css_field_val ) ) { |
|
3606
|
|
|
foreach ( $css_field_val as $css_field_v ) { |
|
3607
|
|
|
if ( is_object( $css_field_v ) ) { |
|
3608
|
|
|
$css_field_v = get_object_vars( $css_field_v ); |
|
3609
|
|
|
} |
|
3610
|
|
|
|
|
3611
|
|
|
$css_classes[] = 'pods-ui-css-value-' . sanitize_title( str_replace( array( "\n", "\r" ), ' ', strip_tags( (string) $css_field_v ) ) ); |
|
3612
|
|
|
} |
|
3613
|
|
|
} |
|
3614
|
|
View Code Duplication |
else { |
|
3615
|
|
|
$css_classes[] = ' pods-ui-css-value-' . sanitize_title( str_replace( array( "\n", "\r" ), ' ', strip_tags( (string) $css_field_val ) ) ); |
|
3616
|
|
|
} |
|
3617
|
|
|
} |
|
3618
|
|
|
} |
|
3619
|
|
View Code Duplication |
else { |
|
3620
|
|
|
$css_classes[] = ' pods-ui-css-value-' . sanitize_title( str_replace( array( "\n", "\r" ), ' ', strip_tags( (string) $css_field_value ) ) ); |
|
3621
|
|
|
} |
|
3622
|
|
|
} |
|
3623
|
|
|
|
|
3624
|
|
|
if ( is_object( $this->pod ) ) |
|
3625
|
|
|
$row_value = $this->do_hook( $this->pod->pod . '_field_value', $row_value, $field, $attributes, $row ); |
|
3626
|
|
|
|
|
3627
|
|
|
$row_value = $this->do_hook( 'field_value', $row_value, $field, $attributes, $row ); |
|
3628
|
|
|
|
|
3629
|
|
|
if ( 'title' == $attributes[ 'field_id' ] ) { |
|
3630
|
|
|
$default_action = $this->do_hook( 'default_action', 'edit', $row ); |
|
3631
|
|
|
|
|
3632
|
|
|
if ( $first_field ) { |
|
3633
|
|
|
$css_classes[] = 'column-primary'; |
|
3634
|
|
|
} |
|
3635
|
|
|
$css_classes[] = 'post-title'; |
|
3636
|
|
|
$css_classes[] = 'page-title'; |
|
3637
|
|
|
$css_classes[] = 'column-title'; |
|
3638
|
|
|
|
|
3639
|
|
|
if ( !in_array( 'edit', $this->actions_disabled ) && !in_array( 'edit', $this->actions_hidden ) && ( false === $reorder || in_array( 'reorder', $this->actions_disabled ) || false === $this->reorder[ 'on' ] ) && 'edit' == $default_action ) { |
|
3640
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'edit', 'id' . $this->num => $row[ $this->sql[ 'field_id' ] ] ), self::$allowed, $this->exclusion() ); |
|
3641
|
|
|
|
|
3642
|
|
|
if ( !empty( $this->action_links[ 'edit' ] ) ) |
|
3643
|
|
|
$link = $this->do_template( $this->action_links[ 'edit' ], $row ); |
|
3644
|
|
|
?> |
|
3645
|
|
|
<td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>"><strong><a class="row-title" href="<?php echo esc_url_raw( $link ); ?>" title="<?php esc_attr_e( 'Edit this item', 'pods' ); ?>"><?php echo wp_kses_post( $row_value ); ?></a></strong> |
|
3646
|
|
|
<?php |
|
3647
|
|
|
} |
|
3648
|
|
|
elseif ( !in_array( 'view', $this->actions_disabled ) && !in_array( 'view', $this->actions_hidden ) && ( false === $reorder || in_array( 'reorder', $this->actions_disabled ) || false === $this->reorder[ 'on' ] ) && 'view' == $default_action ) { |
|
3649
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'view', 'id' . $this->num => $row[ $this->sql[ 'field_id' ] ] ), self::$allowed, $this->exclusion() ); |
|
3650
|
|
|
|
|
3651
|
|
|
if ( !empty( $this->action_links[ 'view' ] ) ) |
|
3652
|
|
|
$link = $this->do_template( $this->action_links[ 'view' ], $row ); |
|
3653
|
|
|
?> |
|
3654
|
|
|
<td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>"><strong><a class="row-title" href="<?php echo esc_url_raw( $link ); ?>" title="<?php esc_attr_e( 'View this item', 'pods' ); ?>"><?php echo wp_kses_post( $row_value ); ?></a></strong> |
|
3655
|
|
|
<?php |
|
3656
|
|
|
} |
|
3657
|
|
|
else { |
|
3658
|
|
|
if ( 1 == $reorder && $this->reorder ) { |
|
|
|
|
|
|
3659
|
|
|
$css_classes[] = 'dragme'; |
|
3660
|
|
|
} |
|
3661
|
|
|
?> |
|
3662
|
|
|
<td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>"><strong><?php echo wp_kses_post( $row_value ); ?></strong> |
|
3663
|
|
|
<?php |
|
3664
|
|
|
} |
|
3665
|
|
|
|
|
3666
|
|
|
if ( true !== $reorder || in_array( 'reorder', $this->actions_disabled ) || false === $this->reorder[ 'on' ] ) { |
|
3667
|
|
|
$toggle = false; |
|
3668
|
|
|
$actions = array(); |
|
3669
|
|
|
|
|
3670
|
|
View Code Duplication |
if ( !in_array( 'view', $this->actions_disabled ) && !in_array( 'view', $this->actions_hidden ) ) { |
|
3671
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'view', 'id' . $this->num => $row[ $this->sql[ 'field_id' ] ] ), self::$allowed, $this->exclusion() ); |
|
3672
|
|
|
|
|
3673
|
|
|
if ( !empty( $this->action_links[ 'view' ] ) ) |
|
3674
|
|
|
$link = $this->do_template( $this->action_links[ 'view' ], $row ); |
|
3675
|
|
|
|
|
3676
|
|
|
$actions[ 'view' ] = '<span class="view"><a href="' . esc_url( $link ) . '" title="' . esc_attr__( 'View this item', 'pods' ) . '">' . __( 'View', 'pods' ) . '</a></span>'; |
|
3677
|
|
|
} |
|
3678
|
|
|
|
|
3679
|
|
View Code Duplication |
if ( !in_array( 'edit', $this->actions_disabled ) && !in_array( 'edit', $this->actions_hidden ) && !$this->restricted( 'edit', $row ) ) { |
|
3680
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'edit', 'id' . $this->num => $row[ $this->sql[ 'field_id' ] ] ), self::$allowed, $this->exclusion() ); |
|
3681
|
|
|
|
|
3682
|
|
|
if ( !empty( $this->action_links[ 'edit' ] ) ) |
|
3683
|
|
|
$link = $this->do_template( $this->action_links[ 'edit' ], $row ); |
|
3684
|
|
|
|
|
3685
|
|
|
$actions[ 'edit' ] = '<span class="edit"><a href="' . esc_url( $link ) . '" title="' . esc_attr__( 'Edit this item', 'pods' ) . '">' . __( 'Edit', 'pods' ) . '</a></span>'; |
|
3686
|
|
|
} |
|
3687
|
|
|
|
|
3688
|
|
View Code Duplication |
if ( !in_array( 'duplicate', $this->actions_disabled ) && !in_array( 'duplicate', $this->actions_hidden ) && !$this->restricted( 'edit', $row ) ) { |
|
3689
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'duplicate', 'id' . $this->num => $row[ $this->sql[ 'field_id' ] ] ), self::$allowed, $this->exclusion() ); |
|
3690
|
|
|
|
|
3691
|
|
|
if ( !empty( $this->action_links[ 'duplicate' ] ) ) |
|
3692
|
|
|
$link = $this->do_template( $this->action_links[ 'duplicate' ], $row ); |
|
3693
|
|
|
|
|
3694
|
|
|
$actions[ 'duplicate' ] = '<span class="edit"><a href="' . esc_url( $link ) . '" title="' . esc_attr__( 'Duplicate this item', 'pods' ) . '">' . __( 'Duplicate', 'pods' ) . '</a></span>'; |
|
3695
|
|
|
} |
|
3696
|
|
|
|
|
3697
|
|
|
if ( !in_array( 'delete', $this->actions_disabled ) && !in_array( 'delete', $this->actions_hidden ) && !$this->restricted( 'delete', $row ) ) { |
|
3698
|
|
|
$link = pods_query_arg( array( 'action' . $this->num => 'delete', 'id' . $this->num => $row[ $this->sql[ 'field_id' ] ], '_wpnonce' => wp_create_nonce( 'pods-ui-action-delete' ) ), self::$allowed, $this->exclusion() ); |
|
3699
|
|
|
|
|
3700
|
|
|
if ( !empty( $this->action_links[ 'delete' ] ) ) { |
|
3701
|
|
|
$link = add_query_arg( array( '_wpnonce' => wp_create_nonce( 'pods-ui-action-delete' ) ), $this->do_template( $this->action_links[ 'delete' ], $row ) ); |
|
3702
|
|
|
} |
|
3703
|
|
|
|
|
3704
|
|
|
$actions[ 'delete' ] = '<span class="delete"><a href="' . esc_url( $link ) . '" title="' . esc_attr__( 'Delete this item', 'pods' ) . '" class="submitdelete" onclick="if(confirm(\'' . esc_attr__( 'You are about to permanently delete this item\n Choose \\\'Cancel\\\' to stop, \\\'OK\\\' to delete.', 'pods' ) . '\')){return true;}return false;">' . __( 'Delete', 'pods' ) . '</a></span>'; |
|
3705
|
|
|
} |
|
3706
|
|
|
|
|
3707
|
|
|
if ( is_array( $this->actions_custom ) ) { |
|
3708
|
|
|
foreach ( $this->actions_custom as $custom_action => $custom_data ) { |
|
3709
|
|
|
if ( 'add' != $custom_action && is_array( $custom_data ) && ( isset( $custom_data[ 'link' ] ) || isset( $custom_data[ 'callback' ] ) ) && !in_array( $custom_action, $this->actions_disabled ) && !in_array( $custom_action, $this->actions_hidden ) ) { |
|
3710
|
|
|
if ( !in_array( $custom_action, array( 'add', 'view', 'edit', 'duplicate', 'delete', 'save', 'export', 'reorder', 'manage', 'table' ) ) ) { |
|
3711
|
|
|
if ( 'toggle' == $custom_action ) { |
|
3712
|
|
|
$toggle = true; |
|
3713
|
|
|
$toggle_labels = array( |
|
3714
|
|
|
__( 'Enable', 'pods' ), |
|
3715
|
|
|
__( 'Disable', 'pods' ) |
|
3716
|
|
|
); |
|
3717
|
|
|
|
|
3718
|
|
|
$custom_data[ 'label' ] = ( $row[ 'toggle' ] ? $toggle_labels[ 1 ] : $toggle_labels[ 0 ] ); |
|
3719
|
|
|
} |
|
3720
|
|
|
|
|
3721
|
|
|
if ( !isset( $custom_data[ 'label' ] ) ) |
|
3722
|
|
|
$custom_data[ 'label' ] = ucwords( str_replace( '_', ' ', $custom_action ) ); |
|
3723
|
|
|
|
|
3724
|
|
|
if ( !isset( $custom_data[ 'link' ] ) ) { |
|
3725
|
|
|
$vars = array( |
|
3726
|
|
|
'action' => $custom_action, |
|
3727
|
|
|
'id' => $row[ $this->sql[ 'field_id' ] ], |
|
3728
|
|
|
'_wpnonce' => wp_create_nonce( 'pods-ui-action-' . $custom_action ) |
|
3729
|
|
|
); |
|
3730
|
|
|
|
|
3731
|
|
|
if ( 'toggle' == $custom_action ) { |
|
3732
|
|
|
$vars[ 'toggle' ] = (int) ( !$row[ 'toggle' ] ); |
|
3733
|
|
|
$vars[ 'toggled' ] = 1; |
|
3734
|
|
|
} |
|
3735
|
|
|
|
|
3736
|
|
|
$custom_data[ 'link' ] = pods_query_arg( $vars, self::$allowed, $this->exclusion() ); |
|
3737
|
|
|
|
|
3738
|
|
|
if ( isset( $this->action_links[ $custom_action ] ) && !empty( $this->action_links[ $custom_action ] ) ) { |
|
3739
|
|
|
$custom_data[ 'link' ] = add_query_arg( array( '_wpnonce' => wp_create_nonce( 'pods-ui-action-' . $custom_action ) ), $this->do_template( $this->action_links[ $custom_action ], $row ) ); |
|
3740
|
|
|
} |
|
3741
|
|
|
} |
|
3742
|
|
|
|
|
3743
|
|
|
$confirm = ''; |
|
3744
|
|
|
|
|
3745
|
|
|
if ( isset( $custom_data[ 'confirm' ] ) ) |
|
3746
|
|
|
$confirm = ' onclick="if(confirm(\'' . esc_js( $custom_data[ 'confirm' ] ) . '\')){return true;}return false;"'; |
|
3747
|
|
|
|
|
3748
|
|
|
if ( $this->restricted( $custom_action, $row ) ) { |
|
3749
|
|
|
continue; |
|
3750
|
|
|
} |
|
3751
|
|
|
|
|
3752
|
|
|
$actions[ $custom_action ] = '<span class="edit action-' . esc_attr( $custom_action ) . '"><a href="' . esc_url( $this->do_template( $custom_data[ 'link' ], $row ) ) . '" title="' . esc_attr( $custom_data[ 'label' ] ) . ' this item"' . $confirm . '>' . $custom_data[ 'label' ] . '</a></span>'; |
|
3753
|
|
|
} |
|
3754
|
|
|
} |
|
3755
|
|
|
} |
|
3756
|
|
|
} |
|
3757
|
|
|
|
|
3758
|
|
|
$actions = $this->do_hook( 'row_actions', $actions, $row[ $this->sql[ 'field_id' ] ] ); |
|
3759
|
|
|
|
|
3760
|
|
|
if ( !empty( $actions ) ) { |
|
3761
|
|
|
?> |
|
3762
|
|
|
<div class="row-actions<?php echo esc_attr( $toggle ? ' row-actions-toggle' : '' ); ?>"> |
|
3763
|
|
|
<?php |
|
3764
|
|
|
$this->callback( 'actions_start', $row, $actions ); |
|
3765
|
|
|
|
|
3766
|
|
|
echo implode( ' | ', $actions ); |
|
3767
|
|
|
|
|
3768
|
|
|
$this->callback( 'actions_end', $row, $actions ); |
|
3769
|
|
|
?> |
|
3770
|
|
|
</div> |
|
3771
|
|
|
<?php |
|
3772
|
|
|
} |
|
3773
|
|
|
} |
|
3774
|
|
|
else { |
|
3775
|
|
|
?> |
|
3776
|
|
|
<input type="hidden" name="order[]" value="<?php echo esc_attr( $row[ $this->sql[ 'field_id' ] ] ); ?>" /> |
|
3777
|
|
|
<?php |
|
3778
|
|
|
} |
|
3779
|
|
|
?><button type="button" class="toggle-row"><span class="screen-reader-text"><?php esc_html_e( 'Show more details', 'pods' ); ?></span></button> |
|
3780
|
|
|
</td> |
|
3781
|
|
|
<?php |
|
3782
|
|
|
} |
|
3783
|
|
|
elseif ( 'date' == $attributes[ 'type' ] ) { |
|
3784
|
|
|
if ( $first_field ) { |
|
3785
|
|
|
$css_classes[] = 'column-primary'; |
|
3786
|
|
|
} |
|
3787
|
|
|
$css_classes[] = 'date'; |
|
3788
|
|
|
$css_classes[] = 'column-date'; |
|
3789
|
|
|
?> |
|
3790
|
|
|
<td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>" data-colname="<?php echo esc_attr( $attributes['label'] ); ?>"> |
|
3791
|
|
|
<abbr title="<?php echo esc_attr( $row_value ); ?>"><?php echo wp_kses_post( $row_value ); ?></abbr> |
|
3792
|
|
|
<?php if ( $first_field ) { ?><button type="button" class="toggle-row"><span class="screen-reader-text"><?php esc_html_e( 'Show more details', 'pods' ); ?></span></button><?php }; ?> |
|
3793
|
|
|
</td> |
|
3794
|
|
|
<?php |
|
3795
|
|
|
} |
|
3796
|
|
|
else { |
|
3797
|
|
|
if ( $first_field ) { |
|
3798
|
|
|
$css_classes[] = 'column-primary'; |
|
3799
|
|
|
} |
|
3800
|
|
|
$css_classes[] = 'author'; |
|
3801
|
|
|
?> |
|
3802
|
|
|
<td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>" data-colname="<?php echo esc_attr( $attributes['label'] ); ?>"> |
|
3803
|
|
|
<span><?php echo wp_kses_post( $row_value ); ?></span> |
|
3804
|
|
|
<?php if ( $first_field ) { ?><button type="button" class="toggle-row"><span class="screen-reader-text"><?php esc_html_e( 'Show more details', 'pods' ); ?></span></button><?php }; ?> |
|
3805
|
|
|
</td> |
|
3806
|
|
|
<?php |
|
3807
|
|
|
} |
|
3808
|
|
|
$first_field = false; |
|
3809
|
|
|
} |
|
3810
|
|
|
?> |
|
3811
|
|
|
</tr> |
|
3812
|
|
|
<?php |
|
3813
|
|
|
} |
|
3814
|
|
|
} |
|
3815
|
|
|
?> |
|
3816
|
|
|
</tbody> |
|
3817
|
|
|
</table> |
|
3818
|
|
|
<?php |
|
3819
|
|
View Code Duplication |
if ( true === $reorder && !in_array( 'reorder', $this->actions_disabled ) && false !== $this->reorder[ 'on' ] ) { |
|
3820
|
|
|
?> |
|
3821
|
|
|
</form> |
|
3822
|
|
|
<?php |
|
3823
|
|
|
} |
|
3824
|
|
|
?> |
|
3825
|
|
|
<script type="text/javascript"> |
|
3826
|
|
|
jQuery( 'table.widefat tbody tr:even' ).addClass( 'alternate' ); |
|
3827
|
|
|
<?php |
|
3828
|
|
View Code Duplication |
if ( true === $reorder && !in_array( 'reorder', $this->actions_disabled ) && false !== $this->reorder[ 'on' ] ) { |
|
3829
|
|
|
?> |
|
3830
|
|
|
jQuery( document ).ready( function () { |
|
3831
|
|
|
jQuery( ".reorderable" ).sortable( {axis : "y", handle : ".dragme"} ); |
|
3832
|
|
|
jQuery( ".reorderable" ).bind( 'sortupdate', function ( event, ui ) { |
|
3833
|
|
|
jQuery( 'table.widefat tbody tr' ).removeClass( 'alternate' ); |
|
3834
|
|
|
jQuery( 'table.widefat tbody tr:even' ).addClass( 'alternate' ); |
|
3835
|
|
|
} ); |
|
3836
|
|
|
} ); |
|
3837
|
|
|
<?php |
|
3838
|
|
|
} |
|
3839
|
|
|
?> |
|
3840
|
|
|
</script> |
|
3841
|
|
|
<?php |
|
3842
|
|
|
} |
|
3843
|
|
|
|
|
3844
|
|
|
/** |
|
3845
|
|
|
* |
|
3846
|
|
|
*/ |
|
3847
|
|
|
public function screen_meta () { |
|
3848
|
|
|
$screen_html = $help_html = ''; |
|
3849
|
|
|
$screen_link = $help_link = ''; |
|
3850
|
|
|
if ( !empty( $this->screen_options ) && !empty( $this->help ) ) { |
|
3851
|
|
View Code Duplication |
foreach ( $this->ui_page as $page ) { |
|
3852
|
|
|
if ( isset( $this->screen_options[ $page ] ) ) { |
|
3853
|
|
|
if ( is_array( $this->screen_options[ $page ] ) ) { |
|
3854
|
|
|
if ( isset( $this->screen_options[ $page ][ 'link' ] ) ) { |
|
3855
|
|
|
$screen_link = $this->screen_options[ $page ][ 'link' ]; |
|
3856
|
|
|
break; |
|
3857
|
|
|
} |
|
3858
|
|
|
} |
|
3859
|
|
|
else { |
|
3860
|
|
|
$screen_html = $this->screen_options[ $page ]; |
|
3861
|
|
|
break; |
|
3862
|
|
|
} |
|
3863
|
|
|
} |
|
3864
|
|
|
} |
|
3865
|
|
View Code Duplication |
foreach ( $this->ui_page as $page ) { |
|
3866
|
|
|
if ( isset( $this->help[ $page ] ) ) { |
|
3867
|
|
|
if ( is_array( $this->help[ $page ] ) ) { |
|
3868
|
|
|
if ( isset( $this->help[ $page ][ 'link' ] ) ) { |
|
3869
|
|
|
$help_link = $this->help[ $page ][ 'link' ]; |
|
3870
|
|
|
break; |
|
3871
|
|
|
} |
|
3872
|
|
|
} |
|
3873
|
|
|
else { |
|
3874
|
|
|
$help_html = $this->help[ $page ]; |
|
3875
|
|
|
break; |
|
3876
|
|
|
} |
|
3877
|
|
|
} |
|
3878
|
|
|
} |
|
3879
|
|
|
} |
|
3880
|
|
|
$screen_html = $this->do_hook( 'screen_meta_screen_html', $screen_html ); |
|
3881
|
|
|
$screen_link = $this->do_hook( 'screen_meta_screen_link', $screen_link ); |
|
3882
|
|
|
$help_html = $this->do_hook( 'screen_meta_help_html', $help_html ); |
|
3883
|
|
|
$help_link = $this->do_hook( 'screen_meta_help_link', $help_link ); |
|
3884
|
|
|
if ( 0 < strlen( $screen_html ) || 0 < strlen( $screen_link ) || 0 < strlen( $help_html ) || 0 < strlen( $help_link ) ) { |
|
3885
|
|
|
?> |
|
3886
|
|
|
<div id="screen-meta"> |
|
3887
|
|
|
<?php |
|
3888
|
|
|
$this->do_hook( 'screen_meta_pre' ); |
|
3889
|
|
|
if ( 0 < strlen( $screen_html ) ) { |
|
3890
|
|
|
?> |
|
3891
|
|
|
<div id="screen-options-wrap" class="hidden"> |
|
3892
|
|
|
<form id="adv-settings" action="" method="post"> |
|
3893
|
|
|
<?php |
|
3894
|
|
|
echo $screen_html; |
|
3895
|
|
|
$fields = array(); |
|
3896
|
|
|
foreach ( $this->ui_page as $page ) { |
|
3897
|
|
View Code Duplication |
if ( isset( $this->fields[ $page ] ) && !empty( $this->fields[ $page ] ) ) |
|
3898
|
|
|
$fields = $this->fields[ $page ]; |
|
3899
|
|
|
} |
|
3900
|
|
|
if ( !empty( $fields ) || true === $this->pagination ) { |
|
3901
|
|
|
?> |
|
3902
|
|
|
<h5><?php _e( 'Show on screen', 'pods' ); ?></h5> |
|
3903
|
|
|
<?php |
|
3904
|
|
|
if ( !empty( $fields ) ) { |
|
3905
|
|
|
?> |
|
3906
|
|
|
<div class="metabox-prefs"> |
|
3907
|
|
|
<?php |
|
3908
|
|
|
$this->do_hook( 'screen_meta_screen_options' ); |
|
3909
|
|
|
foreach ( $fields as $field => $attributes ) { |
|
3910
|
|
|
if ( false === $attributes[ 'display' ] || true === $attributes[ 'hidden' ] ) |
|
3911
|
|
|
continue; |
|
3912
|
|
|
?> |
|
3913
|
|
|
<label for="<?php echo esc_attr( $field ); ?>-hide"> |
|
3914
|
|
|
<input class="hide-column-tog" name="<?php echo esc_attr( $this->unique_identifier ); ?>_<?php echo esc_attr( $field ); ?>-hide" type="checkbox" id="<?php echo esc_attr( $field ); ?>-hide" value="<?php echo esc_attr( $field ); ?>" checked="checked"><?php echo esc_html( $attributes[ 'label' ] ); ?></label> |
|
3915
|
|
|
<?php |
|
3916
|
|
|
} |
|
3917
|
|
|
?> |
|
3918
|
|
|
<br class="clear"> |
|
3919
|
|
|
</div> |
|
3920
|
|
|
<h5><?php _e( 'Show on screen', 'pods' ); ?></h5> |
|
3921
|
|
|
<?php |
|
3922
|
|
|
} |
|
3923
|
|
|
?> |
|
3924
|
|
|
<div class="screen-options"> |
|
3925
|
|
|
<?php |
|
3926
|
|
|
if ( true === $this->pagination ) { |
|
3927
|
|
|
?> |
|
3928
|
|
|
<input type="text" class="screen-per-page" name="wp_screen_options[value]" id="<?php echo esc_attr( $this->unique_identifier ); ?>_per_page" maxlength="3" value="20"> <label for="<?php echo esc_attr( $this->unique_identifier ); ?>_per_page"><?php echo esc_html( $this->items ); ?> per page</label> |
|
3929
|
|
|
<?php |
|
3930
|
|
|
} |
|
3931
|
|
|
$this->do_hook( 'screen_meta_screen_submit' ); |
|
3932
|
|
|
?> |
|
3933
|
|
|
<input type="submit" name="screen-options-apply" id="screen-options-apply" class="button" value="<?php esc_attr_e( 'Apply', 'pods' ); ?>"> |
|
3934
|
|
|
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $this->unique_identifier ); ?>_per_page"> |
|
3935
|
|
|
<?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?> |
|
3936
|
|
|
</div> |
|
3937
|
|
|
<?php |
|
3938
|
|
|
} |
|
3939
|
|
|
?> |
|
3940
|
|
|
</form> |
|
3941
|
|
|
</div> |
|
3942
|
|
|
<?php |
|
3943
|
|
|
} |
|
3944
|
|
|
if ( 0 < strlen( $help_html ) ) { |
|
3945
|
|
|
?> |
|
3946
|
|
|
<div id="contextual-help-wrap" class="hidden"> |
|
3947
|
|
|
<div class="metabox-prefs"> |
|
3948
|
|
|
<?php echo $help_html; ?> |
|
3949
|
|
|
</div> |
|
3950
|
|
|
</div> |
|
3951
|
|
|
<?php |
|
3952
|
|
|
} |
|
3953
|
|
|
?> |
|
3954
|
|
|
<div id="screen-meta-links"> |
|
3955
|
|
|
<?php |
|
3956
|
|
|
$this->do_hook( 'screen_meta_links_pre' ); |
|
3957
|
|
|
if ( 0 < strlen( $help_html ) || 0 < strlen( $help_link ) ) { |
|
3958
|
|
|
?> |
|
3959
|
|
|
<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
|
3960
|
|
|
<?php |
|
3961
|
|
|
if ( 0 < strlen( $help_link ) ) { |
|
3962
|
|
|
?> |
|
3963
|
|
|
<a href="<?php echo esc_url( $help_link ); ?>" class="show-settings">Help</a> |
|
3964
|
|
|
<?php |
|
3965
|
|
|
} |
|
3966
|
|
|
else { |
|
3967
|
|
|
?> |
|
3968
|
|
|
<a href="#contextual-help" id="contextual-help-link" class="show-settings">Help</a> |
|
3969
|
|
|
<?php |
|
3970
|
|
|
} |
|
3971
|
|
|
?> |
|
3972
|
|
|
</div> |
|
3973
|
|
|
<?php |
|
3974
|
|
|
} |
|
3975
|
|
|
if ( 0 < strlen( $screen_html ) || 0 < strlen( $screen_link ) ) { |
|
3976
|
|
|
?> |
|
3977
|
|
|
<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
|
3978
|
|
|
<?php |
|
3979
|
|
|
if ( 0 < strlen( $screen_link ) ) { |
|
3980
|
|
|
?> |
|
3981
|
|
|
<a href="<?php echo esc_url( $screen_link ); ?>" class="show-settings">Screen Options</a> |
|
3982
|
|
|
<?php |
|
3983
|
|
|
} |
|
3984
|
|
|
else { |
|
3985
|
|
|
?> |
|
3986
|
|
|
<a href="#screen-options" id="show-settings-link" class="show-settings">Screen Options</a> |
|
3987
|
|
|
<?php |
|
3988
|
|
|
} |
|
3989
|
|
|
?> |
|
3990
|
|
|
</div> |
|
3991
|
|
|
<?php |
|
3992
|
|
|
} |
|
3993
|
|
|
$this->do_hook( 'screen_meta_links_post' ); |
|
3994
|
|
|
?> |
|
3995
|
|
|
</div> |
|
3996
|
|
|
<?php |
|
3997
|
|
|
$this->do_hook( 'screen_meta_post' ); |
|
3998
|
|
|
?> |
|
3999
|
|
|
</div> |
|
4000
|
|
|
<?php |
|
4001
|
|
|
} |
|
4002
|
|
|
} |
|
4003
|
|
|
|
|
4004
|
|
|
/** |
|
4005
|
|
|
* @param bool $header |
|
4006
|
|
|
* |
|
4007
|
|
|
* @return mixed |
|
4008
|
|
|
*/ |
|
4009
|
|
|
public function pagination ( $header = false ) { |
|
4010
|
|
|
if ( false !== $this->callback( 'pagination', $header ) ) { |
|
4011
|
|
|
return null; |
|
4012
|
|
|
} |
|
4013
|
|
|
|
|
4014
|
|
|
$total_pages = ceil( $this->total_found / $this->limit ); |
|
4015
|
|
|
$request_uri = pods_query_arg( array( 'pg' . $this->num => '' ), array( 'limit' . $this->num, 'orderby' . $this->num, 'orderby_dir' . $this->num, 'search' . $this->num, 'filter_*', 'view' . $this->num, 'page' . $this->num ), $this->exclusion() ); |
|
4016
|
|
|
|
|
4017
|
|
|
$append = false; |
|
4018
|
|
|
|
|
4019
|
|
|
if ( false !== strpos( $request_uri, '?' ) ) |
|
4020
|
|
|
$append = true; |
|
4021
|
|
|
|
|
4022
|
|
|
if ( false !== $this->pagination_total && ( $header || 1 != $this->total_found ) ) { |
|
4023
|
|
|
$singular_label = strtolower( $this->item ); |
|
4024
|
|
|
$plural_label = strtolower( $this->items ); |
|
4025
|
|
|
?> |
|
4026
|
|
|
<span class="displaying-num"><?php echo number_format_i18n( $this->total_found ) . ' ' . _n( $singular_label, $plural_label, $this->total_found, 'pods' ) . $this->extra[ 'total' ]; ?></span> |
|
4027
|
|
|
<?php |
|
4028
|
|
|
} |
|
4029
|
|
|
|
|
4030
|
|
|
if ( false !== $this->pagination ) { |
|
4031
|
|
|
if ( 1 < $total_pages ) { |
|
4032
|
|
|
?> |
|
4033
|
|
|
<a class="first-page<?php echo esc_attr( ( 1 < $this->page ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the first page', 'pods' ); ?>" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=1' ); ?>">«</a> |
|
4034
|
|
|
<a class="prev-page<?php echo esc_attr( ( 1 < $this->page ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the previous page', 'pods' ); ?>" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . max( $this->page - 1, 1 ) ); ?>">‹</a> |
|
4035
|
|
|
<?php |
|
4036
|
|
|
if ( true == $header ) { |
|
|
|
|
|
|
4037
|
|
|
?> |
|
4038
|
|
|
<span class="paging-input"><input class="current-page" title="<?php esc_attr_e( 'Current page', 'pods' ); ?>" type="text" name="pg<?php echo esc_attr( $this->num ); ?>" value="<?php echo esc_attr( absint( $this->page ) ); ?>" size="<?php echo esc_attr( strlen( $total_pages ) ); ?>"> <?php _e( 'of', 'pods' ); ?> <span class="total-pages"><?php echo absint( $total_pages ); ?></span></span> |
|
4039
|
|
|
<script> |
|
4040
|
|
|
|
|
4041
|
|
|
jQuery( document ).ready( function ( $ ) { |
|
4042
|
|
|
var pageInput = $( 'input.current-page' ); |
|
4043
|
|
|
var currentPage = pageInput.val(); |
|
4044
|
|
|
pageInput.closest( 'form' ).submit( function ( e ) { |
|
4045
|
|
|
if ( |
|
4046
|
|
|
( 1 > $( 'select[name="action<?php echo esc_attr( $this->num ); ?>"]' ).length |
|
4047
|
|
|
|| $( 'select[name="action<?php echo esc_attr( $this->num ); ?>"]' ).val() == -1 ) |
|
4048
|
|
|
&& ( 1 > $( 'select[name="action_bulk<?php echo esc_attr( $this->num ); ?>"]' ).length |
|
4049
|
|
|
|| $( 'select[name="action_bulk<?php echo esc_attr( $this->num ); ?>"]' ).val() == -1 ) |
|
4050
|
|
|
&& pageInput.val() == currentPage ) { |
|
4051
|
|
|
pageInput.val( '1' ); |
|
4052
|
|
|
} |
|
4053
|
|
|
} ); |
|
4054
|
|
|
} ); |
|
4055
|
|
|
</script> |
|
4056
|
|
|
<?php |
|
4057
|
|
|
} |
|
4058
|
|
|
else { |
|
4059
|
|
|
?> |
|
4060
|
|
|
<span class="paging-input"><?php echo absint( $this->page ); ?> <?php _e( 'of', 'pods' ); ?> <span class="total-pages"><?php echo number_format_i18n( $total_pages ); ?></span></span> |
|
4061
|
|
|
<?php |
|
4062
|
|
|
} |
|
4063
|
|
|
?> |
|
4064
|
|
|
<a class="next-page<?php echo esc_attr( ( $this->page < $total_pages ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the next page', 'pods' ); ?>" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . min( $this->page + 1, $total_pages ) ); ?>">›</a> |
|
4065
|
|
|
<a class="last-page<?php echo esc_attr( ( $this->page < $total_pages ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the last page', 'pods' ); ?>'" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . $total_pages ); ?>">»</a> |
|
4066
|
|
|
<?php |
|
4067
|
|
|
} |
|
4068
|
|
|
} |
|
4069
|
|
|
} |
|
4070
|
|
|
|
|
4071
|
|
|
/** |
|
4072
|
|
|
* @param bool $options |
|
4073
|
|
|
* |
|
4074
|
|
|
* @return mixed |
|
4075
|
|
|
*/ |
|
4076
|
|
|
public function limit ( $options = false ) { |
|
4077
|
|
|
if ( false !== $this->callback( 'limit', $options ) ) { |
|
4078
|
|
|
return null; |
|
4079
|
|
|
} |
|
4080
|
|
|
|
|
4081
|
|
|
if ( false === $options || !is_array( $options ) || empty( $options ) ) |
|
4082
|
|
|
$options = array( 10, 25, 50, 100, 200 ); |
|
4083
|
|
|
|
|
4084
|
|
|
if ( !in_array( $this->limit, $options ) && -1 != $this->limit ) |
|
4085
|
|
|
$this->limit = $options[ 1 ]; |
|
4086
|
|
|
|
|
4087
|
|
|
foreach ( $options as $option ) { |
|
4088
|
|
|
if ( $option == $this->limit ) |
|
4089
|
|
|
echo ' <span class="page-numbers current">' . esc_html( $option ) . '</span>'; |
|
4090
|
|
|
else |
|
4091
|
|
|
echo ' <a href="' . esc_url( pods_query_arg( array( 'limit' => $option ), array( 'orderby' . $this->num, 'orderby_dir' . $this->num, 'search' . $this->num, 'filter_*', 'page' . $this->num ), $this->exclusion() ) ) . '">' . esc_html( $option ) . '</a>'; |
|
4092
|
|
|
} |
|
4093
|
|
|
} |
|
4094
|
|
|
|
|
4095
|
|
|
/** |
|
4096
|
|
|
* @param $code |
|
4097
|
|
|
* @param bool|array $row |
|
4098
|
|
|
* |
|
4099
|
|
|
* @return mixed |
|
4100
|
|
|
*/ |
|
4101
|
|
|
public function do_template ( $code, $row = false ) { |
|
4102
|
|
|
if ( is_object( $this->pod ) && 1 == 0 && 0 < $this->pod->id() ) |
|
4103
|
|
|
return $this->pod->do_magic_tags( $code ); |
|
4104
|
|
|
else { |
|
4105
|
|
|
if ( false !== $row ) { |
|
4106
|
|
|
$this->temp_row = $this->row; |
|
|
|
|
|
|
4107
|
|
|
$this->row = $row; |
|
4108
|
|
|
} |
|
4109
|
|
|
|
|
4110
|
|
|
$code = preg_replace_callback( "/({@(.*?)})/m", array( $this, "do_magic_tags" ), $code ); |
|
4111
|
|
|
|
|
4112
|
|
|
if ( false !== $row ) { |
|
4113
|
|
|
$this->row = $this->temp_row; |
|
4114
|
|
|
unset( $this->temp_row ); |
|
4115
|
|
|
} |
|
4116
|
|
|
} |
|
4117
|
|
|
|
|
4118
|
|
|
return $code; |
|
4119
|
|
|
} |
|
4120
|
|
|
|
|
4121
|
|
|
/** |
|
4122
|
|
|
* @param $tag |
|
4123
|
|
|
* |
|
4124
|
|
|
* @return string |
|
4125
|
|
|
*/ |
|
4126
|
|
|
public function do_magic_tags ( $tag ) { |
|
4127
|
|
View Code Duplication |
if ( is_array( $tag ) ) { |
|
4128
|
|
|
if ( !isset( $tag[ 2 ] ) && strlen( trim( $tag[ 2 ] ) ) < 1 ) |
|
4129
|
|
|
return ''; |
|
4130
|
|
|
|
|
4131
|
|
|
$tag = $tag[ 2 ]; |
|
4132
|
|
|
} |
|
4133
|
|
|
|
|
4134
|
|
|
$tag = trim( $tag, ' {@}' ); |
|
4135
|
|
|
$tag = explode( ',', $tag ); |
|
4136
|
|
|
|
|
4137
|
|
View Code Duplication |
if ( empty( $tag ) || !isset( $tag[ 0 ] ) || strlen( trim( $tag[ 0 ] ) ) < 1 ) |
|
4138
|
|
|
return null; |
|
4139
|
|
|
|
|
4140
|
|
|
foreach ( $tag as $k => $v ) { |
|
4141
|
|
|
$tag[ $k ] = trim( $v ); |
|
4142
|
|
|
} |
|
4143
|
|
|
|
|
4144
|
|
|
$field_name = $tag[ 0 ]; |
|
4145
|
|
|
|
|
4146
|
|
|
$value = $this->get_field( $field_name ); |
|
4147
|
|
|
|
|
4148
|
|
View Code Duplication |
if ( isset( $tag[ 1 ] ) && !empty( $tag[ 1 ] ) && is_callable( $tag[ 1 ] ) ) |
|
4149
|
|
|
$value = call_user_func_array( $tag[ 1 ], array( $value, $field_name, $this->row, &$this ) ); |
|
4150
|
|
|
|
|
4151
|
|
|
$before = $after = ''; |
|
4152
|
|
|
|
|
4153
|
|
|
if ( isset( $tag[ 2 ] ) && !empty( $tag[ 2 ] ) ) |
|
4154
|
|
|
$before = $tag[ 2 ]; |
|
4155
|
|
|
|
|
4156
|
|
|
if ( isset( $tag[ 3 ] ) && !empty( $tag[ 3 ] ) ) |
|
4157
|
|
|
$after = $tag[ 3 ]; |
|
4158
|
|
|
|
|
4159
|
|
|
if ( 0 < strlen( $value ) ) |
|
4160
|
|
|
return $before . $value . $after; |
|
4161
|
|
|
|
|
4162
|
|
|
return null; |
|
4163
|
|
|
} |
|
4164
|
|
|
|
|
4165
|
|
|
/** |
|
4166
|
|
|
* @param bool|array $exclude |
|
4167
|
|
|
* @param bool|array $array |
|
4168
|
|
|
*/ |
|
4169
|
|
|
public function hidden_vars ( $exclude = false, $array = false ) { |
|
4170
|
|
|
$exclude = $this->do_hook( 'hidden_vars', $exclude, $array ); |
|
4171
|
|
|
if ( false === $exclude ) |
|
4172
|
|
|
$exclude = array(); |
|
4173
|
|
|
if ( !is_array( $exclude ) ) |
|
4174
|
|
|
$exclude = explode( ',', $exclude ); |
|
4175
|
|
|
$get = $_GET; |
|
4176
|
|
|
if ( is_array( $array ) ) { |
|
4177
|
|
|
foreach ( $array as $key => $val ) { |
|
4178
|
|
|
if ( 0 < strlen( $val ) ) |
|
4179
|
|
|
$get[ $key ] = $val; |
|
4180
|
|
|
else |
|
4181
|
|
|
unset( $get[ $key ] ); |
|
4182
|
|
|
} |
|
4183
|
|
|
} |
|
4184
|
|
|
foreach ( $get as $k => $v ) { |
|
4185
|
|
|
if ( in_array( $k, $exclude ) ) |
|
4186
|
|
|
continue; |
|
4187
|
|
|
|
|
4188
|
|
|
if ( is_array( $v ) ) { |
|
4189
|
|
|
foreach ( $v as $vk => $vv ) { |
|
4190
|
|
|
?> |
|
4191
|
|
|
<input type="hidden" name="<?php echo esc_attr( $k ); ?>[<?php echo esc_attr( $vk ); ?>]" value="<?php echo esc_attr( $vv ); ?>" /> |
|
4192
|
|
|
<?php |
|
4193
|
|
|
} |
|
4194
|
|
|
} |
|
4195
|
|
|
else { |
|
4196
|
|
|
?> |
|
4197
|
|
|
<input type="hidden" name="<?php echo esc_attr( $k ); ?>" value="<?php echo esc_attr( $v ); ?>" /> |
|
4198
|
|
|
<?php |
|
4199
|
|
|
} |
|
4200
|
|
|
} |
|
4201
|
|
|
} |
|
4202
|
|
|
|
|
4203
|
|
|
/** |
|
4204
|
|
|
* @return array |
|
4205
|
|
|
*/ |
|
4206
|
|
|
public function exclusion () { |
|
4207
|
|
|
$exclusion = self::$excluded; |
|
4208
|
|
|
|
|
4209
|
|
|
foreach ( $exclusion as $k => $exclude ) { |
|
4210
|
|
|
$exclusion[ $k ] = $exclude . $this->num; |
|
4211
|
|
|
} |
|
4212
|
|
|
|
|
4213
|
|
|
return $exclusion; |
|
4214
|
|
|
} |
|
4215
|
|
|
|
|
4216
|
|
|
public function restricted ( $action = 'edit', $row = null ) { |
|
4217
|
|
|
$restricted = false; |
|
4218
|
|
|
|
|
4219
|
|
|
$restrict = array(); |
|
4220
|
|
|
|
|
4221
|
|
|
if ( isset( $this->restrict[ $action ] ) ) |
|
4222
|
|
|
$restrict = (array) $this->restrict[ $action ]; |
|
4223
|
|
|
|
|
4224
|
|
|
// @todo Build 'edit', 'duplicate', 'delete' action support for 'where' which runs another find() query |
|
4225
|
|
|
/*if ( !in_array( $action, array( 'manage', 'reorder' ) ) ) { |
|
|
|
|
|
|
4226
|
|
|
$where = pods_var_raw( $action, $this->where, null, null, true ); |
|
4227
|
|
|
|
|
4228
|
|
|
if ( !empty( $where ) ) { |
|
4229
|
|
|
$restricted = true; |
|
4230
|
|
|
|
|
4231
|
|
|
$old_where = $this->where[ $action ]; |
|
4232
|
|
|
|
|
4233
|
|
|
$id = $this->row[ $this->sql[ 'field_id' ] ]; |
|
4234
|
|
|
|
|
4235
|
|
|
if ( is_array( $where ) ) { |
|
4236
|
|
|
if ( 'OR' == pods_var( 'relation', $where ) ) |
|
4237
|
|
|
$where = array( $where ); |
|
4238
|
|
|
|
|
4239
|
|
|
$where[] = "`t`.`" . $this->sql[ 'field_id' ] . "` = " . (int) $id; |
|
4240
|
|
|
} |
|
4241
|
|
|
else |
|
4242
|
|
|
$where = "( {$where} ) AND `t`.`" . $this->sql[ 'field_id' ] . "` = " . (int) $id; |
|
4243
|
|
|
|
|
4244
|
|
|
$this->where[ $action ] = $where; |
|
4245
|
|
|
|
|
4246
|
|
|
$data = false; |
|
4247
|
|
|
|
|
4248
|
|
|
//$data = $this->get_data(); |
|
4249
|
|
|
|
|
4250
|
|
|
$this->where[ $action ] = $old_where; |
|
4251
|
|
|
|
|
4252
|
|
|
if ( empty( $data ) ) |
|
4253
|
|
|
$restricted = true; |
|
4254
|
|
|
} |
|
4255
|
|
|
}*/ |
|
4256
|
|
|
|
|
4257
|
|
|
$author_restrict = false; |
|
4258
|
|
|
|
|
4259
|
|
|
if ( !empty( $this->restrict[ 'author_restrict' ] ) && $restrict === $this->restrict[ 'author_restrict' ] ) { |
|
4260
|
|
|
$restricted = false; |
|
4261
|
|
|
|
|
4262
|
|
|
$author_restrict = true; |
|
4263
|
|
|
|
|
4264
|
|
|
if ( is_object( $this->pod ) ) { |
|
4265
|
|
|
$restricted = true; |
|
4266
|
|
|
|
|
4267
|
|
|
if ( 'settings' == $this->pod->pod_data[ 'type' ] && 'add' == $action ) |
|
4268
|
|
|
$action = 'edit'; |
|
4269
|
|
|
|
|
4270
|
|
|
if ( pods_is_admin( array( 'pods', 'pods_content' ) ) ) |
|
4271
|
|
|
$restricted = false; |
|
4272
|
|
|
elseif ( 'manage' == $action ) { |
|
4273
|
|
|
if ( !in_array( 'edit', $this->actions_disabled ) && current_user_can( 'pods_edit_' . $this->pod->pod ) && current_user_can( 'pods_edit_others_' . $this->pod->pod ) ) |
|
4274
|
|
|
$restricted = false; |
|
4275
|
|
|
elseif ( !in_array( 'delete', $this->actions_disabled ) && current_user_can( 'pods_delete_' . $this->pod->pod ) && current_user_can( 'pods_delete_others_' . $this->pod->pod ) ) |
|
4276
|
|
|
$restricted = false; |
|
4277
|
|
View Code Duplication |
elseif ( current_user_can( 'pods_' . $action . '_' . $this->pod->pod ) && current_user_can( 'pods_' . $action . '_others_' . $this->pod->pod ) ) |
|
4278
|
|
|
$restricted = false; |
|
4279
|
|
|
} |
|
4280
|
|
View Code Duplication |
elseif ( current_user_can( 'pods_' . $action . '_' . $this->pod->pod ) && current_user_can( 'pods_' . $action . '_others_' . $this->pod->pod ) ) |
|
4281
|
|
|
$restricted = false; |
|
4282
|
|
|
} |
|
4283
|
|
|
/* @todo determine proper logic for non-pods capabilities |
|
|
|
|
|
|
4284
|
|
|
else { |
|
4285
|
|
|
$restricted = true; |
|
4286
|
|
|
|
|
4287
|
|
|
if ( pods_is_admin( array( 'pods', 'pods_content' ) ) ) |
|
4288
|
|
|
$restricted = false; |
|
4289
|
|
|
elseif ( current_user_can( 'pods_' . $action . '_others_' . $_tbd ) ) |
|
4290
|
|
|
$restricted = false; |
|
4291
|
|
|
}*/ |
|
4292
|
|
|
} |
|
4293
|
|
|
|
|
4294
|
|
|
if ( $restricted && !empty( $restrict ) ) { |
|
4295
|
|
|
$relation = strtoupper( trim( pods_var( 'relation', $restrict, 'AND', null, true ) ) ); |
|
4296
|
|
|
|
|
4297
|
|
|
if ( 'AND' != $relation ) |
|
4298
|
|
|
$relation = 'OR'; |
|
4299
|
|
|
|
|
4300
|
|
|
$okay = true; |
|
4301
|
|
|
|
|
4302
|
|
|
foreach ( $restrict as $field => $match ) { |
|
4303
|
|
|
if ( 'relation' == $field ) |
|
4304
|
|
|
continue; |
|
4305
|
|
|
|
|
4306
|
|
|
if ( is_array( $match ) ) { |
|
4307
|
|
|
$match_okay = true; |
|
4308
|
|
|
|
|
4309
|
|
|
$match_relation = strtoupper( trim( pods_var( 'relation', $match, 'OR', null, true ) ) ); |
|
4310
|
|
|
|
|
4311
|
|
|
if ( 'AND' != $match_relation ) |
|
4312
|
|
|
$match_relation = 'OR'; |
|
4313
|
|
|
|
|
4314
|
|
|
foreach ( $match as $the_field => $the_match ) { |
|
4315
|
|
|
if ( 'relation' == $the_field ) |
|
4316
|
|
|
continue; |
|
4317
|
|
|
|
|
4318
|
|
|
$value = null; |
|
4319
|
|
|
|
|
4320
|
|
View Code Duplication |
if ( is_object( $this->pod ) ) |
|
4321
|
|
|
$value = $this->pod->field( $the_match, true ); |
|
4322
|
|
|
else { |
|
4323
|
|
|
if ( empty( $row ) ) |
|
4324
|
|
|
$row = $this->row; |
|
4325
|
|
|
|
|
4326
|
|
|
if ( isset( $row[ $the_match ] ) ) { |
|
4327
|
|
|
if ( is_array( $row[ $the_match ] ) ) { |
|
4328
|
|
|
if ( false !== strpos( $the_match, '.' ) ) { |
|
4329
|
|
|
$the_matches = explode( '.', $the_match ); |
|
4330
|
|
|
|
|
4331
|
|
|
$value = $row[ $the_match ]; |
|
4332
|
|
|
|
|
4333
|
|
|
foreach ( $the_matches as $m ) { |
|
4334
|
|
|
if ( is_array( $value ) && isset( $value[ $m ] ) ) |
|
4335
|
|
|
$value = $value[ $m ]; |
|
4336
|
|
|
else { |
|
4337
|
|
|
$value = null; |
|
4338
|
|
|
|
|
4339
|
|
|
break; |
|
4340
|
|
|
} |
|
4341
|
|
|
} |
|
4342
|
|
|
} |
|
4343
|
|
|
} |
|
4344
|
|
|
else |
|
4345
|
|
|
$value = $row[ $the_match ]; |
|
4346
|
|
|
} |
|
4347
|
|
|
} |
|
4348
|
|
|
|
|
4349
|
|
View Code Duplication |
if ( is_array( $value ) ) { |
|
4350
|
|
|
if ( !in_array( $the_match, $value ) ) |
|
4351
|
|
|
$match_okay = false; |
|
4352
|
|
|
elseif ( 'OR' == $match_relation ) { |
|
4353
|
|
|
$match_okay = true; |
|
4354
|
|
|
|
|
4355
|
|
|
break; |
|
4356
|
|
|
} |
|
4357
|
|
|
} |
|
4358
|
|
|
elseif ( $value == $the_match ) |
|
4359
|
|
|
$match_okay = false; |
|
4360
|
|
|
elseif ( 'OR' == $match_relation ) { |
|
4361
|
|
|
$match_okay = true; |
|
4362
|
|
|
|
|
4363
|
|
|
break; |
|
4364
|
|
|
} |
|
4365
|
|
|
} |
|
4366
|
|
|
|
|
4367
|
|
|
if ( !$match_okay ) |
|
4368
|
|
|
$okay = false; |
|
4369
|
|
|
if ( 'OR' == $relation ) { |
|
4370
|
|
|
$okay = true; |
|
4371
|
|
|
|
|
4372
|
|
|
break; |
|
4373
|
|
|
} |
|
4374
|
|
|
} |
|
4375
|
|
|
else { |
|
4376
|
|
|
$value = null; |
|
4377
|
|
|
|
|
4378
|
|
View Code Duplication |
if ( is_object( $this->pod ) ) |
|
4379
|
|
|
$value = $this->pod->field( $match, true ); |
|
4380
|
|
|
else { |
|
4381
|
|
|
if ( empty( $row ) ) |
|
4382
|
|
|
$row = $this->row; |
|
4383
|
|
|
|
|
4384
|
|
|
if ( isset( $row[ $match ] ) ) { |
|
4385
|
|
|
if ( is_array( $row[ $match ] ) ) { |
|
4386
|
|
|
if ( false !== strpos( $match, '.' ) ) { |
|
4387
|
|
|
$matches = explode( '.', $match ); |
|
4388
|
|
|
|
|
4389
|
|
|
$value = $row[ $match ]; |
|
4390
|
|
|
|
|
4391
|
|
|
foreach ( $matches as $m ) { |
|
4392
|
|
|
if ( is_array( $value ) && isset( $value[ $m ] ) ) |
|
4393
|
|
|
$value = $value[ $m ]; |
|
4394
|
|
|
else { |
|
4395
|
|
|
$value = null; |
|
4396
|
|
|
|
|
4397
|
|
|
break; |
|
4398
|
|
|
} |
|
4399
|
|
|
} |
|
4400
|
|
|
} |
|
4401
|
|
|
} |
|
4402
|
|
|
else |
|
4403
|
|
|
$value = $row[ $match ]; |
|
4404
|
|
|
} |
|
4405
|
|
|
} |
|
4406
|
|
|
|
|
4407
|
|
View Code Duplication |
if ( is_array( $value ) ) { |
|
4408
|
|
|
if ( !in_array( $match, $value ) ) |
|
4409
|
|
|
$okay = false; |
|
4410
|
|
|
elseif ( 'OR' == $relation ) { |
|
4411
|
|
|
$okay = true; |
|
4412
|
|
|
|
|
4413
|
|
|
break; |
|
4414
|
|
|
} |
|
4415
|
|
|
} |
|
4416
|
|
|
elseif ( $value != $match ) |
|
4417
|
|
|
$okay = false; |
|
4418
|
|
|
elseif ( 'OR' == $relation ) { |
|
4419
|
|
|
$okay = true; |
|
4420
|
|
|
|
|
4421
|
|
|
break; |
|
4422
|
|
|
} |
|
4423
|
|
|
} |
|
4424
|
|
|
} |
|
4425
|
|
|
|
|
4426
|
|
|
if ( !empty( $author_restrict ) ) { |
|
4427
|
|
|
if ( is_object( $this->pod ) && 'manage' == $action ) { |
|
4428
|
|
|
if ( !in_array( 'edit', $this->actions_disabled ) && !current_user_can( 'pods_edit_' . $this->pod->pod ) && !in_array( 'delete', $this->actions_disabled ) && !current_user_can( 'pods_delete_' . $this->pod->pod ) ) |
|
4429
|
|
|
$okay = false; |
|
4430
|
|
|
} |
|
4431
|
|
|
if ( is_object( $this->pod ) && !current_user_can( 'pods_' . $action . '_' . $this->pod->pod ) ) |
|
4432
|
|
|
$okay = false; |
|
4433
|
|
|
/* @todo determine proper logic for non-pods capabilities |
|
4434
|
|
|
elseif ( !current_user_can( 'pods_' . $action . '_' . $_tbd ) ) |
|
4435
|
|
|
$okay = false;*/ |
|
4436
|
|
|
|
|
4437
|
|
|
if ( !$okay && !empty( $row ) ) { |
|
4438
|
|
|
foreach ( $this->restrict[ 'author_restrict' ] as $key => $val ) { |
|
4439
|
|
|
$author_restricted = $this->get_field( $key ); |
|
4440
|
|
|
|
|
4441
|
|
|
if ( !empty( $author_restricted ) ) { |
|
4442
|
|
|
if ( !is_array( $author_restricted ) ) |
|
4443
|
|
|
$author_restricted = (array) $author_restricted; |
|
4444
|
|
|
|
|
4445
|
|
|
if ( is_array( $val ) ) { |
|
4446
|
|
|
foreach ( $val as $v ) { |
|
4447
|
|
|
if ( in_array( $v, $author_restricted ) ) |
|
4448
|
|
|
$okay = true; |
|
4449
|
|
|
} |
|
4450
|
|
|
} |
|
4451
|
|
|
elseif ( in_array( $val, $author_restricted ) ) |
|
4452
|
|
|
$okay = true; |
|
4453
|
|
|
} |
|
4454
|
|
|
} |
|
4455
|
|
|
} |
|
4456
|
|
|
} |
|
4457
|
|
|
|
|
4458
|
|
|
if ( $okay ) |
|
4459
|
|
|
$restricted = false; |
|
4460
|
|
|
} |
|
4461
|
|
|
|
|
4462
|
|
|
if ( isset( $this->actions_custom[ $action ] ) && is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ][ 'restrict_callback' ] ) && is_callable( $this->actions_custom[ $action ][ 'restrict_callback' ] ) ) { |
|
4463
|
|
|
$restricted = call_user_func( $this->actions_custom[ $action ][ 'restrict_callback' ], $restricted, $restrict, $action, $row, $this ); |
|
4464
|
|
|
} |
|
4465
|
|
|
|
|
4466
|
|
|
$restricted = $this->do_hook( 'restricted_' . $action, $restricted, $restrict, $action, $row ); |
|
4467
|
|
|
|
|
4468
|
|
|
return $restricted; |
|
4469
|
|
|
} |
|
4470
|
|
|
|
|
4471
|
|
|
/** |
|
4472
|
|
|
* Check for a custom action callback and run it |
|
4473
|
|
|
* |
|
4474
|
|
|
* @return bool|mixed |
|
4475
|
|
|
*/ |
|
4476
|
|
|
public function callback() { |
|
4477
|
|
|
|
|
4478
|
|
|
$args = func_get_args(); |
|
4479
|
|
|
|
|
4480
|
|
|
if ( empty( $args ) ) { |
|
4481
|
|
|
return false; |
|
4482
|
|
|
} |
|
4483
|
|
|
|
|
4484
|
|
|
$action = array_shift( $args ); |
|
4485
|
|
|
|
|
4486
|
|
|
// Do hook |
|
4487
|
|
|
$callback_args = $args; |
|
4488
|
|
|
array_unshift( $callback_args, null ); |
|
4489
|
|
|
array_unshift( $callback_args, $action ); |
|
4490
|
|
|
|
|
4491
|
|
|
$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args ); |
|
4492
|
|
|
|
|
4493
|
|
|
if ( null === $callback ) { |
|
4494
|
|
|
$callback = false; |
|
4495
|
|
|
} |
|
4496
|
|
|
|
|
4497
|
|
|
$args[] = $this; |
|
4498
|
|
|
|
|
4499
|
|
|
if ( isset( $this->actions_custom[ $action ] ) ) { |
|
4500
|
|
|
if ( is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ][ 'callback' ] ) && is_callable( $this->actions_custom[ $action ][ 'callback' ] ) ) { |
|
4501
|
|
|
$callback = call_user_func_array( $this->actions_custom[ $action ][ 'callback' ], $args ); |
|
4502
|
|
|
} |
|
4503
|
|
|
elseif ( is_callable( $this->actions_custom[ $action ] ) ) { |
|
4504
|
|
|
$callback = call_user_func_array( $this->actions_custom[ $action ], $args ); |
|
4505
|
|
|
} |
|
4506
|
|
|
} |
|
4507
|
|
|
|
|
4508
|
|
|
return $callback; |
|
4509
|
|
|
|
|
4510
|
|
|
} |
|
4511
|
|
|
|
|
4512
|
|
|
/** |
|
4513
|
|
|
* Check for a custom action callback and run it (deprecated reverse arg order) |
|
4514
|
|
|
* |
|
4515
|
|
|
* @return bool|mixed |
|
4516
|
|
|
*/ |
|
4517
|
|
View Code Duplication |
public function callback_action() { |
|
|
|
|
|
|
4518
|
|
|
|
|
4519
|
|
|
$args = func_get_args(); |
|
4520
|
|
|
|
|
4521
|
|
|
if ( empty( $args ) ) { |
|
4522
|
|
|
return false; |
|
4523
|
|
|
} |
|
4524
|
|
|
|
|
4525
|
|
|
$action = array_shift( $args ); |
|
4526
|
|
|
|
|
4527
|
|
|
$deprecated = false; |
|
4528
|
|
|
|
|
4529
|
|
|
if ( is_bool( $action ) ) { |
|
4530
|
|
|
$deprecated = $action; |
|
4531
|
|
|
|
|
4532
|
|
|
$action = array_shift( $args ); |
|
4533
|
|
|
} |
|
4534
|
|
|
|
|
4535
|
|
|
// Do hook |
|
4536
|
|
|
$callback_args = $args; |
|
4537
|
|
|
array_unshift( $callback_args, null ); |
|
4538
|
|
|
array_unshift( $callback_args, 'action_' . $action ); |
|
4539
|
|
|
|
|
4540
|
|
|
$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args ); |
|
4541
|
|
|
|
|
4542
|
|
|
if ( null === $callback ) { |
|
4543
|
|
|
$callback = false; |
|
4544
|
|
|
} |
|
4545
|
|
|
|
|
4546
|
|
|
$args[] = $this; |
|
4547
|
|
|
|
|
4548
|
|
|
// Deprecated reverse arg order |
|
4549
|
|
|
if ( $deprecated ) { |
|
4550
|
|
|
$args = array_reverse( $args ); |
|
4551
|
|
|
} |
|
4552
|
|
|
|
|
4553
|
|
|
if ( isset( $this->actions_custom[ $action ] ) ) { |
|
4554
|
|
|
if ( is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ][ 'callback' ] ) && is_callable( $this->actions_custom[ $action ][ 'callback' ] ) ) { |
|
4555
|
|
|
$callback = call_user_func_array( $this->actions_custom[ $action ][ 'callback' ], $args ); |
|
4556
|
|
|
} |
|
4557
|
|
|
elseif ( is_callable( $this->actions_custom[ $action ] ) ) { |
|
4558
|
|
|
$callback = call_user_func_array( $this->actions_custom[ $action ], $args ); |
|
4559
|
|
|
} |
|
4560
|
|
|
} |
|
4561
|
|
|
|
|
4562
|
|
|
return $callback; |
|
4563
|
|
|
|
|
4564
|
|
|
} |
|
4565
|
|
|
|
|
4566
|
|
|
/** |
|
4567
|
|
|
* Check for a bulk action callback and run it |
|
4568
|
|
|
* |
|
4569
|
|
|
* @return bool|mixed Callback result |
|
4570
|
|
|
*/ |
|
4571
|
|
View Code Duplication |
public function callback_bulk() { |
|
|
|
|
|
|
4572
|
|
|
|
|
4573
|
|
|
$args = func_get_args(); |
|
4574
|
|
|
|
|
4575
|
|
|
if ( empty( $args ) ) { |
|
4576
|
|
|
return false; |
|
4577
|
|
|
} |
|
4578
|
|
|
|
|
4579
|
|
|
$action = array_shift( $args ); |
|
4580
|
|
|
|
|
4581
|
|
|
$deprecated = false; |
|
4582
|
|
|
|
|
4583
|
|
|
if ( is_bool( $action ) ) { |
|
4584
|
|
|
$deprecated = $action; |
|
4585
|
|
|
|
|
4586
|
|
|
$action = array_shift( $args ); |
|
4587
|
|
|
} |
|
4588
|
|
|
|
|
4589
|
|
|
// Do hook |
|
4590
|
|
|
$callback_args = $args; |
|
4591
|
|
|
array_unshift( $callback_args, null ); |
|
4592
|
|
|
array_unshift( $callback_args, 'bulk_action_' . $action ); |
|
4593
|
|
|
|
|
4594
|
|
|
$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args ); |
|
4595
|
|
|
|
|
4596
|
|
|
if ( null === $callback ) { |
|
4597
|
|
|
$callback = false; |
|
4598
|
|
|
} |
|
4599
|
|
|
|
|
4600
|
|
|
$args[] = $this; |
|
4601
|
|
|
|
|
4602
|
|
|
// Deprecated reverse arg order |
|
4603
|
|
|
if ( $deprecated ) { |
|
4604
|
|
|
$args = array_reverse( $args ); |
|
4605
|
|
|
} |
|
4606
|
|
|
|
|
4607
|
|
|
if ( isset( $this->actions_bulk[ $action ] ) ) { |
|
4608
|
|
|
if ( is_array( $this->actions_bulk[ $action ] ) && isset( $this->actions_bulk[ $action ][ 'callback' ] ) && is_callable( $this->actions_bulk[ $action ][ 'callback' ] ) ) { |
|
4609
|
|
|
$callback = call_user_func_array( $this->actions_bulk[ $action ][ 'callback' ], $args ); |
|
4610
|
|
|
} |
|
4611
|
|
|
elseif ( is_callable( $this->actions_bulk[ $action ] ) ) { |
|
4612
|
|
|
$callback = call_user_func_array( $this->actions_bulk[ $action ], $args ); |
|
4613
|
|
|
} |
|
4614
|
|
|
} |
|
4615
|
|
|
|
|
4616
|
|
|
return $callback; |
|
4617
|
|
|
|
|
4618
|
|
|
} |
|
4619
|
|
|
|
|
4620
|
|
|
/* |
|
|
|
|
|
|
4621
|
|
|
// Example code for use with $this->do_hook |
|
4622
|
|
|
public function my_filter_function ($args, $obj) { |
|
4623
|
|
|
$obj[0]->item = 'Post'; |
|
4624
|
|
|
$obj[0]->add = true; |
|
4625
|
|
|
// args are an array (0 => $arg1, 1 => $arg2) |
|
4626
|
|
|
// may have more than one arg, dependant on filter |
|
4627
|
|
|
return $args; |
|
4628
|
|
|
} |
|
4629
|
|
|
add_filter('pods_ui_post_init', 'my_filter_function', 10, 2); |
|
4630
|
|
|
*/ |
|
4631
|
|
|
/** |
|
4632
|
|
|
* @return array|bool|mixed|null |
|
4633
|
|
|
*/ |
|
4634
|
|
View Code Duplication |
private function do_hook() { |
|
|
|
|
|
|
4635
|
|
|
|
|
4636
|
|
|
$args = func_get_args(); |
|
4637
|
|
|
|
|
4638
|
|
|
if ( empty( $args ) ) { |
|
4639
|
|
|
return false; |
|
4640
|
|
|
} |
|
4641
|
|
|
|
|
4642
|
|
|
$name = array_shift( $args ); |
|
4643
|
|
|
|
|
4644
|
|
|
return pods_do_hook( "ui", $name, $args, $this ); |
|
4645
|
|
|
|
|
4646
|
|
|
} |
|
4647
|
|
|
} |
|
4648
|
|
|
|
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.