api.php
1.2 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
<?php
/**
* If you like to register a column of your own please have a look at our documentation.
* We also have a free start-kit available, which contains all the necessary files.
*
* Documentation: https://www.admincolumns.com/documentation/developer-docs/creating-new-column-type/
* Starter-kit: https://github.com/codepress/cac-column-template/
*
*/
/**
* Manually set the columns for a storage model
* This overrides the database settings and thus renders the settings screen for this storage model useless
*
* @since 2.2
*
* @param string $storage_model Storage model key
* @param array $columns List of columns ([column_name] => [column_options])
*/
function ac_register_columns( $storage_model, $columns ) {
global $cpac;
$storage_models = (array) $storage_model;
foreach ( $storage_models as $storage_model ) {
if ( isset( $cpac->exported_columns[ $storage_model ] ) ) {
$cpac->exported_columns[ $storage_model ] = array_merge( $cpac->exported_columns[ $storage_model ], $columns );
}
else {
$cpac->exported_columns[ $storage_model ] = $columns;
}
}
}
function cpac_set_storage_model_columns( $storage_model, $columns ) {
ac_register_columns( $storage_model, $columns );
}