#43850 closed enhancement (fixed)
Add privacy policy URL template tags
Reported by: | iandunn | Owned by: | iandunn |
---|---|---|---|
Milestone: | 4.9.6 | Priority: | normal |
Severity: | normal | Version: | 5.1 |
Component: | Privacy | Keywords: | gdpr fixed-major has-dev-note |
Focuses: | ui, administration | Cc: |
Description
( This is a split off of ticket:43620#comment:30, since this has grown enough to warrant its own ticket. )
#43620 introduced get_privacy_policy_url()
for retrieving the URL of the Privacy Policy page. Themes and plugins are going to need template tags and a filter in order to work modify the URL and generate links to it.
The latest patch before splitting the tickets was 43620.policy_url.policy_link_4.diff.
Attachments (2)
Change History (18)
#2
@
6 years ago
@iandunn Thanks for creating the ticket, it makes things easier to reference.
No problem, I just attached what I had done so far, just in case something might be of any use here.
Regarding the (multiple) numbered placeholders, when not used for translation, it's more of a preference. We see it e.g. in the default themes.
There were few tests for each function in 43850.diff, so I preferred creating a new file for each one. But it looks like I used the wrong link
group reference but should have taken the url
group reference ;-)
#3
follow-up:
↓ 5
@
6 years ago
43850.2.diff merges the tests from 43620.policy_url.policy_link_4.diff and 43850.diff. @birgire, can you take a look and let me know what you think?
Based on the the docs, it sounds like tests/link/getThePrivacyPolicyLink.php
and tests/url/getThePrivacyUrl.php
are the best places for these. test/url/
didn't exist previously, so I created it. There are a lot of tests in tests/url.php
, but it seems like they're an artifact from before the guideline was to create separate files for each function being tested.
I still need to go over the patch with fresh eyes tomorrow, but I think it's in pretty good shape. @azaozz, do you mind giving the tests a quick glance, in case I missed anything? The functions in link-template.php
haven't been changed, so they should still be good to go.
#4
follow-up:
↓ 6
@
6 years ago
@iandunn Thanks for the merge, that looks good
Here are few suggestions:
- Change
Tests_Link_GetPrivacyPolicyUrl()
toTests_Url_GetPrivacyPolicyUrl()
.
- The tag
@subpackage
seems to be on it's way out in the future according to the Handbook here.
- The cleanup must come before assertions, else the cleanup might not run on a failure. We should remove the filter callbacks before the assertion.
- Add a parameter comment here:
* @param WP_UnitTest_Factory $factory
- Add member variable doc comments here:
protected static $privacy_policy_page_id; protected static $privacy_policy_url; protected static $before; protected static $after;
#6
in reply to:
↑ 4
@
6 years ago
Replying to birgire:
- Change
Tests_Link_GetPrivacyPolicyUrl()
toTests_Url_GetPrivacyPolicyUrl()
.
Good catch :)
- The tag
@subpackage
seems to be on it's way out
Ah, I hadn't seen that, thanks for pointing it out. It sounds like we're keeping @subpackage
for the mean time, though?
For the time being, and for the sake of consistency, WordPress Core will continue to use @subpackage tags – both when writing new DocBlocks, and editing old ones.
Only when the new – external – PSR-5 recommendations are finalized, will across-the-board changes be considered, such as deprecating certain tags.
- The cleanup must come before assertions, else the cleanup might not run on a failure. We should remove the filter callbacks before the assertion.
I think hook callbacks are automatically removed after each test is ran, regardless of the assertions:
...all actions and filters are reset to their original state after each test as well, so it is not necessary to manually remove hooks that have been added in a test.
That works in my tests. So technically, we don't even need to call remove_filter()
, since there aren't any assertions after it, but it still seems good to include it, just to be explicit and avoid future problems if more assertions are added.
- Add a parameter comment here:
- Add member variable doc comments here:
Done, thanks!
#8
@
6 years ago
- Keywords needs-testing has-patch removed
r43002 is all that we need to do here, AFAIK, but I left the ticket open because a permanent committer will need to backport this to the 4.9
branch.
Replying to 43620:comment:43 birgire:
Hmmm, what would be the advantage of that, since the string isn't translated?
Doh, so did I.
Do you want to upload the patch here and I'll combine them?
I used
tests/phpunit/tests/url.php
, since that's where some otherlink-template.php
functions are tested. I'm open to other ideas, though.