Implemented additional filter to change the output of the list for linked elements#228
Implemented additional filter to change the output of the list for linked elements#228catlauraherzog wants to merge 2 commits intoinpsyde:masterfrom catlauraherzog:master
Conversation
src/inc/common/Mlp_Helpers.php
Outdated
| $output .= '</ul></div>'; | ||
|
|
||
| return $output; | ||
| return apply_filters( 'show_linked_elements', $output, $items, $params ); |
There was a problem hiding this comment.
I think this filter name should have a prefix, to avoid clashes with other plugins which might have the exact same hook name.
There was a problem hiding this comment.
In my opinon mlp_linked_elements_html would better fit the existing filters.
There was a problem hiding this comment.
In my opinon
mlp_linked_elements_htmlwould better fit the existing filters.
That's exactly what it will be. 👍
We don't name filter hooks just like the function/method they live in, but choose more sensible names. show_linked_elements (prefixed or not) may be misinterpreted as some sort of boolean switch for some functionality.
So mlp_linked_elements_html it is.
Also, for the sake of easier debugging, the result of the filter should be cached in the $output variable, which is returned the line after that. This way, one can step through the code, and easily see the original output and the filtered one.
Lastly, the filter is lacking appropriate documentation. Please see this one as an example.
@DasLlama would you like to take care of that, or do you just want this included? :)
| return apply_filters( 'show_linked_elements', $output, $items, $params ); | ||
|
|
||
| /** | ||
| * Filter the output of the linked elementes |
There was a problem hiding this comment.
Typo - extra e, and no full stop.
No @since.
|
Closed with b03cd6f. |
We want to use different markup for our project. So we need a filter to change the output of show_linked_elements(). I've also added the $items and $params to this filter for additional logical stuff.