/
custom_fields.php
59 lines (49 loc) · 1.56 KB
/
custom_fields.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
53
54
55
56
57
58
59
<?php
api_expose_admin('fields/reorder');
api_expose_admin('fields/delete');
api_expose_admin('fields/make');
api_expose_admin('fields/save');
function get_custom_field_by_id($id)
{
return mw()->fields_manager->getById($id);
}
api_bind_admin('fields/save', 'save_custom_field');
function save_custom_field($data)
{
return mw()->fields_manager->save($data);
}
function delete_custom_field($data)
{
return mw()->fields_manager->delete($data);
}
api_bind_admin('fields/make', 'make_custom_field');
function make_custom_field($field_id = 0, $field_type = 'text', $settings = false)
{
return mw()->fields_manager->make($field_id, $field_type, $settings);
}
function custom_field_value($content_id, $field_name, $table = 'content')
{
return mw()->fields_manager->get_value($content_id, $field_name, $table);
}
function get_custom_fields($table, $id = 0, $return_full = false, $field_for = false, $debug = false, $field_type = false, $for_session = false)
{
if (isset($table) and !is_array($table) and intval($table) > 0) {
$id = intval(intval($table));
$table = 'content';
}
return mw()->fields_manager->get([
'rel_type' => $table,
'rel_id' => $id,
'return_full' => $return_full,
'name' => $field_for,
'debug' => $debug,
'type' => $field_type,
'session_id' => $for_session
]);
}
api_bind_admin('fields/delete', function ($data) {
return mw()->fields_manager->delete($data);
});
api_bind_admin('fields/reorder', function ($data) {
return mw()->fields_manager->reorder($data);
});