Commit Graph

482 Commits

Author SHA1 Message Date
Dion Hulse
67c5150ba6 Canonical: Output correct canonical links for paged posts when not using pretty permalinks.
Props peterwilsoncc.
Fixes #34890

Built from https://develop.svn.wordpress.org/trunk@36096


git-svn-id: http://core.svn.wordpress.org/trunk@36061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-26 04:28:26 +00:00
Boone Gorges
9e0f434726 Improve post-filter sanitization of excluded terms in get_adjacent_post().
See [36078], #35211.
Built from https://develop.svn.wordpress.org/trunk@36079


git-svn-id: http://core.svn.wordpress.org/trunk@36044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-23 20:15:25 +00:00
Boone Gorges
753243a6f7 Move excluded_terms filter in get_adjacent_post().
The filter was added in 4.4 [34528] #9571, but in a place where it could not
affect the adjacent post query.

Fixes #35211.
Built from https://develop.svn.wordpress.org/trunk@36078


git-svn-id: http://core.svn.wordpress.org/trunk@36043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-23 19:57:27 +00:00
Drew Jaynes
13bead9e58 Docs: Fix the syntax for the get_previous_post_link() DocBlock to ensure it's read and parsed as such instead of as a multi-line comment.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@36011


git-svn-id: http://core.svn.wordpress.org/trunk@35976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-18 23:14:26 +00:00
John Blackbourn
3f38dfa688 Correct a parameter name in the @param docs for get_home_url().
See #32246

Built from https://develop.svn.wordpress.org/trunk@35915


git-svn-id: http://core.svn.wordpress.org/trunk@35879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-14 02:45:27 +00:00
Pascal Birchler
54b8c3e53b Docs: Fix some minor DocBlock alignment issues.
See #32246.
Built from https://develop.svn.wordpress.org/trunk@35885


git-svn-id: http://core.svn.wordpress.org/trunk@35849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-12 15:37:28 +00:00
John Blackbourn
932236420c Move the show_ui logic into the get_edit_post_link() and get_edit_term_link() functions to facilitate post types and terms which specify show_ui as false but provide a custom editing UI via the get_edit_post_link and get_edit_term_link filters.
Fixes #33763
Fixes #33938

Built from https://develop.svn.wordpress.org/trunk@35704


git-svn-id: http://core.svn.wordpress.org/trunk@35668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-19 16:25:26 +00:00
Drew Jaynes
a92d4f6fcb Docs: Update the default scheme for get_rest_url() from 'json' to 'rest'.
Also adds 'rest' to the documented list of schemes for `home_url()`, `get_home_url()`, `set_url_scheme()`, and the `home_url` and `set_url_scheme` hooks.

Props rachelbaker.
Fixes #34300.

Built from https://develop.svn.wordpress.org/trunk@35274


git-svn-id: http://core.svn.wordpress.org/trunk@35240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-19 22:39:25 +00:00
Aaron Jorbin
b778726e74 Improve get_post_permalink compatibility with non standard post status
This adds a new filter named `get_post_status` to the function named `get_post_status` which can be used to make additional post types behave like unpublished post status in `get_post_permalink`.

Props misterbisson, antpb, iamfriendly
Fixes #23458


Built from https://develop.svn.wordpress.org/trunk@35233


git-svn-id: http://core.svn.wordpress.org/trunk@35199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-17 00:44:26 +00:00
Drew Jaynes
217b661703 Docs: Add missing descriptions for the $wpdb global in DocBlocks all the places.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@35170


git-svn-id: http://core.svn.wordpress.org/trunk@35136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-14 23:44:25 +00:00
Drew Jaynes
69c828b77b Template: Pass the $post parameter to the the_permalink filter.
Props chriscct7.
Fixes #34234. See #23882.

Built from https://develop.svn.wordpress.org/trunk@35002


git-svn-id: http://core.svn.wordpress.org/trunk@34967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 05:46:24 +00:00
Drew Jaynes
c2b5aeebb0 Template: Rename the $id parameters in the_permalink(), get_the_permalink(), and get_permalink() to $post.
In all three cases, the functions can accept a post ID, a `WP_Post` object, or a falsey value, which defaults to the value of the global `$post`. Switching to `$post` in this context allows the parameters to better self-document and removes ambiguity in the code they are subsequently used in.

