[wp-trac] [WordPress Trac] #37906: Filter to short-circuit do_shortcode_tag
WordPress Trac
noreply at wordpress.org
Thu Sep 1 11:32:20 UTC 2016
#37906: Filter to short-circuit do_shortcode_tag
-------------------------------------+-----------------------
Reporter: ideag | Owner: ideag
Type: enhancement | Status: assigned
Priority: normal | Milestone: 4.7
Component: Shortcodes | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-refresh | Focuses:
-------------------------------------+-----------------------
Changes (by pento):
* keywords: has-patch needs-unit-tests => has-patch needs-refresh
* owner: => ideag
* status: new => assigned
Comment:
Nice work, @ideag!
There are a handful of small changes I'd like you to make.
- Please put the tests in `tests/shortcode.php`, not `tests/filters.php`.
`filters.php` is just for testing the filter handling methods, testing an
actual filter belongs in the file related to the area of code where the
filter runs.
- Don't use `rand_str()` to generate the shortcode. There's a chance
(however small), that it could collide with an existing shortcode, unit
tests should be as deterministic as possible. Naming the shortcode
something related to the new filter will be unique, in the context of the
tests.
- We still support PHP 5.2, so the shortcode lambda functions actually
need to be methods. The general naming convention for filter helper
methods is to prefix them with `_filter_`, like test methods are prefixed
`test_`.
- Clean up at the end of the test - remove the filters and shortcode. We
try to keep unit tests as self-contained as possible, to avoid side
effects on tests that run later.
- Please put both the tests and the new filter in the same patch, it makes
them easier for folks to apply to their dev installs.
All up, it's looking quite good, thank you for taking the time to get it
done! :-)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37906#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list