Add is_year(), is_month(), is_day(), is_time().

git-svn-id: http://svn.automattic.com/wordpress/trunk@1556 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-08-24 01:24:48 +00:00
parent 80842ce65b
commit b7ac2955a2
2 changed files with 72 additions and 18 deletions

View File

@ -12,6 +12,10 @@ class WP_Query {
var $is_single = false;
var $is_archive = false;
var $is_date = false;
var $is_year = false;
var $is_month = false;
var $is_day = false;
var $is_time = false;
var $is_author = false;
var $is_category = false;
var $is_search = false;
@ -22,6 +26,10 @@ class WP_Query {
$this->is_single = false;
$this->is_archive = false;
$this->is_date = false;
$this->is_year = false;
$this->is_month = false;
$this->is_day = false;
$this->is_time = false;
$this->is_author = false;
$this->is_category = false;
$this->is_search = false;
@ -49,34 +57,56 @@ class WP_Query {
$this->is_single = true;
}
if ('' != $qv['m']) {
if ('' != $qv['second']) {
$this->is_time = true;
$this->is_date = true;
}
if ('' != $qv['minute']) {
$this->is_time = true;
$this->is_date = true;
}
if ('' != $qv['hour']) {
$this->is_date = true;
}
if ('' != $qv['minute']) {
$this->is_date = true;
}
if ('' != $qv['second']) {
$this->is_date = true;
}
if ('' != $qv['year']) {
$this->is_date = true;
}
if ('' != $qv['monthnum']) {
$this->is_date = true;
$this->is_time = true;
$this->is_date = true;
}
if ('' != $qv['day']) {
if (! $this->is_date) {
$this->is_day = true;
$this->is_date = true;
}
}
if ('' != $qv['monthnum']) {
if (! $this->is_date) {
$this->is_month = true;
$this->is_date = true;
}
}
if ('' != $qv['year']) {
if (! $this->is_date) {
$this->is_year = true;
$this->is_date = true;
}
}
if ('' != $qv['m']) {
$this->is_date = true;
if (strlen($qv['m']) > 9) {
$this->is_time = true;
} else if (strlen($qv['m']) > 7) {
$this->is_day = true;
} else if (strlen($qv['m']) > 5) {
$this->is_month = true;
} else {
$this->is_year = true;
}
}
if ('' != $qv['w']) {
$this->is_date = true;
}

View File

@ -1602,6 +1602,30 @@ function is_date () {
return $wp_query->is_date;
}
function is_year () {
global $wp_query;
return $wp_query->is_year;
}
function is_month () {
global $wp_query;
return $wp_query->is_month;
}
function is_day () {
global $wp_query;
return $wp_query->is_day;
}
function is_time () {
global $wp_query;
return $wp_query->is_time;
}
function is_author () {
global $wp_query;