Props chriscct7 for the initial patch.
See #34234.

Built from https://develop.svn.wordpress.org/trunk@35001


git-svn-id: http://core.svn.wordpress.org/trunk@34966 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 05:41:29 +00:00
Sergey Biryukov
b40e362711 Fix typo in get_avatar() and get_avatar_data() docs.
Props johnjamesjacoby.
Fixes #34232.
Built from https://develop.svn.wordpress.org/trunk@34988


git-svn-id: http://core.svn.wordpress.org/trunk@34953 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-09 15:52:24 +00:00
Sergey Biryukov
3012b862af Add $id parameter to the_permalink(), for consistency with get_permalink().
Props johnjamesjacoby, chriscct7.
Fixes #23882.
Built from https://develop.svn.wordpress.org/trunk@34982


git-svn-id: http://core.svn.wordpress.org/trunk@34947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-09 04:34:24 +00:00
Drew Jaynes
8b4c499664 Docs: There are quite alot of typos in core inline comments.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@34717


git-svn-id: http://core.svn.wordpress.org/trunk@34681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-30 04:13:48 +00:00
Drew Jaynes
85eafd7632 Themes: Introduce three new arguments for get_the_post_navigation(), in_same_term, excluded_terms, and taxonomy.
The addition of these new arguments brings `get_the_post_navigation()` into argument parity with `get_previous_post_link()` and `get_next_post_link()`, both of which it wraps, and will allow for more flexibility in configuring the next and previous post links for simultaneous display in themes.

Props ChaseWiseman.
Fixes #32618.

Built from https://develop.svn.wordpress.org/trunk@34715


git-svn-id: http://core.svn.wordpress.org/trunk@34679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-30 03:41:26 +00:00
Gary Pendergast
cf173408cd Permalinks: Add pretty permalinks for unattached attachments.
Previously, unattached attachments would have unsightly `/?attachment_id=1` URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.


Built from https://develop.svn.wordpress.org/trunk@34690


git-svn-id: http://core.svn.wordpress.org/trunk@34654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-29 09:42:26 +00:00
Boone Gorges
18d6b3c8dc Force comment pagination on single posts.
Previously, the 'page_comments' toggle allowed users to disable comment
pagination. This toggle was only superficial, however. Even with
'page_comments' turned on, `comments_template()` loaded all of a post's
comments into memory, and passed them to `wp_list_comments()` and
`Walker_Comment`, the latter of which produced markup for only the
current page of comments. In other words, it was possible to enable
'page_comments', thereby showing only a subset of a post's comments on a given
page, but all comments continued to be loaded in the background. This technique
scaled poorly. Posts with hundreds or thousands of comments would load slowly,
or not at all, even when the 'comments_per_page' setting was set to a
reasonable number.

Recent changesets have addressed this problem through more efficient tree-
walking, better descendant caching, and more selective queries for top-level
post comments. The current changeset completes the project by addressing the
root issue: that loading a post causes all of its comments to be loaded too.

Here's the breakdown:

* Comment pagination is now forced. Setting 'page_comments' to false leads to evil things when you have many comments. If you want to avoid pagination, set 'comments_per_page' to something high.
* The 'page_comments' setting has been expunged from options-discussion.php, and from places in the codebase where it was referenced. For plugins relying on 'page_comments', we now force the value to `true` with a `pre_option` filter.
* `comments_template()` now queries for an appropriately small number of comments. Usually, this means the `comments_per_page` value.
* To preserve the current (odd) behavior for comment pagination links, some unholy hacks have been inserted into `comments_template()`. The ugliness is insulated in this function for backward compatibility and to minimize collateral damage. A side-effect is that, for certain settings of 'default_comments_page', up to 2x the value of `comments_per_page` might be fetched at a time.
* In support of these changes, a `$format` parameter has been added to `WP_Comment::get_children()`. This param allows you to request a flattened array of comment children, suitable for feeding into `Walker_Comment`.
* `WP_Query` loops are now informed about total available comment counts and comment pages by the `WP_Comment_Query` (`found_comments`, `max_num_pages`), instead of by `Walker_Comment`.

