Skip to content
This repository was 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
catlauraherzog wants to merge 2 commits intoinpsyde:masterfrom
catlauraherzog:master
Closed

Implemented additional filter to change the output of the list for linked elements#228
catlauraherzog wants to merge 2 commits intoinpsyde:masterfrom
catlauraherzog:master

Conversation

@catlauraherzog
Copy link
Copy Markdown
Contributor

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.

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

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

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
Copy Markdown
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
Copy Markdown
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? :)

@tfrommen tfrommen added this to the v3.0.0 milestone Aug 30, 2016
return apply_filters( 'show_linked_elements', $output, $items, $params );

/**
* Filter the output of the linked elementes
Copy link
Copy Markdown

@GaryJones GaryJones Aug 30, 2016

Choose a reason for hiding this comment

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

Typo - extra e, and no full stop.

No @since.

@tfrommen
Copy link
Copy Markdown
Member

Closed with b03cd6f.

@tfrommen tfrommen closed this Dec 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants