diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index f6c3fdb9bb..94335c50bd 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -9,11 +9,16 @@ function gethelp_link($this_file, $helptag) { return $s; } -if (!isset($use_cache)) $use_cache=1; -if (!isset($blogID)) $blog_ID=1; -if (!isset($debug)) $debug=0; +if (!isset($use_cache)) $use_cache=1; +if (!isset($blogID)) $blog_ID=1; +if (!isset($debug)) $debug=0; timer_start(); +$dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1"); +foreach ($dogs as $catt) { + $cache_categories[$catt->cat_ID] = $catt; +} + get_currentuserinfo(); $posts_per_page = get_settings('posts_per_page'); @@ -27,22 +32,22 @@ $admin_area_charset = (!isset($admin_area_charset)) ? 'iso-8859-15' : $admin_are // let's deactivate quicktags on IE Mac and Lynx, because they don't work there. if (($is_macIE) || ($is_lynx)) - $use_quicktags = 0; + $use_quicktags = 0; $wpvarstoreset = array('profile','standalone','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback'); for ($i=0; $i // @@ -138,10 +143,10 @@ setTimeout("redirect();", 600); \ No newline at end of file +?> \ No newline at end of file diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 1ba6f49de9..8fc56c62c6 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -3,180 +3,188 @@ $title = 'Categories'; /* */ function add_magic_quotes($array) { - foreach ($array as $k => $v) { - if (is_array($v)) { - $array[$k] = add_magic_quotes($v); - } else { - $array[$k] = addslashes($v); - } - } - return $array; -} + foreach ($array as $k => $v) { + if (is_array($v)) { + $array[$k] = add_magic_quotes($v); + } else { + $array[$k] = addslashes($v); + } + } + return $array; +} if (!get_magic_quotes_gpc()) { - $HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS); - $HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS); - $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS); + $HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS); + $HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS); + $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS); } $wpvarstoreset = array('action','standalone','cat'); for ($i=0; $iquery("INSERT INTO $tablecategories (cat_ID, cat_name, category_nicename, category_description) VALUES ('0', '$cat_name', '$category_nicename', '$category_description')"); - - header('Location: categories.php'); + $standalone = 1; + require_once('admin-header.php'); + + if ($user_level < 3) + die ('Cheatin’ uh?'); + + $cat_name= addslashes(stripslashes(stripslashes($HTTP_POST_VARS['cat_name']))); + $category_nicename = sanitize_title($cat_name); + $category_description = addslashes(stripslashes(stripslashes($HTTP_POST_VARS['category_description']))); + + $wpdb->query("INSERT INTO $tablecategories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', $cat)"); + + header('Location: categories.php'); break; case 'Delete': - $standalone = 1; - require_once('admin-header.php'); + $standalone = 1; + require_once('admin-header.php'); - $cat_ID = intval($HTTP_GET_VARS["cat_ID"]); - $cat_name = get_catname($cat_ID); - $cat_name = addslashes($cat_name); + $cat_ID = intval($HTTP_GET_VARS["cat_ID"]); + $cat_name = get_catname($cat_ID); + $cat_name = addslashes($cat_name); - if (1 == $cat_ID) - die("Can't delete the $cat_name category: this is the default one"); + if (1 == $cat_ID) + die("Can't delete the $cat_name category: this is the default one"); - if ($user_level < 3) - die ('Cheatin’ uh?'); + if ($user_level < 3) + die ('Cheatin’ uh?'); - $wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID"); - $wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'"); + $wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID"); + $wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'"); - header('Location: categories.php'); + header('Location: categories.php'); break; case 'edit': - require_once ('admin-header.php'); - $category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = " . $HTTP_GET_VARS['cat_ID']); - $cat_name = stripslashes($category->cat_name); - ?> + require_once ('admin-header.php'); + $category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = " . $HTTP_GET_VARS['cat_ID']); + $cat_name = stripslashes($category->cat_name); + ?>
-

Edit Category

-
- - -

Category name:
-

-

Description:
-

-

-
+

Edit Category

+
+ + +

Category name:
+

+

Category parent:
+ category_parent, $HTTP_GET_VARS['cat_ID']); ?>

+

Description:
+

+

+
- query("UPDATE $tablecategories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description' WHERE cat_ID = $cat_ID"); - - header('Location: categories.php'); + $wpdb->query("UPDATE $tablecategories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = $cat WHERE cat_ID = $cat_ID"); + + header('Location: categories.php'); break; default: - $standalone = 0; - require_once ('admin-header.php'); - if ($user_level < 3) { - die("You have no right to edit the categories for this blog.
Ask for a promotion to your blog admin. :)"); - } - ?> + $standalone = 0; + require_once ('admin-header.php'); + if ($user_level < 3) { + die("You have no right to edit the categories for this blog.
Ask for a promotion to your blog admin. :)"); + } + ?>
-

Current Categories

- - - - - - - - get_results("SELECT * FROM $tablecategories ORDER BY cat_name"); - foreach ($categories as $category) { - $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID"); - $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee'; - echo " - - - - "; - } - ?> -
NameDescription# PostsAction
$category->cat_name$category->category_description$countEditcat_name) ."\' and all its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop.')\" class='delete'>Delete
+

Current Categories

+ + + + + + + + + get_results("SELECT * FROM $tablecategories ORDER BY cat_name"); + foreach ($categories as $category) { + $parent = "None"; + if ($category->category_parent) $parent = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = $category->category_parent"); + $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID"); + $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee'; + echo " + + + + + "; + } + ?> +
NameParentDescription# PostsAction
$category->cat_name$parent$category->category_description$countEditcat_name) ."\' and all its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop.')\" class='delete'>Delete
-

Add New Category

-
- -

Name:
-

-

Description: (optional)
-

-

-
+

Add New Category

+
+ +

Name:
+

+

Category parent:
+

+

Description: (optional)
+

+

+
-
+

Note:
- Deleting a category does not delete posts from that category, it will just - set them back to the default category . + Deleting a category does not delete posts from that category, it will just + set them back to the default category .

- */ include('admin-footer.php'); -?> \ No newline at end of file +?> \ No newline at end of file diff --git a/wp-blog-header.php b/wp-blog-header.php index 89872e8d51..c555cb19e9 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -6,35 +6,35 @@ $use_cache = 1; // No reason not to $curpath = dirname(__FILE__).'/'; if (!file_exists($curpath . '/wp-config.php')) - die("There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."); + die("There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."); require($curpath.'/wp-config.php'); $wpvarstoreset = array('m','p','posts','w','c', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'name', 'category_name'); - for ($i=0; $i5) - $where .= ' AND MONTH(post_date)='.substr($m,4,2); - if (strlen($m)>7) - $where .= ' AND DAYOFMONTH(post_date)='.substr($m,6,2); - if (strlen($m)>9) - $where .= ' AND HOUR(post_date)='.substr($m,8,2); - if (strlen($m)>11) - $where .= ' AND MINUTE(post_date)='.substr($m,10,2); - if (strlen($m)>13) - $where .= ' AND SECOND(post_date)='.substr($m,12,2); + $m = ''.intval($m); + $where .= ' AND YEAR(post_date)='.substr($m,0,4); + if (strlen($m)>5) + $where .= ' AND MONTH(post_date)='.substr($m,4,2); + if (strlen($m)>7) + $where .= ' AND DAYOFMONTH(post_date)='.substr($m,6,2); + if (strlen($m)>9) + $where .= ' AND HOUR(post_date)='.substr($m,8,2); + if (strlen($m)>11) + $where .= ' AND MINUTE(post_date)='.substr($m,10,2); + if (strlen($m)>13) + $where .= ' AND SECOND(post_date)='.substr($m,12,2); } if ($year != '') { - $year = '' . intval($year); - $where .= ' AND YEAR(post_date)=' . $year; + $year = '' . intval($year); + $where .= ' AND YEAR(post_date)=' . $year; } if ($monthnum != '') { - $monthnum = '' . intval($monthnum); - $where .= ' AND MONTH(post_date)=' . $monthnum; + $monthnum = '' . intval($monthnum); + $where .= ' AND MONTH(post_date)=' . $monthnum; } if ($day != '') { - $day = '' . intval($day); - $where .= ' AND DAYOFMONTH(post_date)=' . $day; + $day = '' . intval($day); + $where .= ' AND DAYOFMONTH(post_date)=' . $day; } if ($name != '') { - $name = preg_replace('/[^a-z0-9-]/', '', $name); - $where .= " AND post_name = '$name'"; + $name = preg_replace('/[^a-z0-9-]/', '', $name); + $where .= " AND post_name = '$name'"; } if ($w != '') { - $w = ''.intval($w); - $where .= ' AND WEEK(post_date, 1)=' . $w; + $w = ''.intval($w); + $where .= ' AND WEEK(post_date, 1)=' . $w; } // if a post number is specified, load that post if (($p != '') && ($p != 'all')) { - $p = intval($p); - $where = ' AND ID = '.$p; + $p = intval($p); + $where = ' AND ID = '.$p; } // if a search pattern is specified, load the posts that match if (!empty($s)) { - $s = addslashes_gpc($s); - $search = ' AND ('; - // puts spaces instead of commas - $s = preg_replace('/, +/', '', $s); - $s = str_replace(',', ' ', $s); - $s = str_replace('"', ' ', $s); - $s = trim($s); - if ($exact) { - $n = ''; - } else { - $n = '%'; - } - if (!$sentence) { - $s_array = explode(' ',$s); - $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))'; - for ( $i = 1; $i < count($s_array); $i = $i + 1) { - $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))'; - } - $search .= ' OR (post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\')'; - $search .= ')'; - } else { - $search = ' AND ((post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\'))'; - } + $s = addslashes_gpc($s); + $search = ' AND ('; + // puts spaces instead of commas + $s = preg_replace('/, +/', '', $s); + $s = str_replace(',', ' ', $s); + $s = str_replace('"', ' ', $s); + $s = trim($s); + if ($exact) { + $n = ''; + } else { + $n = '%'; + } + if (!$sentence) { + $s_array = explode(' ',$s); + $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))'; + for ( $i = 1; $i < count($s_array); $i = $i + 1) { + $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))'; + } + $search .= ' OR (post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\')'; + $search .= ')'; + } else { + $search = ' AND ((post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\'))'; + } } // category stuff +$dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1"); +foreach ($dogs as $catt) { + $cache_categories[$catt->cat_ID] = $catt; +} + if ((empty($cat)) || ($cat == 'all') || ($cat == '0')) { - $whichcat=''; + $whichcat=''; } else { - $cat = ''.urldecode($cat).''; - $cat = addslashes_gpc($cat); - if (stristr($cat,'-')) { - $eq = '!='; - $andor = 'AND'; - $cat = explode('-',$cat); - $cat = intval($cat[1]); - } else { - $eq = '='; - $andor = 'OR'; - } - $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) "; - $cat_array = explode(' ',$cat); + $cat = ''.urldecode($cat).''; + $cat = addslashes_gpc($cat); + if (stristr($cat,'-')) { + $eq = '!='; + $andor = 'AND'; + $cat = explode('-',$cat); + $cat = intval($cat[1]); + } else { + $eq = '='; + $andor = 'OR'; + } + $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) "; + $cat_array = explode(' ',$cat); $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]); + $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' '); for ($i = 1; $i < (count($cat_array)); $i = $i + 1) { - $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]); + $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]); + $whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' '); } $whichcat .= ')'; } @@ -166,136 +173,146 @@ if ((empty($cat)) || ($cat == 'all') || ($cat == '0')) { // Category stuff for nice URIs if ('' != $category_name) { - $category_name = preg_replace('|[^a-z0-9-]|', '', $category_name); - $tables = ", $tablepost2cat, $tablecategories"; - $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) "; - $whichcat = " AND (category_nicename = '$category_name') "; - $cat = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE category_nicename = '$category_name'"); + if (stristr($category_name,'/')) { + $category_name = explode('/',$category_name); + if ($category_name[count($category_name)-1]) { + $category_name = $category_name[count($category_name)-1];#no trailing slash + } else { + $category_name = $category_name[count($category_name)-2];#there was a trailling slash + } + } + $category_name = preg_replace('|[^a-z0-9-]|', '', $category_name); + $tables = ", $tablepost2cat, $tablecategories"; + $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) "; + $whichcat = " AND (category_nicename = '$category_name'"; + $cat = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE category_nicename = '$category_name'"); + $whichcat .= get_category_children($cat, " OR category_id = "); + $whichcat .= ")"; } // author stuff if ((empty($author)) || ($author == 'all') || ($author == '0')) { - $whichauthor=''; + $whichauthor=''; } else { - $author = ''.urldecode($author).''; - $author = addslashes_gpc($author); - if (stristr($author, '-')) { - $eq = '!='; - $andor = 'AND'; - $author = explode('-', $author); - $author = ''.intval($author[1]); - } else { - $eq = '='; - $andor = 'OR'; - } - $author_array = explode(' ', $author); - $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]); - for ($i = 1; $i < (count($author_array)); $i = $i + 1) { - $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]); - } - $whichauthor .= ')'; + $author = ''.urldecode($author).''; + $author = addslashes_gpc($author); + if (stristr($author, '-')) { + $eq = '!='; + $andor = 'AND'; + $author = explode('-', $author); + $author = ''.intval($author[1]); + } else { + $eq = '='; + $andor = 'OR'; + } + $author_array = explode(' ', $author); + $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]); + for ($i = 1; $i < (count($author_array)); $i = $i + 1) { + $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]); + } + $whichauthor .= ')'; } $where .= $search.$whichcat.$whichauthor; if ((empty($order)) || ((strtoupper($order) != 'ASC') && (strtoupper($order) != 'DESC'))) { - $order='DESC'; + $order='DESC'; } // order by stuff if (empty($orderby)) { - $orderby='date '.$order; + $orderby='date '.$order; } else { - // used to filter values - $allowed_keys = array('author','date','category','title'); - $orderby = urldecode($orderby); - $orderby = addslashes_gpc($orderby); - $orderby_array = explode(' ',$orderby); - if (!in_array($orderby_array[0],$allowed_keys)) { - $orderby_array[0] = 'date'; - } - $orderby = $orderby_array[0].' '.$order; - if (count($orderby_array)>1) { - for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) { - // Only allow certain values for safety - if (in_array($orderby_array[$i],$allowed_keys)) { - $orderby .= ',post_'.$orderby_array[$i].' '.$order; - } - } - } + // used to filter values + $allowed_keys = array('author','date','category','title'); + $orderby = urldecode($orderby); + $orderby = addslashes_gpc($orderby); + $orderby_array = explode(' ',$orderby); + if (!in_array($orderby_array[0],$allowed_keys)) { + $orderby_array[0] = 'date'; + } + $orderby = $orderby_array[0].' '.$order; + if (count($orderby_array)>1) { + for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) { + // Only allow certain values for safety + if (in_array($orderby_array[$i],$allowed_keys)) { + $orderby .= ',post_'.$orderby_array[$i].' '.$order; + } + } + } } if ((!$whichcat) && (!$m) && (!$p) && (!$w) && (!$s) && empty($poststart) && empty($postend)) { - if ($what_to_show == 'posts') { - $limits = ' LIMIT '.$posts_per_page; - } elseif ($what_to_show == 'days' && empty($monthnum) && empty($year) && empty($day)) { - $lastpostdate = get_lastpostdate(); - $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate); - $lastpostdate = mysql2date('U',$lastpostdate); - $otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($posts_per_page-1) * 86400))); - $where .= ' AND post_date > \''.$otherdate.'\''; - } + if ($what_to_show == 'posts') { + $limits = ' LIMIT '.$posts_per_page; + } elseif ($what_to_show == 'days' && empty($monthnum) && empty($year) && empty($day)) { + $lastpostdate = get_lastpostdate(); + $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate); + $lastpostdate = mysql2date('U',$lastpostdate); + $otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($posts_per_page-1) * 86400))); + $where .= ' AND post_date > \''.$otherdate.'\''; + } } if ( !empty($postend) && ($postend > $poststart) && (!$m) && empty($monthnum) && empty($year) && empty($day) &&(!$w) && (!$whichcat) && (!$s) && (!$p)) { - if ($what_to_show == 'posts' || ($what_to_show == 'paged' && (!$paged))) { - $poststart = intval($poststart); - $postend = intval($postend); - $limposts = $postend - $poststart; - $limits = ' LIMIT '.$poststart.','.$limposts; - } elseif ($what_to_show == 'days') { - $poststart = intval($poststart); - $postend = intval($postend); - $limposts = $postend - $poststart; - $lastpostdate = get_lastpostdate(); - $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate); - $lastpostdate = mysql2date('U',$lastpostdate); - $startdate = date('Y-m-d H:i:s', ($lastpostdate - (($poststart -1) * 86400))); - $otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($postend -1) * 86400))); - $where .= ' AND post_date > \''.$otherdate.'\' AND post_date < \''.$startdate.'\''; - } + if ($what_to_show == 'posts' || ($what_to_show == 'paged' && (!$paged))) { + $poststart = intval($poststart); + $postend = intval($postend); + $limposts = $postend - $poststart; + $limits = ' LIMIT '.$poststart.','.$limposts; + } elseif ($what_to_show == 'days') { + $poststart = intval($poststart); + $postend = intval($postend); + $limposts = $postend - $poststart; + $lastpostdate = get_lastpostdate(); + $lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate); + $lastpostdate = mysql2date('U',$lastpostdate); + $startdate = date('Y-m-d H:i:s', ($lastpostdate - (($poststart -1) * 86400))); + $otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($postend -1) * 86400))); + $where .= ' AND post_date > \''.$otherdate.'\' AND post_date < \''.$startdate.'\''; + } } else { - if (($what_to_show == 'paged') && (!$p) && (!$more)) { - if ($pagenow != 'post.php') { - $pgstrt = ''; - if ($paged) { - $pgstrt = (intval($paged) -1) * $posts_per_page . ', '; - } - $limits = 'LIMIT '.$pgstrt.$posts_per_page; - } else { - if (($m) || ($p) || ($w) || ($s) || ($whichcat)) { - $limits = ''; - } else { - $pgstrt = ''; - if ($paged) { - $pgstrt = (intval($paged) -1) * $posts_per_page . ', '; - } - $limits = 'LIMIT '.$pgstrt.$posts_per_page; - } - } - } - elseif (($m) || ($p) || ($w) || ($s) || ($whichcat) || ($author) || $monthnum || $year || $day) { - $limits = ''; - } + if (($what_to_show == 'paged') && (!$p) && (!$more)) { + if ($pagenow != 'post.php') { + $pgstrt = ''; + if ($paged) { + $pgstrt = (intval($paged) -1) * $posts_per_page . ', '; + } + $limits = 'LIMIT '.$pgstrt.$posts_per_page; + } else { + if (($m) || ($p) || ($w) || ($s) || ($whichcat)) { + $limits = ''; + } else { + $pgstrt = ''; + if ($paged) { + $pgstrt = (intval($paged) -1) * $posts_per_page . ', '; + } + $limits = 'LIMIT '.$pgstrt.$posts_per_page; + } + } + } + elseif (($m) || ($p) || ($w) || ($s) || ($whichcat) || ($author) || $monthnum || $year || $day) { + $limits = ''; + } } if ($p == 'all') { - $where = ''; + $where = ''; } $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); if ($pagenow != 'post.php' && $pagenow != 'edit.php') { - if ((empty($poststart)) || (empty($postend)) || !($postend > $poststart)) { - $where .= ' AND post_date <= \''.$now.'\''; - } + if ((empty($poststart)) || (empty($postend)) || !($postend > $poststart)) { + $where .= ' AND post_date <= \''.$now.'\''; + } - $distinct = 'DISTINCT'; + $distinct = 'DISTINCT'; - if ($use_gzipcompression) { - // gzipping the output of the script - gzip_compression(); - } + if ($use_gzipcompression) { + // gzipping the output of the script + gzip_compression(); + } } $where .= ' AND (post_status = "publish"'; @@ -309,12 +326,12 @@ $request = " SELECT $distinct * FROM $tableposts $join WHERE 1=1".$where." ORDER if ($preview) { - $request = 'SELECT 1-1'; // dummy mysql query for the preview - // little funky fix for IEwin, rawk on that code - $is_winIE = ((preg_match('/MSIE/',$HTTP_USER_AGENT)) && (preg_match('/Win/',$HTTP_USER_AGENT))); - if (($is_winIE) && (!isset($IEWin_bookmarklet_fix))) { - $preview_content = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $preview_content); - } + $request = 'SELECT 1-1'; // dummy mysql query for the preview + // little funky fix for IEwin, rawk on that code + $is_winIE = ((preg_match('/MSIE/',$HTTP_USER_AGENT)) && (preg_match('/Win/',$HTTP_USER_AGENT))); + if (($is_winIE) && (!isset($IEWin_bookmarklet_fix))) { + $preview_content = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $preview_content); + } } // error_log("$request"); @@ -325,39 +342,39 @@ $posts = $wpdb->get_results($request); if ($posts) { // Get the categories for all the posts foreach ($posts as $post) { - $post_id_list[] = $post->ID; + $post_id_list[] = $post->ID; } $post_id_list = implode(',', $post_id_list); - $dogs = $wpdb->get_results("SELECT DISTINCT - ID, category_id, cat_name, category_nicename, category_description - FROM $tablecategories, $tablepost2cat, $tableposts - WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)"); - + $dogs = $wpdb->get_results("SELECT DISTINCT + ID, category_id, cat_name, category_nicename, category_description, category_parent + FROM $tablecategories, $tablepost2cat, $tableposts + WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)"); + foreach ($dogs as $catt) { - $category_cache[$catt->ID][] = $catt; + $category_cache[$catt->ID][] = $catt; } // Do the same for comment numbers - $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount - FROM $tableposts - LEFT JOIN $tablecomments ON ( comment_post_ID = ID AND comment_approved = '1') - WHERE post_status = 'publish' AND ID IN ($post_id_list) - GROUP BY ID"); - - foreach ($comment_counts as $comment_count) { - $comment_count_cache["$comment_count->ID"] = $comment_count->ccount; - } + $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount + FROM $tableposts + LEFT JOIN $tablecomments ON ( comment_post_ID = ID AND comment_approved = '1') + WHERE post_status = 'publish' AND ID IN ($post_id_list) + GROUP BY ID"); + + foreach ($comment_counts as $comment_count) { + $comment_count_cache["$comment_count->ID"] = $comment_count->ccount; + } if (1 == count($posts)) { - if ($p || $name) { - $more = 1; - $c = 1; - $single = 1; - } - if ($s && empty($paged)) { // If they were doing a search and got one result - header('Location: ' . get_permalink($posts[0]->ID)); - } + if ($p || $name) { + $more = 1; + $c = 1; + $single = 1; + } + if ($s && empty($paged)) { // If they were doing a search and got one result + header('Location: ' . get_permalink($posts[0]->ID)); + } } } ?> \ No newline at end of file diff --git a/wp-includes/template-functions.php b/wp-includes/template-functions.php index 18790b6eca..ec09ba6531 100644 --- a/wp-includes/template-functions.php +++ b/wp-includes/template-functions.php @@ -3,9 +3,9 @@ /* new and improved ! now with more querystring stuff ! */ if (!isset($querystring_start)) { - $querystring_start = '?'; - $querystring_equal = '='; - $querystring_separator = '&'; + $querystring_start = '?'; + $querystring_equal = '='; + $querystring_separator = '&'; } /* template functions... */ @@ -19,197 +19,197 @@ if (!isset($querystring_start)) { /* Note: these tags go anywhere in the template */ function bloginfo($show='') { - $info = get_bloginfo($show); - $info = convert_bbcode($info); - $info = convert_gmcode($info); - $info = convert_smilies($info); - $info = apply_filters('bloginfo', $info); - echo convert_chars($info, 'html'); + $info = get_bloginfo($show); + $info = convert_bbcode($info); + $info = convert_gmcode($info); + $info = convert_smilies($info); + $info = apply_filters('bloginfo', $info); + echo convert_chars($info, 'html'); } function bloginfo_rss($show='') { - $info = strip_tags(get_bloginfo($show)); - echo convert_chars($info, 'unicode'); + $info = strip_tags(get_bloginfo($show)); + echo convert_chars($info, 'unicode'); } function bloginfo_unicode($show='') { - $info = get_bloginfo($show); - echo convert_chars($info, 'unicode'); + $info = get_bloginfo($show); + echo convert_chars($info, 'unicode'); } function get_bloginfo($show='') { - global $siteurl, $blogfilename, $blogname, $blogdescription, $siteurl, $admin_email; - switch($show) { - case "url": - $output = $siteurl."/".$blogfilename; - break; - case "description": - $output = $blogdescription; - break; - case "rdf_url": - $output = $siteurl.'/wp-rdf.php'; - break; - case "rss_url": - $output = $siteurl.'/wp-rss.php'; - break; - case "rss2_url": - $output = $siteurl.'/wp-rss2.php'; - break; - case "atom_url": - $output = $siteurl.'/wp-atom.php'; - break; - case "comments_rss2_url": - $output = $siteurl.'/wp-commentsrss2.php'; - break; - case "pingback_url": - $output = $siteurl.'/xmlrpc.php'; - break; - case "admin_email": - $output = $admin_email; - break; - case "name": - default: - $output = $blogname; - break; - } - return $output; + global $siteurl, $blogfilename, $blogname, $blogdescription, $siteurl, $admin_email; + switch($show) { + case "url": + $output = $siteurl."/".$blogfilename; + break; + case "description": + $output = $blogdescription; + break; + case "rdf_url": + $output = $siteurl.'/wp-rdf.php'; + break; + case "rss_url": + $output = $siteurl.'/wp-rss.php'; + break; + case "rss2_url": + $output = $siteurl.'/wp-rss2.php'; + break; + case "atom_url": + $output = $siteurl.'/wp-atom.php'; + break; + case "comments_rss2_url": + $output = $siteurl.'/wp-commentsrss2.php'; + break; + case "pingback_url": + $output = $siteurl.'/xmlrpc.php'; + break; + case "admin_email": + $output = $admin_email; + break; + case "name": + default: + $output = $blogname; + break; + } + return $output; } function wp_title($sep = '»', $display = true) { - global $wpdb, $tableposts, $tablecategories; - global $year, $monthnum, $day, $cat, $p, $name, $month; + global $wpdb, $tableposts, $tablecategories; + global $year, $monthnum, $day, $cat, $p, $name, $month; - // If there's a category - if(!empty($cat)) { - $title = stripslashes(get_the_category_by_ID($cat)); - } - if (!empty($category_name)) { - $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'")); - } + // If there's a category + if(!empty($cat)) { + $title = stripslashes(get_the_category_by_ID($cat)); + } + if (!empty($category_name)) { + $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'")); + } - // If there's a month - if(!empty($m)) { - $my_year = substr($m, 0, 4); - $my_month = $month[substr($m, 4, 2)]; - $title = "$my_year $sep $my_month"; + // If there's a month + if(!empty($m)) { + $my_year = substr($m, 0, 4); + $my_month = $month[substr($m, 4, 2)]; + $title = "$my_year $sep $my_month"; - } - if (!empty($year)) { - $title = $year; - if (!empty($monthnum)) { - $title .= " $sep ".$month[zeroise($monthnum, 2)]; - } - if (!empty($day)) { - $title .= " $sep ".zeroise($day, 2); - } - } + } + if (!empty($year)) { + $title = $year; + if (!empty($monthnum)) { + $title .= " $sep ".$month[zeroise($monthnum, 2)]; + } + if (!empty($day)) { + $title .= " $sep ".zeroise($day, 2); + } + } - // If there's a post - if (intval($p) || '' != $name) { - if (!$p) { - if ($year != '') { - $year = '' . intval($year); - $where .= ' AND YEAR(post_date)=' . $year; - } - - if ($monthnum != '') { - $monthnum = '' . intval($monthnum); - $where .= ' AND MONTH(post_date)=' . $monthnum; - } - - if ($day != '') { - $day = '' . intval($day); - $where .= ' AND DAYOFMONTH(post_date)=' . $day; - } - $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name' $where"); - } - $post_data = get_postdata($p); - $title = strip_tags(stripslashes($post_data['Title'])); - $title = apply_filters('single_post_title', $title); - } + // If there's a post + if (intval($p) || '' != $name) { + if (!$p) { + if ($year != '') { + $year = '' . intval($year); + $where .= ' AND YEAR(post_date)=' . $year; + } + + if ($monthnum != '') { + $monthnum = '' . intval($monthnum); + $where .= ' AND MONTH(post_date)=' . $monthnum; + } + + if ($day != '') { + $day = '' . intval($day); + $where .= ' AND DAYOFMONTH(post_date)=' . $day; + } + $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name' $where"); + } + $post_data = get_postdata($p); + $title = strip_tags(stripslashes($post_data['Title'])); + $title = apply_filters('single_post_title', $title); + } - // Send it out - if ($display && isset($title)) { - echo " $sep $title"; - } elseif (!$display && isset($title)) { - return " $sep $title"; - } + // Send it out + if ($display && isset($title)) { + echo " $sep $title"; + } elseif (!$display && isset($title)) { + return " $sep $title"; + } } function single_post_title($prefix = '', $display = true) { - global $p, $name, $wpdb, $tableposts; - if (intval($p) || '' != $name) { - if (!$p) { - $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'"); - } - $post_data = get_postdata($p); - $title = $post_data['Title']; - $title = apply_filters('single_post_title', $title); - if ($display) { - echo $prefix.strip_tags(stripslashes($title)); - } else { - return strip_tags(stripslashes($title)); - } - } + global $p, $name, $wpdb, $tableposts; + if (intval($p) || '' != $name) { + if (!$p) { + $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'"); + } + $post_data = get_postdata($p); + $title = $post_data['Title']; + $title = apply_filters('single_post_title', $title); + if ($display) { + echo $prefix.strip_tags(stripslashes($title)); + } else { + return strip_tags(stripslashes($title)); + } + } } function single_cat_title($prefix = '', $display = true ) { - global $cat; - if(!empty($cat) && !(strtoupper($cat) == 'ALL')) { - $my_cat_name = get_the_category_by_ID($cat); - if(!empty($my_cat_name)) { - if ($display) - echo $prefix.strip_tags(stripslashes($my_cat_name)); - else - return strip_tags(stripslashes($my_cat_name)); - } - } + global $cat; + if(!empty($cat) && !(strtoupper($cat) == 'ALL')) { + $my_cat_name = get_the_category_by_ID($cat); + if(!empty($my_cat_name)) { + if ($display) + echo $prefix.strip_tags(stripslashes($my_cat_name)); + else + return strip_tags(stripslashes($my_cat_name)); + } + } } function single_month_title($prefix = '', $display = true ) { - global $m, $month; - if(!empty($m)) { - $my_year = substr($m,0,4); - $my_month = $month[substr($m,4,2)]; - if ($display) - echo $prefix.$my_month.$prefix.$my_year; - else - return $m; - } + global $m, $month; + if(!empty($m)) { + $my_year = substr($m,0,4); + $my_month = $month[substr($m,4,2)]; + if ($display) + echo $prefix.$my_month.$prefix.$my_year; + else + return $m; + } } /* link navigation hack by Orien http://icecode.com/ */ function get_archives_link($url, $text, $format = "html", $before = "", $after = "") { - if ('link' == $format) { - return "\t".''."\n"; - } else if ('option' == $format) { - return ''."\n"; - } else if ('html' == $format) { - return "\t".'
  • '.$text.''.$after.'
  • '."\n"; - } else { // custom - return "\t".$before.''.$text.''.$after."\n"; - } + if ('link' == $format) { + return "\t".''."\n"; + } else if ('option' == $format) { + return ''."\n"; + } else if ('html' == $format) { + return "\t".'
  • '.$text.''.$after.'
  • '."\n"; + } else { // custom + return "\t".$before.''.$text.''.$after."\n"; + } } function get_archives($type='', $limit='', $format='html', $before = "", $after = "", $show_post_count = false) { - global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename; + global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename; global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week; if ('' == $type) { $type = get_settings('archive_mode'); } - if ('' != $limit) { + if ('' != $limit) { $limit = (int) $limit; - $limit = " LIMIT $limit"; - } - // this is what will separate dates on weekly archive links - $archive_week_separator = '–'; + $limit = " LIMIT $limit"; + } + // this is what will separate dates on weekly archive links + $archive_week_separator = '–'; - // archive link url - $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive; - $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive; - $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive; + // archive link url + $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive; + $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive; + $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive; // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride $archive_date_format_over_ride = 0; @@ -227,10 +227,10 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after $archive_week_end_date_format = $dateformat; } - $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); + $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); - if ('monthly' == $type) { - $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); + if ('monthly' == $type) { + $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); if ($arcresults) { foreach ($arcresults as $arcresult) { $url = get_month_link($arcresult->year, $arcresult->month); @@ -243,8 +243,8 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after echo get_archives_link($url, $text, $format, $before, $after); } } - } elseif ('daily' == $type) { - $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); + } elseif ('daily' == $type) { + $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); if ($arcresults) { foreach ($arcresults as $arcresult) { $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); @@ -253,12 +253,12 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after echo get_archives_link($url, $text, $format, $before, $after); } } - } elseif ('weekly' == $type) { - if (!isset($start_of_week)) { - $start_of_week = 1; - } - $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); - $arc_w_last = ''; + } elseif ('weekly' == $type) { + if (!isset($start_of_week)) { + $start_of_week = 1; + } + $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); + $arc_w_last = ''; if ($arcresults) { foreach ($arcresults as $arcresult) { if ($arcresult->week != $arc_w_last) { @@ -275,8 +275,8 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after } } } - } elseif ('postbypost' == $type) { - $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); + } elseif ('postbypost' == $type) { + $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); if ($arcresults) { foreach ($arcresults as $arcresult) { if ($arcresult->post_date != '0000-00-00 00:00:00') { @@ -291,11 +291,11 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after } } } - } + } } function get_calendar($daylength = 1) { - global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts; + global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts; // Quick check. If we have no posts at all, abort! if (!$posts) { @@ -304,167 +304,167 @@ function get_calendar($daylength = 1) { return; } - if (isset($HTTP_GET_VARS['w'])) { - $w = ''.intval($HTTP_GET_VARS['w']); - } - $time_difference = get_settings('time_difference'); + if (isset($HTTP_GET_VARS['w'])) { + $w = ''.intval($HTTP_GET_VARS['w']); + } + $time_difference = get_settings('time_difference'); - // Let's figure out when we are - if (!empty($monthnum) && !empty($year)) { - $thismonth = ''.intval($monthnum); - $thisyear = ''.intval($year); - } elseif (!empty($w)) { - // We need to get the month from MySQL - $thisyear = ''.intval(substr($m, 0, 4)); - $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's - $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); - } elseif (!empty($m)) { - $calendar = substr($m, 0, 6); - $thisyear = ''.intval(substr($m, 0, 4)); - if (strlen($m) < 6) { - $thismonth = '01'; - } else { - $thismonth = ''.intval(substr($m, 4, 2)); - } - } else { - $thisyear = intval(date('Y', time()+($time_difference * 3600))); - $thismonth = intval(date('m', time()+($time_difference * 3600))); - } + // Let's figure out when we are + if (!empty($monthnum) && !empty($year)) { + $thismonth = ''.intval($monthnum); + $thisyear = ''.intval($year); + } elseif (!empty($w)) { + // We need to get the month from MySQL + $thisyear = ''.intval(substr($m, 0, 4)); + $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's + $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); + } elseif (!empty($m)) { + $calendar = substr($m, 0, 6); + $thisyear = ''.intval(substr($m, 0, 4)); + if (strlen($m) < 6) { + $thismonth = '01'; + } else { + $thismonth = ''.intval(substr($m, 4, 2)); + } + } else { + $thisyear = intval(date('Y', time()+($time_difference * 3600))); + $thismonth = intval(date('m', time()+($time_difference * 3600))); + } - $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); + $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); - // Get the next and previous month and year with at least one post - $previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year - FROM $tableposts - WHERE post_date < '$thisyear-$thismonth-01' - AND post_status = 'publish' - ORDER BY post_date DESC - LIMIT 1"); - $next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year - FROM $tableposts - WHERE post_date > '$thisyear-$thismonth-01' - AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) - AND post_status = 'publish' - ORDER BY post_date ASC - LIMIT 1"); + // Get the next and previous month and year with at least one post + $previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year + FROM $tableposts + WHERE post_date < '$thisyear-$thismonth-01' + AND post_status = 'publish' + ORDER BY post_date DESC + LIMIT 1"); + $next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year + FROM $tableposts + WHERE post_date > '$thisyear-$thismonth-01' + AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) + AND post_status = 'publish' + ORDER BY post_date ASC + LIMIT 1"); - echo ' - - - '; - foreach ($weekday as $wd) { - echo "\n\t\t'; - } + echo '
    ' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '
    " . substr($wd, 0, $daylength) . '
    + + + '; + foreach ($weekday as $wd) { + echo "\n\t\t'; + } - echo ' - - + echo ' + + - - '; + + '; - if ($previous) { - echo "\n\t\t".''; - } else { - echo "\n\t\t".''; - } + if ($previous) { + echo "\n\t\t".''; + } else { + echo "\n\t\t".''; + } - echo "\n\t\t".''; + echo "\n\t\t".''; - if ($next) { - echo "\n\t\t".''; - } else { - echo "\n\t\t".''; - } + if ($next) { + echo "\n\t\t".''; + } else { + echo "\n\t\t".''; + } - echo ' - - + echo ' + + - - '; + + '; - // Get days with posts - $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) - FROM $tableposts WHERE MONTH(post_date) = $thismonth - AND YEAR(post_date) = $thisyear - AND post_status = 'publish' - AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N); - if ($dayswithposts) { - foreach ($dayswithposts as $daywith) { - $daywithpost[] = $daywith[0]; - } - } else { - $daywithpost = array(); - } + // Get days with posts + $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) + FROM $tableposts WHERE MONTH(post_date) = $thismonth + AND YEAR(post_date) = $thisyear + AND post_status = 'publish' + AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N); + if ($dayswithposts) { + foreach ($dayswithposts as $daywith) { + $daywithpost[] = $daywith[0]; + } + } else { + $daywithpost = array(); + } - if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") || - strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "camino") || - strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "safari")) { - $ak_title_separator = "\n"; - } else { - $ak_title_separator = ", "; - } + if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") || + strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "camino") || + strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "safari")) { + $ak_title_separator = "\n"; + } else { + $ak_title_separator = ", "; + } - $ak_titles_for_day = array(); - $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " - ."FROM $tableposts " - ."WHERE YEAR(post_date) = '$thisyear' " - ."AND MONTH(post_date) = '$thismonth' " - ."AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' " - ."AND post_status = 'publish'" - ); - if ($ak_post_titles) { - foreach ($ak_post_titles as $ak_post_title) { - if (empty($ak_titles_for_day["day_".$ak_post_title->dom])) { - $ak_titles_for_day["day_".$ak_post_title->dom] = ''; - } - if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one - $ak_titles_for_day["$ak_post_title->dom"] .= htmlspecialchars(stripslashes($ak_post_title->post_title)); - } else { - $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . htmlspecialchars(stripslashes($ak_post_title->post_title)); - } - } - } + $ak_titles_for_day = array(); + $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " + ."FROM $tableposts " + ."WHERE YEAR(post_date) = '$thisyear' " + ."AND MONTH(post_date) = '$thismonth' " + ."AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' " + ."AND post_status = 'publish'" + ); + if ($ak_post_titles) { + foreach ($ak_post_titles as $ak_post_title) { + if (empty($ak_titles_for_day["day_".$ak_post_title->dom])) { + $ak_titles_for_day["day_".$ak_post_title->dom] = ''; + } + if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one + $ak_titles_for_day["$ak_post_title->dom"] .= htmlspecialchars(stripslashes($ak_post_title->post_title)); + } else { + $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . htmlspecialchars(stripslashes($ak_post_title->post_title)); + } + } + } - // See how much we should pad in the beginning - $pad = intval(date('w', $unixmonth)); - if (0 != $pad) echo "\n\t\t"; + // See how much we should pad in the beginning + $pad = intval(date('w', $unixmonth)); + if (0 != $pad) echo "\n\t\t"; - $daysinmonth = intval(date('t', $unixmonth)); - for ($day = 1; $day <= $daysinmonth; ++$day) { - if (isset($newrow) && $newrow) - echo "\n\t\n\t\n\t\t"; - $newrow = false; + $daysinmonth = intval(date('t', $unixmonth)); + for ($day = 1; $day <= $daysinmonth; ++$day) { + if (isset($newrow) && $newrow) + echo "\n\t\n\t\n\t\t"; + $newrow = false; - if ($day == date('j', (time() + ($time_difference * 3600))) && $thismonth == date('m', time()+($time_difference * 3600))) - echo ''; + if (in_array($day, $daywithpost)) { // any posts today? + echo '$day"; + } else { + echo $day; + } + echo ''; - if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))) - $newrow = true; - } + if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))) + $newrow = true; + } - $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)); - if ($pad != 0 && $pad != 7) - echo "\n\t\t"; + $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)); + if ($pad != 0 && $pad != 7) + echo "\n\t\t"; - echo "\n\t\n\t\n\t
    ' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '
    " . substr($wd, 0, $daylength) . '
    « ' . substr($month[zeroise($previous->month, 2)], 0, 3) . ' « ' . substr($month[zeroise($previous->month, 2)], 0, 3) . '   ' . substr($month[zeroise($next->month, 2)], 0, 3) . ' » ' . substr($month[zeroise($next->month, 2)], 0, 3) . ' » 
      
    '; - else - echo ""; + if ($day == date('j', (time() + ($time_difference * 3600))) && $thismonth == date('m', time()+($time_difference * 3600))) + echo ''; + else + echo ""; - if (in_array($day, $daywithpost)) { // any posts today? - echo '$day"; - } else { - echo $day; - } - echo '  
    "; + echo "\n\t\n\t\n\t"; } /***** // About-the-blog tags *****/ @@ -472,120 +472,120 @@ function get_calendar($daylength = 1) { /***** Links *****/ function get_permalink($id=false) { - global $post, $wpdb, $tableposts; - global $siteurl, $blogfilename, $querystring_start, $querystring_equal; + global $post, $wpdb, $tableposts; + global $siteurl, $blogfilename, $querystring_start, $querystring_equal; - $rewritecode = array( - '%year%', - '%monthnum%', - '%day%', - '%postname%', - '%post_id%' - ); - if (!$id) { - if ('' != get_settings('permalink_structure')) { - $unixtime = strtotime($post->post_date); - $rewritereplace = array( - date('Y', $unixtime), - date('m', $unixtime), - date('d', $unixtime), - $post->post_name, - $post->ID - ); - return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); - } else { // if they're not using the fancy permalink option - return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$post->ID; - } - } else { // if an ID is given - $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id"); - if ('' != get_settings('permalink_structure')) { - $unixtime = strtotime($idpost->post_date); - $rewritereplace = array( - date('Y', $unixtime), - date('m', $unixtime), - date('d', $unixtime), - $idpost->post_name, - $id - ); - return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); - } else { - return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$id; - } - } + $rewritecode = array( + '%year%', + '%monthnum%', + '%day%', + '%postname%', + '%post_id%' + ); + if (!$id) { + if ('' != get_settings('permalink_structure')) { + $unixtime = strtotime($post->post_date); + $rewritereplace = array( + date('Y', $unixtime), + date('m', $unixtime), + date('d', $unixtime), + $post->post_name, + $post->ID + ); + return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); + } else { // if they're not using the fancy permalink option + return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$post->ID; + } + } else { // if an ID is given + $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id"); + if ('' != get_settings('permalink_structure')) { + $unixtime = strtotime($idpost->post_date); + $rewritereplace = array( + date('Y', $unixtime), + date('m', $unixtime), + date('d', $unixtime), + $idpost->post_name, + $id + ); + return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); + } else { + return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$id; + } + } } function get_month_link($year, $month) { - global $siteurl, $blogfilename, $querystring_start, $querystring_equal; - if (!$year) $year = date('Y', time()+($time_difference * 3600)); - if (!$month) $month = date('m', time()+($time_difference * 3600)); - if ('' != get_settings('permalink_structure')) { - $off = strpos(get_settings('permalink_structure'), '%monthnum%'); - $offset = $off + 11; - $monthlink = substr(get_settings('permalink_structure'), 0, $offset); - if ('/' != substr($monthlink, -1)) $monthlink = substr($monthlink, 0, -1); - $monthlink = str_replace('%year%', $year, $monthlink); - $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); - $monthlink = str_replace('%post_id%', '', $monthlink); - return $siteurl . $monthlink; - } else { - return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2); - } + global $siteurl, $blogfilename, $querystring_start, $querystring_equal; + if (!$year) $year = date('Y', time()+($time_difference * 3600)); + if (!$month) $month = date('m', time()+($time_difference * 3600)); + if ('' != get_settings('permalink_structure')) { + $off = strpos(get_settings('permalink_structure'), '%monthnum%'); + $offset = $off + 11; + $monthlink = substr(get_settings('permalink_structure'), 0, $offset); + if ('/' != substr($monthlink, -1)) $monthlink = substr($monthlink, 0, -1); + $monthlink = str_replace('%year%', $year, $monthlink); + $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); + $monthlink = str_replace('%post_id%', '', $monthlink); + return $siteurl . $monthlink; + } else { + return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2); + } } function get_day_link($year, $month, $day) { - global $siteurl, $blogfilename, $querystring_start, $querystring_equal; - if (!$year) $year = date('Y', time()+($time_difference * 3600)); - if (!$month) $month = date('m', time()+($time_difference * 3600)); - if (!$day) $day = date('j', time()+($time_difference * 3600)); - if ('' != get_settings('permalink_structure')) { - $off = strpos(get_settings('permalink_structure'), '%day%'); - $offset = $off + 6; - $daylink = substr(get_settings('permalink_structure'), 0, $offset); - if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1); - $daylink = str_replace('%year%', $year, $daylink); - $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); - $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); - $daylink = str_replace('%post_id%', '', $daylink); - return $siteurl . $daylink; - } else { - return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2); - } + global $siteurl, $blogfilename, $querystring_start, $querystring_equal; + if (!$year) $year = date('Y', time()+($time_difference * 3600)); + if (!$month) $month = date('m', time()+($time_difference * 3600)); + if (!$day) $day = date('j', time()+($time_difference * 3600)); + if ('' != get_settings('permalink_structure')) { + $off = strpos(get_settings('permalink_structure'), '%day%'); + $offset = $off + 6; + $daylink = substr(get_settings('permalink_structure'), 0, $offset); + if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1); + $daylink = str_replace('%year%', $year, $daylink); + $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); + $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); + $daylink = str_replace('%post_id%', '', $daylink); + return $siteurl . $daylink; + } else { + return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2); + } } function edit_post_link($link = 'Edit This', $before = '', $after = '') { - global $user_level, $post, $siteurl; + global $user_level, $post, $siteurl; - get_currentuserinfo(); + get_currentuserinfo(); - if ($user_level > 0) { - $authordata = get_userdata($post->post_author); - if ($user_level < $authordata->user_level) { - return; - } - } else { - return; - } + if ($user_level > 0) { + $authordata = get_userdata($post->post_author); + if ($user_level < $authordata->user_level) { + return; + } + } else { + return; + } - $location = "$siteurl/wp-admin/post.php?action=edit&post=$post->ID"; - echo "$before $link $after"; + $location = "$siteurl/wp-admin/post.php?action=edit&post=$post->ID"; + echo "$before $link $after"; } function edit_comment_link($link = 'Edit This', $before = '', $after = '') { - global $user_level, $post, $comment, $siteurl; + global $user_level, $post, $comment, $siteurl; - get_currentuserinfo(); + get_currentuserinfo(); - if ($user_level > 0) { - $authordata = get_userdata($post->post_author); - if ($user_level < $authordata->user_level) { - return; - } - } else { - return; - } + if ($user_level > 0) { + $authordata = get_userdata($post->post_author); + if ($user_level < $authordata->user_level) { + return; + } + } else { + return; + } - $location = "$siteurl/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID"; - echo "$before $link $after"; + $location = "$siteurl/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID"; + echo "$before $link $after"; } /***** Date/Time tags *****/ @@ -597,59 +597,59 @@ function the_date_xml() { } function the_date($d='', $before='', $after='', $echo = true) { - global $id, $post, $day, $previousday, $dateformat, $newday; - $the_date = ''; - if ($day != $previousday) { - $the_date .= $before; - if ($d=='') { - $the_date .= mysql2date($dateformat, $post->post_date); - } else { - $the_date .= mysql2date($d, $post->post_date); - } - $the_date .= $after; - $previousday = $day; - } - $the_date = apply_filters('the_date', $the_date); - if ($echo) { - echo $the_date; - } else { - return $the_date; - } + global $id, $post, $day, $previousday, $dateformat, $newday; + $the_date = ''; + if ($day != $previousday) { + $the_date .= $before; + if ($d=='') { + $the_date .= mysql2date($dateformat, $post->post_date); + } else { + $the_date .= mysql2date($d, $post->post_date); + } + $the_date .= $after; + $previousday = $day; + } + $the_date = apply_filters('the_date', $the_date); + if ($echo) { + echo $the_date; + } else { + return $the_date; + } } function the_time($d='', $echo = true) { - global $id, $post, $timeformat; - if ($d=='') { - $the_time = mysql2date($timeformat, $post->post_date); - } else { - $the_time = mysql2date($d, $post->post_date); - } - $the_time = apply_filters('the_time', $the_time); - if ($echo) { - echo $the_time; - } else { - return $the_time; - } + global $id, $post, $timeformat; + if ($d=='') { + $the_time = mysql2date($timeformat, $post->post_date); + } else { + $the_time = mysql2date($d, $post->post_date); + } + $the_time = apply_filters('the_time', $the_time); + if ($echo) { + echo $the_time; + } else { + return $the_time; + } } function the_weekday() { - global $weekday, $id, $post; - $the_weekday = $weekday[mysql2date('w', $post->post_date)]; - $the_weekday = apply_filters('the_weekday', $the_weekday); - echo $the_weekday; + global $weekday, $id, $post; + $the_weekday = $weekday[mysql2date('w', $post->post_date)]; + $the_weekday = apply_filters('the_weekday', $the_weekday); + echo $the_weekday; } function the_weekday_date($before='',$after='') { - global $weekday, $id, $post, $day, $previousweekday; - $the_weekday_date = ''; - if ($day != $previousweekday) { - $the_weekday_date .= $before; - $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)]; - $the_weekday_date .= $after; - $previousweekday = $day; - } - $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date); - echo $the_weekday_date; + global $weekday, $id, $post, $day, $previousweekday; + $the_weekday_date = ''; + if ($day != $previousweekday) { + $the_weekday_date .= $before; + $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)]; + $the_weekday_date .= $after; + $previousweekday = $day; + } + $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date); + echo $the_weekday_date; } /***** // Date/Time tags *****/ @@ -779,66 +779,66 @@ function print_DegreeConfluence_Url() { /***** Author tags *****/ function the_author() { - global $id, $authordata; - $i = $authordata->user_idmode; - if ($i == 'nickname') echo $authordata->user_nickname; - if ($i == 'login') echo $authordata->user_login; - if ($i == 'firstname') echo $authordata->user_firstname; - if ($i == 'lastname') echo $authordata->user_lastname; - if ($i == 'namefl') echo $authordata->user_firstname.' '.$authordata->user_lastname; - if ($i == 'namelf') echo $authordata->user_lastname.' '.$authordata->user_firstname; - if (!$i) echo $authordata->user_nickname; + global $id, $authordata; + $i = $authordata->user_idmode; + if ($i == 'nickname') echo $authordata->user_nickname; + if ($i == 'login') echo $authordata->user_login; + if ($i == 'firstname') echo $authordata->user_firstname; + if ($i == 'lastname') echo $authordata->user_lastname; + if ($i == 'namefl') echo $authordata->user_firstname.' '.$authordata->user_lastname; + if ($i == 'namelf') echo $authordata->user_lastname.' '.$authordata->user_firstname; + if (!$i) echo $authordata->user_nickname; } function the_author_description() { - global $authordata; - echo $authordata->user_description; + global $authordata; + echo $authordata->user_description; } function the_author_login() { - global $id,$authordata; echo $authordata->user_login; + global $id,$authordata; echo $authordata->user_login; } function the_author_firstname() { - global $id,$authordata; echo $authordata->user_firstname; + global $id,$authordata; echo $authordata->user_firstname; } function the_author_lastname() { - global $id,$authordata; echo $authordata->user_lastname; + global $id,$authordata; echo $authordata->user_lastname; } function the_author_nickname() { - global $id,$authordata; echo $authordata->user_nickname; + global $id,$authordata; echo $authordata->user_nickname; } function the_author_ID() { - global $id,$authordata; echo $authordata->ID; + global $id,$authordata; echo $authordata->ID; } function the_author_email() { - global $id,$authordata; echo antispambot($authordata->user_email); + global $id,$authordata; echo antispambot($authordata->user_email); } function the_author_url() { - global $id,$authordata; echo $authordata->user_url; + global $id,$authordata; echo $authordata->user_url; } function the_author_icq() { - global $id,$authordata; echo $authordata->user_icq; + global $id,$authordata; echo $authordata->user_icq; } function the_author_aim() { - global $id,$authordata; echo str_replace(' ', '+', $authordata->user_aim); + global $id,$authordata; echo str_replace(' ', '+', $authordata->user_aim); } function the_author_yim() { - global $id,$authordata; echo $authordata->user_yim; + global $id,$authordata; echo $authordata->user_yim; } function the_author_msn() { - global $id,$authordata; echo $authordata->user_msn; + global $id,$authordata; echo $authordata->user_msn; } function the_author_posts() { - global $id,$postdata; $posts=get_usernumposts($post->post_author); echo $posts; + global $id,$postdata; $posts=get_usernumposts($post->post_author); echo $posts; } /***** // Author tags *****/ @@ -849,217 +849,217 @@ function the_author_posts() { /***** Post tags *****/ function get_the_password_form() { - $output = "
    -

    This post is password protected. To view it please enter your password below:

    -

    -
    - "; - return $output; + $output = "
    +

    This post is password protected. To view it please enter your password below:

    +

    +
    + "; + return $output; } function the_ID() { - global $id; - echo $id; + global $id; + echo $id; } function the_title($before = '', $after = '', $echo = true) { - $title = get_the_title(); - $title = convert_smilies($title); - if (!empty($title)) { - $title = convert_chars($before.$title.$after); - $title = apply_filters('the_title', $title); + $title = get_the_title(); + $title = convert_smilies($title); + if (!empty($title)) { + $title = convert_chars($before.$title.$after); + $title = apply_filters('the_title', $title); if ($echo) echo $title; else return $title; - } + } } function the_title_rss() { - $title = get_the_title(); - $title = strip_tags($title); - if (trim($title)) { - echo convert_chars($title, 'unicode'); - } + $title = get_the_title(); + $title = strip_tags($title); + if (trim($title)) { + echo convert_chars($title, 'unicode'); + } } function the_title_unicode($before='',$after='') { - $title = get_the_title(); - $title = convert_bbcode($title); - $title = convert_gmcode($title); - if ($title) { - $title = convert_chars($before.$title.$after); - $title = apply_filters('the_title_unicode', $title); - echo $title; - } + $title = get_the_title(); + $title = convert_bbcode($title); + $title = convert_gmcode($title); + if ($title) { + $title = convert_chars($before.$title.$after); + $title = apply_filters('the_title_unicode', $title); + echo $title; + } } function get_the_title() { - global $post; - $output = stripslashes($post->post_title); - if (!empty($post->post_password)) { // if there's a password - $output = 'Protected: ' . $output; - } - return $output; + global $post; + $output = stripslashes($post->post_title); + if (!empty($post->post_password)) { // if there's a password + $output = 'Protected: ' . $output; + } + return $output; } function the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') { - $content = get_the_content($more_link_text, $stripteaser, $more_file); - $content = convert_bbcode($content); - $content = convert_gmcode($content); - $content = convert_smilies($content); - $content = convert_chars($content, 'html'); - $content = apply_filters('the_content', $content); - echo $content; + $content = get_the_content($more_link_text, $stripteaser, $more_file); + $content = convert_bbcode($content); + $content = convert_gmcode($content); + $content = convert_smilies($content); + $content = convert_chars($content, 'html'); + $content = apply_filters('the_content', $content); + echo $content; } function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { - $content = get_the_content($more_link_text, $stripteaser, $more_file); - $content = convert_bbcode($content); - $content = convert_gmcode($content); - $content = convert_chars($content, 'unicode'); - if ($cut && !$encode_html) { - $encode_html = 2; - } - if ($encode_html == 1) { - $content = htmlspecialchars($content); - $cut = 0; - } elseif ($encode_html == 0) { - $content = make_url_footnote($content); - } elseif ($encode_html == 2) { - $content = strip_tags($content); - } - if ($cut) { - $blah = explode(' ', $content); - if (count($blah) > $cut) { - $k = $cut; - $use_dotdotdot = 1; - } else { - $k = count($blah); - $use_dotdotdot = 0; - } - for ($i=0; $i<$k; $i++) { - $excerpt .= $blah[$i].' '; - } - $excerpt .= ($use_dotdotdot) ? '...' : ''; - $content = $excerpt; - } - echo $content; + $content = get_the_content($more_link_text, $stripteaser, $more_file); + $content = convert_bbcode($content); + $content = convert_gmcode($content); + $content = convert_chars($content, 'unicode'); + if ($cut && !$encode_html) { + $encode_html = 2; + } + if ($encode_html == 1) { + $content = htmlspecialchars($content); + $cut = 0; + } elseif ($encode_html == 0) { + $content = make_url_footnote($content); + } elseif ($encode_html == 2) { + $content = strip_tags($content); + } + if ($cut) { + $blah = explode(' ', $content); + if (count($blah) > $cut) { + $k = $cut; + $use_dotdotdot = 1; + } else { + $k = count($blah); + $use_dotdotdot = 0; + } + for ($i=0; $i<$k; $i++) { + $excerpt .= $blah[$i].' '; + } + $excerpt .= ($use_dotdotdot) ? '...' : ''; + $content = $excerpt; + } + echo $content; } function the_content_unicode($more_link_text='(more...)', $stripteaser=0, $more_file='') { - $content = get_the_content($more_link_text, $stripteaser, $more_file); - $content = convert_bbcode($content); - $content = convert_gmcode($content); - $content = convert_smilies($content); - $content = convert_chars($content, 'unicode'); - $content = apply_filters('the_content_unicode', $content); - echo $content; + $content = get_the_content($more_link_text, $stripteaser, $more_file); + $content = convert_bbcode($content); + $content = convert_gmcode($content); + $content = convert_smilies($content); + $content = convert_chars($content, 'unicode'); + $content = apply_filters('the_content_unicode', $content); + echo $content; } function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') { - global $id, $post, $more, $c, $withcomments, $page, $pages, $multipage, $numpages; - global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; - global $querystring_start, $querystring_equal, $querystring_separator; + global $id, $post, $more, $c, $withcomments, $page, $pages, $multipage, $numpages; + global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; + global $querystring_start, $querystring_equal, $querystring_separator; global $pagenow; - $output = ''; + $output = ''; - if (!empty($post->post_password)) { // if there's a password - if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie - $output = get_the_password_form(); - return $output; - } - } + if (!empty($post->post_password)) { // if there's a password + if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie + $output = get_the_password_form(); + return $output; + } + } - if ($more_file != '') { - $file = $more_file; - } else { - $file = $pagenow; //$HTTP_SERVER_VARS['PHP_SELF']; - } - $content = $pages[$page-1]; - $content = explode('', $content); - if ((preg_match('//', $post->post_content) && ((!$multipage) || ($page==1)))) - $stripteaser = 1; - $teaser = $content[0]; - if (($more) && ($stripteaser)) - $teaser = ''; - $output .= $teaser; - if (count($content)>1) { - if ($more) { - $output .= ''.$content[1]; - } else { - $output .= " $more_link_text"; - } - } - if ($preview) { // preview fix for javascript bug with foreign languages - $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); - } - return $output; + if ($more_file != '') { + $file = $more_file; + } else { + $file = $pagenow; //$HTTP_SERVER_VARS['PHP_SELF']; + } + $content = $pages[$page-1]; + $content = explode('', $content); + if ((preg_match('//', $post->post_content) && ((!$multipage) || ($page==1)))) + $stripteaser = 1; + $teaser = $content[0]; + if (($more) && ($stripteaser)) + $teaser = ''; + $output .= $teaser; + if (count($content)>1) { + if ($more) { + $output .= ''.$content[1]; + } else { + $output .= " $more_link_text"; + } + } + if ($preview) { // preview fix for javascript bug with foreign languages + $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); + } + return $output; } function the_excerpt() { - $excerpt = get_the_excerpt(); - $excerpt = convert_bbcode($excerpt); - $excerpt = convert_gmcode($excerpt); - $excerpt = convert_smilies($excerpt); - $excerpt = convert_chars($excerpt, 'html'); - $excerpt = apply_filters('the_excerpt', $excerpt); - echo $excerpt; + $excerpt = get_the_excerpt(); + $excerpt = convert_bbcode($excerpt); + $excerpt = convert_gmcode($excerpt); + $excerpt = convert_smilies($excerpt); + $excerpt = convert_chars($excerpt, 'html'); + $excerpt = apply_filters('the_excerpt', $excerpt); + echo $excerpt; } function the_excerpt_rss($cut = 0, $encode_html = 0) { - $output = get_the_excerpt(true); - $output = convert_bbcode($output); - $output = convert_gmcode($output); - $output = convert_chars($output, 'unicode'); - if ($cut && !$encode_html) { - $encode_html = 2; - } - if ($encode_html == 1) { - $output = htmlspecialchars($output); - $cut = 0; - } elseif ($encode_html == 0) { - $output = make_url_footnote($output); - } elseif ($encode_html == 2) { - $output = strip_tags($output); - } - if ($cut) { + $output = get_the_excerpt(true); + $output = convert_bbcode($output); + $output = convert_gmcode($output); + $output = convert_chars($output, 'unicode'); + if ($cut && !$encode_html) { + $encode_html = 2; + } + if ($encode_html == 1) { + $output = htmlspecialchars($output); + $cut = 0; + } elseif ($encode_html == 0) { + $output = make_url_footnote($output); + } elseif ($encode_html == 2) { + $output = strip_tags($output); + } + if ($cut) { $excerpt = ''; - $blah = explode(' ', $output); - if (count($blah) > $cut) { - $k = $cut; - $use_dotdotdot = 1; - } else { - $k = count($blah); - $use_dotdotdot = 0; - } - for ($i=0; $i<$k; $i++) { - $excerpt .= $blah[$i].' '; - } - $excerpt .= ($use_dotdotdot) ? '...' : ''; - $output = $excerpt; - } - echo $output; + $blah = explode(' ', $output); + if (count($blah) > $cut) { + $k = $cut; + $use_dotdotdot = 1; + } else { + $k = count($blah); + $use_dotdotdot = 0; + } + for ($i=0; $i<$k; $i++) { + $excerpt .= $blah[$i].' '; + } + $excerpt .= ($use_dotdotdot) ? '...' : ''; + $output = $excerpt; + } + echo $output; } function the_excerpt_unicode() { - $excerpt = get_the_excerpt(); - $excerpt = convert_bbcode($excerpt); - $excerpt = convert_gmcode($excerpt); - $excerpt = convert_smilies($excerpt); - $excerpt = convert_chars($excerpt, 'unicode'); - $excerpt = apply_filters('the_excerpt_unicode', $excerpt); - echo $excerpt; + $excerpt = get_the_excerpt(); + $excerpt = convert_bbcode($excerpt); + $excerpt = convert_gmcode($excerpt); + $excerpt = convert_smilies($excerpt); + $excerpt = convert_chars($excerpt, 'unicode'); + $excerpt = apply_filters('the_excerpt_unicode', $excerpt); + echo $excerpt; } function get_the_excerpt($fakeit = false) { - global $id, $post; - global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; - $output = ''; - $output = stripslashes($post->post_excerpt); - if (!empty($post->post_password)) { // if there's a password - if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie - $output = "There is no excerpt because this is a protected post."; - return $output; - } - } + global $id, $post; + global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; + $output = ''; + $output = stripslashes($post->post_excerpt); + if (!empty($post->post_password)) { // if there's a password + if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie + $output = "There is no excerpt because this is a protected post."; + return $output; + } + } //if we haven't got an excerpt, make one in the style of the rss ones if (($output == '') && $fakeit) { $output = get_the_content(); @@ -1067,260 +1067,260 @@ function get_the_excerpt($fakeit = false) { $blah = explode(' ', $output); $excerpt_length = 120; if (count($blah) > $excerpt_length) { - $k = $excerpt_length; - $use_dotdotdot = 1; - } else { - $k = count($blah); - $use_dotdotdot = 0; - } + $k = $excerpt_length; + $use_dotdotdot = 1; + } else { + $k = count($blah); + $use_dotdotdot = 0; + } $excerpt = ''; - for ($i=0; $i<$k; $i++) { - $excerpt .= $blah[$i].' '; - } - $excerpt .= ($use_dotdotdot) ? '...' : ''; - $output = $excerpt; + for ($i=0; $i<$k; $i++) { + $excerpt .= $blah[$i].' '; + } + $excerpt .= ($use_dotdotdot) ? '...' : ''; + $output = $excerpt; } // end if no excerpt - if ($preview) { // preview fix for javascript bug with foreign languages - $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); - } - return $output; + if ($preview) { // preview fix for javascript bug with foreign languages + $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); + } + return $output; } function link_pages($before='
    ', $after='
    ', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { - global $id, $page, $numpages, $multipage, $more; - global $pagenow; - global $querystring_start, $querystring_equal, $querystring_separator; - if ($more_file != '') { - $file = $more_file; - } else { - $file = $pagenow; - } - if (($multipage)) { - if ($next_or_number=='number') { - echo $before; - for ($i = 1; $i < ($numpages+1); $i = $i + 1) { - $j=str_replace('%',"$i",$pagelink); - echo " "; - if (($i != $page) || ((!$more) && ($page==1))) { - if ('' == get_settings('permalink_structure')) { - echo ''; - } else { - echo ''; - } - } - echo $j; - if (($i != $page) || ((!$more) && ($page==1))) - echo ''; - } - echo $after; - } else { - if ($more) { - echo $before; - $i=$page-1; - if ($i && $more) { - if ('' == get_settings('permalink_structure')) { - echo ''; - } else { - echo ''; - } - } - $i=$page+1; - if ($i<=$numpages && $more) { - if ('' == get_settings('permalink_structure')) { - echo ''; - } else { - echo ''; - } - } - echo $after; - } - } - } + global $id, $page, $numpages, $multipage, $more; + global $pagenow; + global $querystring_start, $querystring_equal, $querystring_separator; + if ($more_file != '') { + $file = $more_file; + } else { + $file = $pagenow; + } + if (($multipage)) { + if ($next_or_number=='number') { + echo $before; + for ($i = 1; $i < ($numpages+1); $i = $i + 1) { + $j=str_replace('%',"$i",$pagelink); + echo " "; + if (($i != $page) || ((!$more) && ($page==1))) { + if ('' == get_settings('permalink_structure')) { + echo ''; + } else { + echo ''; + } + } + echo $j; + if (($i != $page) || ((!$more) && ($page==1))) + echo ''; + } + echo $after; + } else { + if ($more) { + echo $before; + $i=$page-1; + if ($i && $more) { + if ('' == get_settings('permalink_structure')) { + echo ''; + } else { + echo ''; + } + } + $i=$page+1; + if ($i<=$numpages && $more) { + if ('' == get_settings('permalink_structure')) { + echo ''; + } else { + echo ''; + } + } + echo $after; + } + } + } } function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { - global $tableposts, $id, $post, $siteurl, $blogfilename, $wpdb; - global $p, $posts, $posts_per_page, $s, $single; - global $querystring_start, $querystring_equal, $querystring_separator; + global $tableposts, $id, $post, $siteurl, $blogfilename, $wpdb; + global $p, $posts, $posts_per_page, $s, $single; + global $querystring_start, $querystring_equal, $querystring_separator; - if(($p) || ($posts_per_page == 1) || 1 == $single) { + if(($p) || ($posts_per_page == 1) || 1 == $single) { - $current_post_date = $post->post_date; - $current_category = $post->post_category; + $current_post_date = $post->post_date; + $current_category = $post->post_category; - $sqlcat = ''; - if ($in_same_cat != 'no') { - $sqlcat = " AND post_category = '$current_category' "; - } + $sqlcat = ''; + if ($in_same_cat != 'no') { + $sqlcat = " AND post_category = '$current_category' "; + } - $sql_exclude_cats = ''; - if (!empty($excluded_categories)) { - $blah = explode('and', $excluded_categories); - foreach($blah as $category) { - $category = intval($category); - $sql_exclude_cats .= " AND post_category != $category"; - } - } + $sql_exclude_cats = ''; + if (!empty($excluded_categories)) { + $blah = explode('and', $excluded_categories); + foreach($blah as $category) { + $category = intval($category); + $sql_exclude_cats .= " AND post_category != $category"; + } + } - $limitprev--; - $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1"); - if ($lastpost) { - $string = ''.$previous; - if ($title == 'yes') { + $limitprev--; + $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1"); + if ($lastpost) { + $string = ''.$previous; + if ($title == 'yes') { $string .= wptexturize(stripslashes($lastpost->post_title)); } - $string .= ''; - $format = str_replace('%', $string, $format); - echo $format; - } - } + $string .= ''; + $format = str_replace('%', $string, $format); + echo $format; + } + } } function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { - global $tableposts, $p, $posts, $id, $post, $siteurl, $blogfilename, $wpdb; - global $time_difference, $single; - global $querystring_start, $querystring_equal, $querystring_separator; - if(($p) || ($posts==1) || 1 == $single) { + global $tableposts, $p, $posts, $id, $post, $siteurl, $blogfilename, $wpdb; + global $time_difference, $single; + global $querystring_start, $querystring_equal, $querystring_separator; + if(($p) || ($posts==1) || 1 == $single) { - $current_post_date = $post->post_date; - $current_category = $post->post_category; + $current_post_date = $post->post_date; + $current_category = $post->post_category; - $sqlcat = ''; - if ($in_same_cat != 'no') { - $sqlcat = " AND post_category='$current_category' "; - } + $sqlcat = ''; + if ($in_same_cat != 'no') { + $sqlcat = " AND post_category='$current_category' "; + } - $sql_exclude_cats = ''; - if (!empty($excluded_categories)) { - $blah = explode('and', $excluded_categories); - foreach($blah as $category) { - $category = intval($category); - $sql_exclude_cats .= " AND post_category != $category"; - } - } + $sql_exclude_cats = ''; + if (!empty($excluded_categories)) { + $blah = explode('and', $excluded_categories); + foreach($blah as $category) { + $category = intval($category); + $sql_exclude_cats .= " AND post_category != $category"; + } + } - $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); + $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); - $limitnext--; + $limitnext--; - $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext,1"); - if ($nextpost) { - $string = ''.$next; - if ($title=='yes') { - $string .= wptexturize(stripslashes($nextpost->post_title)); - } - $string .= ''; - $format = str_replace('%', $string, $format); - echo $format; - } - } + $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext,1"); + if ($nextpost) { + $string = ''.$next; + if ($title=='yes') { + $string .= wptexturize(stripslashes($nextpost->post_title)); + } + $string .= ''; + $format = str_replace('%', $string, $format); + echo $format; + } + } } function next_posts($max_page = 0) { // original by cfactor at cooltux.org - global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow; - global $querystring_start, $querystring_equal, $querystring_separator; - if (empty($p) && ($what_to_show == 'paged')) { - $qstr = $HTTP_SERVER_VARS['QUERY_STRING']; - if (!empty($qstr)) { - $qstr = preg_replace("/&paged=\d{0,}/","",$qstr); - $qstr = preg_replace("/paged=\d{0,}/","",$qstr); - } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) { - if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', - $HTTP_SERVER_VARS['REQUEST_URI']) ) { - $qstr = preg_replace("/^\//", "", $qstr); - $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr); - $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr); - $qstr = preg_replace("/\/$/", "", $qstr); - } - } - if (!$paged) $paged = 1; - $nextpage = intval($paged) + 1; - if (!$max_page || $max_page >= $nextpage) { - echo $siteurl.'/'.$pagenow.$querystring_start. - ($qstr == '' ? '' : $qstr.$querystring_separator) . - 'paged'.$querystring_equal.$nextpage; - } - } + global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow; + global $querystring_start, $querystring_equal, $querystring_separator; + if (empty($p) && ($what_to_show == 'paged')) { + $qstr = $HTTP_SERVER_VARS['QUERY_STRING']; + if (!empty($qstr)) { + $qstr = preg_replace("/&paged=\d{0,}/","",$qstr); + $qstr = preg_replace("/paged=\d{0,}/","",$qstr); + } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) { + if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', + $HTTP_SERVER_VARS['REQUEST_URI']) ) { + $qstr = preg_replace("/^\//", "", $qstr); + $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr); + $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr); + $qstr = preg_replace("/\/$/", "", $qstr); + } + } + if (!$paged) $paged = 1; + $nextpage = intval($paged) + 1; + if (!$max_page || $max_page >= $nextpage) { + echo $siteurl.'/'.$pagenow.$querystring_start. + ($qstr == '' ? '' : $qstr.$querystring_separator) . + 'paged'.$querystring_equal.$nextpage; + } + } } function next_posts_link($label='Next Page »', $max_page=0) { - global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb; - if ($what_to_show == 'paged') { - if (!$max_page) { - $nxt_request = $request; + global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb; + if ($what_to_show == 'paged') { + if (!$max_page) { + $nxt_request = $request; //if the query includes a limit clause, call it again without that //limit clause! - if ($pos = strpos(strtoupper($request), 'LIMIT')) { - $nxt_request = substr($request, 0, $pos); - } - $nxt_result = $wpdb->query($nxt_request); - $numposts = $wpdb->num_rows; - $max_page = ceil($numposts / $posts_per_page); - } - if (!$paged) + if ($pos = strpos(strtoupper($request), 'LIMIT')) { + $nxt_request = substr($request, 0, $pos); + } + $nxt_result = $wpdb->query($nxt_request); + $numposts = $wpdb->num_rows; + $max_page = ceil($numposts / $posts_per_page); + } + if (!$paged) $paged = 1; - $nextpage = intval($paged) + 1; - if (empty($p) && (empty($paged) || $nextpage <= $max_page)) { - echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; - } - } + $nextpage = intval($paged) + 1; + if (empty($p) && (empty($paged) || $nextpage <= $max_page)) { + echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; + } + } } function previous_posts() { // original by cfactor at cooltux.org - global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow; - global $querystring_start, $querystring_equal, $querystring_separator; - if (empty($p) && ($what_to_show == 'paged')) { - $qstr = $HTTP_SERVER_VARS['QUERY_STRING']; - if (!empty($qstr)) { - $qstr = preg_replace("/&paged=\d{0,}/","",$qstr); - $qstr = preg_replace("/paged=\d{0,}/","",$qstr); - } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) { - if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', - $HTTP_SERVER_VARS['REQUEST_URI']) ) { - $qstr = preg_replace("/^\//", "", $qstr); - $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr); - $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr); - $qstr = preg_replace("/\/$/", "", $qstr); - } - } - $nextpage = intval($paged) - 1; - if ($nextpage < 1) $nextpage = 1; - echo $siteurl.'/'.$pagenow.$querystring_start. - ($qstr == '' ? '' : $qstr.$querystring_separator) . - 'paged'.$querystring_equal.$nextpage; - } + global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow; + global $querystring_start, $querystring_equal, $querystring_separator; + if (empty($p) && ($what_to_show == 'paged')) { + $qstr = $HTTP_SERVER_VARS['QUERY_STRING']; + if (!empty($qstr)) { + $qstr = preg_replace("/&paged=\d{0,}/","",$qstr); + $qstr = preg_replace("/paged=\d{0,}/","",$qstr); + } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) { + if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', + $HTTP_SERVER_VARS['REQUEST_URI']) ) { + $qstr = preg_replace("/^\//", "", $qstr); + $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr); + $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr); + $qstr = preg_replace("/\/$/", "", $qstr); + } + } + $nextpage = intval($paged) - 1; + if ($nextpage < 1) $nextpage = 1; + echo $siteurl.'/'.$pagenow.$querystring_start. + ($qstr == '' ? '' : $qstr.$querystring_separator) . + 'paged'.$querystring_equal.$nextpage; + } } function previous_posts_link($label='« Previous Page') { - global $p, $paged, $what_to_show; - if (empty($p) && ($paged > 1) && ($what_to_show == 'paged')) { - echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; - } + global $p, $paged, $what_to_show; + if (empty($p) && ($paged > 1) && ($what_to_show == 'paged')) { + echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; + } } function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Next Page >>') { - global $p, $what_to_show, $request, $posts_per_page, $wpdb; - if (empty($p) && ($what_to_show == 'paged')) { - $nxt_request = $request; - if ($pos = strpos(strtoupper($request), 'LIMIT')) { - $nxt_request = substr($request, 0, $pos); - } + global $p, $what_to_show, $request, $posts_per_page, $wpdb; + if (empty($p) && ($what_to_show == 'paged')) { + $nxt_request = $request; + if ($pos = strpos(strtoupper($request), 'LIMIT')) { + $nxt_request = substr($request, 0, $pos); + } $nxt_result = $wpdb->query($nxt_request); $numposts = $wpdb->num_rows; - $max_page = ceil($numposts / $posts_per_page); - if ($max_page > 1) { - previous_posts_link($prelabel); - echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep); - next_posts_link($nxtlabel, $max_page); - } - } + $max_page = ceil($numposts / $posts_per_page); + if ($max_page > 1) { + previous_posts_link($prelabel); + echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep); + next_posts_link($nxtlabel, $max_page); + } + } } /***** // Post tags *****/ @@ -1331,92 +1331,148 @@ function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Ne /***** Category tags *****/ function get_the_category() { - global $post, $tablecategories, $tablepost2cat, $wpdb, $category_cache; - if ($category_cache[$post->ID]) { - return $category_cache[$post->ID]; - } else { - $categories = $wpdb->get_results(" - SELECT category_id, cat_name, category_nicename, category_description - FROM $tablecategories, $tablepost2cat - WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID - "); - - return $categories; - } + global $post, $tablecategories, $tablepost2cat, $wpdb, $category_cache; + if ($category_cache[$post->ID]) { + return $category_cache[$post->ID]; + } else { + $categories = $wpdb->get_results(" + SELECT category_id, cat_name, category_nicename, category_description, category_parent + FROM $tablecategories, $tablepost2cat + WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID + "); + + return $categories; + } } function get_category_link($echo = false, $category_id, $category_nicename) { - global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename; - $cat_ID = $category_id; - $permalink_structure = get_settings('permalink_structure'); - - if ('' == $permalink_structure) { - $file = "$siteurl/$blogfilename"; - $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; - } else { - if ('' == $category_nicename) $category_nicename = $wpdb->get_var("SELECT category_nicename FROM $tablecategories WHERE cat_ID = $category_id"); - // Get any static stuff from the front - $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); - $link = $siteurl . $front . 'category/' . $category_nicename . '/'; - } + global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename, $cache_categories; + $cat_ID = $category_id; + $permalink_structure = get_settings('permalink_structure'); + + if ('' == $permalink_structure) { + $file = "$siteurl/$blogfilename"; + $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; + } else { + if ('' == $category_nicename) $category_nicename = $cache_categories[$category_id]->category_nicename; + // Get any static stuff from the front + $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); + $link = $siteurl . $front . 'category/'; + if ($parent=$cache_categories[$category_id]->category_parent) $link .= get_category_parents($parent, FALSE, '/', TRUE); + $link .= $category_nicename . '/'; + } - if ($echo) echo $link; - return $link; + if ($echo) echo $link; + return $link; } -function the_category($seperator = '') { - $categories = get_the_category(); - if ('' == $seperator) { - echo '
      '; - foreach ($categories as $category) { - $category->cat_name = stripslashes($category->cat_name); - echo "\n\t
    • $category->cat_name
    • "; - } - echo '
    '; - } else { - $i = 0; - foreach ($categories as $category) { - $category->cat_name = stripslashes($category->cat_name); - if (0 < $i) echo $seperator . ' '; - echo "$category->cat_name"; - ++$i; - } - } +function the_category($seperator = '', $parents='') { + $categories = get_the_category(); + if ('' == $seperator) { + echo ''; + } else { + $i = 0; + foreach ($categories as $category) { + $category->cat_name = stripslashes($category->cat_name); + if (0 < $i) echo $seperator . ' '; + switch(strtolower($parents)) { + case 'multiple': + if ($category->category_parent) echo get_category_parents($category->category_parent, TRUE); + echo "$category->cat_name"; + case 'single': + echo ""; + if ($category->category_parent)echo get_category_parents($category->category_parent, FALSE); + echo "$category->cat_name"; + case '': + default: + echo "$category->cat_name"; + } + ++$i; + } + } } function the_category_rss($type = 'rss') { - $categories = get_the_category(); - foreach ($categories as $category) { - $category->cat_name = stripslashes(convert_chars($category->cat_name)); - if ('rdf' == $type) { - echo "\n$category->cat_name"; - } else { - echo "\n$category->cat_name"; - } - } + $categories = get_the_category(); + foreach ($categories as $category) { + $category->cat_name = stripslashes(convert_chars($category->cat_name)); + if ('rdf' == $type) { + echo "\n$category->cat_name"; + } else { + echo "\n$category->cat_name"; + } + } } function the_category_unicode() { - $category = get_the_category(); - $category = apply_filters('the_category_unicode', $category); - echo convert_chars($category, 'unicode'); + $category = get_the_category(); + $category = apply_filters('the_category_unicode', $category); + echo convert_chars($category, 'unicode'); } - - function get_the_category_by_ID($cat_ID) { - global $tablecategories, $cache_categories, $use_cache, $wpdb; - if ((!$cache_categories[$cat_ID]) OR (!$use_cache)) { - $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"); - $cache_categories[$cat_ID] = $cat_name; - } else { - $cat_name = $cache_categories[$cat_ID]; - } - return(stripslashes($cat_name)); + global $tablecategories, $cache_categories, $use_cache, $wpdb; + if ((!$cache_categories[$cat_ID]) OR (!$use_cache)) { + $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"); + $cache_categories[$cat_ID]->cat_name = $cat_name; + } else { + $cat_name = $cache_categories[$cat_ID]->cat_name; + } + return(stripslashes($cat_name)); +} + +function get_category_parents($id, $link=FALSE, $separator=' / ', $nicename=FALSE){ + global $tablecategories, $cache_categories; + $chain = ""; + $parent = $cache_categories[$id]; + if ($nicename) { + $name = $parent->category_nicename; + } else { + $name = $parent->cat_name; + } + if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); + if ($link) { + $chain .= "$name" . $separator; + } else { + $chain .= $name.$separator; + } + return $chain; +} + +function get_category_children($id, $before=' / ', $after='') { + global $tablecategories, $cache_categories; + $c_cache=$cache_categories;#can't do recursive foreach on a global, have to make a copy + $chain = ""; + foreach ($c_cache as $category){ + if ($category->category_parent == $id){ + $chain .= $before.$category->cat_ID.$after; + $chain .= get_category_children($category->cat_ID, $before, $after); + } + } + return $chain; } function the_category_ID($echo=true) { - global $post; + global $post; if ($echo) echo $post->post_category; else @@ -1424,68 +1480,76 @@ function the_category_ID($echo=true) { } function the_category_head($before='', $after='') { - global $post, $currentcat, $previouscat, $dateformat, $newday; - $currentcat = $post->post_category; - if ($currentcat != $previouscat) { - echo $before; - echo get_the_category_by_ID($currentcat); - echo $after; - $previouscat = $currentcat; - } + global $post, $currentcat, $previouscat, $dateformat, $newday; + $currentcat = $post->post_category; + if ($currentcat != $previouscat) { + echo $before; + echo get_the_category_by_ID($currentcat); + echo $after; + $previouscat = $currentcat; + } } function category_description($category = 0) { - global $cat, $wpdb, $tablecategories; - if (!$category) $category = $cat; - $category_description = $wpdb->get_var("SELECT category_description FROM $tablecategories WHERE cat_ID = $category"); - $category_description = apply_filters('category_description', $category_description); - return $category_description; + global $cat, $wpdb, $tablecategories, $cache_categories; + if (!$category) $category = $cat; + $category_description = $cache_categories[$category]->category_description; + $category_description = apply_filters('category_description', $category_description); + return $category_description; } // out of the WordPress loop function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', - $optiondates = 0, $optioncount = 0, $hide_empty = 1) { - global $cat, $tablecategories, $tableposts, $wpdb; + $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, + $selected=0, $hide=0) { + global $tablecategories, $tableposts, $tablepost2cat, $wpdb; + global $pagenow, $siteurl, $blogfilename; + global $querystring_start, $querystring_equal, $querystring_separator; + if (($file == 'blah') || ($file == '')) $file = "$siteurl/$blogfilename"; + if (!$selected) $selected=$cat; $sort_column = 'cat_'.$sort_column; - $query = " SELECT cat_ID, cat_name,"; - $query .= " COUNT($tableposts.ID) AS cat_count,"; - $query .= " DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth"; - $query .= " FROM $tablecategories LEFT JOIN $tableposts ON cat_ID = post_category"; - $query .= " WHERE cat_ID > 0 "; - $query .= " GROUP BY post_category "; - if (intval($hide_empty) == 1) { - $query .= " HAVING cat_count > 0"; + $query = " + SELECT cat_ID, cat_name, category_nicename,category_parent, + COUNT($tablepost2cat.post_id) AS cat_count, + DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth + FROM $tablecategories LEFT JOIN $tablepost2cat ON (cat_ID = category_id) + LEFT JOIN $tableposts ON (ID = post_id) + WHERE cat_ID > 0 + "; + if ($hide) { + $query .= " AND cat_ID != $hide"; + $query .= get_category_children($hide, " AND cat_ID != "); } + $query .=" GROUP BY cat_ID"; + if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0"; $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; - $categories = $wpdb->get_results($query); - echo "\n"; + $categories = $wpdb->get_results($query); + echo "\n"; } -// Out of the WordPress loop -function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 0) { +// out of the WordPress loop +function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 0, $children=FALSE, $child_of=0, $categories=0, $recurse=0) { global $tablecategories, $tableposts, $tablepost2cat, $wpdb; global $pagenow, $siteurl, $blogfilename; global $querystring_start, $querystring_equal, $querystring_separator; @@ -1493,16 +1557,17 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde if ('' == $file) { $file = "$siteurl/$blogfilename"; } - $sort_column = 'cat_'.$sort_column; + if (intval($categories)==0){ + $sort_column = 'cat_'.$sort_column; - $query = " - SELECT cat_ID, cat_name, category_nicename, category_description - FROM $tablecategories - WHERE cat_ID > 0 - ORDER BY $sort_column $sort_order"; - - $categories = $wpdb->get_results($query); + $query = " + SELECT cat_ID, cat_name, category_nicename, category_description, category_parent + FROM $tablecategories + WHERE cat_ID > 0 + ORDER BY $sort_column $sort_order"; + $categories = $wpdb->get_results($query); + } if (intval($hide_empty) == 1 || intval($optioncount) == 1) { $cat_counts = $wpdb->get_results(" SELECT cat_ID, COUNT($tablepost2cat.post_id) AS cat_count @@ -1525,18 +1590,23 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $category_lastmonth["$cat_date->cat_ID"] = $cat_date->lastmonth; } } - - if (!$categories) { + + if (intval($optionall) == 1 && !$child_of && $categories) { + $all = apply_filters('list_cats', $all); + $link = "'.$all.""; if ($list) { - $before = '
  • '; - $after = '
  • '; + echo "\n\t
  • $link
  • "; + } else { + echo "\t$link
    \n"; } - echo $before . "No categories" . $after . "\n"; - return; } - + + $num_found=0; + $thelist = ""; + foreach ($categories as $category) { - if (intval($hide_empty) == 0 || $category_posts["$category->cat_ID"] > 0) { + if ((intval($hide_empty) == 0 || $category_posts["$category->cat_ID"] > 0) && (!$children || $category->category_parent == $child_of)) { + $num_found++; $link = 'category_description)) { $link .= 'title="View all posts filed under ' . htmlspecialchars($category->cat_name) . '"'; @@ -1552,12 +1622,31 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $link .= ' '.$category_lastday["$category->cat_ID"].'/'.$category_lastmonth["$category->cat_ID"]; } if ($list) { - echo "\t
  • $link
  • \n"; + $thelist .= "\t
  • $link\n"; } else { - echo "\t$link
    \n"; + $thelist .= "\t$link
    \n"; + } + if ($children) $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $children, $category->cat_ID, $categories, 1); + if ($list) $thelist .= "
  • \n"; } - } } + if (!$num_found && !$child_of){ + if ($list) { + $before = '
  • '; + $after = '
  • '; + } + echo $before . "No categories" . $after . "\n"; + return; + } + if ($list && $child_of && $num_found && $recurse) { + $pre = "\t\t
      "; + $post = "\t\t
    \n"; + } + $thelist=$pre.$thelist.$post; + if ($recurse) { + return $thelist; + } + echo $thelist; } /***** // Category tags *****/ @@ -1579,47 +1668,47 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde // generic comments/trackbacks/pingbacks numbering function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') { - global $id, $comment, $tablecomments, $wpdb; - if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'"); - if ($number == 0) { - $blah = $zero; - } elseif ($number == 1) { - $blah = $one; - } elseif ($number > 1) { - $blah = str_replace('%', $number, $more); - } - echo $blah; + global $id, $comment, $tablecomments, $wpdb; + if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'"); + if ($number == 0) { + $blah = $zero; + } elseif ($number == 1) { + $blah = $one; + } elseif ($number > 1) { + $blah = str_replace('%', $number, $more); + } + echo $blah; } function comments_link($file='', $echo=true) { - global $id, $pagenow; - if ($file == '') $file = $pagenow; - if ($file == '/') $file = ''; - if (!$echo) return get_permalink() . '#comments'; - else echo get_permalink() . '#comments'; + global $id, $pagenow; + if ($file == '') $file = $pagenow; + if ($file == '/') $file = ''; + if (!$echo) return get_permalink() . '#comments'; + else echo get_permalink() . '#comments'; } function comments_popup_script($width=400, $height=400, $file='wp-comments-popup.php') { - global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript; - $wpcommentspopupfile = $file; - $wpcommentsjavascript = 1; - $javascript = "\n"; - echo $javascript; + global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript; + $wpcommentspopupfile = $file; + $wpcommentsjavascript = 1; + $javascript = "\n"; + echo $javascript; } function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { - global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash; - global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; - global $comment_count_cache; - if ('' == $comment_count_cache["$id"]) { - $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';"); - } else { - $number = $comment_count_cache["$id"]; - } - if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) { - echo $none; - return; - } else { + global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash; + global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; + global $comment_count_cache; + if ('' == $comment_count_cache["$id"]) { + $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';"); + } else { + $number = $comment_count_cache["$id"]; + } + if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) { + echo $none; + return; + } else { if (!empty($post->post_password)) { // if there's a password if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie echo("Enter your password to view comments"); @@ -1646,182 +1735,183 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com } function comment_ID() { - global $comment; - echo $comment->comment_ID; + global $comment; + echo $comment->comment_ID; } function comment_author() { - global $comment; - $author = stripslashes(stripslashes($comment->comment_author)); - $author = apply_filters('comment_auther', $author); - $author = convert_chars($author); - if (!empty($author)) { - echo $author; - } else { - echo "Anonymous"; - } + global $comment; + $author = stripslashes(stripslashes($comment->comment_author)); + $author = apply_filters('comment_auther', $author); + $author = convert_chars($author); + if (!empty($author)) { + echo $comment->comment_author; + } + else { + echo "Anonymous"; + } } function comment_author_email() { - global $comment; - $email = stripslashes(stripslashes($comment->comment_author_email)); - - echo antispambot(stripslashes($comment->comment_author_email)); + global $comment; + $email = stripslashes(stripslashes($comment->comment_author_email)); + + echo antispambot(stripslashes($comment->comment_author_email)); } function comment_author_link() { - global $comment; - $url = trim(stripslashes($comment->comment_author_url)); - $email = stripslashes($comment->comment_author_email); - $author = stripslashes($comment->comment_author); - $author = convert_chars($author); - $author = wptexturize($author); - if (empty($author)) { - $author = "Anonymous"; - } + global $comment; + $url = trim(stripslashes($comment->comment_author_url)); + $email = stripslashes($comment->comment_author_email); + $author = stripslashes($comment->comment_author); + $author = convert_chars($author); + $author = wptexturize($author); + if (empty($author)) { + $author = "Anonymous"; + } - $url = str_replace('http://url', '', $url); - $url = preg_replace('|[^a-z0-9-_.?#=&;,/:]|i', '', $url); - if (empty($url) && empty($email)) { - echo $author; - return; - } - echo '
    ' . $author . ''; + $url = str_replace('http://url', '', $url); + $url = preg_replace('|[^a-z0-9-_.?#=&;,/:]|i', '', $url); + if (empty($url) && empty($email)) { + echo $author; + return; + } + echo '' . $author . ''; } function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { - global $comment; - if (preg_match('||', $comment->comment_content)) echo $trackbacktxt; - elseif (preg_match('||', $comment->comment_content)) echo $pingbacktxt; - else echo $commenttxt; + global $comment; + if (preg_match('||', $comment->comment_content)) echo $trackbacktxt; + elseif (preg_match('||', $comment->comment_content)) echo $pingbacktxt; + else echo $commenttxt; } function comment_author_url() { - global $comment; - $url = trim(stripslashes($comment->comment_author_url)); - $url = str_replace(';//', '://', $url); - $url = (!strstr($url, '://')) ? 'http://'.$url : $url; - // convert & into & - $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); - $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url); - if ($url != 'http://url') { - echo $url; - } + global $comment; + $url = trim(stripslashes($comment->comment_author_url)); + $url = str_replace(';//', '://', $url); + $url = (!strstr($url, '://')) ? 'http://'.$url : $url; + // convert & into & + $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); + $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url); + if ($url != 'http://url') { + echo $url; + } } function comment_author_email_link($linktext='', $before='', $after='') { - global $comment; - $email = $comment->comment_author_email; - if ((!empty($email)) && ($email != '@')) { - $display = ($linktext != '') ? $linktext : antispambot(stripslashes($email)); - echo $before; - echo ''.$display.''; - echo $after; - } + global $comment; + $email = $comment->comment_author_email; + if ((!empty($email)) && ($email != '@')) { + $display = ($linktext != '') ? $linktext : antispambot(stripslashes($email)); + echo $before; + echo ''.$display.''; + echo $after; + } } function comment_author_url_link($linktext='', $before='', $after='') { - global $comment; - $url = trim(stripslashes($comment->comment_author_url)); - $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); - $url = (!stristr($url, '://')) ? 'http://'.$url : $url; - $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url); - if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) { - $display = ($linktext != '') ? $linktext : stripslashes($url); - echo $before; - echo ''.$display.''; - echo $after; - } + global $comment; + $url = trim(stripslashes($comment->comment_author_url)); + $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); + $url = (!stristr($url, '://')) ? 'http://'.$url : $url; + $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url); + if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) { + $display = ($linktext != '') ? $linktext : stripslashes($url); + echo $before; + echo ''.$display.''; + echo $after; + } } function comment_author_IP() { - global $comment; - echo stripslashes($comment->comment_author_IP); + global $comment; + echo stripslashes($comment->comment_author_IP); } function comment_text() { - global $comment; - $comment_text = stripslashes($comment->comment_content); - $comment_text = str_replace('', '', $comment_text); - $comment_text = str_replace('', '', $comment_text); - $comment_text = convert_chars($comment_text); - $comment_text = convert_bbcode($comment_text); - $comment_text = convert_gmcode($comment_text); - $comment_text = make_clickable($comment_text); - $comment_text = balanceTags($comment_text,1); - $comment_text = apply_filters('comment_text', $comment_text); - $comment_text = convert_smilies($comment_text); - echo $comment_text; + global $comment; + $comment_text = stripslashes($comment->comment_content); + $comment_text = str_replace('', '', $comment_text); + $comment_text = str_replace('', '', $comment_text); + $comment_text = convert_chars($comment_text); + $comment_text = convert_bbcode($comment_text); + $comment_text = convert_gmcode($comment_text); + $comment_text = make_clickable($comment_text); + $comment_text = balanceTags($comment_text,1); + $comment_text = apply_filters('comment_text', $comment_text); + $comment_text = convert_smilies($comment_text); + echo $comment_text; } function comment_date($d='') { - global $comment, $dateformat; - if ($d == '') { - echo mysql2date($dateformat, $comment->comment_date); - } else { - echo mysql2date($d, $comment->comment_date); - } + global $comment, $dateformat; + if ($d == '') { + echo mysql2date($dateformat, $comment->comment_date); + } else { + echo mysql2date($d, $comment->comment_date); + } } function comment_time($d='') { - global $comment, $timeformat; - if ($d == '') { - echo mysql2date($timeformat, $comment->comment_date); - } else { - echo mysql2date($d, $comment->comment_date); - } + global $comment, $timeformat; + if ($d == '') { + echo mysql2date($timeformat, $comment->comment_date); + } else { + echo mysql2date($d, $comment->comment_date); + } } function comments_rss_link($link_text='Comments RSS', $commentsrssfilename = 'wp-commentsrss2.php') { - global $id; - global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; - $url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id; - $url = ''.$link_text.''; - echo $url; + global $id; + global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; + $url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id; + $url = ''.$link_text.''; + echo $url; } function comment_author_rss() { - global $comment; - if (!empty($comment->comment_author)) { - echo htmlspecialchars(strip_tags(stripslashes($comment->comment_author))); - } - else { - echo "Anonymous"; - } + global $comment; + if (!empty($comment->comment_author)) { + echo htmlspecialchars(strip_tags(stripslashes($comment->comment_author))); + } + else { + echo "Anonymous"; + } } function comment_text_rss() { - global $comment; - $comment_text = stripslashes($comment->comment_content); - $comment_text = str_replace('', '', $comment_text); - $comment_text = str_replace('', '', $comment_text); - $comment_text = convert_chars($comment_text); - $comment_text = convert_bbcode($comment_text); - $comment_text = convert_gmcode($comment_text); - $comment_text = convert_smilies($comment_text); - $comment_text = apply_filters('comment_text', $comment_text); - $comment_text = strip_tags($comment_text); - $comment_text = htmlspecialchars($comment_text); - echo $comment_text; + global $comment; + $comment_text = stripslashes($comment->comment_content); + $comment_text = str_replace('', '', $comment_text); + $comment_text = str_replace('', '', $comment_text); + $comment_text = convert_chars($comment_text); + $comment_text = convert_bbcode($comment_text); + $comment_text = convert_gmcode($comment_text); + $comment_text = convert_smilies($comment_text); + $comment_text = apply_filters('comment_text', $comment_text); + $comment_text = strip_tags($comment_text); + $comment_text = htmlspecialchars($comment_text); + echo $comment_text; } function comment_link_rss() { - global $comment; - echo get_permalink($comment->comment_post_ID).'#comments'; + global $comment; + echo get_permalink($comment->comment_post_ID).'#comments'; } function permalink_comments_rss() { - global $comment; - echo get_permalink($comment->comment_post_ID); + global $comment; + echo get_permalink($comment->comment_post_ID); } /***** // Comment tags *****/ @@ -1831,33 +1921,33 @@ function permalink_comments_rss() { /***** TrackBack tags *****/ function trackback_url($display = true) { - global $siteurl, $id; - $tb_url = $siteurl.'/wp-trackback.php/'.$id; - if ($display) { - echo $tb_url; - } else { - return $tb_url; - } + global $siteurl, $id; + $tb_url = $siteurl.'/wp-trackback.php/'.$id; + if ($display) { + echo $tb_url; + } else { + return $tb_url; + } } function trackback_rdf($timezone = 0) { - global $siteurl, $id, $HTTP_SERVER_VARS; - if (!stristr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'W3C_Validator')) { - echo ''."\n"; - echo '\n"; - echo ''; - } + global $siteurl, $id, $HTTP_SERVER_VARS; + if (!stristr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'W3C_Validator')) { + echo ''."\n"; + echo '\n"; + echo ''; + } } /***** // TrackBack tags *****/ @@ -1865,58 +1955,58 @@ function trackback_rdf($timezone = 0) { /***** Permalink tags *****/ function permalink_anchor($mode = 'id') { - global $id, $post; - switch(strtolower($mode)) { - case 'title': - $title = sanitize_title($post->post_title) . '-' . $id; - echo ''; - break; - case 'id': - default: - echo ''; - break; - } + global $id, $post; + switch(strtolower($mode)) { + case 'title': + $title = sanitize_title($post->post_title) . '-' . $id; + echo ''; + break; + case 'id': + default: + echo ''; + break; + } } function permalink_link($file='', $mode = 'id') { - global $post, $pagenow, $cacheweekly, $wpdb; - $file = ($file=='') ? $pagenow : $file; - switch(strtolower($mode)) { - case 'title': - $title = sanitize_title($post->post_title) . '-' . $post->ID; - $anchor = $title; - break; - case 'id': - default: - $anchor = $id; - break; - } - echo get_permalink(); + global $post, $pagenow, $cacheweekly, $wpdb; + $file = ($file=='') ? $pagenow : $file; + switch(strtolower($mode)) { + case 'title': + $title = sanitize_title($post->post_title) . '-' . $post->ID; + $anchor = $title; + break; + case 'id': + default: + $anchor = $id; + break; + } + echo get_permalink(); } function permalink_single($file = '') { - echo get_permalink(); + echo get_permalink(); } function permalink_single_rss($file = '') { - global $siteurl; - echo get_permalink(); + global $siteurl; + echo get_permalink(); } /***** // Permalink tags *****/ function allowed_tags() { - global $allowedtags; - foreach($allowedtags as $tag => $attributes) { - $allowed .= "<$tag"; - if (0 < count($attributes)) { - foreach ($attributes as $attribute => $limits) { - $allowed .= " $attribute=\"\""; - } - } - $allowed .= "> "; - } - return htmlentities($allowed); + global $allowedtags; + foreach($allowedtags as $tag => $attributes) { + $allowed .= "<$tag"; + if (0 < count($attributes)) { + foreach ($attributes as $attribute => $limits) { + $allowed .= " $attribute=\"\""; + } + } + $allowed .= "> "; + } + return htmlentities($allowed); } ?> \ No newline at end of file diff --git a/wp-layout.css b/wp-layout.css index 94a4bfe9c7..b1f3acb6f7 100644 --- a/wp-layout.css +++ b/wp-layout.css @@ -223,6 +223,11 @@ p, li, .feedback { border-bottom: 1px solid #809080; } +#menu ul ul ul.children { + padding-left:4px; + font-size:142%; +} + #wp-calendar { border: 1px solid #ddd; empty-cells: show;