Aside from radical performance improvements in the case of a post with many
comments, this changeset fixes a bug that caused the first page of comments to
be partial (`found_comments` % `comments_per_page`), rather than the last, as
you'd expect.

Props boonebgorges, wonderboymusic.
Fixes #8071.
Built from https://develop.svn.wordpress.org/trunk@34561


git-svn-id: http://core.svn.wordpress.org/trunk@34525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 20:40:25 +00:00
Scott Taylor
80974b0db6 Links: in get_adjacent_post(), add a "get_{$adjacent}_post_excluded_terms" filter.
Props rmccue, Japh, MikeHansenMe.
Fixes #9571.

Built from https://develop.svn.wordpress.org/trunk@34528


git-svn-id: http://core.svn.wordpress.org/trunk@34492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 02:38:25 +00:00
Scott Taylor
9405b8b10e Canonical/Rewrite: After [34492], fix rel="canonical" URLs for paginated posts.
Props wonderboymusic, joostdevalk.
See #11694.

Built from https://develop.svn.wordpress.org/trunk@34496


git-svn-id: http://core.svn.wordpress.org/trunk@34460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 14:30:24 +00:00
Scott Taylor
6dc400395c Links: the esc_html() additions in [34444] aren't very nice to screen reader <span>s. Revert those specific calls.
See #14900.

Built from https://develop.svn.wordpress.org/trunk@34452


git-svn-id: http://core.svn.wordpress.org/trunk@34416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-23 04:26:27 +00:00
Scott Taylor
d866a40d09 After [34444​], wp_get_shortlink() can call get_queried_object_id() instead of using the $wp_query global.
See #14900.

Built from https://develop.svn.wordpress.org/trunk@34445


git-svn-id: http://core.svn.wordpress.org/trunk@34409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 20:09:23 +00:00
Scott Taylor
7cbd096c2b Links: use consistent late-escaping in some HTML link-generation functions:
* `post_comments_feed_link()`
* `edit_post_link()`
* `edit_comment_link()`
* `edit_bookmark_link()`
* `rel_canonical()`

Props niallkennedy, wonderboymusic.
Fixes #14900.

Built from https://develop.svn.wordpress.org/trunk@34444


git-svn-id: http://core.svn.wordpress.org/trunk@34408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 20:06:24 +00:00
Konstantin Obenland
c5a684fc27 Introduce template functions for comment navigation:
* `get_the_comments_navigation()` and `the_comments_navigation()` for navigation to the next and previous page of comments.
* `get_the_comments_pagination()` and `the_comments_pagination()` for paginated navigation between pages of comments. Uses `paginate_comments_links()`.

This reduces the need for themes to define their own sets of comment navigation
functions, like Twenty Fifteen and others.
Completes the navigation template tag API started in #29808 for posts.

Fixes #30589.


Built from https://develop.svn.wordpress.org/trunk@34367


git-svn-id: http://core.svn.wordpress.org/trunk@34331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-21 16:32:26 +00:00
Drew Jaynes
b336035dac Docs: The $post parameter has been passed to the preview_post_link since 4.0.0.
Fixes a version mixup introduced in [34170].

Props dimadin.
See #24345.

Built from https://develop.svn.wordpress.org/trunk@34363


git-svn-id: http://core.svn.wordpress.org/trunk@34327 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-21 13:17:26 +00:00
John Blackbourn
015349cd6e Revisions are an exception when it comes to the editing UI. The revision post type cannot have its show_ui argument set to true because this allows access to the post type listing, creation, and editing UI, but get_edit_post_link() needs to return a URL for the editing UI for revisions as that's how the revisions UI works.
Fixes #33763

Built from https://develop.svn.wordpress.org/trunk@34357


git-svn-id: http://core.svn.wordpress.org/trunk@34321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-20 16:38:26 +00:00
Scott Taylor
8d2abbffac Feeds/Links: fix feed links for unattached attachments.
Adds unit tests.

Props wonderboymusic, iworks.
Fixes #33693.

Built from https://develop.svn.wordpress.org/trunk@34336


