Opened 7 years ago
Closed 7 years ago
#2585 closed defect (bug) (fixed)
Add is() function that checks for single object queries.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.1 |
| Component: | Administration | Version: | 2.1 |
| Severity: | normal | Keywords: | query bg|has-patch bg|needs-testing bg|2nd-opinion |
| Cc: |
Description
Perhaps call it is_singular().
| is_page() | is_attachemnt() ) quite often. This would clean those checks up and make it easier to add new single object queries. |
I wish we had called is_single() is_post() instead. Oh well.
Attachments (2)
Change History (10)
comment:3
markjaquith — 7 years ago
If you can find any calls that are like this:
if ( is_single() || is_page() || is_attachment() ) :
Then yes, they should probably be collapsed.
| is_page() checks to determine if an is_attachment() check is needed too. |
There are no calls like what markjaquith mentioned. There are, however, quite a few that ryan mentioned.
Here is a list of all calls that are associated with this patch:
./wp-commentsrss2.php:23: <title><?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); } ?></title>
./wp-commentsrss2.php:24: <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
./wp-commentsrss2.php:30: if (is_single() || is_page()) {
./wp-commentsrss2.php:55: <title><?php if ( ! (is_single() || is_page()) ) {
./wp-content/themes/default/header.php:7:<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
./wp-content/themes/default/header.php:21:<?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single())) { ?>
./wp-trackback.php:50:if ( is_single() || is_page() )
./wp-includes/functions.php:1247: if ( is_single() || is_page() )
./wp-includes/functions.php:2262: if ( is_single() || (get_query_var('withcomments') == 1) ) {
./wp-includes/template-functions-general.php:189: if ( is_single() || is_page() ) {
./wp-includes/template-functions-links.php:211: if ( is_attachment() )
./wp-includes/template-functions-links.php:248: if( !is_single() || is_attachment() )
./wp-includes/template-functions-links.php:281: if( !is_single() || is_attachment() )
./wp-includes/template-functions-links.php:314: if ( is_attachment() )
./wp-includes/template-functions-links.php:420: if ( !is_single() ) {
./wp-includes/template-functions-links.php:437: if ( (! is_single()) && (empty($paged) || $nextpage <= $max_page) ) {
./wp-includes/template-functions-links.php:448: if ( !is_single() ) {
./wp-includes/template-functions-links.php:459: if ( (!is_single()) && ($paged > 1) ) {
./wp-includes/template-functions-links.php:487: if ( !is_single() ) {
./wp-includes/template-loader.php:19: } else if ( is_attachment() && $template = get_attachment_template() ) {
./wp-includes/template-loader.php:22: } else if ( is_single() && $template = get_single_template() ) {
./wp-includes/template-loader.php:23: if ( is_attachment() )
./wp-includes/template-loader.php:27: } else if ( is_page() && $template = get_page_template() ) {
./wp-includes/template-loader.php:28: if ( is_attachment() )
./wp-includes/template-loader.php:51: if ( is_attachment() )
./wp-includes/comment-functions.php:8: if ( is_single() || is_page() || $withcomments ) :
./wp-includes/comment-functions.php:297: if (! is_single() && ! is_page()) {
./wp-includes/classes.php:299: if ( is_single() || is_page() ) {
./wp-admin/edit.php:66: if ( is_single() )
- Keywords bg|2nd-opinion added
collapsed some of the checks. I believe I have caught the right ones.
comment:7
markjaquith — 7 years ago
[4126] Add is_singular() convenience function
Note: See
TracTickets for help on using
tickets.

Do we want to also change all the existing is_single(), is_attachment(), is_page() calls?