manage_plugins_custom_column

Home » Hooks » manage_plugins_custom_column

Hook Name: manage_plugins_custom_column

WordPress hook manage_plugins_custom_column is used to add or modify custom columns in the Plugins page of the WordPress admin dashboard. This hook allows developers to customize the display of plugin-related information in the table columns.

By using this hook, developers can add their own column headers and populate them with custom data for each plugin listed in the Plugins page. This is particularly useful when additional information about plugins needs to be displayed, such as custom status indicators, activation dates, or any other relevant plugin-specific details.

To make use of this hook, developers need to create a callback function and hook it to the manage_plugins_custom_column action. This callback function will be responsible for rendering the custom content within the custom column for each plugin.

Example Usage:

// Add a custom column header
function custom_plugins_column_header($columns) {
    $columns['custom_column'] = 'Custom Column';
    return $columns;
}
add_filter('manage_plugins_columns', 'custom_plugins_column_header');

// Populate the custom column with data for each plugin
function custom_plugins_column_content($column, $plugin_file) {
    if ($column === 'custom_column') {
        // Display custom data for each plugin, e.g., plugin activation date
        echo 'Activated on: ' . get_option('activation_date_' . $plugin_file);
    }
}
add_action('manage_plugins_custom_column', 'custom_plugins_column_content', 10, 2);

In this example, we start by adding a custom column header in the Plugins page using the manage_plugins_columns filter. We define a function custom_plugins_column_header that adds our custom column with the label "Custom Column" to the existing columns array.

Next, we create another function custom_plugins_column_content and hook it to the manage_plugins_custom_column action. This function checks if the column being rendered is our custom column. If it is, we can retrieve and display the custom data specific to each plugin by accessing the plugin file name and using it to fetch the corresponding activation date from the options table.

By customizing this hook and using our own callback functions, we can extend the functionality of the Plugins page and display additional information that is relevant to our specific project or requirements.

Learn More on WordPress.org

WordPress snippets using the manage_plugins_custom_column hook

Register an account to save your snippets or go Pro to get more features.