codepress-admin-columns
Last commit date
assets
11 years ago
classes
11 years ago
external
11 years ago
includes
11 years ago
languages
11 years ago
api.php
11 years ago
codepress-admin-columns.php
11 years ago
readme.txt
11 years ago
api.php
32 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Manually set the columns for a storage model |
| 4 | * This overrides the database settings and thus renders the settings screen for this storage model useless |
| 5 | * |
| 6 | * @since 2.2 |
| 7 | * |
| 8 | * @param string $storage_model Storage model key |
| 9 | * @param array $columns List of columns ([column_name] => [column_options]) |
| 10 | */ |
| 11 | function cpac_set_storage_model_columns( $storage_model, $columns ) { |
| 12 | global $_cac_exported_columns; |
| 13 | $_cac_exported_columns[ $storage_model ] = $columns; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Set exported columns |
| 18 | * |
| 19 | * @since 3.2 |
| 20 | */ |
| 21 | function cpac_set_exported_columns( $cpac ) { |
| 22 | global $_cac_exported_columns; |
| 23 | if ( $_cac_exported_columns ) { |
| 24 | foreach( $_cac_exported_columns as $model => $columns ) { |
| 25 | if ( $storage_model = $cpac->get_storage_model( $model ) ) { |
| 26 | $storage_model->set_stored_columns( $columns ); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | add_action( 'cac/loaded', 'cpac_set_exported_columns', 5 ); |
| 32 |