Commit Graph

472 Commits

Author SHA1 Message Date
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
Scott Taylor
5e994cd6a1 Customizer et al, use elseif in PHP, not else if.
This was corrected via brute force in [31090].

See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-19 22:01:25 +00:00
Scott Taylor
09c4444150 Make sure that all Gravatars are generated by get_avatar() or at least run through apply_filters( 'get_avatar', $avatar ) for the sake of extensibility.
Props miqrogroove, GlennM, SergeyBiryukov.
Fixes #22650.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32816 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-18 18:36:25 +00:00
Scott Taylor
bf16064448 Fix doc blocks to link-template.php
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-26 18:44:25 +00:00
Andrew Ozz
ad475b3c69 Press This: check the bookmarklet version and add the update notice from PHP.
Fixes #31942.
Built from https://develop.svn.wordpress.org/trunk@32106


git-svn-id: http://core.svn.wordpress.org/trunk@32085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-10 21:08:29 +00:00
Drew Jaynes
d79ecd8bba Various inline documentation syntax fixes in wp-includes/link-template.php.
See #31888.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32021 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-05 16:04:28 +00:00
Andrew Ozz
c04a1affd1 Press This: bump bookmarklet's version. See #31657.
Built from https://develop.svn.wordpress.org/trunk@31800


git-svn-id: http://core.svn.wordpress.org/trunk@31782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-17 01:19:27 +00:00
Andrew Ozz
be24bc3a97 PressThis:
- Filter and select the content on the PHP side. Then pass only the needed data to JS.
- Add the suggested post title and contend directly to the HTML.
- Standardise the data type names.
- Some cleanup/reduction of the code in the bookmarklet.
See #31373.
Built from https://develop.svn.wordpress.org/trunk@31693


git-svn-id: http://core.svn.wordpress.org/trunk@31674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-09 21:49:28 +00:00
Boone Gorges
34715e3b1a In get_next_comments_link(), ensure proper pagination when no 'cpage' query var is found.
The 'cpage' query var is only set when using `comments_template()` to display
comments. If displaying them in a context where 'cpage' is not yet set, the
default value should be 1, not 0.

Props MomDad, couturefreak.
Fixes #20319.
Built from https://develop.svn.wordpress.org/trunk@31617


git-svn-id: http://core.svn.wordpress.org/trunk@31598 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-05 03:57:24 +00:00
Andrew Ozz
f53199487d PressThis:
- Improve handling of the data, both from the bookmarklet and from server-side parsing.
- Standardize on processing the data in PHP and remove duplicate code from JS.
- Improve the bookmarklet code and remove pre-filtering of the data.
Part props stephdau, see #31373.
Built from https://develop.svn.wordpress.org/trunk@31609


git-svn-id: http://core.svn.wordpress.org/trunk@31590 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-04 19:29:25 +00:00
Drew Jaynes
33d9dd8066 Adjust the description for the $extra_attr argument in the DocBlocks for get_avatar_data() and get_avatar().
See [31561]. See #31469.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31572 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-01 07:19:24 +00:00