The function was erroneously calling `is_wp_error()` on the result of a `get_post()` call, which returns `null` on failure, and never returns a `WP_Error` object.
Previously, passing a non-existing post ID to the function would result in a home URL being returned and a few `Attempt to read property "post_type, post_name, hierarchical..." on null` PHP warnings.
This commit ensures `get_post_permalink()` returns `false` on failure, which brings parity with `get_permalink()`.
Includes a unit test to confirm the correct behavior.
Follow-up to [12923], [13023], [32606].
Props renegeuze, manzoorwani.jk.
Fixes#45329.
Built from https://develop.svn.wordpress.org/trunk@53733
git-svn-id: http://core.svn.wordpress.org/trunk@53292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This ensures that the global is explicitly declared and documented in:
* `get_next_posts_link()`
* `get_posts_nav_link()`
* `get_the_posts_navigation()`
* `get_the_posts_pagination()`
* `get_next_comments_link()`
Follow-up to [30065].
Props mt8.biz, sabernhardt.
Fixes#43164.
Built from https://develop.svn.wordpress.org/trunk@53520
git-svn-id: http://core.svn.wordpress.org/trunk@53109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This aims to improve performance by calling `sanitize_url()` directly, instead of the `esc_url_raw()` wrapper. As of WordPress 6.1, `sanitize_url()` is the recommended function for sanitizing a URL for database or redirect usage.
Follow-up to [11383], [13096], [51597], [53452].
Props benjgrolleau, peterwilsoncc, SergeyBiryukov.
Fixes#55852.
Built from https://develop.svn.wordpress.org/trunk@53455
git-svn-id: http://core.svn.wordpress.org/trunk@53044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
While `AS` is an optional keyword in SQL, it is commonly considered best practice to include it for better readability and compatibility. This also makes the queries more consistent with other queries using aliases in core.
Follow-up to [6359], [30238].
Props costdev, domainsupport.
Fixes#54769.
Built from https://develop.svn.wordpress.org/trunk@52553
git-svn-id: http://core.svn.wordpress.org/trunk@52143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This change performs the type safety check on `$term` before it is used to retrieve the taxonomy in `get_term_feed_link()`. It also updates the related DocBlock after [52255].
Follow up to [52255].
Props dlh.
Fixes#50225.
Built from https://develop.svn.wordpress.org/trunk@52258
git-svn-id: http://core.svn.wordpress.org/trunk@51850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This change fixes a backward compatibility issue introduced in [52180] where `get_term_feed_link()` did not honor the `$taxonomy` parameter anymore. Rather than using the default `category` taxonomy when passing a term ID in `get_term_feed_link()`, use the `WP_Term` object to get the taxonomy.
Follow-up to [52180].
Props hugod.
Fixes#50225.
Built from https://develop.svn.wordpress.org/trunk@52255
git-svn-id: http://core.svn.wordpress.org/trunk@51847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`get_term()` accepts a term ID, instance of `WP_Term`, or an object (i.e. `stdClass` as a result of a db query). Functions that use `get_term()` also now allow for the same data types.
Why? For consistency, removing extra processing code in consuming functions, and performance.
Functions changed in this commit are:
* `get_category_feed_link()`
* `get_term_feed_link()`
* `get_tag_feed_link()`
* `get_edit_tag_link()`
* `get_edit_term_link()`
* `edit_term_link()`
For each of consumer of these functions, changes to pass the object instead of the term ID.
Includes unit/integration tests for test coverage of these changes.
Follow-up to [6365], [9136], [9340], [14711], [15792], [15800], [18827], [32606], [36646], [37252].
Props davidbinda, johnbillion, peterwilsoncc, hellofromTonya, sergeybiryukov, mista-flo, hareesh-pillai, audrasjb, jeffpaul, chaion07.
Fixes#50225.
Built from https://develop.svn.wordpress.org/trunk@52180
git-svn-id: http://core.svn.wordpress.org/trunk@51772 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Role="navigation" was required for assistive technology to recognize HTML5 element's native ARIA roles while HTML5 and ARIA were being introduced. With the deprecation of IE11, the role attribute is only required when mapping elements that don't have native role.
Props costdev, mukesh27.
Fixes#54054.
Built from https://develop.svn.wordpress.org/trunk@51967
git-svn-id: http://core.svn.wordpress.org/trunk@51556 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This avoids an "Undefined index" PHP notice in `wp_resource_hints()` tests when running the full test suite.
Remove the unused global from `get_home_url()`.
Follow-up to [25443], [38100], [38174], [50156], [50164].
Props peterwilsoncc.
Fixes#52566.
Built from https://develop.svn.wordpress.org/trunk@50393
git-svn-id: http://core.svn.wordpress.org/trunk@50004 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, `network_home_url()` would automatically switch to `https` if the current request is already `https`, but would only do so on the front end.
This mirrors the change made earlier for `get_home_url()`.
Follow-up to [12598], [21937], [24844], [50156].
See #52421.
Built from https://develop.svn.wordpress.org/trunk@50168
git-svn-id: http://core.svn.wordpress.org/trunk@49847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, `get_home_url()` would automatically switch to `https` if the current request is already `https`, but would only do so on the front end.
This addresses the inconsistent behavior of returning different values in the admin and on the frontend.
Follow-up to [12598], [21937], [24844].
Props herregroen, mukesh27.
Fixes#52421.
Built from https://develop.svn.wordpress.org/trunk@50156
git-svn-id: http://core.svn.wordpress.org/trunk@49835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add check to `redirect_canonical()` to ensure private posts only redirect for logged in users.
Modifies the `read_post` mata capability to user `get_post_status()` rather than the post's `post_status` property to allow attachments to redirect based on the inherited post status.
Introduces `wp_force_ugly_post_permalink()` to unify the check to determine if an ugly link should be displayed in each of the functions used for determining permalinks: `get_permalink()`, `get_post_permalink()`, `_get_page_link()` and `get_attachment_link()`.
Improves logic of `get_attachment_link()` to validate parent post and resolution of inherited post status. This is an incomplete fix of #52373 to prevent the function returning links resulting in a file not found error. Required to unblock this ticket.
Props peterwilsoncc, TimothyBlynJacobs.
See #52373.
Fixes#5272.
Built from https://develop.svn.wordpress.org/trunk@50132
git-svn-id: http://core.svn.wordpress.org/trunk@49811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This largely reverts [49563] due to attachment pages returning 404: File not found errors when they use the `inherit` status.
Permalink changes to attachment pages are retained when they are descendants of trashed or deleted posts.
Props Toro_Unit, helen, johnbillion, peterwilsoncc.
Fixes#51776.
See #5272.
Built from https://develop.svn.wordpress.org/trunk@49622
git-svn-id: http://core.svn.wordpress.org/trunk@49360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add check to `redirect_canonical()` to ensure the destination post is not using a private post status.
Props dd32, Denis-de-Bernardy, donmhico, helen, nacin, peterwilsoncc, pishmishy, TimothyBlynJacobs, tzafrir, Viper007Bond, whyisjake.
Fixes#5272.
Built from https://develop.svn.wordpress.org/trunk@49563
git-svn-id: http://core.svn.wordpress.org/trunk@49301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The filter is the callback function added with `add_filter()`, therefore the hook passes a value to the filter, and the filter returns a value to change its behaviour.
The documentation is referring to the latter.
Props johnbillion.
See #49572, #16557.
Built from https://develop.svn.wordpress.org/trunk@48185
git-svn-id: http://core.svn.wordpress.org/trunk@47954 1a063a9b-81f0-0310-95a4-ce76da25c4cd