Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Implemented additional filter to change the output of the list for linked elements #228

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/inc/common/Mlp_Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public static function show_linked_elements( $args ) {

$output .= '</ul></div>';

return $output;
return apply_filters( 'show_linked_elements', $output, $items, $params );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this filter name should have a prefix, to avoid clashes with other plugins which might have the exact same hook name.

Copy link
Member

@tyrann0us tyrann0us Aug 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinon mlp_linked_elements_html would better fit the existing filters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinon mlp_linked_elements_html would 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? :)

}

/**
Expand Down