Using WordPress ‘manage_{$this->screen->id}_custom_column_js_template’ PHP action

The manage_{$this->screen->id}_custom_column_js_template WordPress PHP action allows you to add custom JavaScript templates for each custom column in the Application Passwords list table.

Usage

add_action('manage_application-passwords-user_custom_column_js_template', 'your_custom_function', 10, 1);

function your_custom_function($column_name) {
  // your custom code here
}

Parameters

  • $column_name (string) – Name of the custom column.

More information

See WordPress Developer Resources: manage_{$this->screen->id}_custom_column_js_template

Custom columns are registered using the manage_application-passwords-user_columns filter.

Examples

Add a JavaScript template for a custom column

This example demonstrates how to add a JavaScript template for a custom column called “my_custom_column” in the Application Passwords list table.

add_action('manage_application-passwords-user_custom_column_js_template', 'add_my_custom_column_js_template', 10, 1);

function add_my_custom_column_js_template($column_name) {
  if ($column_name === 'my_custom_column') {
    // Add your custom JavaScript template for the column here
    echo '<td class="my-custom-column" data-colname="my_custom_column">{{data.my_custom_data}}</td>';
  }
}

Add multiple JavaScript templates for custom columns

This example shows how to add JavaScript templates for multiple custom columns in the Application Passwords list table.

add_action('manage_application-passwords-user_custom_column_js_template', 'add_multiple_custom_column_js_templates', 10, 1);

function add_multiple_custom_column_js_templates($column_name) {
  switch ($column_name) {
    case 'custom_column_1':
      // Add your custom JavaScript template for custom_column_1 here
      echo '<td class="custom-column-1" data-colname="custom_column_1">{{data.custom_data_1}}</td>';
      break;

    case 'custom_column_2':
      // Add your custom JavaScript template for custom_column_2 here
      echo '<td class="custom-column-2" data-colname="custom_column_2">{{data.custom_data_2}}</td>';
      break;
  }
}