git-svn-id: http://core.svn.wordpress.org/trunk@34300 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-19 20:10:24 +00:00
John Blackbourn
541dbb2711 Remove the ability to view the post listing screen and post editing screen for post types with show_ui set to false. It is unexpected and unintended behaviour that this is allowed.
If your plugin or site does rely on this behaviour, the arguments that are passed to `register_post_type()` should be altered so that `show_ui` is `true`, and arguments such as `show_in_menu`, `show_in_nav_menus`, and `show_in_admin_bar` are `false`.

Fixes #33763
Props swissspidy, johnbillion

Built from https://develop.svn.wordpress.org/trunk@34177


git-svn-id: http://core.svn.wordpress.org/trunk@34145 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 10:27:29 +00:00
John Blackbourn
caf90ec1c6 Improve the docblocks for the get_preview_post_link() function and the preview_post_link filter.
See #24345

Built from https://develop.svn.wordpress.org/trunk@34176


git-svn-id: http://core.svn.wordpress.org/trunk@34144 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 08:25:25 +00:00
John Blackbourn
9cd91030a6 Correct the value of the preview query variable added by get_preview_post_link().
See #24345
Props kitchin

Built from https://develop.svn.wordpress.org/trunk@34175


git-svn-id: http://core.svn.wordpress.org/trunk@34143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 08:16:24 +00:00
Scott Taylor
54829b6305 Create a function, get_preview_post_link(), to DRY the logic for applying the 'preview_post_link' filter to a URL.
Props TomHarrigan, wonderboymusic.
Fixes #24345.

Built from https://develop.svn.wordpress.org/trunk@34170


git-svn-id: http://core.svn.wordpress.org/trunk@34138 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 04:15:25 +00:00
Scott Taylor
cf2aaf8393 In get_avatar_data(), promote stdClass objects to WP_Comment if passed.
Props DrewAPicture, ocean90.
Fixes #32619.

Built from https://develop.svn.wordpress.org/trunk@34160


git-svn-id: http://core.svn.wordpress.org/trunk@34128 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 01:34:25 +00:00
Sergey Biryukov
d9bc36d068 Escape class attribute in edit_post_link() after [34098].
Props Offereins.
See #30563.
Built from https://develop.svn.wordpress.org/trunk@34117


git-svn-id: http://core.svn.wordpress.org/trunk@34085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-14 13:01:25 +00:00
Sergey Biryukov
97c0303f41 Docs: Add a changelog entry for the $class argument added to edit_post_link() in [34098].
Fixes #30563.
Built from https://develop.svn.wordpress.org/trunk@34115


git-svn-id: http://core.svn.wordpress.org/trunk@34083 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-14 12:20:26 +00:00
Scott Taylor
c745c2deb3 In edit_post_link(), add an argument for the class attribute that defaults to post-edit-link.
Props voldemortensen.
Fixes #30563.

Built from https://develop.svn.wordpress.org/trunk@34098


git-svn-id: http://core.svn.wordpress.org/trunk@34066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-13 23:34:24 +00:00
Boone Gorges
e0b1340461 Remove extraneous table join in get_adjacent_post().
Since [29248], a table join has not been necessary to process the
`$excluded_terms` parameter of `get_adjacent_post()`. Aside from adding extra
overhead, this join meant that post records that don't have any corresponding
rows in `wp_term_relationships` were erroneously excluded from results.

Fixes #32833.
Built from https://develop.svn.wordpress.org/trunk@34088


git-svn-id: http://core.svn.wordpress.org/trunk@34056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-12 20:34:24 +00:00
Scott Taylor
db4f22bfb5 After [33961], pass $comment to get_comment_link() where possible to avoid extra cache/db lookups.
See #33638.

Built from https://develop.svn.wordpress.org/trunk@34042


git-svn-id: http://core.svn.wordpress.org/trunk@34010 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-11 06:21:25 +00:00
Scott Taylor
b05593c0b9 Add a parameter, $post, to get_{$adjacent}_post_join, get_{$adjacent}_post_where, and get_{$adjacent}_post_sort
Props JustinSainton.
Fixes #24597.

Built from https://develop.svn.wordpress.org/trunk@33968


git-svn-id: http://core.svn.wordpress.org/trunk@33937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-09 03:49:24 +00:00
Scott Taylor
d973339738 After [33891], get_comment() returns global $comment if no args are passed and the global is set (after setting the default to null here). This allows us to ditch global comment imports.
See #33638.

