Changeset 798 for trunk/wp-includes/template-functions.php
- Timestamp:
- 01/27/2004 06:35:07 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/template-functions.php (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions.php
r797 r798 4 4 5 5 if (!isset($querystring_start)) { 6 $querystring_start = '?';7 $querystring_equal = '=';8 $querystring_separator = '&';6 $querystring_start = '?'; 7 $querystring_equal = '='; 8 $querystring_separator = '&'; 9 9 } 10 10 … … 20 20 21 21 function bloginfo($show='') { 22 $info = get_bloginfo($show);23 $info = convert_bbcode($info);24 $info = convert_gmcode($info);25 $info = convert_smilies($info);26 $info = apply_filters('bloginfo', $info);27 echo convert_chars($info, 'html');22 $info = get_bloginfo($show); 23 $info = convert_bbcode($info); 24 $info = convert_gmcode($info); 25 $info = convert_smilies($info); 26 $info = apply_filters('bloginfo', $info); 27 echo convert_chars($info, 'html'); 28 28 } 29 29 30 30 function bloginfo_rss($show='') { 31 $info = strip_tags(get_bloginfo($show));32 echo convert_chars($info, 'unicode');31 $info = strip_tags(get_bloginfo($show)); 32 echo convert_chars($info, 'unicode'); 33 33 } 34 34 35 35 function bloginfo_unicode($show='') { 36 $info = get_bloginfo($show);37 echo convert_chars($info, 'unicode');36 $info = get_bloginfo($show); 37 echo convert_chars($info, 'unicode'); 38 38 } 39 39 40 40 function get_bloginfo($show='') { 41 global $siteurl, $blogfilename, $blogname, $blogdescription, $siteurl, $admin_email;42 switch($show) {43 case "url":44 $output = $siteurl."/".$blogfilename;45 break;46 case "description":47 $output = $blogdescription;48 break;49 case "rdf_url":50 $output = $siteurl.'/wp-rdf.php';51 break;52 case "rss_url":53 $output = $siteurl.'/wp-rss.php';54 break;55 case "rss2_url":56 $output = $siteurl.'/wp-rss2.php';57 break;58 case "atom_url":59 $output = $siteurl.'/wp-atom.php';60 break; 61 case "comments_rss2_url":62 $output = $siteurl.'/wp-commentsrss2.php';63 break;64 case "pingback_url":65 $output = $siteurl.'/xmlrpc.php';66 break;67 case "admin_email":68 $output = $admin_email;69 break;70 case "name":71 default:72 $output = $blogname;73 break;74 }75 return $output;41 global $siteurl, $blogfilename, $blogname, $blogdescription, $siteurl, $admin_email; 42 switch($show) { 43 case "url": 44 $output = $siteurl."/".$blogfilename; 45 break; 46 case "description": 47 $output = $blogdescription; 48 break; 49 case "rdf_url": 50 $output = $siteurl.'/wp-rdf.php'; 51 break; 52 case "rss_url": 53 $output = $siteurl.'/wp-rss.php'; 54 break; 55 case "rss2_url": 56 $output = $siteurl.'/wp-rss2.php'; 57 break; 58 case "atom_url": 59 $output = $siteurl.'/wp-atom.php'; 60 break; 61 case "comments_rss2_url": 62 $output = $siteurl.'/wp-commentsrss2.php'; 63 break; 64 case "pingback_url": 65 $output = $siteurl.'/xmlrpc.php'; 66 break; 67 case "admin_email": 68 $output = $admin_email; 69 break; 70 case "name": 71 default: 72 $output = $blogname; 73 break; 74 } 75 return $output; 76 76 } 77 77 78 78 function wp_title($sep = '»', $display = true) { 79 global $wpdb, $tableposts, $tablecategories;80 global $year, $monthnum, $day, $cat, $p, $name, $month;81 82 // If there's a category83 if(!empty($cat)) {84 $title = stripslashes(get_the_category_by_ID($cat));85 }86 if (!empty($category_name)) {87 $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));88 }89 90 // If there's a month91 if(!empty($m)) {92 $my_year = substr($m, 0, 4);93 $my_month = $month[substr($m, 4, 2)];94 $title = "$my_year $sep $my_month";95 96 }97 if (!empty($year)) {98 $title = $year;99 if (!empty($monthnum)) {100 $title .= " $sep ".$month[zeroise($monthnum, 2)];101 }102 if (!empty($day)) {103 $title .= " $sep ".zeroise($day, 2);104 }105 }106 107 // If there's a post108 if (intval($p) || '' != $name) {109 if (!$p) {110 if ($year != '') {111 $year = '' . intval($year);112 $where .= ' AND YEAR(post_date)=' . $year;113 }114 115 if ($monthnum != '') {116 $monthnum = '' . intval($monthnum);117 $where .= ' AND MONTH(post_date)=' . $monthnum;118 }119 120 if ($day != '') {121 $day = '' . intval($day);122 $where .= ' AND DAYOFMONTH(post_date)=' . $day;123 }124 $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name' $where");125 }126 $post_data = get_postdata($p);127 $title = strip_tags(stripslashes($post_data['Title']));128 $title = apply_filters('single_post_title', $title);129 }130 131 // Send it out132 if ($display && isset($title)) {133 echo " $sep $title";134 } elseif (!$display && isset($title)) {135 return " $sep $title";136 }79 global $wpdb, $tableposts, $tablecategories; 80 global $year, $monthnum, $day, $cat, $p, $name, $month; 81 82 // If there's a category 83 if(!empty($cat)) { 84 $title = stripslashes(get_the_category_by_ID($cat)); 85 } 86 if (!empty($category_name)) { 87 $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'")); 88 } 89 90 // If there's a month 91 if(!empty($m)) { 92 $my_year = substr($m, 0, 4); 93 $my_month = $month[substr($m, 4, 2)]; 94 $title = "$my_year $sep $my_month"; 95 96 } 97 if (!empty($year)) { 98 $title = $year; 99 if (!empty($monthnum)) { 100 $title .= " $sep ".$month[zeroise($monthnum, 2)]; 101 } 102 if (!empty($day)) { 103 $title .= " $sep ".zeroise($day, 2); 104 } 105 } 106 107 // If there's a post 108 if (intval($p) || '' != $name) { 109 if (!$p) { 110 if ($year != '') { 111 $year = '' . intval($year); 112 $where .= ' AND YEAR(post_date)=' . $year; 113 } 114 115 if ($monthnum != '') { 116 $monthnum = '' . intval($monthnum); 117 $where .= ' AND MONTH(post_date)=' . $monthnum; 118 } 119 120 if ($day != '') { 121 $day = '' . intval($day); 122 $where .= ' AND DAYOFMONTH(post_date)=' . $day; 123 } 124 $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name' $where"); 125 } 126 $post_data = get_postdata($p); 127 $title = strip_tags(stripslashes($post_data['Title'])); 128 $title = apply_filters('single_post_title', $title); 129 } 130 131 // Send it out 132 if ($display && isset($title)) { 133 echo " $sep $title"; 134 } elseif (!$display && isset($title)) { 135 return " $sep $title"; 136 } 137 137 } 138 138 139 139 function single_post_title($prefix = '', $display = true) { 140 global $p, $name, $wpdb, $tableposts;141 if (intval($p) || '' != $name) {142 if (!$p) {143 $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'");144 }145 $post_data = get_postdata($p);146 $title = $post_data['Title'];147 $title = apply_filters('single_post_title', $title);148 if ($display) {149 echo $prefix.strip_tags(stripslashes($title));150 } else {151 return strip_tags(stripslashes($title));152 }153 }140 global $p, $name, $wpdb, $tableposts; 141 if (intval($p) || '' != $name) { 142 if (!$p) { 143 $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'"); 144 } 145 $post_data = get_postdata($p); 146 $title = $post_data['Title']; 147 $title = apply_filters('single_post_title', $title); 148 if ($display) { 149 echo $prefix.strip_tags(stripslashes($title)); 150 } else { 151 return strip_tags(stripslashes($title)); 152 } 153 } 154 154 } 155 155 156 156 function single_cat_title($prefix = '', $display = true ) { 157 global $cat;158 if(!empty($cat) && !(strtoupper($cat) == 'ALL')) {159 $my_cat_name = get_the_category_by_ID($cat);160 if(!empty($my_cat_name)) {161 if ($display)162 echo $prefix.strip_tags(stripslashes($my_cat_name));163 else164 return strip_tags(stripslashes($my_cat_name));165 }166 }157 global $cat; 158 if(!empty($cat) && !(strtoupper($cat) == 'ALL')) { 159 $my_cat_name = get_the_category_by_ID($cat); 160 if(!empty($my_cat_name)) { 161 if ($display) 162 echo $prefix.strip_tags(stripslashes($my_cat_name)); 163 else 164 return strip_tags(stripslashes($my_cat_name)); 165 } 166 } 167 167 } 168 168 169 169 function single_month_title($prefix = '', $display = true ) { 170 global $m, $month;171 if(!empty($m)) {172 $my_year = substr($m,0,4);173 $my_month = $month[substr($m,4,2)];174 if ($display)175 echo $prefix.$my_month.$prefix.$my_year;176 else177 return $m;178 }170 global $m, $month; 171 if(!empty($m)) { 172 $my_year = substr($m,0,4); 173 $my_month = $month[substr($m,4,2)]; 174 if ($display) 175 echo $prefix.$my_month.$prefix.$my_year; 176 else 177 return $m; 178 } 179 179 } 180 180 181 181 /* link navigation hack by Orien http://icecode.com/ */ 182 182 function get_archives_link($url, $text, $format = "html", $before = "", $after = "") { 183 if ('link' == $format) {184 return "\t".'<link rel="archives" title="'.$text.'" href="'.$url.'" />'."\n";185 } else if ('option' == $format) {186 return '<option value="'.$url.'">'.$text.'</option>'."\n";187 } else if ('html' == $format) {188 return "\t".'<li><a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after.'</li>'."\n";189 } else { // custom190 return "\t".$before.'<a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after."\n";191 }183 if ('link' == $format) { 184 return "\t".'<link rel="archives" title="'.$text.'" href="'.$url.'" />'."\n"; 185 } else if ('option' == $format) { 186 return '<option value="'.$url.'">'.$text.'</option>'."\n"; 187 } else if ('html' == $format) { 188 return "\t".'<li><a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after.'</li>'."\n"; 189 } else { // custom 190 return "\t".$before.'<a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after."\n"; 191 } 192 192 } 193 193 194 194 function get_archives($type='', $limit='', $format='html', $before = "", $after = "", $show_post_count = false) { 195 global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename;195 global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename; 196 196 global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week; 197 197 … … 200 200 } 201 201 202 if ('' != $limit) {202 if ('' != $limit) { 203 203 $limit = (int) $limit; 204 $limit = " LIMIT $limit";205 }206 // this is what will separate dates on weekly archive links207 $archive_week_separator = '–';208 209 // archive link url210 $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal;# monthly archive;211 $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal;# weekly archive;212 $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal;# post-by-post archive;204 $limit = " LIMIT $limit"; 205 } 206 // this is what will separate dates on weekly archive links 207 $archive_week_separator = '–'; 208 209 // archive link url 210 $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive; 211 $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive; 212 $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive; 213 213 214 214 // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride … … 228 228 } 229 229 230 $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));231 232 if ('monthly' == $type) {233 $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);230 $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); 231 232 if ('monthly' == $type) { 233 $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); 234 234 if ($arcresults) { 235 235 foreach ($arcresults as $arcresult) { … … 244 244 } 245 245 } 246 } elseif ('daily' == $type) {247 $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);246 } elseif ('daily' == $type) { 247 $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); 248 248 if ($arcresults) { 249 249 foreach ($arcresults as $arcresult) { … … 254 254 } 255 255 } 256 } elseif ('weekly' == $type) {257 if (!isset($start_of_week)) {258 $start_of_week = 1;259 }260 $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);261 $arc_w_last = '';256 } elseif ('weekly' == $type) { 257 if (!isset($start_of_week)) { 258 $start_of_week = 1; 259 } 260 $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); 261 $arc_w_last = ''; 262 262 if ($arcresults) { 263 263 foreach ($arcresults as $arcresult) { … … 276 276 } 277 277 } 278 } elseif ('postbypost' == $type) {279 $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);278 } elseif ('postbypost' == $type) { 279 $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); 280 280 if ($arcresults) { 281 281 foreach ($arcresults as $arcresult) { … … 292 292 } 293 293 } 294 }294 } 295 295 } 296 296 297 297 function get_calendar($daylength = 1) { 298 global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts;298 global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts; 299 299 300 300 // Quick check. If we have no posts at all, abort! … … 305 305 } 306 306 307 if (isset($HTTP_GET_VARS['w'])) {308 $w = ''.intval($HTTP_GET_VARS['w']);309 }310 $time_difference = get_settings('time_difference');311 312 // Let's figure out when we are313 if (!empty($monthnum) && !empty($year)) {314 $thismonth = ''.intval($monthnum);315 $thisyear = ''.intval($year);316 } elseif (!empty($w)) {317 // We need to get the month from MySQL318 $thisyear = ''.intval(substr($m, 0, 4));319 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's320 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");321 } elseif (!empty($m)) {322 $calendar = substr($m, 0, 6);323 $thisyear = ''.intval(substr($m, 0, 4));324 if (strlen($m) < 6) {325 $thismonth = '01';326 } else {327 $thismonth = ''.intval(substr($m, 4, 2));328 }329 } else {330 $thisyear = intval(date('Y', time()+($time_difference * 3600)));331 $thismonth = intval(date('m', time()+($time_difference * 3600)));332 }333 334 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);335 336 // Get the next and previous month and year with at least one post337 $previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year338 FROM $tableposts339 WHERE post_date < '$thisyear-$thismonth-01'340 AND post_status = 'publish'341 ORDER BY post_date DESC342 LIMIT 1");343 $next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year344 FROM $tableposts345 WHERE post_date > '$thisyear-$thismonth-01'346 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )347 AND post_status = 'publish'348 ORDER BY post_date ASC349 LIMIT 1");350 351 echo '<table id="wp-calendar">352 <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>353 <thead>354 <tr>';355 foreach ($weekday as $wd) {356 echo "\n\t\t<th abbr='$wd' scope='col' title='$wd'>" . substr($wd, 0, $daylength) . '</th>';357 }358 359 echo '360 </tr>361 </thead>362 363 <tfoot>364 <tr>';365 366 if ($previous) {367 echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .368 get_month_link($previous->year, $previous->month) . '" title="View posts for ' . $month[zeroise($previous->month, 2)] . ' ' .369 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)) . '">« ' . substr($month[zeroise($previous->month, 2)], 0, 3) . '</a></td>';370 } else {371 echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';372 }373 374 echo "\n\t\t".'<td class="pad"> </td>';375 376 if ($next) {377 echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .378 get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .379 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . substr($month[zeroise($next->month, 2)], 0, 3) . ' »</a></td>';380 } else {381 echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';382 }383 384 echo '385 </tr>386 </tfoot>387 388 <tbody>389 <tr>';390 391 // Get days with posts392 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)393 FROM $tableposts WHERE MONTH(post_date) = $thismonth394 AND YEAR(post_date) = $thisyear395 AND post_status = 'publish'396 AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N);397 if ($dayswithposts) {398 foreach ($dayswithposts as $daywith) {399 $daywithpost[] = $daywith[0];400 }401 } else {402 $daywithpost = array();403 }404 405 406 407 if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") ||408 strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "camino") ||409 strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "safari")) {410 $ak_title_separator = "\n";411 } else {412 $ak_title_separator = ", ";413 }414 415 $ak_titles_for_day = array();416 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "417 ."FROM $tableposts "418 ."WHERE YEAR(post_date) = '$thisyear' "419 ."AND MONTH(post_date) = '$thismonth' "420 ."AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' "421 ."AND post_status = 'publish'"422 );423 if ($ak_post_titles) {424 foreach ($ak_post_titles as $ak_post_title) {425 if (empty($ak_titles_for_day["day_".$ak_post_title->dom])) {426 $ak_titles_for_day["day_".$ak_post_title->dom] = '';427 }428 if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one429 $ak_titles_for_day["$ak_post_title->dom"] .= htmlspecialchars(stripslashes($ak_post_title->post_title));430 } else {431 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . htmlspecialchars(stripslashes($ak_post_title->post_title));432 }433 }434 }435 436 437 // See how much we should pad in the beginning438 $pad = intval(date('w', $unixmonth));439 if (0 != $pad) echo "\n\t\t<td colspan='$pad' class='pad'> </td>";440 441 $daysinmonth = intval(date('t', $unixmonth));442 for ($day = 1; $day <= $daysinmonth; ++$day) {443 if (isset($newrow) && $newrow)444 echo "\n\t</tr>\n\t<tr>\n\t\t";445 $newrow = false;446 447 if ($day == date('j', (time() + ($time_difference * 3600))) && $thismonth == date('m', time()+($time_difference * 3600)))448 echo '<td id="today">';449 else450 echo "<td>";451 452 if (in_array($day, $daywithpost)) { // any posts today?453 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";454 } else {455 echo $day;456 }457 echo '</td>';458 459 if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))460 $newrow = true;461 }462 463 $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear));464 if ($pad != 0 && $pad != 7)465 echo "\n\t\t<td class='pad' colspan='$pad'> </td>";466 467 echo "\n\t</tr>\n\t</tbody>\n\t</table>";307 if (isset($HTTP_GET_VARS['w'])) { 308 $w = ''.intval($HTTP_GET_VARS['w']); 309 } 310 $time_difference = get_settings('time_difference'); 311 312 // Let's figure out when we are 313 if (!empty($monthnum) && !empty($year)) { 314 $thismonth = ''.intval($monthnum); 315 $thisyear = ''.intval($year); 316 } elseif (!empty($w)) { 317 // We need to get the month from MySQL 318 $thisyear = ''.intval(substr($m, 0, 4)); 319 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's 320 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); 321 } elseif (!empty($m)) { 322 $calendar = substr($m, 0, 6); 323 $thisyear = ''.intval(substr($m, 0, 4)); 324 if (strlen($m) < 6) { 325 $thismonth = '01'; 326 } else { 327 $thismonth = ''.intval(substr($m, 4, 2)); 328 } 329 } else { 330 $thisyear = intval(date('Y', time()+($time_difference * 3600))); 331 $thismonth = intval(date('m', time()+($time_difference * 3600))); 332 } 333 334 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); 335 336 // Get the next and previous month and year with at least one post 337 $previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year 338 FROM $tableposts 339 WHERE post_date < '$thisyear-$thismonth-01' 340 AND post_status = 'publish' 341 ORDER BY post_date DESC 342 LIMIT 1"); 343 $next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year 344 FROM $tableposts 345 WHERE post_date > '$thisyear-$thismonth-01' 346 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 347 AND post_status = 'publish' 348 ORDER BY post_date ASC 349 LIMIT 1"); 350 351 echo '<table id="wp-calendar"> 352 <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption> 353 <thead> 354 <tr>'; 355 foreach ($weekday as $wd) { 356 echo "\n\t\t<th abbr='$wd' scope='col' title='$wd'>" . substr($wd, 0, $daylength) . '</th>'; 357 } 358 359 echo ' 360 </tr> 361 </thead> 362 363 <tfoot> 364 <tr>'; 365 366 if ($previous) { 367 echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' . 368 get_month_link($previous->year, $previous->month) . '" title="View posts for ' . $month[zeroise($previous->month, 2)] . ' ' . 369 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)) . '">« ' . substr($month[zeroise($previous->month, 2)], 0, 3) . '</a></td>'; 370 } else { 371 echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; 372 } 373 374 echo "\n\t\t".'<td class="pad"> </td>'; 375 376 if ($next) { 377 echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' . 378 get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' . 379 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . substr($month[zeroise($next->month, 2)], 0, 3) . ' »</a></td>'; 380 } else { 381 echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; 382 } 383 384 echo ' 385 </tr> 386 </tfoot> 387 388 <tbody> 389 <tr>'; 390 391 // Get days with posts 392 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 393 FROM $tableposts WHERE MONTH(post_date) = $thismonth 394 AND YEAR(post_date) = $thisyear 395 AND post_status = 'publish' 396 AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N); 397 if ($dayswithposts) { 398 foreach ($dayswithposts as $daywith) { 399 $daywithpost[] = $daywith[0]; 400 } 401 } else { 402 $daywithpost = array(); 403 } 404 405 406 407 if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") || 408 strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "camino") || 409 strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "safari")) { 410 $ak_title_separator = "\n"; 411 } else { 412 $ak_title_separator = ", "; 413 } 414 415 $ak_titles_for_day = array(); 416 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 417 ."FROM $tableposts " 418 ."WHERE YEAR(post_date) = '$thisyear' " 419 ."AND MONTH(post_date) = '$thismonth' " 420 ."AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' " 421 ."AND post_status = 'publish'" 422 ); 423 if ($ak_post_titles) { 424 foreach ($ak_post_titles as $ak_post_title) { 425 if (empty($ak_titles_for_day["day_".$ak_post_title->dom])) { 426 $ak_titles_for_day["day_".$ak_post_title->dom] = ''; 427 } 428 if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one 429 $ak_titles_for_day["$ak_post_title->dom"] .= htmlspecialchars(stripslashes($ak_post_title->post_title)); 430 } else { 431 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . htmlspecialchars(stripslashes($ak_post_title->post_title)); 432 } 433 } 434 } 435 436 437 // See how much we should pad in the beginning 438 $pad = intval(date('w', $unixmonth)); 439 if (0 != $pad) echo "\n\t\t<td colspan='$pad' class='pad'> </td>"; 440 441 $daysinmonth = intval(date('t', $unixmonth)); 442 for ($day = 1; $day <= $daysinmonth; ++$day) { 443 if (isset($newrow) && $newrow) 444 echo "\n\t</tr>\n\t<tr>\n\t\t"; 445 $newrow = false; 446 447 if ($day == date('j', (time() + ($time_difference * 3600))) && $thismonth == date('m', time()+($time_difference * 3600))) 448 echo '<td id="today">'; 449 else 450 echo "<td>"; 451 452 if (in_array($day, $daywithpost)) { // any posts today? 453 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>"; 454 } else { 455 echo $day; 456 } 457 echo '</td>'; 458 459 if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))) 460 $newrow = true; 461 } 462 463 $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)); 464 if ($pad != 0 && $pad != 7) 465 echo "\n\t\t<td class='pad' colspan='$pad'> </td>"; 466 467 echo "\n\t</tr>\n\t</tbody>\n\t</table>"; 468 468 } 469 469 … … 473 473 /***** Links *****/ 474 474 function get_permalink($id=false) { 475 global $post, $wpdb, $tableposts;476 global $siteurl, $blogfilename, $querystring_start, $querystring_equal;477 478 $rewritecode = array(479 '%year%',480 '%monthnum%',481 '%day%',482 '%postname%',483 '%post_id%'484 );485 if (!$id) {486 if ('' != get_settings('permalink_structure')) {487 $unixtime = strtotime($post->post_date);488 $rewritereplace = array(489 date('Y', $unixtime),490 date('m', $unixtime),491 date('d', $unixtime),492 $post->post_name,493 $post->ID494 );495 return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));496 } else { // if they're not using the fancy permalink option497 return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$post->ID;498 }499 } else { // if an ID is given500 $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");501 if ('' != get_settings('permalink_structure')) {502 $unixtime = strtotime($idpost->post_date);503 $rewritereplace = array(504 date('Y', $unixtime),505 date('m', $unixtime),506 date('d', $unixtime),507 $idpost->post_name,508 $id509 );510 return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));511 } else {512 return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$id;513 }514 }475 global $post, $wpdb, $tableposts; 476 global $siteurl, $blogfilename, $querystring_start, $querystring_equal; 477 478 $rewritecode = array( 479 '%year%', 480 '%monthnum%', 481 '%day%', 482 '%postname%', 483 '%post_id%' 484 ); 485 if (!$id) { 486 if ('' != get_settings('permalink_structure')) { 487 $unixtime = strtotime($post->post_date); 488 $rewritereplace = array( 489 date('Y', $unixtime), 490 date('m', $unixtime), 491 date('d', $unixtime), 492 $post->post_name, 493 $post->ID 494 ); 495 return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); 496 } else { // if they're not using the fancy permalink option 497 return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$post->ID; 498 } 499 } else { // if an ID is given 500 $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id"); 501 if ('' != get_settings('permalink_structure')) { 502 $unixtime = strtotime($idpost->post_date); 503 $rewritereplace = array( 504 date('Y', $unixtime), 505 date('m', $unixtime), 506 date('d', $unixtime), 507 $idpost->post_name, 508 $id 509 ); 510 return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); 511 } else { 512 return $siteurl . '/' . $blogfilename.$querystring_start.'p'.$querystring_equal.$id; 513 } 514 } 515 515 } 516 516 517 517 function get_month_link($year, $month) { 518 global $siteurl, $blogfilename, $querystring_start, $querystring_equal;519 if (!$year) $year = date('Y', time()+($time_difference * 3600));520 if (!$month) $month = date('m', time()+($time_difference * 3600));521 if ('' != get_settings('permalink_structure')) {522 $off = strpos(get_settings('permalink_structure'), '%monthnum%');523 $offset = $off + 11;524 $monthlink = substr(get_settings('permalink_structure'), 0, $offset);525 if ('/' != substr($monthlink, -1)) $monthlink = substr($monthlink, 0, -1);526 $monthlink = str_replace('%year%', $year, $monthlink);527 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);528 $monthlink = str_replace('%post_id%', '', $monthlink);529 return $siteurl . $monthlink;530 } else {531 return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2);532 }518 global $siteurl, $blogfilename, $querystring_start, $querystring_equal; 519 if (!$year) $year = date('Y', time()+($time_difference * 3600)); 520 if (!$month) $month = date('m', time()+($time_difference * 3600)); 521 if ('' != get_settings('permalink_structure')) { 522 $off = strpos(get_settings('permalink_structure'), '%monthnum%'); 523 $offset = $off + 11; 524 $monthlink = substr(get_settings('permalink_structure'), 0, $offset); 525 if ('/' != substr($monthlink, -1)) $monthlink = substr($monthlink, 0, -1); 526 $monthlink = str_replace('%year%', $year, $monthlink); 527 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); 528 $monthlink = str_replace('%post_id%', '', $monthlink); 529 return $siteurl . $monthlink; 530 } else { 531 return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2); 532 } 533 533 } 534 534 535 535 function get_day_link($year, $month, $day) { 536 global $siteurl, $blogfilename, $querystring_start, $querystring_equal;537 if (!$year) $year = date('Y', time()+($time_difference * 3600));538 if (!$month) $month = date('m', time()+($time_difference * 3600));539 if (!$day) $day = date('j', time()+($time_difference * 3600));540 if ('' != get_settings('permalink_structure')) {541 $off = strpos(get_settings('permalink_structure'), '%day%');542 $offset = $off + 6;543 $daylink = substr(get_settings('permalink_structure'), 0, $offset);544 if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1);545 $daylink = str_replace('%year%', $year, $daylink);546 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);547 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);548 $daylink = str_replace('%post_id%', '', $daylink);549 return $siteurl . $daylink;550 } else {551 return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2);552 }536 global $siteurl, $blogfilename, $querystring_start, $querystring_equal; 537 if (!$year) $year = date('Y', time()+($time_difference * 3600)); 538 if (!$month) $month = date('m', time()+($time_difference * 3600)); 539 if (!$day) $day = date('j', time()+($time_difference * 3600)); 540 if ('' != get_settings('permalink_structure')) { 541 $off = strpos(get_settings('permalink_structure'), '%day%'); 542 $offset = $off + 6; 543 $daylink = substr(get_settings('permalink_structure'), 0, $offset); 544 if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1); 545 $daylink = str_replace('%year%', $year, $daylink); 546 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); 547 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); 548 $daylink = str_replace('%post_id%', '', $daylink); 549 return $siteurl . $daylink; 550 } else { 551 return $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2); 552 } 553 553 } 554 554 555 555 function edit_post_link($link = 'Edit This', $before = '', $after = '') { 556 global $user_level, $post, $siteurl;557 558 get_currentuserinfo();559 560 if ($user_level > 0) {561 $authordata = get_userdata($post->post_author);562 if ($user_level < $authordata->user_level) {563 return;564 }565 } else {566 return;567 }568 569 $location = "$siteurl/wp-admin/post.php?action=edit&post=$post->ID";570 echo "$before <a href='$location'>$link</a> $after";556 global $user_level, $post, $siteurl; 557 558 get_currentuserinfo(); 559 560 if ($user_level > 0) { 561 $authordata = get_userdata($post->post_author); 562 if ($user_level < $authordata->user_level) { 563 return; 564 } 565 } else { 566 return; 567 } 568 569 $location = "$siteurl/wp-admin/post.php?action=edit&post=$post->ID"; 570 echo "$before <a href='$location'>$link</a> $after"; 571 571 } 572 572 573 573 function edit_comment_link($link = 'Edit This', $before = '', $after = '') { 574 global $user_level, $post, $comment, $siteurl;575 576 get_currentuserinfo();577 578 if ($user_level > 0) {579 $authordata = get_userdata($post->post_author);580 if ($user_level < $authordata->user_level) {581 return;582 }583 } else {584 return;585 }586 587 $location = "$siteurl/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID";588 echo "$before <a href='$location'>$link</a> $after";574 global $user_level, $post, $comment, $siteurl; 575 576 get_currentuserinfo(); 577 578 if ($user_level > 0) { 579 $authordata = get_userdata($post->post_author); 580 if ($user_level < $authordata->user_level) { 581 return; 582 } 583 } else { 584 return; 585 } 586 587 $location = "$siteurl/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID"; 588 echo "$before <a href='$location'>$link</a> $after"; 589 589 } 590 590 … … 598 598 599 599 function the_date($d='', $before='', $after='', $echo = true) { 600 global $id, $post, $day, $previousday, $dateformat, $newday;601 $the_date = '';602 if ($day != $previousday) {603 $the_date .= $before;604 if ($d=='') {605 $the_date .= mysql2date($dateformat, $post->post_date);606 } else {607 $the_date .= mysql2date($d, $post->post_date);608 }609 $the_date .= $after;610 $previousday = $day;611 }612 $the_date = apply_filters('the_date', $the_date);613 if ($echo) {614 echo $the_date;615 } else {616 return $the_date;617 }600 global $id, $post, $day, $previousday, $dateformat, $newday; 601 $the_date = ''; 602 if ($day != $previousday) { 603 $the_date .= $before; 604 if ($d=='') { 605 $the_date .= mysql2date($dateformat, $post->post_date); 606 } else { 607 $the_date .= mysql2date($d, $post->post_date); 608 } 609 $the_date .= $after; 610 $previousday = $day; 611 } 612 $the_date = apply_filters('the_date', $the_date); 613 if ($echo) { 614 echo $the_date; 615 } else { 616 return $the_date; 617 } 618 618 } 619 619 620 620 function the_time($d='', $echo = true) { 621 global $id, $post, $timeformat;622 if ($d=='') {623 $the_time = mysql2date($timeformat, $post->post_date);624 } else {625 $the_time = mysql2date($d, $post->post_date);626 }627 $the_time = apply_filters('the_time', $the_time);628 if ($echo) {629 echo $the_time;630 } else {631 return $the_time;632 }621 global $id, $post, $timeformat; 622 if ($d=='') { 623 $the_time = mysql2date($timeformat, $post->post_date); 624 } else { 625 $the_time = mysql2date($d, $post->post_date); 626 } 627 $the_time = apply_filters('the_time', $the_time); 628 if ($echo) { 629 echo $the_time; 630 } else { 631 return $the_time; 632 } 633 633 } 634 634 635 635 function the_weekday() { 636 global $weekday, $id, $post;637 $the_weekday = $weekday[mysql2date('w', $post->post_date)];638 $the_weekday = apply_filters('the_weekday', $the_weekday);639 echo $the_weekday;636 global $weekday, $id, $post; 637 $the_weekday = $weekday[mysql2date('w', $post->post_date)]; 638 $the_weekday = apply_filters('the_weekday', $the_weekday); 639 echo $the_weekday; 640 640 } 641 641 642 642 function the_weekday_date($before='',$after='') { 643 global $weekday, $id, $post, $day, $previousweekday;644 $the_weekday_date = '';645 if ($day != $previousweekday) {646 $the_weekday_date .= $before;647 $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)];648 $the_weekday_date .= $after;649 $previousweekday = $day;650 }651 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date);652 echo $the_weekday_date;643 global $weekday, $id, $post, $day, $previousweekday; 644 $the_weekday_date = ''; 645 if ($day != $previousweekday) { 646 $the_weekday_date .= $before; 647 $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)]; 648 $the_weekday_date .= $after; 649 $previousweekday = $day; 650 } 651 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date); 652 echo $the_weekday_date; 653 653 } 654 654 … … 780 780 781 781 function the_author() { 782 global $id, $authordata;783 $i = $authordata->user_idmode;784 if ($i == 'nickname')echo $authordata->user_nickname;785 if ($i == 'login')echo $authordata->user_login;786 if ($i == 'firstname')echo $authordata->user_firstname;787 if ($i == 'lastname')echo $authordata->user_lastname;788 if ($i == 'namefl')echo $authordata->user_firstname.' '.$authordata->user_lastname;789 if ($i == 'namelf')echo $authordata->user_lastname.' '.$authordata->user_firstname;790 if (!$i) echo $authordata->user_nickname;782 global $id, $authordata; 783 $i = $authordata->user_idmode; 784 if ($i == 'nickname') echo $authordata->user_nickname; 785 if ($i == 'login') echo $authordata->user_login; 786 if ($i == 'firstname') echo $authordata->user_firstname; 787 if ($i == 'lastname') echo $authordata->user_lastname; 788 if ($i == 'namefl') echo $authordata->user_firstname.' '.$authordata->user_lastname; 789 if ($i == 'namelf') echo $authordata->user_lastname.' '.$authordata->user_firstname; 790 if (!$i) echo $authordata->user_nickname; 791 791 } 792 792 function the_author_description() { 793 global $authordata;794 echo $authordata->user_description;793 global $authordata; 794 echo $authordata->user_description; 795 795 } 796 796 function the_author_login() { 797 global $id,$authordata;echo $authordata->user_login;797 global $id,$authordata; echo $authordata->user_login; 798 798 } 799 799 800 800 function the_author_firstname() { 801 global $id,$authordata;echo $authordata->user_firstname;801 global $id,$authordata; echo $authordata->user_firstname; 802 802 } 803 803 804 804 function the_author_lastname() { 805 global $id,$authordata;echo $authordata->user_lastname;805 global $id,$authordata; echo $authordata->user_lastname; 806 806 } 807 807 808 808 function the_author_nickname() { 809 global $id,$authordata;echo $authordata->user_nickname;809 global $id,$authordata; echo $authordata->user_nickname; 810 810 } 811 811 812 812 function the_author_ID() { 813 global $id,$authordata;echo $authordata->ID;813 global $id,$authordata; echo $authordata->ID; 814 814 } 815 815 816 816 function the_author_email() { 817 global $id,$authordata;echo antispambot($authordata->user_email);817 global $id,$authordata; echo antispambot($authordata->user_email); 818 818 } 819 819 820 820 function the_author_url() { 821 global $id,$authordata;echo $authordata->user_url;821 global $id,$authordata; echo $authordata->user_url; 822 822 } 823 823 824 824 function the_author_icq() { 825 global $id,$authordata;echo $authordata->user_icq;825 global $id,$authordata; echo $authordata->user_icq; 826 826 } 827 827 828 828 function the_author_aim() { 829 global $id,$authordata;echo str_replace(' ', '+', $authordata->user_aim);829 global $id,$authordata; echo str_replace(' ', '+', $authordata->user_aim); 830 830 } 831 831 832 832 function the_author_yim() { 833 global $id,$authordata;echo $authordata->user_yim;833 global $id,$authordata; echo $authordata->user_yim; 834 834 } 835 835 836 836 function the_author_msn() { 837 global $id,$authordata;echo $authordata->user_msn;837 global $id,$authordata; echo $authordata->user_msn; 838 838 } 839 839 840 840 function the_author_posts() { 841 global $id,$postdata; $posts=get_usernumposts($post->post_author);echo $posts;841 global $id,$postdata; $posts=get_usernumposts($post->post_author); echo $posts; 842 842 } 843 843 … … 850 850 851 851 function get_the_password_form() { 852 $output = "<form action='" . get_settings('siteurl') . "/wp-pass.php' method='post'>853 <p>This post is password protected. To view it please enter your password below:</p>854 <p><label>Password: <input name='post_password' type='text' size='20' /></label> <input type='submit' name='Submit' value='Submit' /></p>855 </form>856 ";857 return $output;852 $output = "<form action='" . get_settings('siteurl') . "/wp-pass.php' method='post'> 853 <p>This post is password protected. To view it please enter your password below:</p> 854 <p><label>Password: <input name='post_password' type='text' size='20' /></label> <input type='submit' name='Submit' value='Submit' /></p> 855 </form> 856 "; 857 return $output; 858 858 } 859 859 860 860 function the_ID() { 861 global $id;862 echo $id;861 global $id; 862 echo $id; 863 863 } 864 864 865 865 function the_title($before = '', $after = '', $echo = true) { 866 $title = get_the_title();867 $title = convert_smilies($title);868 if (!empty($title)) {869 $title = convert_chars($before.$title.$after);870 $title = apply_filters('the_title', $title);866 $title = get_the_title(); 867 $title = convert_smilies($title); 868 if (!empty($title)) { 869 $title = convert_chars($before.$title.$after); 870 $title = apply_filters('the_title', $title); 871 871 if ($echo) 872 872 echo $title; 873 873 else 874 874 return $title; 875 }875 } 876 876 } 877 877 function the_title_rss() { 878 $title = get_the_title();879 $title = strip_tags($title);880 if (trim($title)) {881 echo convert_chars($title, 'unicode');882 }878 $title = get_the_title(); 879 $title = strip_tags($title); 880 if (trim($title)) { 881 echo convert_chars($title, 'unicode'); 882 } 883 883 } 884 884 function the_title_unicode($before='',$after='') { 885 $title = get_the_title();886 $title = convert_bbcode($title);887 $title = convert_gmcode($title);888 if ($title) {889 $title = convert_chars($before.$title.$after);890 $title = apply_filters('the_title_unicode', $title);891 echo $title;892 }885 $title = get_the_title(); 886 $title = convert_bbcode($title); 887 $title = convert_gmcode($title); 888 if ($title) { 889 $title = convert_chars($before.$title.$after); 890 $title = apply_filters('the_title_unicode', $title); 891 echo $title; 892 } 893 893 } 894 894 function get_the_title() { 895 global $post;896 $output = stripslashes($post->post_title);897 if (!empty($post->post_password)) { // if there's a password898 $output = 'Protected: ' . $output;899 }900 return $output;895 global $post; 896 $output = stripslashes($post->post_title); 897 if (!empty($post->post_password)) { // if there's a password 898 $output = 'Protected: ' . $output; 899 } 900 return $output; 901 901 } 902 902 903 903 function the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') { 904 $content = get_the_content($more_link_text, $stripteaser, $more_file);905 $content = convert_bbcode($content);906 $content = convert_gmcode($content);907 $content = convert_smilies($content);908 $content = convert_chars($content, 'html');909 $content = apply_filters('the_content', $content);910 echo $content;904 $content = get_the_content($more_link_text, $stripteaser, $more_file); 905 $content = convert_bbcode($content); 906 $content = convert_gmcode($content); 907 $content = convert_smilies($content); 908 $content = convert_chars($content, 'html'); 909 $content = apply_filters('the_content', $content); 910 echo $content; 911 911 } 912 912 913 913 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { 914 $content = get_the_content($more_link_text, $stripteaser, $more_file);915 $content = convert_bbcode($content);916 $content = convert_gmcode($content);917 $content = convert_chars($content, 'unicode');918 if ($cut && !$encode_html) {919 $encode_html = 2;920 }921 if ($encode_html == 1) {922 $content = htmlspecialchars($content);923 $cut = 0;924 } elseif ($encode_html == 0) {925 $content = make_url_footnote($content);926 } elseif ($encode_html == 2) {927 $content = strip_tags($content);928 }929 if ($cut) {930 $blah = explode(' ', $content);931 if (count($blah) > $cut) {932 $k = $cut;933 $use_dotdotdot = 1;934 } else {935 $k = count($blah);936 $use_dotdotdot = 0;937 }938 for ($i=0; $i<$k; $i++) {939 $excerpt .= $blah[$i].' ';940 }941 $excerpt .= ($use_dotdotdot) ? '...' : '';942 $content = $excerpt;943 }944 echo $content;914 $content = get_the_content($more_link_text, $stripteaser, $more_file); 915 $content = convert_bbcode($content); 916 $content = convert_gmcode($content); 917 $content = convert_chars($content, 'unicode'); 918 if ($cut && !$encode_html) { 919 $encode_html = 2; 920 } 921 if ($encode_html == 1) { 922 $content = htmlspecialchars($content); 923 $cut = 0; 924 } elseif ($encode_html == 0) { 925 $content = make_url_footnote($content); 926 } elseif ($encode_html == 2) { 927 $content = strip_tags($content); 928 } 929 if ($cut) { 930 $blah = explode(' ', $content); 931 if (count($blah) > $cut) { 932 $k = $cut; 933 $use_dotdotdot = 1; 934 } else { 935 $k = count($blah); 936 $use_dotdotdot = 0; 937 } 938 for ($i=0; $i<$k; $i++) { 939 $excerpt .= $blah[$i].' '; 940 } 941 $excerpt .= ($use_dotdotdot) ? '...' : ''; 942 $content = $excerpt; 943 } 944 echo $content; 945 945 } 946 946 947 947 function the_content_unicode($more_link_text='(more...)', $stripteaser=0, $more_file='') { 948 $content = get_the_content($more_link_text, $stripteaser, $more_file);949 $content = convert_bbcode($content);950 $content = convert_gmcode($content);951 $content = convert_smilies($content);952 $content = convert_chars($content, 'unicode');953 $content = apply_filters('the_content_unicode', $content);954 echo $content;948 $content = get_the_content($more_link_text, $stripteaser, $more_file); 949 $content = convert_bbcode($content); 950 $content = convert_gmcode($content); 951 $content = convert_smilies($content); 952 $content = convert_chars($content, 'unicode'); 953 $content = apply_filters('the_content_unicode', $content); 954 echo $content; 955 955 } 956 956 957 957 function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') { 958 global $id, $post, $more, $c, $withcomments, $page, $pages, $multipage, $numpages;959 global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash;960 global $querystring_start, $querystring_equal, $querystring_separator;958 global $id, $post, $more, $c, $withcomments, $page, $pages, $multipage, $numpages; 959 global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; 960 global $querystring_start, $querystring_equal, $querystring_separator; 961 961 global $pagenow; 962 $output = '';963 964 if (!empty($post->post_password)) { // if there's a password965 if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie966 $output = get_the_password_form();967 return $output;968 }969 }970 971 if ($more_file != '') {972 $file = $more_file;973 } else {974 $file = $pagenow; //$HTTP_SERVER_VARS['PHP_SELF'];975 }976 $content = $pages[$page-1];977 $content = explode('<!--more-->', $content);978 if ((preg_match('/<!--noteaser-->/', $post->post_content) && ((!$multipage) || ($page==1))))979 $stripteaser = 1;980 $teaser = $content[0];981 if (($more) && ($stripteaser))982 $teaser = '';983 $output .= $teaser;984 if (count($content)>1) {985 if ($more) {986 $output .= '<a id="more-'.$id.'"></a>'.$content[1];987 } else {988 $output .= " <a href='". get_permalink() . "#more-$id'>$more_link_text</a>";989 }990 }991 if ($preview) { // preview fix for javascript bug with foreign languages992 $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);993 }994 return $output;962 $output = ''; 963 964 if (!empty($post->post_password)) { // if there's a password 965 if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie 966 $output = get_the_password_form(); 967 return $output; 968 } 969 } 970 971 if ($more_file != '') { 972 $file = $more_file; 973 } else { 974 $file = $pagenow; //$HTTP_SERVER_VARS['PHP_SELF']; 975 } 976 $content = $pages[$page-1]; 977 $content = explode('<!--more-->', $content); 978 if ((preg_match('/<!--noteaser-->/', $post->post_content) && ((!$multipage) || ($page==1)))) 979 $stripteaser = 1; 980 $teaser = $content[0]; 981 if (($more) && ($stripteaser)) 982 $teaser = ''; 983 $output .= $teaser; 984 if (count($content)>1) { 985 if ($more) { 986 $output .= '<a id="more-'.$id.'"></a>'.$content[1]; 987 } else { 988 $output .= " <a href='". get_permalink() . "#more-$id'>$more_link_text</a>"; 989 } 990 } 991 if ($preview) { // preview fix for javascript bug with foreign languages 992 $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); 993 } 994 return $output; 995 995 } 996 996 997 997 function the_excerpt() { 998 $excerpt = get_the_excerpt();999 $excerpt = convert_bbcode($excerpt);1000 $excerpt = convert_gmcode($excerpt);1001 $excerpt = convert_smilies($excerpt);1002 $excerpt = convert_chars($excerpt, 'html');1003 $excerpt = apply_filters('the_excerpt', $excerpt);1004 echo $excerpt;998 $excerpt = get_the_excerpt(); 999 $excerpt = convert_bbcode($excerpt); 1000 $excerpt = convert_gmcode($excerpt); 1001 $excerpt = convert_smilies($excerpt); 1002 $excerpt = convert_chars($excerpt, 'html'); 1003 $excerpt = apply_filters('the_excerpt', $excerpt); 1004 echo $excerpt; 1005 1005 } 1006 1006 1007 1007 function the_excerpt_rss($cut = 0, $encode_html = 0) { 1008 $output = get_the_excerpt(true);1009 $output = convert_bbcode($output);1010 $output = convert_gmcode($output);1011 $output = convert_chars($output, 'unicode');1012 if ($cut && !$encode_html) {1013 $encode_html = 2;1014 }1015 if ($encode_html == 1) {1016 $output = htmlspecialchars($output);1017 $cut = 0;1018 } elseif ($encode_html == 0) {1019 $output = make_url_footnote($output);1020 } elseif ($encode_html == 2) {1021 $output = strip_tags($output);1022 }1023 if ($cut) {1008 $output = get_the_excerpt(true); 1009 $output = convert_bbcode($output); 1010 $output = convert_gmcode($output); 1011 $output = convert_chars($output, 'unicode'); 1012 if ($cut && !$encode_html) { 1013 $encode_html = 2; 1014 } 1015 if ($encode_html == 1) { 1016 $output = htmlspecialchars($output); 1017 $cut = 0; 1018 } elseif ($encode_html == 0) { 1019 $output = make_url_footnote($output); 1020 } elseif ($encode_html == 2) { 1021 $output = strip_tags($output); 1022 } 1023 if ($cut) { 1024 1024 $excerpt = ''; 1025 $blah = explode(' ', $output);1026 if (count($blah) > $cut) {1027 $k = $cut;1028 $use_dotdotdot = 1;1029 } else {1030 $k = count($blah);1031 $use_dotdotdot = 0;1032 }1033 for ($i=0; $i<$k; $i++) {1034 $excerpt .= $blah[$i].' ';1035 }1036 $excerpt .= ($use_dotdotdot) ? '...' : '';1037 $output = $excerpt;1038 }1039 echo $output;1025 $blah = explode(' ', $output); 1026 if (count($blah) > $cut) { 1027 $k = $cut; 1028 $use_dotdotdot = 1; 1029 } else { 1030 $k = count($blah); 1031 $use_dotdotdot = 0; 1032 } 1033 for ($i=0; $i<$k; $i++) { 1034 $excerpt .= $blah[$i].' '; 1035 } 1036 $excerpt .= ($use_dotdotdot) ? '...' : ''; 1037 $output = $excerpt; 1038 } 1039 echo $output; 1040 1040 } 1041 1041 1042 1042 function the_excerpt_unicode() { 1043 $excerpt = get_the_excerpt();1044 $excerpt = convert_bbcode($excerpt);1045 $excerpt = convert_gmcode($excerpt);1046 $excerpt = convert_smilies($excerpt);1047 $excerpt = convert_chars($excerpt, 'unicode');1048 $excerpt = apply_filters('the_excerpt_unicode', $excerpt);1049 echo $excerpt;1043 $excerpt = get_the_excerpt(); 1044 $excerpt = convert_bbcode($excerpt); 1045 $excerpt = convert_gmcode($excerpt); 1046 $excerpt = convert_smilies($excerpt); 1047 $excerpt = convert_chars($excerpt, 'unicode'); 1048 $excerpt = apply_filters('the_excerpt_unicode', $excerpt); 1049 echo $excerpt; 1050 1050 } 1051 1051 1052 1052 function get_the_excerpt($fakeit = false) { 1053 global $id, $post;1054 global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash;1055 $output = '';1056 $output = stripslashes($post->post_excerpt);1057 if (!empty($post->post_password)) { // if there's a password1058 if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie1059 $output = "There is no excerpt because this is a protected post.";1060 return $output;1061 }1062 }1053 global $id, $post; 1054 global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; 1055 $output = ''; 1056 $output = stripslashes($post->post_excerpt); 1057 if (!empty($post->post_password)) { // if there's a password 1058 if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie 1059 $output = "There is no excerpt because this is a protected post."; 1060 return $output; 1061 } 1062 } 1063 1063 //if we haven't got an excerpt, make one in the style of the rss ones 1064 1064 if (($output == '') && $fakeit) { … … 1068 1068 $excerpt_length = 120; 1069 1069 if (count($blah) > $excerpt_length) { 1070 $k = $excerpt_length;1071 $use_dotdotdot = 1;1072 } else {1073 $k = count($blah);1074 $use_dotdotdot = 0;1075 }1070 $k = $excerpt_length; 1071 $use_dotdotdot = 1; 1072 } else { 1073 $k = count($blah); 1074 $use_dotdotdot = 0; 1075 } 1076 1076 $excerpt = ''; 1077 for ($i=0; $i<$k; $i++) {1078 $excerpt .= $blah[$i].' ';1079 }1080 $excerpt .= ($use_dotdotdot) ? '...' : '';1081 $output = $excerpt;1077 for ($i=0; $i<$k; $i++) { 1078 $excerpt .= $blah[$i].' '; 1079 } 1080 $excerpt .= ($use_dotdotdot) ? '...' : ''; 1081 $output = $excerpt; 1082 1082 } // end if no excerpt 1083 if ($preview) { // preview fix for javascript bug with foreign languages1084 $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);1085 }1086 return $output;1083 if ($preview) { // preview fix for javascript bug with foreign languages 1084 $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); 1085 } 1086 return $output; 1087 1087 } 1088 1088 1089 1089 1090 1090 function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { 1091 global $id, $page, $numpages, $multipage, $more;1092 global $pagenow;1093 global $querystring_start, $querystring_equal, $querystring_separator;1094 if ($more_file != '') {1095 $file = $more_file;1096 } else {1097 $file = $pagenow;1098 }1099 if (($multipage)) {1100 if ($next_or_number=='number') {1101 echo $before;1102 for ($i = 1; $i < ($numpages+1); $i = $i + 1) {1103 $j=str_replace('%',"$i",$pagelink);1104 echo " ";1105 if (($i != $page) || ((!$more) && ($page==1))) {1106 if ('' == get_settings('permalink_structure')) {1107 echo '<a href="'.get_permalink().$querystring_separator.'page'.$querystring_equal.$i.'">';1108 } else {1109 echo '<a href="'.get_permalink().$i.'/">';1110 }1111 }1112 echo $j;1113 if (($i != $page) || ((!$more) && ($page==1)))1114 echo '</a>';1115 }1116 echo $after;1117 } else {1118 if ($more) {1119 echo $before;1120 $i=$page-1;1121 if ($i && $more) {1122 if ('' == get_settings('permalink_structure')) {1123 echo '<a href="'.get_permalink().$querystring_separator.'page'.$querystring_equal.$i.'">';1124 } else {1125 echo '<a href="'.get_permalink().$i.'/">';1126 }1127 }1128 $i=$page+1;1129 if ($i<=$numpages && $more) {1130 if ('' == get_settings('permalink_structure')) {1131 echo '<a href="'.get_permalink().$querystring_separator.'page'.$querystring_equal.$i.'">';1132 } else {1133 echo '<a href="'.get_permalink().$i.'/">';1134 }1135 }1136 echo $after;1137 }1138 }1139 }1091 global $id, $page, $numpages, $multipage, $more; 1092 global $pagenow; 1093 global $querystring_start, $querystring_equal, $querystring_separator; 1094 if ($more_file != '') { 1095 $file = $more_file; 1096 } else { 1097 $file = $pagenow; 1098 } 1099 if (($multipage)) { 1100 if ($next_or_number=='number') { 1101 echo $before; 1102 for ($i = 1; $i < ($numpages+1); $i = $i + 1) { 1103 $j=str_replace('%',"$i",$pagelink); 1104 echo " "; 1105 if (($i != $page) || ((!$more) && ($page==1))) { 1106 if ('' == get_settings('permalink_structure')) { 1107 echo '<a href="'.get_permalink().$querystring_separator.'page'.$querystring_equal.$i.'">'; 1108 } else { 1109 echo '<a href="'.get_permalink().$i.'/">'; 1110 } 1111 } 1112 echo $j; 1113 if (($i != $page) || ((!$more) && ($page==1))) 1114 echo '</a>'; 1115 } 1116 echo $after; 1117 } else { 1118 if ($more) { 1119 echo $before; 1120 $i=$page-1; 1121 if ($i && $more) { 1122 if ('' == get_settings('permalink_structure')) { 1123 echo '<a href="'.get_permalink().$querystring_separator.'page'.$querystring_equal.$i.'">'; 1124 } else { 1125 echo '<a href="'.get_permalink().$i.'/">'; 1126 } 1127 } 1128 $i=$page+1; 1129 if ($i<=$numpages && $more) { 1130 if ('' == get_settings('permalink_structure')) { 1131 echo '<a href="'.get_permalink().$querystring_separator.'page'.$querystring_equal.$i.'">'; 1132 } else { 1133 echo '<a href="'.get_permalink().$i.'/">'; 1134 } 1135 } 1136 echo $after; 1137 } 1138 } 1139 } 1140 1140 } 1141 1141 1142 1142 1143 1143 function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { 1144 global $tableposts, $id, $post, $siteurl, $blogfilename, $wpdb;1145 global $p, $posts, $posts_per_page, $s, $single;1146 global $querystring_start, $querystring_equal, $querystring_separator;1147 1148 if(($p) || ($posts_per_page == 1) || 1 == $single) {1149 1150 $current_post_date = $post->post_date;1151 $current_category = $post->post_category;1152 1153 $sqlcat = '';1154 if ($in_same_cat != 'no') {1155 $sqlcat = " AND post_category = '$current_category' ";1156 }1157 1158 $sql_exclude_cats = '';1159 if (!empty($excluded_categories)) {1160 $blah = explode('and', $excluded_categories);1161 foreach($blah as $category) {1162 $category = intval($category);1163 $sql_exclude_cats .= " AND post_category != $category";1164 }1165 }1166 1167 $limitprev--;1168 $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");1169 if ($lastpost) {1170 $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous;1171 if ($title == 'yes') {1144 global $tableposts, $id, $post, $siteurl, $blogfilename, $wpdb; 1145 global $p, $posts, $posts_per_page, $s, $single; 1146 global $querystring_start, $querystring_equal, $querystring_separator; 1147 1148 if(($p) || ($posts_per_page == 1) || 1 == $single) { 1149 1150 $current_post_date = $post->post_date; 1151 $current_category = $post->post_category; 1152 1153 $sqlcat = ''; 1154 if ($in_same_cat != 'no') { 1155 $sqlcat = " AND post_category = '$current_category' "; 1156 } 1157 1158 $sql_exclude_cats = ''; 1159 if (!empty($excluded_categories)) { 1160 $blah = explode('and', $excluded_categories); 1161 foreach($blah as $category) { 1162 $category = intval($category); 1163 $sql_exclude_cats .= " AND post_category != $category"; 1164 } 1165 } 1166 1167 $limitprev--; 1168 $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"); 1169 if ($lastpost) { 1170 $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous; 1171 if ($title == 'yes') { 1172 1172 $string .= wptexturize(stripslashes($lastpost->post_title)); 1173 1173 } 1174 $string .= '</a>';1175 $format = str_replace('%', $string, $format);1176 echo $format;1177 }1178 }1174 $string .= '</a>'; 1175 $format = str_replace('%', $string, $format); 1176 echo $format; 1177 } 1178 } 1179 1179 } 1180 1180 1181 1181 function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { 1182 global $tableposts, $p, $posts, $id, $post, $siteurl, $blogfilename, $wpdb;1183 global $time_difference, $single;1184 global $querystring_start, $querystring_equal, $querystring_separator;1185 if(($p) || ($posts==1) || 1 == $single) {1186 1187 $current_post_date = $post->post_date;1188 $current_category = $post->post_category;1189 1190 $sqlcat = '';1191 if ($in_same_cat != 'no') {1192 $sqlcat = " AND post_category='$current_category' ";1193 }1194 1195 $sql_exclude_cats = '';1196 if (!empty($excluded_categories)) {1197 $blah = explode('and', $excluded_categories);1198 foreach($blah as $category) {1199 $category = intval($category);1200 $sql_exclude_cats .= " AND post_category != $category";1201 }1202 }1203 1204 $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));1205 1206 $limitnext--;1207 1208 $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");1209 if ($nextpost) {1210 $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next;1211 if ($title=='yes') {1212 $string .= wptexturize(stripslashes($nextpost->post_title));1213 }1214 $string .= '</a>';1215 $format = str_replace('%', $string, $format);1216 echo $format;1217 }1218 }1182 global $tableposts, $p, $posts, $id, $post, $siteurl, $blogfilename, $wpdb; 1183 global $time_difference, $single; 1184 global $querystring_start, $querystring_equal, $querystring_separator; 1185 if(($p) || ($posts==1) || 1 == $single) { 1186 1187 $current_post_date = $post->post_date; 1188 $current_category = $post->post_category; 1189 1190 $sqlcat = ''; 1191 if ($in_same_cat != 'no') { 1192 $sqlcat = " AND post_category='$current_category' "; 1193 } 1194 1195 $sql_exclude_cats = ''; 1196 if (!empty($excluded_categories)) { 1197 $blah = explode('and', $excluded_categories); 1198 foreach($blah as $category) { 1199 $category = intval($category); 1200 $sql_exclude_cats .= " AND post_category != $category"; 1201 } 1202 } 1203 1204 $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); 1205 1206 $limitnext--; 1207 1208 $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"); 1209 if ($nextpost) { 1210 $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next; 1211 if ($title=='yes') { 1212 $string .= wptexturize(stripslashes($nextpost->post_title)); 1213 } 1214 $string .= '</a>'; 1215 $format = str_replace('%', $string, $format); 1216 echo $format; 1217 } 1218 } 1219 1219 } 1220 1220 1221 1221 function next_posts($max_page = 0) { // original by cfactor at cooltux.org 1222 global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow;1223 global $querystring_start, $querystring_equal, $querystring_separator;1224 if (empty($p) && ($what_to_show == 'paged')) {1225 $qstr = $HTTP_SERVER_VARS['QUERY_STRING'];1226 if (!empty($qstr)) {1227 $qstr = preg_replace("/&paged=\d{0,}/","",$qstr);1228 $qstr = preg_replace("/paged=\d{0,}/","",$qstr);1229 } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) {1230 if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '',1231 $HTTP_SERVER_VARS['REQUEST_URI']) ) {1232 $qstr = preg_replace("/^\//", "", $qstr);1233 $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);1234 $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);1235 $qstr = preg_replace("/\/$/", "", $qstr);1236 }1237 }1238 if (!$paged) $paged = 1;1239 $nextpage = intval($paged) + 1;1240 if (!$max_page || $max_page >= $nextpage) {1241 echo $siteurl.'/'.$pagenow.$querystring_start.1242 ($qstr == '' ? '' : $qstr.$querystring_separator) .1243 'paged'.$querystring_equal.$nextpage;1244 }1245 }1222 global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow; 1223 global $querystring_start, $querystring_equal, $querystring_separator; 1224 if (empty($p) && ($what_to_show == 'paged')) { 1225 $qstr = $HTTP_SERVER_VARS['QUERY_STRING']; 1226 if (!empty($qstr)) { 1227 $qstr = preg_replace("/&paged=\d{0,}/","",$qstr); 1228 $qstr = preg_replace("/paged=\d{0,}/","",$qstr); 1229 } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) { 1230 if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', 1231 $HTTP_SERVER_VARS['REQUEST_URI']) ) { 1232 $qstr = preg_replace("/^\//", "", $qstr); 1233 $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr); 1234 $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr); 1235 $qstr = preg_replace("/\/$/", "", $qstr); 1236 } 1237 } 1238 if (!$paged) $paged = 1; 1239 $nextpage = intval($paged) + 1; 1240 if (!$max_page || $max_page >= $nextpage) { 1241 echo $siteurl.'/'.$pagenow.$querystring_start. 1242 ($qstr == '' ? '' : $qstr.$querystring_separator) . 1243 'paged'.$querystring_equal.$nextpage; 1244 } 1245 } 1246 1246 } 1247 1247 1248 1248 function next_posts_link($label='Next Page »', $max_page=0) { 1249 global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb;1250 if ($what_to_show == 'paged') {1251 if (!$max_page) {1252 $nxt_request = $request;1249 global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb; 1250 if ($what_to_show == 'paged') { 1251 if (!$max_page) { 1252 $nxt_request = $request; 1253 1253 //if the query includes a limit clause, call it again without that 1254 1254 //limit clause! 1255 if ($pos = strpos(strtoupper($request), 'LIMIT')) {1256 $nxt_request = substr($request, 0, $pos);1257 }1258 $nxt_result = $wpdb->query($nxt_request);1259 $numposts = $wpdb->num_rows;1260 $max_page = ceil($numposts / $posts_per_page);1261 }1262 if (!$paged)1255 if ($pos = strpos(strtoupper($request), 'LIMIT')) { 1256 $nxt_request = substr($request, 0, $pos); 1257 } 1258 $nxt_result = $wpdb->query($nxt_request); 1259 $numposts = $wpdb->num_rows; 1260 $max_page = ceil($numposts / $posts_per_page); 1261 } 1262 if (!$paged) 1263 1263 $paged = 1; 1264 $nextpage = intval($paged) + 1;1265 if (empty($p) && (empty($paged) || $nextpage <= $max_page)) {1266 echo '<a href="';1267 next_posts($max_page);1268 echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';1269 }1270 }1264 $nextpage = intval($paged) + 1; 1265 if (empty($p) && (empty($paged) || $nextpage <= $max_page)) { 1266 echo '<a href="'; 1267 next_posts($max_page); 1268 echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; 1269 } 1270 } 1271 1271 } 1272 1272 1273 1273 1274 1274 function previous_posts() { // original by cfactor at cooltux.org 1275 global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow;1276 global $querystring_start, $querystring_equal, $querystring_separator;1277 if (empty($p) && ($what_to_show == 'paged')) {1278 $qstr = $HTTP_SERVER_VARS['QUERY_STRING'];1279 if (!empty($qstr)) {1280 $qstr = preg_replace("/&paged=\d{0,}/","",$qstr);1281 $qstr = preg_replace("/paged=\d{0,}/","",$qstr);1282 } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) {1283 if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '',1284 $HTTP_SERVER_VARS['REQUEST_URI']) ) {1285 $qstr = preg_replace("/^\//", "", $qstr);1286 $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);1287 $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);1288 $qstr = preg_replace("/\/$/", "", $qstr);1289 }1290 }1291 $nextpage = intval($paged) - 1;1292 if ($nextpage < 1) $nextpage = 1;1293 echo $siteurl.'/'.$pagenow.$querystring_start.1294 ($qstr == '' ? '' : $qstr.$querystring_separator) .1295 'paged'.$querystring_equal.$nextpage;1296 }1275 global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow; 1276 global $querystring_start, $querystring_equal, $querystring_separator; 1277 if (empty($p) && ($what_to_show == 'paged')) { 1278 $qstr = $HTTP_SERVER_VARS['QUERY_STRING']; 1279 if (!empty($qstr)) { 1280 $qstr = preg_replace("/&paged=\d{0,}/","",$qstr); 1281 $qstr = preg_replace("/paged=\d{0,}/","",$qstr); 1282 } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) { 1283 if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', 1284 $HTTP_SERVER_VARS['REQUEST_URI']) ) { 1285 $qstr = preg_replace("/^\//", "", $qstr); 1286 $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr); 1287 $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr); 1288 $qstr = preg_replace("/\/$/", "", $qstr); 1289 } 1290 } 1291 $nextpage = intval($paged) - 1; 1292 if ($nextpage < 1) $nextpage = 1; 1293 echo $siteurl.'/'.$pagenow.$querystring_start. 1294 ($qstr == '' ? '' : $qstr.$querystring_separator) . 1295 'paged'.$querystring_equal.$nextpage; 1296 } 1297 1297 } 1298 1298 1299 1299 function previous_posts_link($label='« Previous Page') { 1300 global $p, $paged, $what_to_show;1301 if (empty($p) && ($paged > 1) && ($what_to_show == 'paged')) {1302 echo '<a href="';1303 previous_posts();1304 echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';1305 }1300 global $p, $paged, $what_to_show; 1301 if (empty($p) && ($paged > 1) && ($what_to_show == 'paged')) { 1302 echo '<a href="'; 1303 previous_posts(); 1304 echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; 1305 } 1306 1306 } 1307 1307 1308 1308 function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Next Page >>') { 1309 global $p, $what_to_show, $request, $posts_per_page, $wpdb;1310 if (empty($p) && ($what_to_show == 'paged')) {1311 $nxt_request = $request;1312 if ($pos = strpos(strtoupper($request), 'LIMIT')) {1313 $nxt_request = substr($request, 0, $pos);1314 }1309 global $p, $what_to_show, $request, $posts_per_page, $wpdb; 1310 if (empty($p) && ($what_to_show == 'paged')) { 1311 $nxt_request = $request; 1312 if ($pos = strpos(strtoupper($request), 'LIMIT')) { 1313 $nxt_request = substr($request, 0, $pos); 1314 } 1315 1315 $nxt_result = $wpdb->query($nxt_request); 1316 1316 $numposts = $wpdb->num_rows; 1317 $max_page = ceil($numposts / $posts_per_page);1318 if ($max_page > 1) {1319 previous_posts_link($prelabel);1320 echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep);1321 next_posts_link($nxtlabel, $max_page);1322 }1323 }1317 $max_page = ceil($numposts / $posts_per_page); 1318 if ($max_page > 1) { 1319 previous_posts_link($prelabel); 1320 echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep); 1321 next_posts_link($nxtlabel, $max_page); 1322 } 1323 } 1324 1324 } 1325 1325 … … 1332 1332 1333 1333 function get_the_category() { 1334 global $post, $tablecategories, $tablepost2cat, $wpdb, $category_cache;1335 if ($category_cache[$post->ID]) {1336 return $category_cache[$post->ID];1337 } else {1338 $categories = $wpdb->get_results("1339 SELECT category_id, cat_name, category_nicename, category_description 1340 FROM $tablecategories, $tablepost2cat 1341 WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID1342 ");1343 1344 return $categories;1345 }1334 global $post, $tablecategories, $tablepost2cat, $wpdb, $category_cache; 1335 if ($category_cache[$post->ID]) { 1336 return $category_cache[$post->ID]; 1337 } else { 1338 $categories = $wpdb->get_results(" 1339 SELECT category_id, cat_name, category_nicename, category_description, category_parent 1340 FROM $tablecategories, $tablepost2cat 1341 WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID 1342 "); 1343 1344 return $categories; 1345 } 1346 1346 } 1347 1347 1348 1348 function get_category_link($echo = false, $category_id, $category_nicename) { 1349 global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename; 1350 $cat_ID = $category_id; 1351 $permalink_structure = get_settings('permalink_structure'); 1352 1353 if ('' == $permalink_structure) { 1354 $file = "$siteurl/$blogfilename"; 1355 $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; 1356 } else { 1357 if ('' == $category_nicename) $category_nicename = $wpdb->get_var("SELECT category_nicename FROM $tablecategories WHERE cat_ID = $category_id"); 1358 // Get any static stuff from the front 1359 $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); 1360 $link = $siteurl . $front . 'category/' . $category_nicename . '/'; 1361 } 1362 1363 if ($echo) echo $link; 1364 return $link; 1365 } 1366 1367 function the_category($seperator = '') { 1368 $categories = get_the_category(); 1369 if ('' == $seperator) { 1370 echo '<ul class="post-categories">'; 1371 foreach ($categories as $category) { 1372 $category->cat_name = stripslashes($category->cat_name); 1373 echo "\n\t<li><a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>$category->cat_name</a></li>"; 1374 } 1375 echo '</ul>'; 1376 } else { 1377 $i = 0; 1378 foreach ($categories as $category) { 1379 $category->cat_name = stripslashes($category->cat_name); 1380 if (0 < $i) echo $seperator . ' '; 1381 echo "<a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>$category->cat_name</a>"; 1382 ++$i; 1383 } 1384 } 1349 global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename, $cache_categories; 1350 $cat_ID = $category_id; 1351 $permalink_structure = get_settings('permalink_structure'); 1352 1353 if ('' == $permalink_structure) { 1354 $file = "$siteurl/$blogfilename"; 1355 $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; 1356 } else { 1357 if ('' == $category_nicename) $category_nicename = $cache_categories[$category_id]->category_nicename; 1358 // Get any static stuff from the front 1359 $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); 1360 $link = $siteurl . $front . 'category/'; 1361 if ($parent=$cache_categories[$category_id]->category_parent) $link .= get_category_parents($parent, FALSE, '/', TRUE); 1362 $link .= $category_nicename . '/'; 1363 } 1364 1365 if ($echo) echo $link; 1366 return $link; 1367 } 1368 1369 function the_category($seperator = '', $parents='') { 1370 $categories = get_the_category(); 1371 if ('' == $seperator) { 1372 echo '<ul class="post-categories">'; 1373 foreach ($categories as $category) { 1374 $category->cat_name = stripslashes($category->cat_name); 1375 echo "\n\t<li>"; 1376 switch(strtolower($parents)) { 1377 case 'multiple': 1378 if ($category->category_parent) echo get_category_parents($category->category_parent, TRUE); 1379 echo "<a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>$category->cat_name</a></li>"; 1380 break; 1381 case 'single': 1382 echo "<a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>"; 1383 if ($category->category_parent)echo get_category_parents($category->category_parent, FALSE); 1384 echo "$category->cat_name</a></li>"; 1385 break; 1386 case '': 1387 default: 1388 echo "<a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>$category->cat_name</a></li>"; 1389 } 1390 } 1391 echo '</ul>'; 1392 } else { 1393 $i = 0; 1394 foreach ($categories as $category) { 1395 $category->cat_name = stripslashes($category->cat_name); 1396 if (0 < $i) echo $seperator . ' '; 1397 switch(strtolower($parents)) { 1398 case 'multiple': 1399 if ($category->category_parent) echo get_category_parents($category->category_parent, TRUE); 1400 echo "<a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>$category->cat_name</a>"; 1401 case 'single': 1402 echo "<a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>"; 1403 if ($category->category_parent)echo get_category_parents($category->category_parent, FALSE); 1404 echo "$category->cat_name</a>"; 1405 case '': 1406 default: 1407 echo "<a href='" . get_category_link(0, $category->category_id, $category->category_nicename) . "' title='View all posts in $category->cat_name'>$category->cat_name</a>"; 1408 } 1409 ++$i; 1410 } 1411 } 1385 1412 } 1386 1413 1387 1414 function the_category_rss($type = 'rss') { 1388 $categories = get_the_category();1389 foreach ($categories as $category) {1390 $category->cat_name = stripslashes(convert_chars($category->cat_name));1391 if ('rdf' == $type) {1392 echo "\n<dc:subject>$category->cat_name</dc:subject>";1393 } else {1394 echo "\n<category>$category->cat_name</category>";1395 }1396 }1415 $categories = get_the_category(); 1416 foreach ($categories as $category) { 1417 $category->cat_name = stripslashes(convert_chars($category->cat_name)); 1418 if ('rdf' == $type) { 1419 echo "\n<dc:subject>$category->cat_name</dc:subject>"; 1420 } else { 1421 echo "\n<category>$category->cat_name</category>"; 1422 } 1423 } 1397 1424 1398 1425 } 1399 1426 function the_category_unicode() { 1400 $category = get_the_category(); 1401 $category = apply_filters('the_category_unicode', $category); 1402 echo convert_chars($category, 'unicode'); 1403 } 1404 1405 1427 $category = get_the_category(); 1428 $category = apply_filters('the_category_unicode', $category); 1429 echo convert_chars($category, 'unicode'); 1430 } 1406 1431 1407 1432 function get_the_category_by_ID($cat_ID) { 1408 global $tablecategories, $cache_categories, $use_cache, $wpdb; 1409 if ((!$cache_categories[$cat_ID]) OR (!$use_cache)) { 1410 $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"); 1411 $cache_categories[$cat_ID] = $cat_name; 1412 } else { 1413 $cat_name = $cache_categories[$cat_ID]; 1414 } 1415 return(stripslashes($cat_name)); 1433 global $tablecategories, $cache_categories, $use_cache, $wpdb; 1434 if ((!$cache_categories[$cat_ID]) OR (!$use_cache)) { 1435 $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"); 1436 $cache_categories[$cat_ID]->cat_name = $cat_name; 1437 } else { 1438 $cat_name = $cache_categories[$cat_ID]->cat_name; 1439 } 1440 return(stripslashes($cat_name)); 1441 } 1442 1443 function get_category_parents($id, $link=FALSE, $separator=' / ', $nicename=FALSE){ 1444 global $tablecategories, $cache_categories; 1445 $chain = ""; 1446 $parent = $cache_categories[$id]; 1447 if ($nicename) { 1448 $name = $parent->category_nicename; 1449 } else { 1450 $name = $parent->cat_name; 1451 } 1452 if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); 1453 if ($link) { 1454 $chain .= "<a href='" . get_category_link(0, $parent->cat_ID, $parent->category_nicename) . "' title='View all posts in $parent->cat_name'>$name</a>" . $separator; 1455 } else { 1456 $chain .= $name.$separator; 1457 } 1458 return $chain; 1459 } 1460 1461 function get_category_children($id, $before=' / ', $after='') { 1462 global $tablecategories, $cache_categories; 1463 $c_cache=$cache_categories;#can't do recursive foreach on a global, have to make a copy 1464 $chain = ""; 1465 foreach ($c_cache as $category){ 1466 if ($category->category_parent == $id){ 1467 $chain .= $before.$category->cat_ID.$after; 1468 $chain .= get_category_children($category->cat_ID, $before, $after); 1469 } 1470 } 1471 return $chain; 1416 1472 } 1417 1473 1418 1474 function the_category_ID($echo=true) { 1419 global $post;1475 global $post; 1420 1476 if ($echo) 1421 1477 echo $post->post_category; … … 1425 1481 1426 1482 function the_category_head($before='', $after='') { 1427 global $post, $currentcat, $previouscat, $dateformat, $newday;1428 $currentcat = $post->post_category;1429 if ($currentcat != $previouscat) {1430 echo $before;1431 echo get_the_category_by_ID($currentcat);1432 echo $after;1433 $previouscat = $currentcat;1434 }1483 global $post, $currentcat, $previouscat, $dateformat, $newday; 1484 $currentcat = $post->post_category; 1485 if ($currentcat != $previouscat) { 1486 echo $before; 1487 echo get_the_category_by_ID($currentcat); 1488 echo $after; 1489 $previouscat = $currentcat; 1490 } 1435 1491 } 1436 1492 1437 1493 function category_description($category = 0) { 1438 global $cat, $wpdb, $tablecategories;1439 if (!$category) $category = $cat;1440 $category_description = $wpdb->get_var("SELECT category_description FROM $tablecategories WHERE cat_ID = $category");1441 $category_description = apply_filters('category_description', $category_description);1442 return $category_description;1494 global $cat, $wpdb, $tablecategories, $cache_categories; 1495 if (!$category) $category = $cat; 1496 $category_description = $cache_categories[$category]->category_description; 1497 $category_description = apply_filters('category_description', $category_description); 1498 return $category_description; 1443 1499 } 1444 1500 1445 1501 // out of the WordPress loop 1446 1502 function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', 1447 $optiondates = 0, $optioncount = 0, $hide_empty = 1) { 1448 global $cat, $tablecategories, $tableposts, $wpdb; 1503 $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, 1504 $selected=0, $hide=0) { 1505 global $tablecategories, $tableposts, $tablepost2cat, $wpdb; 1506 global $pagenow, $siteurl, $blogfilename; 1507 global $querystring_start, $querystring_equal, $querystring_separator; 1508 if (($file == 'blah') || ($file == '')) $file = "$siteurl/$blogfilename"; 1509 if (!$selected) $selected=$cat; 1449 1510 $sort_column = 'cat_'.$sort_column; 1450 1511 1451 $query = " SELECT cat_ID, cat_name,"; 1452 $query .= " COUNT($tableposts.ID) AS cat_count,"; 1453 $query .= " DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth"; 1454 $query .= " FROM $tablecategories LEFT JOIN $tableposts ON cat_ID = post_category"; 1455 $query .= " WHERE cat_ID > 0 "; 1456 $query .= " GROUP BY post_category "; 1457 if (intval($hide_empty) == 1) { 1458 $query .= " HAVING cat_count > 0"; 1459 } 1512 $query = " 1513 SELECT cat_ID, cat_name, category_nicename,category_parent, 1514 COUNT($tablepost2cat.post_id) AS cat_count, 1515 DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth 1516 FROM $tablecategories LEFT JOIN $tablepost2cat ON (cat_ID = category_id) 1517 LEFT JOIN $tableposts ON (ID = post_id) 1518 WHERE cat_ID > 0 1519 "; 1520 if ($hide) { 1521 $query .= " AND cat_ID != $hide"; 1522 $query .= get_category_children($hide, " AND cat_ID != "); 1523 } 1524 $query .=" GROUP BY cat_ID"; 1525 if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0"; 1460 1526 $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; 1461 1527 1462 $categories = $wpdb->get_results($query); 1463 echo "<select name='cat' class='postform'>\n"; 1464 if (intval($optionall) == 1) { 1465 $all = apply_filters('list_cats', $all); 1466 echo "\t<option value='all'>$all</option>\n"; 1467 } 1468 if ($categories) { 1469 foreach ($categories as $category) { 1470 $cat_name = apply_filters('list_cats', $category->cat_name); 1471 echo "\t<option value=\"".$category->cat_ID."\""; 1472 if ($category->cat_ID == $cat) 1473 echo ' selected="selected"'; 1474 echo '>'.stripslashes($cat_name); 1475 if (intval($optioncount) == 1) { 1476 echo ' ('.$category->cat_count.')'; 1477 } 1478 if (intval($optiondates) == 1) { 1479 echo ' '.$category->lastday.'/'.$category->lastmonth; 1480 } 1481 echo "</option>\n"; 1482 } 1483 } 1484 echo "</select>\n"; 1485 } 1486 1487 // Out of the WordPress loop 1488 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) { 1528 $categories = $wpdb->get_results($query); 1529 echo "<select name='cat' class='postform'>\n"; 1530 if (intval($optionall) == 1) { 1531 $all = apply_filters('list_cats', $all); 1532 echo "\t<option value='all'>$all</option>\n"; 1533 } 1534 if (intval($optionnone) == 1) echo "\t<option value='0'>None</option>\n"; 1535 if ($categories) { 1536 foreach ($categories as $category) { 1537 $cat_name = apply_filters('list_cats', $category->cat_name); 1538 echo "\t<option value=\"".$category->cat_ID."\""; 1539 if ($category->cat_ID == $selected) 1540 echo ' selected="selected"'; 1541 echo '>'; 1542 echo stripslashes($cat_name); 1543 if (intval($optioncount) == 1) echo ' ('.$category->cat_count.')'; 1544 if (intval($optiondates) == 1) echo ' '.$category->lastday.'/'.$category->lastmonth; 1545 echo "</option>\n"; 1546 } 1547 } 1548 echo "</select>\n"; 1549 } 1550 1551 // out of the WordPress loop 1552 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) { 1489 1553 global $tablecategories, $tableposts, $tablepost2cat, $wpdb; 1490 1554 global $pagenow, $siteurl, $blogfilename; … … 1494 1558 $file = "$siteurl/$blogfilename"; 1495 1559 } 1496 $sort_column = 'cat_'.$sort_column; 1497 1498 $query = " 1499 SELECT cat_ID, cat_name, category_nicename, category_description 1500 FROM $tablecategories 1501 WHERE cat_ID > 0 1502 ORDER BY $sort_column $sort_order"; 1503 1504 $categories = $wpdb->get_results($query); 1505 1560 if (intval($categories)==0){ 1561 $sort_column = 'cat_'.$sort_column; 1562 1563 $query = " 1564 SELECT cat_ID, cat_name, category_nicename, category_description, category_parent 1565 FROM $tablecategories 1566 WHERE cat_ID > 0 1567 ORDER BY $sort_column $sort_order"; 1568 1569 $categories = $wpdb->get_results($query); 1570 } 1506 1571 if (intval($hide_empty) == 1 || intval($optioncount) == 1) { 1507 1572 $cat_counts = $wpdb->get_results(" SELECT cat_ID, … … 1526 1591 } 1527 1592 } 1528 1529 if (!$categories) { 1593 1594 if (intval($optionall) == 1 && !$child_of && $categories) { 1595 $all = apply_filters('list_cats', $all); 1596 $link = "<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a>"; 1530 1597 if ($list) { 1531 $before = '<li>'; 1532 $after = '</li>'; 1533 } 1534 echo $before . "No categories" . $after . "\n"; 1535 return; 1536 } 1537 1598 echo "\n\t<li>$link</li>"; 1599 } else { 1600 echo "\t$link<br />\n"; 1601 } 1602 } 1603 1604 $num_found=0; 1605 $thelist = ""; 1606 1538 1607 foreach ($categories as $category) { 1539 if (intval($hide_empty) == 0 || $category_posts["$category->cat_ID"] > 0) { 1608 if ((intval($hide_empty) == 0 || $category_posts["$category->cat_ID"] > 0) && (!$children || $category->category_parent == $child_of)) { 1609 $num_found++; 1540 1610 $link = '<a href="'.get_category_link(0, $category->cat_ID, $category->category_nicename).'" '; 1541 1611 if ($use_desc_for_title == 0 || empty($category->category_description)) { … … 1553 1623 } 1554 1624 if ($list) { 1555 echo "\t<li>$link</li>\n";1625 $thelist .= "\t<li>$link\n"; 1556 1626 } else { 1557 echo "\t$link<br />\n"; 1558 } 1559 } 1560 } 1627 $thelist .= "\t$link<br />\n"; 1628 } 1629 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); 1630 if ($list) $thelist .= "</li>\n"; 1631 } 1632 } 1633 if (!$num_found && !$child_of){ 1634 if ($list) { 1635 $before = '<li>'; 1636 $after = '</li>'; 1637 } 1638 echo $before . "No categories" . $after . "\n"; 1639 return; 1640 } 1641 if ($list && $child_of && $num_found && $recurse) { 1642 $pre = "\t\t<ul class='children'>"; 1643 $post = "\t\t</ul>\n"; 1644 } 1645 $thelist=$pre.$thelist.$post; 1646 if ($recurse) { 1647 return $thelist; 1648 } 1649 echo $thelist; 1561 1650 } 1562 1651 … … 1580 1669 1581 1670 function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') { 1582 global $id, $comment, $tablecomments, $wpdb;1583 if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");1584 if ($number == 0) {1585 $blah = $zero;1586 } elseif ($number == 1) {1587 $blah = $one;1588 } elseif ($number > 1) {1589 $blah = str_replace('%', $number, $more);1590 }1591 echo $blah;1671 global $id, $comment, $tablecomments, $wpdb; 1672 if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'"); 1673 if ($number == 0) { 1674 $blah = $zero; 1675 } elseif ($number == 1) { 1676 $blah = $one; 1677 } elseif ($number > 1) { 1678 $blah = str_replace('%', $number, $more); 1679 } 1680 echo $blah; 1592 1681 } 1593 1682 1594 1683 function comments_link($file='', $echo=true) { 1595 global $id, $pagenow;1596 if ($file == '')$file = $pagenow;1597 if ($file == '/')$file = '';1598 if (!$echo) return get_permalink() . '#comments';1599 else echo get_permalink() . '#comments';1684 global $id, $pagenow; 1685 if ($file == '') $file = $pagenow; 1686 if ($file == '/') $file = ''; 1687 if (!$echo) return get_permalink() . '#comments'; 1688 else echo get_permalink() . '#comments'; 1600 1689 } 1601 1690 1602 1691 function comments_popup_script($width=400, $height=400, $file='wp-comments-popup.php') { 1603 global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;1604 $wpcommentspopupfile = $file;1605 $wpcommentsjavascript = 1;1606 $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";1607 echo $javascript;1692 global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript; 1693 $wpcommentspopupfile = $file; 1694 $wpcommentsjavascript = 1; 1695 $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n"; 1696 echo $javascript; 1608 1697 } 1609 1698 1610 1699 function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { 1611 global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;1612 global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;1613 global $comment_count_cache;1614 if ('' == $comment_count_cache["$id"]) {1615 $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';");1616 } else {1617 $number = $comment_count_cache["$id"];1618 }1619 if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {1620 echo $none;1621 return;1622 } else {1700 global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash; 1701 global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; 1702 global $comment_count_cache; 1703 if ('' == $comment_count_cache["$id"]) { 1704 $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';"); 1705 } else { 1706 $number = $comment_count_cache["$id"]; 1707 } 1708 if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) { 1709 echo $none; 1710 return; 1711 } else { 1623 1712 if (!empty($post->post_password)) { // if there's a password 1624 1713 if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie … … 1647 1736 1648 1737 function comment_ID() { 1649 global $comment;1650 echo $comment->comment_ID;1738 global $comment; 1739 echo $comment->comment_ID; 1651 1740 } 1652 1741 1653 1742 function comment_author() { 1654 global $comment; 1655 $author = stripslashes(stripslashes($comment->comment_author)); 1656 $author = apply_filters('comment_auther', $author); 1657 $author = convert_chars($author); 1658 if (!empty($author)) { 1659 echo $author; 1660 } else { 1661 echo "Anonymous"; 1662 } 1743 global $comment; 1744 $author = stripslashes(stripslashes($comment->comment_author)); 1745 $author = apply_filters('comment_auther', $author); 1746 $author = convert_chars($author); 1747 if (!empty($author)) { 1748 echo $comment->comment_author; 1749 } 1750 else { 1751 echo "Anonymous"; 1752 } 1663 1753 } 1664 1754 1665 1755 function comment_author_email() { 1666 global $comment;1667 $email = stripslashes(stripslashes($comment->comment_author_email));1668 1669 echo antispambot(stripslashes($comment->comment_author_email));1756 global $comment; 1757 $email = stripslashes(stripslashes($comment->comment_author_email)); 1758 1759 echo antispambot(stripslashes($comment->comment_author_email)); 1670 1760 } 1671 1761 1672 1762 function comment_author_link() { 1673 global $comment;1674 $url = trim(stripslashes($comment->comment_author_url));1675 $email = stripslashes($comment->comment_author_email);1676 $author = stripslashes($comment->comment_author);1677 $author = convert_chars($author);1678 $author = wptexturize($author);1679 if (empty($author)) {1680 $author = "Anonymous";1681 }1682 1683 $url = str_replace('http://url', '', $url);1684 $url = preg_replace('|[^a-z0-9-_.?#=&;,/:]|i', '', $url);1685 if (empty($url) && empty($email)) {1686 echo $author;1687 return;1688 }1689 echo '<a href="';1690 if ($url) {1691 $url = str_replace(';//', '://', $url);1692 $url = (!strstr($url, '://')) ? 'http://'.$url : $url;1693 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);1694 echo $url;1695 } else {1696 echo 'mailto:'.antispambot($email);1697 }1698 echo '" rel="external">' . $author . '</a>';1763 global $comment; 1764 $url = trim(stripslashes($comment->comment_author_url)); 1765 $email = stripslashes($comment->comment_author_email); 1766 $author = stripslashes($comment->comment_author); 1767 $author = convert_chars($author); 1768 $author = wptexturize($author); 1769 if (empty($author)) { 1770 $author = "Anonymous"; 1771 } 1772 1773 $url = str_replace('http://url', '', $url); 1774 $url = preg_replace('|[^a-z0-9-_.?#=&;,/:]|i', '', $url); 1775 if (empty($url) && empty($email)) { 1776 echo $author; 1777 return; 1778 } 1779 echo '<a href="'; 1780 if ($url) { 1781 $url = str_replace(';//', '://', $url); 1782 $url = (!strstr($url, '://')) ? 'http://'.$url : $url; 1783 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 1784 echo $url; 1785 } else { 1786 echo 'mailto:'.antispambot($email); 1787 } 1788 echo '" rel="external">' . $author . '</a>'; 1699 1789 } 1700 1790 1701 1791 function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { 1702 global $comment;1703 if (preg_match('|<trackback />|', $comment->comment_content)) echo $trackbacktxt;1704 elseif (preg_match('|<pingback />|', $comment->comment_content)) echo $pingbacktxt;1705 else echo $commenttxt;1792 global $comment; 1793 if (preg_match('|<trackback />|', $comment->comment_content)) echo $trackbacktxt; 1794 elseif (preg_match('|<pingback />|', $comment->comment_content)) echo $pingbacktxt; 1795 else echo $commenttxt; 1706 1796 } 1707 1797 1708 1798 function comment_author_url() { 1709 global $comment;1710 $url = trim(stripslashes($comment->comment_author_url));1711 $url = str_replace(';//', '://', $url);1712 $url = (!strstr($url, '://')) ? 'http://'.$url : $url;1713 // convert & into &1714 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);1715 $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url);1716 if ($url != 'http://url') {1717 echo $url;1718 }1799 global $comment; 1800 $url = trim(stripslashes($comment->comment_author_url)); 1801 $url = str_replace(';//', '://', $url); 1802 $url = (!strstr($url, '://')) ? 'http://'.$url : $url; 1803 // convert & into & 1804 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 1805 $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url); 1806 if ($url != 'http://url') { 1807 echo $url; 1808 } 1719 1809 } 1720 1810 1721 1811 function comment_author_email_link($linktext='', $before='', $after='') { 1722 global $comment;1723 $email = $comment->comment_author_email;1724 if ((!empty($email)) && ($email != '@')) {1725 $display = ($linktext != '') ? $linktext : antispambot(stripslashes($email));1726 echo $before;1727 echo '<a href="mailto:'.antispambot(stripslashes($email)).'">'.$display.'</a>';1728 echo $after;1729 }1812 global $comment; 1813 $email = $comment->comment_author_email; 1814 if ((!empty($email)) && ($email != '@')) { 1815 $display = ($linktext != '') ? $linktext : antispambot(stripslashes($email)); 1816 echo $before; 1817 echo '<a href="mailto:'.antispambot(stripslashes($email)).'">'.$display.'</a>'; 1818 echo $after; 1819 } 1730 1820 } 1731 1821 1732 1822 function comment_author_url_link($linktext='', $before='', $after='') { 1733 global $comment;1734 $url = trim(stripslashes($comment->comment_author_url));1735 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);1736 $url = (!stristr($url, '://')) ? 'http://'.$url : $url;1737 $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url);1738 if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) {1739 $display = ($linktext != '') ? $linktext : stripslashes($url);1740 echo $before;1741 echo '<a href="'.stripslashes($url).'" rel="external">'.$display.'</a>';1742 echo $after;1743 }1823 global $comment; 1824 $url = trim(stripslashes($comment->comment_author_url)); 1825 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 1826 $url = (!stristr($url, '://')) ? 'http://'.$url : $url; 1827 $url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url); 1828 if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) { 1829 $display = ($linktext != '') ? $linktext : stripslashes($url); 1830 echo $before; 1831 echo '<a href="'.stripslashes($url).'" rel="external">'.$display.'</a>'; 1832 echo $after; 1833 } 1744 1834 } 1745 1835 1746 1836 function comment_author_IP() { 1747 global $comment;1748 echo stripslashes($comment->comment_author_IP);1837 global $comment; 1838 echo stripslashes($comment->comment_author_IP); 1749 1839 } 1750 1840 1751 1841 function comment_text() { 1752 global $comment;1753 $comment_text = stripslashes($comment->comment_content);1754 $comment_text = str_replace('<trackback />', '', $comment_text);1755 $comment_text = str_replace('<pingback />', '', $comment_text);1756 $comment_text = convert_chars($comment_text);1757 $comment_text = convert_bbcode($comment_text);1758 $comment_text = convert_gmcode($comment_text);1759 $comment_text = make_clickable($comment_text);1760 $comment_text = balanceTags($comment_text,1);1761 $comment_text = apply_filters('comment_text', $comment_text);1762 $comment_text = convert_smilies($comment_text);1763 echo $comment_text;1842 global $comment; 1843 $comment_text = stripslashes($comment->comment_content); 1844 $comment_text = str_replace('<trackback />', '', $comment_text); 1845 $comment_text = str_replace('<pingback />', '', $comment_text); 1846 $comment_text = convert_chars($comment_text); 1847 $comment_text = convert_bbcode($comment_text); 1848 $comment_text = convert_gmcode($comment_text); 1849 $comment_text = make_clickable($comment_text); 1850 $comment_text = balanceTags($comment_text,1); 1851 $comment_text = apply_filters('comment_text', $comment_text); 1852 $comment_text = convert_smilies($comment_text); 1853 echo $comment_text; 1764 1854 } 1765 1855 1766 1856 function comment_date($d='') { 1767 global $comment, $dateformat;1768 if ($d == '') {1769 echo mysql2date($dateformat, $comment->comment_date);1770 } else {1771 echo mysql2date($d, $comment->comment_date);1772 }1857 global $comment, $dateformat; 1858 if ($d == '') { 1859 echo mysql2date($dateformat, $comment->comment_date); 1860 } else { 1861 echo mysql2date($d, $comment->comment_date); 1862 } 1773 1863 } 1774 1864 1775 1865 function comment_time($d='') { 1776 global $comment, $timeformat;1777 if ($d == '') {1778 echo mysql2date($timeformat, $comment->comment_date);1779 } else {1780 echo mysql2date($d, $comment->comment_date);1781 }1866 global $comment, $timeformat; 1867 if ($d == '') { 1868 echo mysql2date($timeformat, $comment->comment_date); 1869 } else { 1870 echo mysql2date($d, $comment->comment_date); 1871 } 1782 1872 } 1783 1873 1784 1874 function comments_rss_link($link_text='Comments RSS', $commentsrssfilename = 'wp-commentsrss2.php') { 1785 global $id;1786 global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;1787 $url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id;1788 $url = '<a href="'.$url.'">'.$link_text.'</a>';1789 echo $url;1875 global $id; 1876 global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; 1877 $url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id; 1878 $url = '<a href="'.$url.'">'.$link_text.'</a>'; 1879 echo $url; 1790 1880 } 1791 1881 1792 1882 function comment_author_rss() { 1793 global $comment;1794 if (!empty($comment->comment_author)) {1795 echo htmlspecialchars(strip_tags(stripslashes($comment->comment_author)));1796 }1797 else {1798 echo "Anonymous";1799 }1883 global $comment; 1884 if (!empty($comment->comment_author)) { 1885 echo htmlspecialchars(strip_tags(stripslashes($comment->comment_author))); 1886 } 1887 else { 1888 echo "Anonymous"; 1889 } 1800 1890 } 1801 1891 1802 1892 function comment_text_rss() { 1803 global $comment;1804 $comment_text = stripslashes($comment->comment_content);1805 $comment_text = str_replace('<trackback />', '', $comment_text);1806 $comment_text = str_replace('<pingback />', '', $comment_text);1807 $comment_text = convert_chars($comment_text);1808 $comment_text = convert_bbcode($comment_text);1809 $comment_text = convert_gmcode($comment_text);1810 $comment_text = convert_smilies($comment_text);1811 $comment_text = apply_filters('comment_text', $comment_text);1812 $comment_text = strip_tags($comment_text);1813 $comment_text = htmlspecialchars($comment_text);1814 echo $comment_text;1893 global $comment; 1894 $comment_text = stripslashes($comment->comment_content); 1895 $comment_text = str_replace('<trackback />', '', $comment_text); 1896 $comment_text = str_replace('<pingback />', '', $comment_text); 1897 $comment_text = convert_chars($comment_text); 1898 $comment_text = convert_bbcode($comment_text); 1899 $comment_text = convert_gmcode($comment_text); 1900 $comment_text = convert_smilies($comment_text); 1901 $comment_text = apply_filters('comment_text', $comment_text); 1902 $comment_text = strip_tags($comment_text); 1903 $comment_text = htmlspecialchars($comment_text); 1904 echo $comment_text; 1815 1905 } 1816 1906 1817 1907 function comment_link_rss() { 1818 global $comment;1819 echo get_permalink($comment->comment_post_ID).'#comments';1908 global $comment; 1909 echo get_permalink($comment->comment_post_ID).'#comments'; 1820 1910 } 1821 1911 1822 1912 function permalink_comments_rss() { 1823 global $comment;1824 echo get_permalink($comment->comment_post_ID);1913 global $comment; 1914 echo get_permalink($comment->comment_post_ID); 1825 1915 } 1826 1916 … … 1832 1922 1833 1923 function trackback_url($display = true) { 1834 global $siteurl, $id;1835 $tb_url = $siteurl.'/wp-trackback.php/'.$id;1836 if ($display) {1837 echo $tb_url;1838 } else {1839 return $tb_url;1840 }1924 global $siteurl, $id; 1925 $tb_url = $siteurl.'/wp-trackback.php/'.$id; 1926 if ($display) { 1927 echo $tb_url; 1928 } else { 1929 return $tb_url; 1930 } 1841 1931 } 1842 1932 1843 1933 1844 1934 function trackback_rdf($timezone = 0) { 1845 global $siteurl, $id, $HTTP_SERVER_VARS;1846 if (!stristr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'W3C_Validator')) {1847 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" '."\n";1848 echo ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n";1849 echo ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n";1850 echo '<rdf:Description'."\n";1851 echo ' rdf:about="';1852 permalink_single();1853 echo '"'."\n";1854 echo ' dc:identifier="';1855 permalink_single();1856 echo '"'."\n";1857 echo ' dc:title="'.str_replace('--', '--', addslashes(strip_tags(get_the_title()))).'"'."\n";1858 echo ' trackback:ping="'.trackback_url(0).'"'." />\n";1859 echo '</rdf:RDF>';1860 }1935 global $siteurl, $id, $HTTP_SERVER_VARS; 1936 if (!stristr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'W3C_Validator')) { 1937 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" '."\n"; 1938 echo ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n"; 1939 echo ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n"; 1940 echo '<rdf:Description'."\n"; 1941 echo ' rdf:about="'; 1942 permalink_single(); 1943 echo '"'."\n"; 1944 echo ' dc:identifier="'; 1945 permalink_single(); 1946 echo '"'."\n"; 1947 echo ' dc:title="'.str_replace('--', '--', addslashes(strip_tags(get_the_title()))).'"'."\n"; 1948 echo ' trackback:ping="'.trackback_url(0).'"'." />\n"; 1949 echo '</rdf:RDF>'; 1950 } 1861 1951 } 1862 1952 … … 1866 1956 /***** Permalink tags *****/ 1867 1957 function permalink_anchor($mode = 'id') { 1868 global $id, $post;1869 switch(strtolower($mode)) {1870 case 'title':1871 $title = sanitize_title($post->post_title) . '-' . $id;1872 echo '<a id="'.$title.'"></a>';1873 break;1874 case 'id':1875 default:1876 echo '<a id="post-'.$id.'"></a>';1877 break;1878 }1958 global $id, $post; 1959 switch(strtolower($mode)) { 1960 case 'title': 1961 $title = sanitize_title($post->post_title) . '-' . $id; 1962 echo '<a id="'.$title.'"></a>'; 1963 break; 1964 case 'id': 1965 default: 1966 echo '<a id="post-'.$id.'"></a>'; 1967 break; 1968 } 1879 1969 } 1880 1970 1881 1971 function permalink_link($file='', $mode = 'id') { 1882 global $post, $pagenow, $cacheweekly, $wpdb;1883 $file = ($file=='') ? $pagenow : $file;1884 switch(strtolower($mode)) {1885 case 'title':1886 $title = sanitize_title($post->post_title) . '-' . $post->ID;1887 $anchor = $title;1888 break;1889 case 'id':1890 default:1891 $anchor = $id;1892 break;1893 }1894 echo get_permalink();1972 global $post, $pagenow, $cacheweekly, $wpdb; 1973 $file = ($file=='') ? $pagenow : $file; 1974 switch(strtolower($mode)) { 1975 case 'title': 1976 $title = sanitize_title($post->post_title) . '-' . $post->ID; 1977 $anchor = $title; 1978 break; 1979 case 'id': 1980 default: 1981 $anchor = $id; 1982 break; 1983 } 1984 echo get_permalink(); 1895 1985 } 1896 1986 1897 1987 function permalink_single($file = '') { 1898 echo get_permalink();1988 echo get_permalink(); 1899 1989 } 1900 1990 1901 1991 function permalink_single_rss($file = '') { 1902 global $siteurl;1903 echo get_permalink();1992 global $siteurl; 1993 echo get_permalink(); 1904 1994 } 1905 1995 … … 1907 1997 1908 1998 function allowed_tags() { 1909 global $allowedtags;1910 foreach($allowedtags as $tag => $attributes) {1911 $allowed .= "<$tag";1912 if (0 < count($attributes)) {1913 foreach ($attributes as $attribute => $limits) {1914 $allowed .= " $attribute=\"\"";1915 }1916 }1917 $allowed .= "> ";1918 }1919 return htmlentities($allowed);1999 global $allowedtags; 2000 foreach($allowedtags as $tag => $attributes) { 2001 $allowed .= "<$tag"; 2002 if (0 < count($attributes)) { 2003 foreach ($attributes as $attribute => $limits) { 2004 $allowed .= " $attribute=\"\""; 2005 } 2006 } 2007 $allowed .= "> "; 2008 } 2009 return htmlentities($allowed); 1920 2010 } 1921 2011
Note: See TracChangeset
for help on using the changeset viewer.