Commit Graph

50 Commits

Author SHA1 Message Date
John Blackbourn
1100cca947 Themes: Add template type and template candidates as parameters to the {$type}_template filter.
Props mschadegg
Fixes #39525

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


git-svn-id: http://core.svn.wordpress.org/trunk@39994 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-02-12 21:25:42 +00:00
Boone Gorges
e836e47a8a Avoid PHP notices in get_post_type_archive_template().
The function should fail more gracefully when called in the context
where `get_query_var( 'post_type' )` doesn't represent an actual post
type.

Props technopolitica, dlh.
Fixes #38374.
Built from https://develop.svn.wordpress.org/trunk@40031


git-svn-id: http://core.svn.wordpress.org/trunk@39968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-30 19:32:42 +00:00
Sergey Biryukov
32564f9332 Themes: Use curly braces for variables inside strings in `get_page_template() to explicitly specify the end of the variable name.
Props kuck1u.
Fixes #38625.
Built from https://develop.svn.wordpress.org/trunk@39884


git-svn-id: http://core.svn.wordpress.org/trunk@39821 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-12 04:13:42 +00:00
Pascal Birchler
81a26f6900 Posts, Post Types: Add support for post type templates.
WordPress has supported custom page templates for over 12 years, allowing developers to create various layouts for specific pages.
While this feature is very helpful, it has always been limited to the 'page' post type and not was not available to other post types.

By opening up the page template functionality to all post types, we continue to improve the template hierarchy's flexibility.

In addition to the `Template Name` file header, the post types supported by a template can be specified using `Template Post Type: post, foo, bar`.
When at least one template exists for a post type, the 'Post Attributes' meta box will be displayed in the back end, without the need to add post type support for `'page-attributes'`. 'Post Attributes' can be customized per post type using the `'attributes'` label when registering a post type.

Props johnbillion, Mte90, dipesh.kakadiya, swissspidy.
Fixes #18375.
Built from https://develop.svn.wordpress.org/trunk@38951


git-svn-id: http://core.svn.wordpress.org/trunk@38894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-26 08:07:30 +00:00
John Blackbourn
afff60c378 Themes: Improve the inline documentation for the get_*_template() functions by providing examples instead of verbose explanations.
Fixes #38249
See #37770

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


git-svn-id: http://core.svn.wordpress.org/trunk@38732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-14 14:20:29 +00:00
John Blackbourn
c0f1a49575 Themes: Remove paged.php from the theme template hierarchy.
The position of this template within the hierarchy is of so little use that zero themes in the WordPress.org theme directory make use of it. It's second only to `index.php` in the hierarchy, meaning that any archive template such as `category.php` or `archive.php` will be chosen before it.

Fixes #38162
Props ryankienstra for initial patch

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


git-svn-id: http://core.svn.wordpress.org/trunk@38698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-07 21:03:31 +00:00
Sergey Biryukov
f348f9a59c Docs: Use a third-person singular verb for {$type}_template_hierarchy filter added in [38385].
See #14310.
Built from https://develop.svn.wordpress.org/trunk@38609


git-svn-id: http://core.svn.wordpress.org/trunk@38552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-14 21:54:30 +00:00
John Blackbourn
e482549183 Themes: Add the non-encoded form of the queried item slug to the template hierarchy when the slug contains non-ASCII characters.
This affects category, tag, and custom taxonomy archives, and single posts, pages, and custom post types.

Fixes #37655

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


git-svn-id: http://core.svn.wordpress.org/trunk@38526 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-09 00:48:28 +00:00
John Blackbourn
b3faafc632 Themes: Correct the list of possible values for the dynamic portion of the {$type}_template_hierarchy and {$type}_template filters.
See #14310

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


git-svn-id: http://core.svn.wordpress.org/trunk@38369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-28 23:57:49 +00:00
John Blackbourn
d346835bfb Themes: Update filter names in the inline documentation for the get_*_template() functions.
See #14310, #37770

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


git-svn-id: http://core.svn.wordpress.org/trunk@38359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-28 16:15:30 +00:00
John Blackbourn
9e1542b9ec Themes: Make the template hierarchy for a given template type filterable.
This introduces a `{$type}_template_hierarchy` filter that allows the hierarchy of candidate template filenames for a given template type to be filtered.

This allows the hierarchy to be added to or altered completely without resorting to re-building the hierarchy from scratch within the `template_include` filter, which is common and prone to conflicts between plugins and prone to getting out of sync with core's hierarchy.

Fixes #14310

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


git-svn-id: http://core.svn.wordpress.org/trunk@38326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 21:03:27 +00:00
Drew Jaynes
9cb5247392 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:50:28 +00:00
Drew Jaynes
f52a8cb1fa Docs: Remove/replace invalid inline @link tags in DocBlocks in wp-includes/*.
Fixes #36910.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 17:39:28 +00:00
Drew Jaynes
2e0866bcbc Docs: Correct a typo in the DocBlock summary for get_embed_template(), introduced in [36963].
Props swissspidy.
See #34561, #34278. See #35986.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36933 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-10 22:45:26 +00:00
Drew Jaynes
b533878fa2 Docs: Use a third-person singular verb in the summary for get_embed_template(), introduced in [36876].
See #34561, #34278. See #35986.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36931 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-10 22:09:26 +00:00
Pascal Birchler
dc2f39b7f0 Embeds: Add support for embeds in the theme template hierarchy.
This allows themes to directly override the default template. The order in which the template is retrieved is as follows: `embed-$post_type-$post_format.php` -> `embed-$post_type.php` -> `embed.php`.

The `embed_template` filter gets replaced by the dynamic `{$type}_template` filter in `get_query_template()`.

Props ChriCo, swissspidy.
See #34561. Fixes #34278.
Built from https://develop.svn.wordpress.org/trunk@36876


git-svn-id: http://core.svn.wordpress.org/trunk@36843 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-07 19:33:26 +00:00
Drew Jaynes
0fc00feec3 Embeds: Introduce embed templates into the template hierarchy via theme-compat.
Splits wp-includes/embed-template.php, introduced in 4.4, into five new templates that can be individually overridden by themes:

* embed.php
* embed-404.php
* embed-content.php
* header-embed.php
* footer-embed.php

Also introduces a new template tag for outputting the site title, `the_embed_site_title()`.

The five new templates live in theme-compat, allowing for graceful fallbacks should themes prefer not to override any or all of them.

Props swissspidy, imath, ocean90, DrewAPicture.
See #34561.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-24 20:57:26 +00:00
John Blackbourn
a027edc277 Comments: The year is 2003. Permalinks are a new thing and everyone's using Blogger. It's a time when opening a modal window in JavaScript to view a section of a website is not a completely weird thing, although many users get annoyed by it. b2 has recently become WordPress, and with it comes a bunch of functionality that will become stale over the next decade, remnants of simpler times.
Twelve years later, after no fewer than three themes have intentionally implemented popup comments in their functionality, before being abandoned for at least the last six years, we've reached a time where we can put this era behind us. A time when we can remove comment popup functionality from WordPress.

If this breaks the internet, I'll eat my hat.

Fixes #28617

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


git-svn-id: http://core.svn.wordpress.org/trunk@35812 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-10 03:06:30 +00:00
John Blackbourn
ef6abd3891 List the possible values for the dynamic portion of the {type}_template hook.
See #14310, #32246

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


git-svn-id: http://core.svn.wordpress.org/trunk@35377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-28 14:06:27 +00:00
Scott Taylor
00ade45fd1 Docs: some @global object vernaculars should be converted to the actual object type.
See #33491.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 15:45:25 +00:00
Sergey Biryukov
3792591dfb Add single-{post_type}-{post_name}.php to the top of the template hierarchy for single posts.
This is consistent with page and taxonomy templates, which support slugs as well.

Props ericjuden, johnbillion.
Fixes #18859.
Built from https://develop.svn.wordpress.org/trunk@34800


git-svn-id: http://core.svn.wordpress.org/trunk@34765 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-03 15:00:25 +00:00
Drew Jaynes
cf7e13813f Docs: Update the DocBlock descriptions for a variety of template functions to better reflect that the dynamic $type_template hook can be used to filter the template path.
It's important to reference the actual dynamic hook name instead of an alias for purposes of auto-linking in the Code Reference.

Affects the docs for:
* `get_index_template()`
* `get_404_template()`
* `get_archive_template()`
* `get_post_type_archive_template()`
* `get_author_template()`
* `get_category_template()`
* `get_tag_template()`
* `get_taxonomy_template()`
* `get_date_template()`
* `get_home_template()`
* `get_page_template()`
* `get_paged_template()`
* `get_search_template()`
* `get_single_template()`
* `get_singular_template()`
* `get_attachment_template()`

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-14 22:27:24 +00:00
Drew Jaynes
f7f4a97d07 Docs: Clarify the hook docs for the {$type}_template hook to mention that non-alphanumeric characters delimiting words will also be removed from the passed $type parameter.
Also remove a now-unnecessary inline `@see` tag from the return description.

See #32246. See #32989.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-14 22:12:25 +00:00
Drew Jaynes
84419a51b8 Update the descriptions for get_front_page_template() and get_comments_popup_template() to reference the correct dynamic hook names.
Part props @birgire.

Fixes #32989. See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-14 21:59:25 +00:00
Drew Jaynes
08ad571942 Fix inline documentation syntax in the DocBlock for get_singular_template(), added in 4.3.
See [32846]. See #32891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:59:24 +00:00
Aaron Jorbin
4b7ce555d0 Add singular.php to template hierarchy
Singular is the only template context conditional that lacks a corresponding template. This allows some themes to simplify.

Fixes #22314.
Props chipbennett.


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


git-svn-id: http://core.svn.wordpress.org/trunk@32817 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-18 19:01:26 +00:00
Scott Taylor
a1bd091d65 In get_attachment_template(), pass an array of templates to get_query_template( 'attachment', $templates ), instead of bailing on the first found template.
Props willnorris, jfarthing84, SergeyBiryukov, DrewAPicture, wonderboymusic.
Fixes #15337.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 20:50:26 +00:00
Scott Taylor
0c1b765a6f Add missing doc blocks to template.php.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32598 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-27 22:04:26 +00:00
Andrew Nacin
5a84e32652 Escape the $s global.
fixes #32142.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-27 05:10:27 +00:00
Scott Taylor
fe6b5983df In PHP 5.0.0, is_a() became deprecated in favour of the instanceof operator. Calling is_a() would result in an E_STRICT warning.
In PHP 5.3.0, `is_a()` is no longer deprecated, and will therefore no longer throw `E_STRICT` warnings.

To avoid warnings in PHP < 5.3.0, convert all `is_a()` calls to `$var instanceof WP_Class` calls.

`instanceof` does not throw any error if the variable being tested is not an object, it simply returns `false`.

Props markoheijnen, wonderboymusic.
Fixes #25672.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31169 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 01:06:24 +00:00
Scott Taylor
60b0cd7943 The keyword elseif should be used instead of else if so that all control keywords look like single words.
This was a mess, is now standardized across the codebase, except for a few 3rd-party libs. 

See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 07:05:25 +00:00
Drew Jaynes
bffe95d34c Docs Formatting: Backtick-escape inline code for all remaining dynamic hook docs in wp-includes/*.
Affects DocBlocks for the following hooks:
* `auth_post_meta_{$meta_key}`
* `term_links-$taxonomy`
* `customize_render_control_ . $this->id`
* `customize_render_panel_{$this->id}`
* `customize_render_section_{$this->id}`
* `customize_preview_{$this->id}`
* `customize_save_ . $this->id_data[ 'base' ]`
* `customize_update_ . $this->type`
* `customize_value_ . $this->id_data[ 'base' ]`
* `customize_sanitize_js_{$this->id}`
* `comment_form_field_{$name}`
* `comment_{$old_status}_to_{$new_status}`
* `comment_{$new_status}_{$comment->comment_type}`
* `extra_{$context}_headers`
* `get_template_part_{$slug}`
* `get_the_generator_{$type}`
* `get_{$adjacent}_post_join`
* `get_{$adjacent}_post_where`
* `get_{$adjacent}_post_sort`
* `{$adjacent}_post_rel_link`
* `{$adjacent}_post_link`
* `{$adjacent}_image_link`
* `blog_option_{$option}`
* `$permastructname . _rewrite_rules`
* `{$type}_template`
* `theme_mod_{$name}`
* `pre_set_theme_mod_$name`
* `current_theme_supports-{$feature}`
* `get_user_option_{$option}`
* `edit_user_{$field}`
* `pre_user_{$field}`
* `user_{$field}`

See #30552.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 12:10:23 +00:00
Scott Taylor
ef436cb6e0 Revert [28563]. See #18298.
Built from https://develop.svn.wordpress.org/trunk@29044


git-svn-id: http://core.svn.wordpress.org/trunk@28832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-09 18:07:16 +00:00
Scott Taylor
b75c79500b Replaces all uses of TEMPLATEPATH and STYLESHEETPATH in core with get_template_directory() and get_stylesheet_directory().
Add `@deprecated` annotations to `TEMPLATEPATH` and `STYLESHEETPATH` definitions.

Props obenland, aaroncampbell. 
Fixes #18298.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-23 20:12:15 +00:00
Drew Jaynes
95bb449a4d Inline documentation improvements for get_*_template() functions in wp-includes/template.php.
* Adds `@see` references for `get_query_template()` or similar
* Adds complete `@return` descriptions
* Clarifies which dynamic hooks can be used to filter specific template types

Props UmeshSingla for the initial patches. Props SergeyBiryukov, DrewAPicture.
Fixes #26742.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26789 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-05 17:55:11 +00:00
Andrew Nacin
d0cfa40983 Add jshintrc to qunit.
props jorbin.
see #25187.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-30 14:39:10 +00:00
Drew Jaynes
a8bce2a54d Inline documentation for a hooks in wp-includes/template.php.
Props jonlynch for the initial patch.
Fixes #25487.
Built from https://develop.svn.wordpress.org/trunk@25703


git-svn-id: http://core.svn.wordpress.org/trunk@25618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-06 19:01:09 +00:00
Scott Taylor
71430cd29a Add sanity checks to get_*_template() functions to ensure that the return value of get_queried_object() is compatible with the assumed context.
Fixes #25291.
See #25282.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-12 05:32:10 +00:00
Scott Taylor
8bd9659d0d Move checks for post_type being an array inline. See [25291], [25292], #18614.
Built from https://develop.svn.wordpress.org/trunk@25312


git-svn-id: http://core.svn.wordpress.org/trunk@25274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-10 03:02:10 +00:00
Scott Taylor
d24a3940de Make sure the queried object is non-null before accessing its properties.
Props markoheijnen, ryan.
Fixes #21394.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-10 02:28:11 +00:00
Scott Taylor
a67d551dac Ensure that the post type object is the queried object when a post type has been registered with has_archive => true. Ensure it is not stomped when decorated with tax_query. Adds unit tests.
Props nacin.
Fixes #18614.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-06 22:07:09 +00:00
Sergey Biryukov
763e039b0b Improve punctuation in phpdoc. see #23090.
git-svn-id: http://core.svn.wordpress.org/trunk@23665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-12 09:30:13 +00:00
Helen Hou-Sandí
b538d6163f Make sure .widefat border and background coloring only applies to tables. props MikeHansenMe. fixes #21936.
git-svn-id: http://core.svn.wordpress.org/trunk@23315 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-01-22 14:44:04 +00:00
Andrew Nacin
ba3036ed75 Ensure that get_archive_template() only loads a post type archive (archive-$post_type.php file) if there is exactly one post type in the query.
props scribu.
see #22956.
for trunk.



git-svn-id: http://core.svn.wordpress.org/trunk@23249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-01-03 06:17:47 +00:00
Ryan Boren
06ee370814 Pinking shears
git-svn-id: http://core.svn.wordpress.org/trunk@22634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-17 15:11:29 +00:00
Ryan Boren
5c713162f1 Avoid notices in get_*_template() functions that use get_queried_object(), which can return null. Props wonderboymusic. fixes #20519
git-svn-id: http://core.svn.wordpress.org/trunk@22293 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-25 12:54:50 +00:00
Andrew Nacin
4c64b3a4b9 Expect a possible array of post types in get_archive_template(). props SergeyBiryukov. fixes #20867.
git-svn-id: http://core.svn.wordpress.org/trunk@21861 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-15 20:07:15 +00:00
nacin
111f59eac5 Remove reference to a global eliminated long ago. props tamlyn, fixes #20668.
git-svn-id: http://core.svn.wordpress.org/trunk@20872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-05-24 07:06:13 +00:00
nacin
ae8af5d0dd Introduce get_page_template_slug( $id = null ) to return a page's template (like "showcase.php"). Returns false if post ID is not a page, and an empty string for the default page template. Use the function across core. props billerickson for initial patch. fixes #18750.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20075 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-03-02 18:56:54 +00:00
nacin
e4bfd6ecc1 Move the template loading functions from wp-includes/theme.php to wp-includes/template.php. This includes get_query_template(), locate_template(), and friends. see #20103.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-28 01:49:49 +00:00