-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathManageValue.php
52 lines (40 loc) · 1.37 KB
/
ManageValue.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
namespace AC\Table;
use AC\Column;
use AC\ColumnRepository;
use AC\Registerable;
use AC\Sanitize\Kses;
abstract class ManageValue implements Registerable
{
private $column_repository;
public function __construct(ColumnRepository $column_repository)
{
$this->column_repository = $column_repository;
}
public function render_cell(string $column_name, $id, string $fallback_value = null): ?string
{
$column = $this->column_repository->find($column_name);
if ( ! $column) {
return $fallback_value;
}
$value = $column->get_value($id);
if (is_scalar($value) && apply_filters('ac/column/value/sanitize', true, $column, $id)) {
$value = (new Kses())->sanitize((string)$value);
}
// You can overwrite the display value for original columns by making sure get_value() does not return an empty string.
if ($column->is_original() && ac_helper()->string->is_empty($value)) {
return $fallback_value;
}
/**
* Column display value
*
* @param string $value Column display value
* @param int $id Object ID
* @param Column $column Column object
*
* @since 3.0
*/
return (string)apply_filters('ac/column/value', $value, $id, $column);
}
}