cac/editable/editables_data

Deprecated This documentation is deprecated since Admin Columns version 4.
Please view the updated version of this documentation here.

The filter cac/editable/editables_data allow you to set the editable settings for a column. Use this filter to set what type of editable field the column should use, for example a text or select field.

Usage

There are 4 ways to hook into cac/editable/editables_data.

  • cac/editable/editables_data – filter for every column
  • cac/editable/editables_data/type=[type] – filter for a specific type: post, user, media, comment or taxonomy
  • cac/editable/editables_data/post_type=[post type] – filter for a specific post type
  • cac/editable/editables_data/taxonomy=[taxonomy] – filter for a specific taxonomy
/**
 * Filtering: change editability settings for a column
 *
 * Filter cac/editable/editables_data
 * Filter cac/editable/editables_data/type=[type]
 * Filter cac/editable/editables_data/post_type=[post type]
 * Filter cac/editable/editables_data/taxonomy=[taxonomy]
 *
 * @param array $data {
 *      Editability settings.
 *
 *      @type bool      $default_column Whether the column is a default column not yet handled by Admin Columns itself
 *      @type string	$type			Editability type. Accepts 'text', 'select', 'textarea', 'media', 'float', 'togglable', 'select', 'select2_dropdown' and 'select2_tags'
 *      @type string    $placeholder    Optional. Set a placeholder text for the input field when empty.
 *      @type array     $options        Optional. Options for dropdown ([value] => [label]), only used when $type is "select"
 *      @type array     $selector       Optional. Change the jQuery selector for the edit button to trigger on a specific element.
 * }
 * @param CACIE_Editable_Model $editable_model Editability storage model
 */
function my_cac_editable_column_settings( $editable_data, $editable_model ) {

	// Possibly modify $editable_data

	return $editable_data;
}
add_filter( 'cac/editable/editables_data', 'my_cac_editable_column_settings', 10, 2 );

// For a specific type
add_filter( 'cac/editable/editables_data/type=[type]', 'my_cac_editable_column_settings', 10, 2 );  // 'post', 'user', 'media', 'taxonomy' or 'comment'
add_filter( 'cac/editable/editables_data/post_type=[post type]', 'my_cac_editable_column_settings', 10, 2 ); // 'page', 'post', etc.
add_filter( 'cac/editable/editables_data/post_type=[taxonomy]', 'my_cac_editable_column_settings', 10, 2 ); // 'category', 'post_tag', etc.

Parameters

Editability settings has several parameters.

default_column 
Whether the column is a default column not yet handled by Admin Columns itself. Set this to ‘true’.

type
Accepts ‘text’, ‘select’, ‘textarea’, ‘media’, ‘float’, ‘togglable’, ‘select’, ‘select2_dropdown’ and ‘select2_tags’.

placeholder
(Optional) Set a placeholder text for when the field empty, only used when type is ‘text’.

options
(Optional) Options for dropdown, only used when type is ‘select’ or ‘togglable’.

selector
(Optional) Change the jQuery selector for the edit button to trigger on a specific element.

Example

In this example we define the editable settings for the Title SEO column ( WordPress SEO by Yoast ). When you add support for an existing column make sure you set default_column to true.

// Editable settings for the Title SEO column ( WordPress SEO by Yoast )

function my_cac_editable_column_settings_seo_title( $editable_data, $model ) {
	$editable_data['wpseo-title'] = array(
		'default_column' => true,
		'type' => 'text',
		'placeholder' => __( 'Enter new SEO Title', 'cac-post_seo_title' )
	);
	return $editable_data;
}
add_filter( 'cac/editable/editables_data', 'my_cac_editable_column_settings_seo_title', 10, 2 );

Tutorial

You can make your own created column editable in just minutes with our tutorial on how to make a column editable.