acp/editing/view_settings

This Filter acp/editing/view_settings allows 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 2 ways to hook into acp/editing/view_settings.

  • acp/editing/view_settings – filter for every column
  • acp/editing/view_settings/[column-type] – filter for a specific column-type
/**
 * Filters the Editing settings for a column
 *
 * Filter acp/editing/view_settings
 * Filter acp/editing/view_settings/{$type}
 *
 * @param array     $data     {
 *
 * @type string     $type     Editability type. Accepts 'text', 'select', 'textarea', 'media', 'float', 'togglable', 'select', 'select2_dropdown' and 'select2_tags'
 * @type array      $options  Optional. Options for dropdown ([value] => [label]), only used when $type is "select"
 * @type boolean    $multiple Multiple values possible for select types
 * }
 *
 * @param AC_Column $column
 *
 */
function my_acp_editing_settings( $data, $column ) {

	// Possibly modify $editable

	return $data;
}

add_filter( 'acp/editing/view_settings', 'my_acp_editing_settings', 10, 2 );

Example

By default the inline edit for Custom Fields only allows editing with text field. The example below shows how you can change the field to a dropdown with populated values for a specific custom field.

/**
 * Change inline eit for a specific custom field to a prefilled drop down
 *
 * @param $data   array
 * @param $column AC_Column
 *
 * @return mixed
 */
function my_acp_custom_field_editing_selectbox( $data, $column ) {

	if ( $column instanceof ACP_Column_CustomField ) {

		if ( 'my_fruit_custom_field' === $column->get_meta_key() ) {
			$data['type'] = 'select';
			$data['options'] = array(
				'apple'  => 'Apple',
				'orange' => 'Orange',
				'banana' => 'Banana',
				'pear'   => 'Pear',
			);
		}

	}

	return $data;
}

add_filter( 'acp/editing/view_settings', 'my_acp_custom_field_editing_selectbox', 10, 2 );

Legacy

The following filters are replaced by acp/editing/view_settings since Admin Columns Pro 4.0.
cac/editable/options
cac/editable/editables_data