codepress-admin-columns
Last commit date
assets
10 years ago
classes
10 years ago
external
10 years ago
includes
10 years ago
languages
10 years ago
api.php
10 years ago
codepress-admin-columns.php
10 years ago
readme.txt
10 years ago
api.php
37 lines
| 1 | <?php |
| 2 | /** |
| 3 | * If you like to register a column of your own please have a look at our documentation. |
| 4 | * We also have a free start-kit available, which contains all the necessary files. |
| 5 | * |
| 6 | * Documentation: https://www.admincolumns.com/documentation/developer-docs/creating-new-column-type/ |
| 7 | * Starter-kit: https://github.com/codepress/cac-column-template/ |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * Manually set the columns for a storage model |
| 13 | * This overrides the database settings and thus renders the settings screen for this storage model useless |
| 14 | * |
| 15 | * @since 2.2 |
| 16 | * |
| 17 | * @param string $storage_model Storage model key |
| 18 | * @param array $columns List of columns ([column_name] => [column_options]) |
| 19 | */ |
| 20 | function ac_register_columns( $storage_model, $columns ) { |
| 21 | global $_cac_exported_columns; |
| 22 | |
| 23 | $storage_models = (array) $storage_model; |
| 24 | |
| 25 | foreach ( $storage_models as $storage_model ) { |
| 26 | if ( isset( $_cac_exported_columns[ $storage_model ] ) ) { |
| 27 | $_cac_exported_columns[ $storage_model ] = array_merge( $_cac_exported_columns[ $storage_model ], $columns ); |
| 28 | } |
| 29 | else { |
| 30 | $_cac_exported_columns[ $storage_model ] = $columns; |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | function cpac_set_storage_model_columns( $storage_model, $columns ) { |
| 36 | ac_register_columns( $storage_model, $columns ); |
| 37 | } |