-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathac-editing-saved.php
More file actions
57 lines (51 loc) · 1.67 KB
/
ac-editing-saved.php
File metadata and controls
57 lines (51 loc) · 1.67 KB
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
53
54
55
56
57
<?php
/**
* The ac/editing/saved action fires after the value of a column is stored when using Inline Edit.
*/
/**
* Fires after a inline-edit saved a value
*/
function ac_editing_saved_usage(AC\Column\Context $column, $id, $value, AC\TableScreen $table)
{
// Place your code here
}
add_action('ac/editing/saved', 'ac_editing_saved_usage', 10, 4);
/**
* In this example we will save the submitted value to second custom field.
*/
add_action(
'ac/editing/saved',
static function (AC\Column\Context $column, $id, $value, AC\TableScreen $table) {
if (
$table instanceof AC\PostType &&
$table->get_post_type()->equals('page') &&
$column instanceof AC\Column\CustomFieldContext &&
'my_custom_field' === $column->get_meta_key()
) {
// Modify the value here
// $value = $value * 2;
update_post_meta($id, 'my_second_custom_field', $value);
}
},
10,
4
);
/**
* By default, the post modified date is not always updated when using inline or bulk edit with Admin Column Pro.
* For example, when updating metadata the `wp_update_post` is not called, which is the call that set then post's modified date.
* In this example we will trigger this call manually.
*/
add_action(
'ac/editing/saved',
static function (AC\Column\Context $column, $id, $value, AC\TableScreen $table) {
if (
$table instanceof AC\PostType &&
$table->get_post_type()->equals('post')
) {
// Update the `modified_date` after making any changes using inline or bulk editing
wp_update_post(['ID' => $id]);
}
},
10,
4
);