Built from https://develop.svn.wordpress.org/trunk@33963


git-svn-id: http://core.svn.wordpress.org/trunk@33932 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-09 02:51:24 +00:00
Scott Taylor
e73ee5ac98 Introduce WP_Comment class to model/strongly-type rows from the comments database table. Inclusion of this class is a pre-req for some more general comment cleanup and sanity.
* Takes inspiration from `WP_Post` and adds sanity to comment caching. 
* Clarifies when the current global value for `$comment` is returned. The current implementation in `get_comment()` introduces side effects and an occasion stale global value for `$comment` when comment caches are cleaned.
* Strongly-types `@param` docs
* This class is marked `final` for now

Props wonderboymusic, nacin.

See #32619.

Built from https://develop.svn.wordpress.org/trunk@33891


git-svn-id: http://core.svn.wordpress.org/trunk@33860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-03 18:17:24 +00:00
Boone Gorges
a0e00c0d24 Pass taxonomy name to filters in get_adjacent_post().
Props sboisvert.
Fixes #33568.
Built from https://develop.svn.wordpress.org/trunk@33805


git-svn-id: http://core.svn.wordpress.org/trunk@33773 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-29 19:59:21 +00:00
Scott Taylor
d8752c191d In get_home_url(), import the $pagenow global to avoid having to check if it exists before comparing against it.
Props KalenJohnson.
See #33545.

Built from https://develop.svn.wordpress.org/trunk@33736


git-svn-id: http://core.svn.wordpress.org/trunk@33704 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 21:03:20 +00:00
Drew Jaynes
45578c525e Docs: Add a description and example to the hook docs for the navigation_markup_template filter, introduced in [33714].
Since the value of the filter is passed through `sprintf()` it's important to note that any filtered output needs to contain the expected specifiers.

See #31315.

Built from https://develop.svn.wordpress.org/trunk@33717


git-svn-id: http://core.svn.wordpress.org/trunk@33684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-23 18:08:25 +00:00
Scott Taylor
27b551ee50 Add a filter to _navigation_markup: 'navigation_markup_template'
Props joedolson, mordauk.
Fixes #31315.

Built from https://develop.svn.wordpress.org/trunk@33714


git-svn-id: http://core.svn.wordpress.org/trunk@33681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-23 16:34:26 +00:00
Drew Jaynes
dffa53dca8 Docs: Fix a minor alignment issue in the DocBlock for get_pagenum_link().
See #32246.

Built from https://develop.svn.wordpress.org/trunk@33712


git-svn-id: http://core.svn.wordpress.org/trunk@33679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-23 07:19:27 +00:00
Scott Taylor
45fc6a3def Deprecate post_permalink() (Introduced in 1.0, already had a deprecated argument in 1.3), which just wraps get_permalink() and was only used by XML-RPC in 4 places.
Props solarissmoke.
Fixes #16982.

Built from https://develop.svn.wordpress.org/trunk@33659


git-svn-id: http://core.svn.wordpress.org/trunk@33626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 06:24:26 +00:00
Scott Taylor
a0e373ef80 For doc block types, favor bool over the few remaining booleans
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32964


git-svn-id: http://core.svn.wordpress.org/trunk@32935 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-27 01:03:25 +00:00
Boone Gorges
d99f9d3a22 Improve error checking in get_edit_term_link().
The function should not throw notices when an improper term or taxonomy is
passed.

Props tmatsuur, MikeHansenMe.
Fixes #32786.
Built from https://develop.svn.wordpress.org/trunk@32954


git-svn-id: http://core.svn.wordpress.org/trunk@32925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-26 14:13:24 +00:00
Drew Jaynes
e872f02bc8 Document default values for optional arguments in edit_term_link().
See #32246.

Built from https://develop.svn.wordpress.org/trunk@32926


git-svn-id: http://core.svn.wordpress.org/trunk@32897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-24 10:56:27 +00:00
Drew Jaynes
8a6f4cb0ef Add missing documentation for the $echo parameter in the DocBlock for edit_term_link().
Props tmatsuur.
Fixes #32776.

Built from https://develop.svn.wordpress.org/trunk@32925


git-svn-id: http://core.svn.wordpress.org/trunk@32896 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-24 10:53:28 +00:00