How to use exported column settings

PHP exported columns can be used to load all columns settings from your theme or plugin.

Usage

1. Export your column settings to PHP

export_import

2. Copy the results.

export_result

3. Paste the results in  your theme’s functions.php or plugin, and make sure it’s within the init action. ( see a full example below )

<?php
/*
Plugin Name: Admin Column - Column Settings
Version: 1.0
Description: Load column settings with PHP for Admin Columns
*/
function my_plugin_load_admin_column_settings() {

	// Place the exported column settings here

}
add_action( 'init', 'my_plugin_load_admin_column_settings' );

4. That’s it! You column settings will now load from the exported settings

export_settings

Example

In this example we exported the post column settings and included it in our functions.php. Just make sure the settings are within the init action.

<?php
/**
 * Load column settings with PHP for Admin Columns
 *
 * Usage: export the column settings to php, then
 * place the settings inside init action.
 */
function my_load_admin_column_settings() {
	if ( function_exists( 'ac_register_columns' ) ) {

		// Post column settings
		ac_register_columns( 'post', array(
			'column-status' => array(
				'column-name' => 'column-status',
				'type' => 'column-status',
				'clone' => '',
				'label' => 'Status',
				'width' => '10%',
				'filter' => 'on',
				'sort' => 'on',
				'edit' => 'on',
				'active' => 'on'
			)
		) );
	}
}
add_action( 'init', 'my_load_admin_column_settings' );

Plugin

You can also load your settings into a seperate plugin. This is usefull when you develop locally and want use the exported column settings on a production (live) site. Just add your settings to this plugin and activate it on your production site.

<?php
/*
Plugin Name: Admin Column - Column Settings
Version: 1.0
Description: Load column settings with PHP for Admin Columns
*/
function my_plugin_load_admin_column_settings() {

	// Place the exported column settings here

}
add_action( 'init', 'my_plugin_load_admin_column_settings' );