Filters the headings array before output.
$headings is an array of items, where each item has the following offsets:
- id
- title
- depth
- url
add_filter('joli_toc_headings', 'filter_headings', 10, 2);
// Example how to capitalize all the headings
function filter_headings( $headings ){
$headings = array_map(function($heading){
//for H2 only
if ($heading['depth'] == 2){
//Capitalizes the first word only
$heading['title'] = ucfirst(strtolower($heading['title']));
}
return $heading;
}, $headings);
return $headings;
}
add_filter('joli_toc_headings', 'edit_headings', 10, 2);
// Example how to add a custom link to a specific heading
function edit_headings( $headings ){
$headings = array_map(function($heading){
if ($heading['id'] == 'target-id'){
//edit id
$heading['url'] = 'https://customlink.com';
}
return $heading;
}, $headings);
return $headings;
}