-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathacp-editing-save_value.php
40 lines (34 loc) · 1.07 KB
/
acp-editing-save_value.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
<?php
/**
* Filter for changing the value before storing it to the DB
*
* @param mixed $value Value send from inline edit ajax callback
* @param AC\Column $column Column object
* @param int $id Post/User/Comment ID
*
* @return string
*/
function my_acp_editable_ajax_column_save_value($value, AC\Column $column, $id)
{
// Possibly modify $value
return $value;
}
add_filter('acp/editing/save_value', 'my_acp_editable_ajax_column_save_value', 10, 3);
/**
* Change the value to a timestamp for a specific custom field
*
* @param string $value
* @param AC\Column $column
*
* @return string
*/
function acp_editing_change_date_format_for_custom_field($value, AC\Column $column)
{
if ($column instanceof ACP\Column\CustomField && 'date' == $column->get_field_type(
) && 'my_date_field_key' === $column->get_meta_key() && $value) {
// Convert submitted value to a unix timestamp
$value = strtotime($value);
}
return $value;
}
add_filter('acp/editing/save_value', 'acp_editing_change_date_format_for_custom_field', 10, 2);