Closed louwers closed 4 years ago
Here's a link to hide whitespace changes:
https://github.com/dokufreaks/plugin-include/pull/243/files?diff=split&w=1
Sorry for requesting yet another change. The include plugin is just really complex and while thinking about it I noticed that it would be beneficial to filter pages earlier. While the current implementation should work and should be okay, I think it would be much cleaner to do the exclusion in _get_included_pages
in helper.php
, more precisely in line 735, i.e., after collecting the pages but before sorting. We already have $flags
passed to this function, so all necessary data should be there. Apart from being slightly cleaner software design imho, this has two benefits:
_get_included_pages
is stored in the metadata and the page is re-rendered only if one of them changes. By directly excluding excluded pages, less checks will be necessary and the page can be cached more often.You should be able to use array_filter with a simple lambda to filter the pages.
No problem! I'll look into it. :+1:
Thank you very much for your contribution and for adapting the code! The code could be further improved by moving the check if the flag is set out of the loop and instead of returning true
/false
, the (negation of) the condition could be returned directly, but this is minor nitpicking and I will just merge it as it is. Could you then please also adapt the documentation?
This PR adds an 'exclude' option that takes a regular expression as value. Pages of which the id matches the regular expression will be excluded. E.g.:
Looking at the diff, my editor also removed some trailing whitespace...