Type
Action
Arguments
int $licence_id
array $args
Description
This filter allows developers to modify the columns displayed in the license details table within the my-licence-manage.php template file. By using this filter, you can append additional columns, remove existing ones, or change the content of the default columns. The default columns include License Key, Status, Domain, and Action.
Example of usage
The following example demonstrates how to add a new column called “Creation Date” to the license details table, which displays the creation date of each license. Keep in mind you have to add a table “Creation Date” header in the my-licence-manage.php template file, as explained in the article Update the License templates
add_filter('woo_sl/interface/license_keys_meta_box/td', 'theme_add_create_date_column', 10, 3);
function theme_add_create_date_column($licence_id, $args)
{
// Retrieve the license details using the licence ID.
$license_data = WOO_SL_functions::get_licence_key_data_by_licence_id($licence_id);
// Extract the expiration date from the license data, or default to 'N/A' if not set.
$created_date = isset ( $license_data->created ) ? $license_data->created : __('N/A', 'software-license');
// Build the expiration date column as an HTML <td> element.
$args['columns']['created_date'] = '<td>' . esc_html( $created_date ) . '</td>';
return $args;
}
In this example:
– The filter woo_sl/interface/license_keys_meta_box/td is hooked into a custom function theme_add_expiration_date_column.
– The $columns array contains all the existing table columns, each defined as an HTML <td> element.
– The custom function appends a new column to display the license’s creation date. If no creation date is found, it returns “N/A”.
– The $order_item_id and $license_group_id parameters are used to retrieve the relevant order and license details necessary for extracting the expiration date.
By using this filter, you can easily extend or customize the license details table to include any additional information you wish to display.
Read more