[wp-cvs]
wordpress/wp-includes classes.php, NONE, 1.1 functions.php,
1.127, 1.128
Ryan Boren
rboren at users.sourceforge.net
Wed Jun 30 15:31:51 UTC 2004
Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17714/wp-includes
Modified Files:
functions.php
Added Files:
classes.php
Log Message:
Add WP_Query_State class. Introduce is_single(), is_archive(), and friends.
Index: functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions.php,v
retrieving revision 1.127
retrieving revision 1.128
diff -C2 -d -r1.127 -r1.128
*** functions.php 24 Jun 2004 01:00:31 -0000 1.127
--- functions.php 30 Jun 2004 15:31:49 -0000 1.128
***************
*** 1806,1808 ****
--- 1806,1856 ----
}
+ function is_single () {
+ global $wp_query_state;
+
+ return $wp_query_state->single;
+ }
+
+ function is_archive () {
+ global $wp_query_state;
+
+ return $wp_query_state->archive;
+ }
+
+ function is_date () {
+ global $wp_query_state;
+
+ return $wp_query_state->date;
+ }
+
+ function is_author () {
+ global $wp_query_state;
+
+ return $wp_query_state->author;
+ }
+
+ function is_category () {
+ global $wp_query_state;
+
+ return $wp_query_state->category;
+ }
+
+ function is_search () {
+ global $wp_query_state;
+
+ return $wp_query_state->search;
+ }
+
+ function is_feed () {
+ global $wp_query_state;
+
+ return $wp_query_state->search;
+ }
+
+ function is_home () {
+ global $wp_query_state;
+
+ return $wp_query_state->home;
+ }
+
?>
\ No newline at end of file
--- NEW FILE: classes.php ---
<?php
class WP_Query_State {
var $single = false;
var $archive = false;
var $date = false;
var $author = false;
var $category = false;
var $search = false;
var $feed = false;
var $home = false;
function init () {
$this->single = false;
$this->archive = false;
$this->date = false;
$this->author = false;
$this->category = false;
$this->search = false;
$this->feed = false;
$this->home = false;
}
function parse_query ($query) {
parse_str($query);
$this->init();
if ('' != $m) {
$this->date = true;
}
if ('' != $hour) {
$this->date = true;
}
if ('' != $minute) {
$this->date = true;
}
if ('' != $second) {
$this->date = true;
}
if ('' != $year) {
$this->date = true;
}
if ('' != $monthnum) {
$this->date = true;
}
if ('' != $day) {
$this->date = true;
}
if ('' != $w) {
$this->date = true;
}
if ('' != $name) {
$this->single = true;
}
if (($p != '') && ($p != 'all')) {
$this->single = true;
}
if (!empty($s)) {
$this->search = true;
}
if ((empty($cat)) || ($cat == 'all') || ($cat == '0') ||
// Bypass cat checks if fetching specific posts
(
intval($year) || intval($monthnum) || intval($day) || intval($w) ||
intval($p) || !empty($name) || !empty($s)
)
) {
$this->category = false;
} else {
if (stristr($cat,'-')) {
$this->category = false;
} else {
$this->category = true;
}
}
if ('' != $category_name) {
$this->category = true;
}
if ((empty($author)) || ($author == 'all') || ($author == '0')) {
$this->author = false;
} else {
$this->author = true;
}
if ('' != $author_name) {
$this->author = true;
}
if ('' != $feed) {
$this->feed = true;
}
if ( ($this->date || $this->author || $this->category)
&& (! $this->single)) {
$this->archive = true;
}
if ( ! ($this->archive || $this->single || $this->search || $this->feed)) {
$this->home = true;
}
}
function WP_Query_State ($query = '') {
if (! empty($query)) {
$this->parse_query($query);
}
}
}
// Make a global instance.
if (! isset($wp_query_state)) {
$wp_query_state = new WP_Query_State();
}
?>
More information about the cvs
mailing list