2003-04-21 21:37:11 +00:00
< ? php
/* new and improved ! now with more querystring stuff ! */
if ( ! isset ( $querystring_start )) {
$querystring_start = '?' ;
$querystring_equal = '=' ;
$querystring_separator = '&' ;
}
/* template functions... */
// @@@ These are template tags, you can edit them if you know what you're doing...
/***** About-the-blog tags *****/
/* Note: these tags go anywhere in the template */
function bloginfo ( $show = '' ) {
$info = get_bloginfo ( $show );
$info = convert_bbcode ( $info );
$info = convert_gmcode ( $info );
$info = convert_smilies ( $info );
$info = apply_filters ( 'bloginfo' , $info );
echo convert_chars ( $info , 'html' );
}
function bloginfo_rss ( $show = '' ) {
$info = strip_tags ( get_bloginfo ( $show ));
echo convert_chars ( $info , 'unicode' );
}
function bloginfo_unicode ( $show = '' ) {
$info = get_bloginfo ( $show );
echo convert_chars ( $info , 'unicode' );
}
function get_bloginfo ( $show = '' ) {
2003-05-24 21:50:22 +00:00
global $siteurl , $blogfilename , $blogname , $blogdescription , $siteurl , $admin_email ;
2003-04-21 21:37:11 +00:00
switch ( $show ) {
case " url " :
$output = $siteurl . " / " . $blogfilename ;
break ;
case " description " :
$output = $blogdescription ;
break ;
case " rdf_url " :
$output = $siteurl . '/b2rdf.php' ;
break ;
case " rss_url " :
$output = $siteurl . '/b2rss.php' ;
break ;
case " rss2_url " :
$output = $siteurl . '/b2rss2.php' ;
break ;
case " pingback_url " :
2003-05-24 21:50:22 +00:00
$output = $siteurl . '/xmlrpc.php' ;
2003-04-21 21:37:11 +00:00
break ;
case " admin_email " :
$output = $admin_email ;
break ;
case " name " :
default :
$output = $blogname ;
break ;
}
return ( $output );
}
2003-05-29 14:04:30 +00:00
function single_post_title ( $prefix = '' , $display = true ) {
2003-04-21 21:37:11 +00:00
global $p ;
if ( intval ( $p )) {
$post_data = get_postdata ( $p );
$title = $post_data [ 'Title' ];
$title = apply_filters ( 'single_post_title' , $title );
if ( $display ) {
echo $prefix . strip_tags ( stripslashes ( $title ));
} else {
return strip_tags ( stripslashes ( $title ));
}
}
}
2003-05-29 14:04:30 +00:00
function single_cat_title ( $prefix = '' , $display = true ) {
2003-04-21 21:37:11 +00:00
global $cat ;
if ( ! empty ( $cat ) && ! ( strtoupper ( $cat ) == 'ALL' )) {
$my_cat_name = get_the_category_by_ID ( $cat );
if ( ! empty ( $my_cat_name )) {
if ( $display )
echo $prefix . strip_tags ( stripslashes ( $my_cat_name ));
else
return strip_tags ( stripslashes ( $my_cat_name ));
}
}
}
2003-05-29 14:04:30 +00:00
function single_month_title ( $prefix = '' , $display = true ) {
2003-04-21 21:37:11 +00:00
global $m , $month ;
if ( ! empty ( $m )) {
$my_year = substr ( $m , 0 , 4 );
$my_month = $month [ substr ( $m , 4 , 2 )];
if ( $display )
echo $prefix . $my_month . $prefix . $my_year ;
else
return $m ;
}
}
2003-06-08 00:15:39 +00:00
function get_archives ( $type = '' , $limit = '' ) {
2003-06-08 01:12:38 +00:00
global $tableposts , $dateformat , $time_difference , $siteurl , $blogfilename ;
GLOBAL $querystring_start , $querystring_equal , $querystring_separator , $month , $wpdb , $start_of_week ;
2003-06-08 00:10:07 +00:00
2003-06-08 00:15:39 +00:00
if ( '' == $type ) {
$type = get_settings ( 'archive_mode' );
}
2003-05-21 11:17:09 +00:00
if ( '' != $limit ) {
2003-06-08 00:10:07 +00:00
$limit = ( int ) $limit ;
$limit = " LIMIT $limit " ;
2003-05-21 11:17:09 +00:00
}
// this is what will separate dates on weekly archive links
$archive_week_separator = '–' ;
2003-06-08 00:10:07 +00:00
2003-05-21 11:17:09 +00:00
// archive link url
2003-06-08 00:10:07 +00:00
$archive_link_m = $siteurl . '/' . $blogfilename . $querystring_start . 'm' . $querystring_equal ; # monthly archive;
$archive_link_w = $siteurl . '/' . $blogfilename . $querystring_start . 'w' . $querystring_equal ; # weekly archive;
$archive_link_p = $siteurl . '/' . $blogfilename . $querystring_start . 'p' . $querystring_equal ; # post-by-post archive;
2003-06-08 00:15:39 +00:00
2003-06-08 00:10:07 +00:00
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0 ;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d' ;
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d' ;
$archive_week_end_date_format = 'Y/m/d' ;
if ( ! $archive_date_format_over_ride ) {
$archive_day_date_format = $dateformat ;
$archive_week_start_date_format = $dateformat ;
$archive_week_end_date_format = $dateformat ;
}
2003-06-08 00:15:39 +00:00
2003-05-21 11:17:09 +00:00
$now = date ( 'Y-m-d H:i:s' ,( time () + ( $time_difference * 3600 )));
2003-06-08 00:15:39 +00:00
2003-05-29 14:04:30 +00:00
if ( 'monthly' == $type ) {
++ $querycount ;
2003-06-08 00:10:07 +00:00
$arcresults = $wpdb -> get_results ( " SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month` FROM $tableposts WHERE post_date < ' $now ' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC " . $limit );
2003-05-29 14:04:30 +00:00
foreach ( $arcresults as $arcresult ) {
echo " <li><a href= \" $archive_link_m $arcresult->year " . zeroise ( $arcresult -> month , 2 ) . '">' ;
echo $month [ zeroise ( $arcresult -> month , 2 )] . ' ' . $arcresult -> year ;
2003-05-21 11:17:09 +00:00
echo " </a></li> \n " ;
}
2003-05-29 14:04:30 +00:00
} elseif ( 'daily' == $type ) {
++ $querycount ;
2003-06-08 00:10:07 +00:00
$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_category > 0 AND post_status = 'publish' ORDER BY post_date DESC " . $limit );
2003-05-29 14:04:30 +00:00
foreach ( $arcresults as $arcresult ) {
echo " <li><a href= \" $archive_link_m $arcresult->year " . zeroise ( $arcresult -> month , 2 ) . zeroise ( $arcresult -> dayofmonth , 2 ) . '">' ;
echo mysql2date ( $archive_day_date_format , $arcresult -> year . '-' . zeroise ( $arcresult -> month , 2 ) . '-' . zeroise ( $arcresult -> dayofmonth , 2 ) . ' 00:00:00' );
2003-05-21 11:17:09 +00:00
echo " </a></li> \n " ;
}
2003-05-29 14:04:30 +00:00
} elseif ( 'weekly' == $type ) {
2003-05-21 11:17:09 +00:00
if ( ! isset ( $start_of_week )) {
$start_of_week = 1 ;
}
2003-05-29 14:04:30 +00:00
++ $querycount ;
2003-06-08 01:12:38 +00:00
$arcresults = $wpdb -> get_results ( " SELECT DISTINCT WEEK(post_date) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < ' $now ' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC " . $limit );
2003-05-21 11:17:09 +00:00
$arc_w_last = '' ;
2003-05-29 14:04:30 +00:00
foreach ( $arcresults as $arcresult ) {
if ( $arcresult -> week != $arc_w_last ) {
2003-06-08 01:12:38 +00:00
$arc_year = $arcresult -> yr ;
2003-05-29 14:04:30 +00:00
$arc_w_last = $arcresult -> week ;
2003-06-08 01:12:38 +00:00
$arc_week = get_weekstartend ( $arcresult -> yyyymmdd , $start_of_week );
2003-05-21 11:17:09 +00:00
$arc_week_start = date_i18n ( $archive_week_start_date_format , $arc_week [ 'start' ]);
$arc_week_end = date_i18n ( $archive_week_end_date_format , $arc_week [ 'end' ]);
2003-06-08 01:12:38 +00:00
echo " <li><a href=' $siteurl / $blogfilename $querystring_start " . " m $querystring_equal $arc_year $querystring_separator " . " w $querystring_equal $arcresult->week '> " ;
2003-05-21 11:17:09 +00:00
echo $arc_week_start . $archive_week_separator . $arc_week_end ;
echo " </a></li> \n " ;
}
}
2003-05-29 14:04:30 +00:00
} elseif ( 'postbypost' == $type ) {
++ $querycount ;
2003-06-08 00:10:07 +00:00
$arcresults = $wpdb -> get_results ( " SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < ' $now ' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC " . $limit );
2003-05-29 14:04:30 +00:00
foreach ( $arcresults as $arcresult ) {
if ( $arcresult -> post_date != '0000-00-00 00:00:00' ) {
echo " <li><a href= \" $archive_link_p " . $arcresult -> ID . '">' ;
$arc_title = stripslashes ( $arcresult -> post_title );
2003-05-21 11:17:09 +00:00
if ( $arc_title ) {
echo strip_tags ( $arc_title );
} else {
2003-05-29 14:04:30 +00:00
echo $arcresult -> ID ;
2003-05-21 11:17:09 +00:00
}
echo " </a></li> \n " ;
}
}
}
}
2003-04-21 21:37:11 +00:00
/***** // About-the-blog tags *****/
/***** Date/Time tags *****/
2003-05-29 14:04:30 +00:00
function the_date ( $d = '' , $before = '' , $after = '' , $echo = true ) {
2003-05-29 15:51:10 +00:00
global $id , $post , $day , $previousday , $dateformat , $newday ;
2003-04-21 21:37:11 +00:00
$the_date = '' ;
if ( $day != $previousday ) {
$the_date .= $before ;
if ( $d == '' ) {
2003-05-29 15:51:10 +00:00
$the_date .= mysql2date ( $dateformat , $post -> post_date );
2003-04-21 21:37:11 +00:00
} else {
2003-05-29 15:51:10 +00:00
$the_date .= mysql2date ( $d , $post -> post_date );
2003-04-21 21:37:11 +00:00
}
$the_date .= $after ;
$previousday = $day ;
}
$the_date = apply_filters ( 'the_date' , $the_date );
if ( $echo ) {
echo $the_date ;
} else {
return $the_date ;
}
}
2003-05-29 14:04:30 +00:00
function the_time ( $d = '' , $echo = true ) {
2003-05-29 15:51:10 +00:00
global $id , $post , $timeformat ;
2003-04-21 21:37:11 +00:00
if ( $d == '' ) {
2003-05-29 15:51:10 +00:00
$the_time = mysql2date ( $timeformat , $post -> post_date );
2003-04-21 21:37:11 +00:00
} else {
2003-05-29 15:51:10 +00:00
$the_time = mysql2date ( $d , $post -> post_date );
2003-04-21 21:37:11 +00:00
}
$the_time = apply_filters ( 'the_time' , $the_time );
if ( $echo ) {
echo $the_time ;
} else {
return $the_time ;
}
}
function the_weekday () {
2003-05-29 15:51:10 +00:00
global $weekday , $id , $post ;
$the_weekday = $weekday [ mysql2date ( 'w' , $post -> post_date )];
2003-04-21 21:37:11 +00:00
$the_weekday = apply_filters ( 'the_weekday' , $the_weekday );
echo $the_weekday ;
}
function the_weekday_date ( $before = '' , $after = '' ) {
2003-05-29 15:51:10 +00:00
global $weekday , $id , $post , $day , $previousweekday ;
2003-04-21 21:37:11 +00:00
$the_weekday_date = '' ;
if ( $day != $previousweekday ) {
$the_weekday_date .= $before ;
2003-05-29 15:51:10 +00:00
$the_weekday_date .= $weekday [ mysql2date ( 'w' , $post -> post_date )];
2003-04-21 21:37:11 +00:00
$the_weekday_date .= $after ;
$previousweekday = $day ;
}
$the_weekday_date = apply_filters ( 'the_weekday_date' , $the_weekday_date );
echo $the_weekday_date ;
}
/***** // Date/Time tags *****/
/***** Author tags *****/
function the_author () {
2003-05-29 15:51:10 +00:00
global $id , $authordata ;
2003-06-01 11:57:50 +00:00
$i = $authordata -> user_idmode ;
if ( $i == 'nickname' ) echo $authordata -> user_nickname ;
if ( $i == 'login' ) echo $authordata -> user_login ;
if ( $i == 'firstname' ) echo $authordata -> user_firstname ;
if ( $i == 'lastname' ) echo $authordata -> user_lastname ;
if ( $i == 'namefl' ) echo $authordata -> user_firstname . ' ' . $authordata -> user_lastname ;
if ( $i == 'namelf' ) echo $authordata -> user_lastname . ' ' . $authordata -> user_firstname ;
if ( ! $i ) echo $authordata -> user_nickname ;
2003-04-21 21:37:11 +00:00
}
function the_author_login () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_login ;
2003-04-21 21:37:11 +00:00
}
function the_author_firstname () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_firstname ;
2003-04-21 21:37:11 +00:00
}
function the_author_lastname () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_lastname ;
2003-04-21 21:37:11 +00:00
}
function the_author_nickname () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_nickname ;
2003-04-21 21:37:11 +00:00
}
function the_author_ID () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> ID ;
2003-04-21 21:37:11 +00:00
}
function the_author_email () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo antispambot ( $authordata -> user_email );
2003-04-21 21:37:11 +00:00
}
function the_author_url () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_url ;
2003-04-21 21:37:11 +00:00
}
function the_author_icq () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_icq ;
2003-04-21 21:37:11 +00:00
}
function the_author_aim () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo str_replace ( ' ' , '+' , $authordata -> user_aim );
2003-04-21 21:37:11 +00:00
}
function the_author_yim () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_yim ;
2003-04-21 21:37:11 +00:00
}
function the_author_msn () {
2003-06-01 11:57:50 +00:00
global $id , $authordata ; echo $authordata -> user_msn ;
2003-04-21 21:37:11 +00:00
}
function the_author_posts () {
2003-05-29 15:51:10 +00:00
global $id , $postdata ; $posts = get_usernumposts ( $post -> post_author ); echo $posts ;
2003-04-21 21:37:11 +00:00
}
/***** // Author tags *****/
/***** Post tags *****/
function the_ID () {
global $id ;
echo $id ;
}
2003-05-29 15:51:10 +00:00
function the_title ( $before = '' , $after = '' ) {
2003-04-21 21:37:11 +00:00
$title = get_the_title ();
$title = convert_bbcode ( $title );
$title = convert_gmcode ( $title );
$title = convert_smilies ( $title );
$title = apply_filters ( 'the_title' , $title );
if ( $title ) {
echo convert_chars ( $before . $title . $after , 'html' );
}
}
function the_title_rss () {
$title = get_the_title ();
$title = convert_bbcode ( $title );
$title = convert_gmcode ( $title );
$title = strip_tags ( $title );
if ( trim ( $title )) {
echo convert_chars ( $title , 'unicode' );
}
}
function the_title_unicode ( $before = '' , $after = '' ) {
$title = get_the_title ();
$title = convert_bbcode ( $title );
$title = convert_gmcode ( $title );
$title = apply_filters ( 'the_title_unicode' , $title );
if ( trim ( $title )) {
echo convert_chars ( $before . $title . $after , 'unicode' );
}
}
function get_the_title () {
2003-05-29 15:51:10 +00:00
global $id , $post ;
$output = stripslashes ( $post -> post_title );
2003-04-21 21:37:11 +00:00
$output = apply_filters ( 'the_title' , $output );
return ( $output );
}
function the_content ( $more_link_text = '(more...)' , $stripteaser = 0 , $more_file = '' ) {
2003-05-29 15:51:10 +00:00
$content = get_the_content ( $more_link_text , $stripteaser , $more_file );
2003-04-21 21:37:11 +00:00
$content = convert_bbcode ( $content );
$content = convert_gmcode ( $content );
$content = convert_smilies ( $content );
$content = convert_chars ( $content , 'html' );
$content = apply_filters ( 'the_content' , $content );
echo $content ;
}
function the_content_rss ( $more_link_text = '(more...)' , $stripteaser = 0 , $more_file = '' , $cut = 0 , $encode_html = 0 ) {
2003-05-29 15:51:10 +00:00
$content = get_the_content ( $more_link_text , $stripteaser , $more_file );
2003-04-21 21:37:11 +00:00
$content = convert_bbcode ( $content );
$content = convert_gmcode ( $content );
$content = convert_chars ( $content , 'unicode' );
if ( $cut && ! $encode_html ) {
$encode_html = 2 ;
}
if ( $encode_html == 1 ) {
$content = htmlspecialchars ( $content );
$cut = 0 ;
} elseif ( $encode_html == 0 ) {
$content = make_url_footnote ( $content );
} elseif ( $encode_html == 2 ) {
$content = strip_tags ( $content );
}
if ( $cut ) {
$blah = explode ( ' ' , $content );
if ( count ( $blah ) > $cut ) {
$k = $cut ;
$use_dotdotdot = 1 ;
} else {
$k = count ( $blah );
$use_dotdotdot = 0 ;
}
for ( $i = 0 ; $i < $k ; $i ++ ) {
$excerpt .= $blah [ $i ] . ' ' ;
}
$excerpt .= ( $use_dotdotdot ) ? '...' : '' ;
$content = $excerpt ;
}
echo $content ;
}
2003-05-29 15:51:10 +00:00
2003-04-21 21:37:11 +00:00
function the_content_unicode ( $more_link_text = '(more...)' , $stripteaser = 0 , $more_file = '' ) {
2003-05-29 15:51:10 +00:00
$content = get_the_content ( $more_link_text , $stripteaser , $more_file );
2003-04-21 21:37:11 +00:00
$content = convert_bbcode ( $content );
$content = convert_gmcode ( $content );
$content = convert_smilies ( $content );
$content = convert_chars ( $content , 'unicode' );
$content = apply_filters ( 'the_content_unicode' , $content );
echo $content ;
}
2003-05-29 15:51:10 +00:00
2003-04-21 21:37:11 +00:00
function get_the_content ( $more_link_text = '(more...)' , $stripteaser = 0 , $more_file = '' ) {
2003-05-29 15:51:10 +00:00
global $id , $post , $more , $c , $withcomments , $page , $pages , $multipage , $numpages ;
2003-04-21 21:37:11 +00:00
global $HTTP_SERVER_VARS , $preview ;
global $querystring_start , $querystring_equal , $querystring_separator ;
global $pagenow ;
$output = '' ;
if ( $more_file != '' ) {
2003-05-29 15:51:10 +00:00
$file = $more_file ;
2003-04-21 21:37:11 +00:00
} else {
2003-05-29 15:51:10 +00:00
$file = $pagenow ; //$HTTP_SERVER_VARS['PHP_SELF'];
2003-04-21 21:37:11 +00:00
}
2003-05-29 15:51:10 +00:00
$content = $pages [ $page - 1 ];
$content = explode ( '<!--more-->' , $content );
if (( preg_match ( '/<!--noteaser-->/' , $post -> post_content ) && (( ! $multipage ) || ( $page == 1 ))))
$stripteaser = 1 ;
$teaser = $content [ 0 ];
2003-04-21 21:37:11 +00:00
if (( $more ) && ( $stripteaser ))
2003-05-29 15:51:10 +00:00
$teaser = '' ;
2003-04-21 21:37:11 +00:00
$output .= $teaser ;
if ( count ( $content ) > 1 ) {
if ( $more ) {
$output .= '<a name="more' . $id . '"></a>' . $content [ 1 ];
} else {
$output .= ' <a href="' . $file . $querystring_start . 'p' . $querystring_equal . $id . $querystring_separator . 'more' . $querystring_equal . '1#more' . $id . '">' . $more_link_text . '</a>' ;
}
}
if ( $preview ) { // preview fix for javascript bug with foreign languages
$output = preg_replace ( '/\%u([0-9A-F]{4,4})/e' , " '&#'.base_convert(' \\ 1',16,10).';' " , $output );
}
return ( $output );
}
2003-04-24 01:04:42 +00:00
function the_excerpt () {
$excerpt = get_the_excerpt ();
$excerpt = convert_bbcode ( $excerpt );
$excerpt = convert_gmcode ( $excerpt );
$excerpt = convert_smilies ( $excerpt );
$excerpt = convert_chars ( $excerpt , 'html' );
$excerpt = apply_filters ( 'the_excerpt' , $excerpt );
echo $excerpt ;
}
function the_excerpt_rss ( $cut = 0 , $encode_html = 0 ) {
2003-05-24 23:44:19 +00:00
$output = get_the_excerpt ( true );
$output = convert_bbcode ( $output );
$output = convert_gmcode ( $output );
$output = convert_chars ( $output , 'unicode' );
2003-04-24 01:04:42 +00:00
if ( $cut && ! $encode_html ) {
$encode_html = 2 ;
}
if ( $encode_html == 1 ) {
2003-05-24 23:44:19 +00:00
$output = htmlspecialchars ( $output );
2003-04-24 01:04:42 +00:00
$cut = 0 ;
} elseif ( $encode_html == 0 ) {
2003-05-24 23:44:19 +00:00
$output = make_url_footnote ( $output );
2003-04-24 01:04:42 +00:00
} elseif ( $encode_html == 2 ) {
2003-05-24 23:44:19 +00:00
$output = strip_tags ( $output );
2003-04-24 01:04:42 +00:00
}
if ( $cut ) {
2003-05-24 23:44:19 +00:00
$blah = explode ( ' ' , $output );
2003-04-24 01:04:42 +00:00
if ( count ( $blah ) > $cut ) {
$k = $cut ;
$use_dotdotdot = 1 ;
} else {
$k = count ( $blah );
$use_dotdotdot = 0 ;
}
for ( $i = 0 ; $i < $k ; $i ++ ) {
$excerpt .= $blah [ $i ] . ' ' ;
}
$excerpt .= ( $use_dotdotdot ) ? '...' : '' ;
2003-05-24 23:44:19 +00:00
$output = $excerpt ;
2003-04-24 01:04:42 +00:00
}
2003-05-24 23:44:19 +00:00
echo $output ;
2003-04-24 01:04:42 +00:00
}
2003-05-06 22:15:28 +00:00
2003-04-24 01:04:42 +00:00
function the_excerpt_unicode () {
$excerpt = get_the_excerpt ();
$excerpt = convert_bbcode ( $excerpt );
$excerpt = convert_gmcode ( $excerpt );
$excerpt = convert_smilies ( $excerpt );
$excerpt = convert_chars ( $excerpt , 'unicode' );
$excerpt = apply_filters ( 'the_excerpt_unicode' , $excerpt );
echo $excerpt ;
}
2003-05-06 22:15:28 +00:00
2003-05-24 23:14:04 +00:00
function get_the_excerpt ( $fakeit = false ) {
2003-05-29 15:51:10 +00:00
global $id , $post ;
2003-04-24 01:04:42 +00:00
global $HTTP_SERVER_VARS , $preview ;
$output = '' ;
2003-05-29 15:51:10 +00:00
$output = $post -> post_excerpt ;
2003-05-06 22:15:28 +00:00
//if we haven't got an excerpt, make one in the style of the rss ones
2003-05-24 23:14:04 +00:00
if (( $output == '' ) && $fakeit ) {
2003-05-06 22:15:28 +00:00
$output = get_the_content ();
$output = strip_tags ( $output );
$blah = explode ( ' ' , $output );
$excerpt_length = 120 ;
if ( count ( $blah ) > $excerpt_length ) {
$k = $excerpt_length ;
$use_dotdotdot = 1 ;
} else {
$k = count ( $blah );
$use_dotdotdot = 0 ;
}
for ( $i = 0 ; $i < $k ; $i ++ ) {
$excerpt .= $blah [ $i ] . ' ' ;
}
$excerpt .= ( $use_dotdotdot ) ? '...' : '' ;
$output = $excerpt ;
} // end if no excerpt
2003-04-24 01:04:42 +00:00
if ( $preview ) { // preview fix for javascript bug with foreign languages
$output = preg_replace ( '/\%u([0-9A-F]{4,4})/e' , " '&#'.base_convert(' \\ 1',16,10).';' " , $output );
}
2003-05-06 22:15:28 +00:00
return $output ;
2003-04-24 01:04:42 +00:00
}
2003-04-21 21:37:11 +00:00
function link_pages ( $before = '<br />' , $after = '<br />' , $next_or_number = 'number' , $nextpagelink = 'next page' , $previouspagelink = 'previous page' , $pagelink = '%' , $more_file = '' ) {
2003-05-29 15:51:10 +00:00
global $id , $page , $numpages , $multipage , $more ;
2003-04-21 21:37:11 +00:00
global $pagenow ;
global $querystring_start , $querystring_equal , $querystring_separator ;
if ( $more_file != '' ) {
$file = $more_file ;
} else {
$file = $pagenow ;
}
if (( $multipage )) { // && ($more)) {
if ( $next_or_number == 'number' ) {
echo $before ;
for ( $i = 1 ; $i < ( $numpages + 1 ); $i = $i + 1 ) {
$j = str_replace ( '%' , " $i " , $pagelink );
echo " " ;
if (( $i != $page ) || (( ! $more ) && ( $page == 1 )))
echo '<a href="' . $file . $querystring_start . 'p' . $querystring_equal . $id .
$querystring_separator . 'more' . $querystring_equal . '1' .
$querystring_separator . 'page' . $querystring_equal . $i . '">' ;
echo $j ;
if (( $i != $page ) || (( ! $more ) && ( $page == 1 )))
echo '</a>' ;
}
echo $after ;
} else {
if ( $more ) {
echo $before ;
$i = $page - 1 ;
if ( $i && $more )
echo ' <a href="' . $file . $querystring_start . 'p' . $querystring_equal . $id .
$querystring_separator . 'more' . $querystring_equal . '1' .
$querystring_separator . 'page' . $querystring_equal . $i . '">' .
$previouspagelink . '</a>' ;
$i = $page + 1 ;
if ( $i <= $numpages && $more )
echo ' <a href="' . $file . $querystring_start . 'p' . $querystring_equal . $id .
$querystring_separator . 'more' . $querystring_equal . '1' .
$querystring_separator . 'page' . $querystring_equal . $i . '">' .
$nextpagelink . '</a>' ;
echo $after ;
}
}
}
}
function previous_post ( $format = '%' , $previous = 'previous post: ' , $title = 'yes' , $in_same_cat = 'no' , $limitprev = 1 , $excluded_categories = '' ) {
2003-05-29 15:51:10 +00:00
global $tableposts , $id , $post , $siteurl , $blogfilename , $querycount , $wpdb ;
2003-04-21 21:37:11 +00:00
global $p , $posts , $posts_per_page , $s ;
global $querystring_start , $querystring_equal , $querystring_separator ;
if (( $p ) || ( $posts_per_page == 1 )) {
2003-06-08 00:15:39 +00:00
2003-05-29 15:51:10 +00:00
$current_post_date = $post -> post_date ;
$current_category = $post -> post_category ;
2003-04-21 21:37:11 +00:00
$sqlcat = '' ;
if ( $in_same_cat != 'no' ) {
2003-05-29 15:51:10 +00:00
$sqlcat = " AND post_category = ' $current_category ' " ;
2003-04-21 21:37:11 +00:00
}
$sql_exclude_cats = '' ;
if ( ! empty ( $excluded_categories )) {
$blah = explode ( 'and' , $excluded_categories );
foreach ( $blah as $category ) {
$category = intval ( $category );
$sql_exclude_cats .= " AND post_category != $category " ;
}
}
$limitprev -- ;
2003-05-29 15:51:10 +00:00
$lastpost = @ $wpdb -> get_row ( " SELECT ID, post_title FROM $tableposts WHERE post_date < ' $current_post_date ' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev , 1 " );
2003-05-29 14:04:30 +00:00
++ $querycount ;
2003-05-29 15:51:10 +00:00
if ( $lastpost ) {
$string = '<a href="' . $blogfilename . $querystring_start . 'p' . $querystring_equal . $lastpost -> ID . $querystring_separator . 'more' . $querystring_equal . '1' . $querystring_separator . 'c' . $querystring_equal . '1">' . $previous ;
$string .= wptexturize ( stripslashes ( $lastpost -> post_title ));
2003-04-21 21:37:11 +00:00
$string .= '</a>' ;
2003-05-29 15:51:10 +00:00
$format = str_replace ( '%' , $string , $format );
2003-04-21 21:37:11 +00:00
echo $format ;
}
}
}
function next_post ( $format = '%' , $next = 'next post: ' , $title = 'yes' , $in_same_cat = 'no' , $limitnext = 1 , $excluded_categories = '' ) {
2003-05-29 15:51:10 +00:00
global $tableposts , $p , $posts , $id , $post , $siteurl , $blogfilename , $querycount ;
2003-04-21 21:37:11 +00:00
global $time_difference ;
global $querystring_start , $querystring_equal , $querystring_separator ;
if (( $p ) || ( $posts == 1 )) {
2003-06-08 00:15:39 +00:00
2003-05-29 15:51:10 +00:00
$current_post_date = $post -> post_date ;
$current_category = $post -> post_category ;
2003-04-21 21:37:11 +00:00
$sqlcat = '' ;
if ( $in_same_cat != 'no' ) {
$sqlcat = " AND post_category=' $current_category ' " ;
}
$sql_exclude_cats = '' ;
if ( ! empty ( $excluded_categories )) {
$blah = explode ( 'and' , $excluded_categories );
foreach ( $blah as $category ) {
$category = intval ( $category );
$sql_exclude_cats .= " AND post_category != $category " ;
}
}
$now = date ( 'Y-m-d H:i:s' ,( time () + ( $time_difference * 3600 )));
$limitnext -- ;
2003-05-29 15:51:10 +00:00
$nextpost = @ $wpdb -> get_row ( " SELECT ID,post_title FROM $tableposts WHERE post_date > ' $current_post_date ' AND post_date < ' $now ' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext ,1 " );
2003-05-29 14:04:30 +00:00
++ $querycount ;
2003-05-29 15:51:10 +00:00
if ( $nextpost ) {
$string = '<a href="' . $blogfilename . $querystring_start . 'p' . $querystring_equal . $nextpost -> ID . $querystring_separator . 'more' . $querystring_equal . '1' . $querystring_separator . 'c' . $querystring_equal . '1">' . $next ;
2003-04-21 21:37:11 +00:00
if ( $title == 'yes' ) {
2003-05-29 15:51:10 +00:00
$string .= wptexturize ( stripslashes ( $nextpost -> post_title ));
2003-04-21 21:37:11 +00:00
}
$string .= '</a>' ;
2003-05-29 15:51:10 +00:00
$format = str_replace ( '%' , $string , $format );
2003-04-21 21:37:11 +00:00
echo $format ;
}
}
}
function next_posts ( $max_page = 0 ) { // original by cfactor at cooltux.org
global $HTTP_SERVER_VARS , $siteurl , $blogfilename , $p , $paged , $what_to_show , $pagenow ;
global $querystring_start , $querystring_equal , $querystring_separator ;
if ( empty ( $p ) && ( $what_to_show == 'paged' )) {
$qstr = $HTTP_SERVER_VARS [ 'QUERY_STRING' ];
if ( ! empty ( $qstr )) {
$qstr = preg_replace ( " /&paged= \ d { 0,}/ " , " " , $qstr );
$qstr = preg_replace ( " /paged= \ d { 0,}/ " , " " , $qstr );
} elseif ( stristr ( $HTTP_SERVER_VARS [ 'REQUEST_URI' ], $HTTP_SERVER_VARS [ 'SCRIPT_NAME' ] )) {
2003-06-08 00:15:39 +00:00
if ( '' != $qstr = str_replace ( $HTTP_SERVER_VARS [ 'SCRIPT_NAME' ], '' ,
2003-04-21 21:37:11 +00:00
$HTTP_SERVER_VARS [ 'REQUEST_URI' ]) ) {
$qstr = preg_replace ( " /^ \ // " , " " , $qstr );
2003-06-08 00:15:39 +00:00
$qstr = preg_replace ( " /paged \ / \ d { 0,} \ // " , " " , $qstr );
2003-04-21 21:37:11 +00:00
$qstr = preg_replace ( " /paged \ / \ d { 0,}/ " , " " , $qstr );
$qstr = preg_replace ( " / \ / $ / " , " " , $qstr );
}
}
if ( ! $paged ) $paged = 1 ;
$nextpage = intval ( $paged ) + 1 ;
if ( ! $max_page || $max_page >= $nextpage ) {
echo $pagenow . $querystring_start .
( $qstr == '' ? '' : $qstr . $querystring_separator ) .
'paged' . $querystring_equal . $nextpage ;
}
}
}
function next_posts_link ( $label = 'Next Page >>' , $max_page = 0 ) {
global $p , $paged , $result , $request , $posts_per_page , $what_to_show ;
if ( $what_to_show == 'paged' ) {
if ( ! $max_page ) {
$nxt_request = $request ;
if ( $pos = strpos ( strtoupper ( $request ), 'LIMIT' )) {
$nxt_request = substr ( $request , 0 , $pos );
}
$nxt_result = mysql_query ( $nxt_request );
$numposts = mysql_num_rows ( $nxt_result );
$max_page = ceil ( $numposts / $posts_per_page );
}
if ( ! $paged ) $paged = 1 ;
$nextpage = intval ( $paged ) + 1 ;
if ( empty ( $p ) && ( empty ( $paged ) || $nextpage <= $max_page )) {
echo '<a href="' ;
echo next_posts ( $max_page );
echo '">' . htmlspecialchars ( $label ) . '</a>' ;
}
}
}
function previous_posts () { // original by cfactor at cooltux.org
global $HTTP_SERVER_VARS , $siteurl , $blogfilename , $p , $paged , $what_to_show , $pagenow ;
global $querystring_start , $querystring_equal , $querystring_separator ;
if ( empty ( $p ) && ( $what_to_show == 'paged' )) {
$qstr = $HTTP_SERVER_VARS [ 'QUERY_STRING' ];
if ( ! empty ( $qstr )) {
$qstr = preg_replace ( " /&paged= \ d { 0,}/ " , " " , $qstr );
$qstr = preg_replace ( " /paged= \ d { 0,}/ " , " " , $qstr );
} elseif ( stristr ( $HTTP_SERVER_VARS [ 'REQUEST_URI' ], $HTTP_SERVER_VARS [ 'SCRIPT_NAME' ] )) {
2003-06-08 00:15:39 +00:00
if ( '' != $qstr = str_replace ( $HTTP_SERVER_VARS [ 'SCRIPT_NAME' ], '' ,
2003-04-21 21:37:11 +00:00
$HTTP_SERVER_VARS [ 'REQUEST_URI' ]) ) {
$qstr = preg_replace ( " /^ \ // " , " " , $qstr );
2003-06-08 00:15:39 +00:00
$qstr = preg_replace ( " /paged \ / \ d { 0,} \ // " , " " , $qstr );
2003-04-21 21:37:11 +00:00
$qstr = preg_replace ( " /paged \ / \ d { 0,}/ " , " " , $qstr );
$qstr = preg_replace ( " / \ / $ / " , " " , $qstr );
}
}
$nextpage = intval ( $paged ) - 1 ;
if ( $nextpage < 1 ) $nextpage = 1 ;
echo $pagenow . $querystring_start .
( $qstr == '' ? '' : $qstr . $querystring_separator ) .
'paged' . $querystring_equal . $nextpage ;
}
2003-06-08 00:15:39 +00:00
}
2003-04-21 21:37:11 +00:00
function previous_posts_link ( $label = '<< Previous Page' ) {
global $p , $paged , $what_to_show ;
if ( empty ( $p ) && ( $paged > 1 ) && ( $what_to_show == 'paged' )) {
echo '<a href="' ;
echo previous_posts ();
echo '">' . htmlspecialchars ( $label ) . '</a>' ;
}
}
function posts_nav_link ( $sep = ' :: ' , $prelabel = '<< Previous Page' , $nxtlabel = 'Next Page >>' ) {
global $p , $what_to_show , $request , $posts_per_page ;
if ( empty ( $p ) && ( $what_to_show == 'paged' )) {
$nxt_request = $request ;
if ( $pos = strpos ( strtoupper ( $request ), 'LIMIT' )) {
$nxt_request = substr ( $request , 0 , $pos );
}
$nxt_result = mysql_query ( $nxt_request );
$numposts = mysql_num_rows ( $nxt_result );
$max_page = ceil ( $numposts / $posts_per_page );
if ( $max_page > 1 ) {
previous_posts_link ( $prelabel );
echo htmlspecialchars ( $sep );
next_posts_link ( $nxtlabel , $max_page );
}
}
}
/***** // Post tags *****/
/***** Category tags *****/
function the_category () {
$category = get_the_category ();
$category = apply_filters ( 'the_category' , $category );
echo convert_chars ( $category , 'html' );
}
function the_category_rss () {
echo convert_chars ( strip_tags ( get_the_category ()), 'xml' );
}
function the_category_unicode () {
$category = get_the_category ();
$category = apply_filters ( 'the_category_unicode' , $category );
echo convert_chars ( $category , 'unicode' );
}
2003-05-29 15:51:10 +00:00
2003-04-21 21:37:11 +00:00
function get_the_category () {
2003-05-29 15:51:10 +00:00
global $post , $tablecategories , $querycount , $cache_categories , $use_cache , $wpdb ;
$cat_ID = $post -> post_category ;
2003-04-21 21:37:11 +00:00
if (( empty ( $cache_categories [ $cat_ID ])) OR ( ! $use_cache )) {
2003-05-29 15:51:10 +00:00
$cat_name = $wpdb -> get_var ( " SELECT cat_name FROM $tablecategories WHERE cat_ID = ' $cat_ID ' " );
2003-05-29 14:04:30 +00:00
++ $querycount ;
2003-05-29 15:51:10 +00:00
$cache_categories [ $cat_ID ] = & $cat_name ;
2003-04-21 21:37:11 +00:00
} else {
$cat_name = $cache_categories [ $cat_ID ];
}
return ( stripslashes ( $cat_name ));
}
function get_the_category_by_ID ( $cat_ID ) {
2003-05-29 15:51:10 +00:00
global $tablecategories , $querycount , $cache_categories , $use_cache , $wpdb ;
2003-04-21 21:37:11 +00:00
if (( ! $cache_categories [ $cat_ID ]) OR ( ! $use_cache )) {
2003-05-29 15:51:10 +00:00
$cat_name = $wpdb -> get_var ( " SELECT cat_name FROM $tablecategories WHERE cat_ID = ' $cat_ID ' " );
2003-05-29 14:04:30 +00:00
++ $querycount ;
2003-05-29 15:51:10 +00:00
$cache_categories [ $cat_ID ] = & $cat_name ;
2003-04-21 21:37:11 +00:00
} else {
$cat_name = $cache_categories [ $cat_ID ];
}
return ( stripslashes ( $cat_name ));
}
function the_category_ID () {
2003-05-29 15:51:10 +00:00
global $post ;
echo $post -> post_category ;
2003-04-21 21:37:11 +00:00
}
2003-05-29 15:51:10 +00:00
function the_category_head ( $before = '' , $after = '' ) {
global $post , $currentcat , $previouscat , $dateformat , $newday ;
$currentcat = $post -> post_category ;
2003-04-21 21:37:11 +00:00
if ( $currentcat != $previouscat ) {
echo $before ;
echo get_the_category_by_ID ( $currentcat );
echo $after ;
$previouscat = $currentcat ;
}
}
// out of the b2 loop
function dropdown_cats ( $optionall = 1 , $all = 'All' ) {
2003-05-29 15:51:10 +00:00
global $cat , $tablecategories , $querycount , $wpdb ;
$categories = $wpdb -> get_results ( " SELECT cat_ID, cat_name FROM $tablecategories " );
2003-05-29 14:04:30 +00:00
++ $querycount ;
2003-05-29 15:51:10 +00:00
echo " <select name='cat' class='postform'> \n " ;
2003-04-21 21:37:11 +00:00
if ( intval ( $optionall ) == 1 ) {
2003-05-29 15:51:10 +00:00
echo " \t <option value='all'> $all </option> \n " ;
2003-04-21 21:37:11 +00:00
}
2003-05-29 15:51:10 +00:00
foreach ( $categories as $category ) {
echo " \t <option value= \" " . $category -> cat_ID . " \" " ;
if ( $category -> cat_ID == $cat )
2003-04-21 21:37:11 +00:00
echo ' selected="selected"' ;
2003-05-29 15:51:10 +00:00
echo '>' . stripslashes ( $category -> cat_name ) . " </option> \n " ;
2003-04-21 21:37:11 +00:00
}
echo " </select> \n " ;
}
// out of the b2 loop
2003-05-29 15:51:10 +00:00
function list_cats ( $optionall = 1 , $all = 'All' , $sort_column = 'ID' , $sort_order = 'asc' , $file = 'blah' , $list = true ) {
global $tablecategories , $querycount , $wpdb ;
2003-04-21 21:37:11 +00:00
global $pagenow ;
global $querystring_start , $querystring_equal , $querystring_separator ;
$file = ( $file == 'blah' ) ? $pagenow : $file ;
$sort_column = 'cat_' . $sort_column ;
2003-05-29 15:51:10 +00:00
$categories = $wpdb -> get_results ( " SELECT * FROM $tablecategories WHERE cat_ID > 0 ORDER BY $sort_column $sort_order " );
2003-05-29 14:04:30 +00:00
++ $querycount ;
2003-04-21 21:37:11 +00:00
if ( intval ( $optionall ) == 1 ) {
$all = apply_filters ( 'list_cats' , $all );
2003-05-06 08:06:57 +00:00
if ( $list ) echo " \n \t <li><a href= \" " . $file . $querystring_start . 'cat' . $querystring_equal . 'all">' . $all . " </a></li> " ;
else echo " \t <a href= \" " . $file . $querystring_start . 'cat' . $querystring_equal . 'all">' . $all . " </a><br /> \n " ;
2003-04-21 21:37:11 +00:00
}
2003-05-29 15:51:10 +00:00
foreach ( $categories as $category ) {
$cat_name = apply_filters ( 'list_cats' , $category -> cat_name );
2003-05-06 08:06:57 +00:00
if ( $list ) {
2003-05-29 15:51:10 +00:00
echo " \n \t <li><a href= \" " . $file . $querystring_start . 'cat' . $querystring_equal . $category -> cat_ID . '">' ;
2003-05-06 08:06:57 +00:00
echo stripslashes ( $cat_name ) . " </a></li> " ;
} else {
2003-05-29 15:51:10 +00:00
echo " \t <a href= \" " . $file . $querystring_start . 'cat' . $querystring_equal . $category -> cat_ID . '">' ;
2003-05-06 08:06:57 +00:00
echo stripslashes ( $cat_name ) . " </a><br /> \n " ;
}
2003-04-21 21:37:11 +00:00
}
}
/***** // Category tags *****/
/***** <Link> tags *****/
/***** // <Link> tags *****/
/***** Comment tags *****/
// generic comments/trackbacks/pingbacks numbering
2003-05-29 14:04:30 +00:00
function comments_number ( $zero = 'No Comments' , $one = '1 Comment' , $more = '% Comments' ) {
global $id , $comment , $tablecomments , $querycount , $wpdb ;
$number = $wpdb -> get_var ( " SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id " );
2003-04-21 21:37:11 +00:00
if ( $number == 0 ) {
$blah = $zero ;
} elseif ( $number == 1 ) {
$blah = $one ;
} elseif ( $number > 1 ) {
2003-05-29 14:04:30 +00:00
$blah = str_replace ( '%' , $number , $more );
2003-04-21 21:37:11 +00:00
}
echo $blah ;
}
2003-05-29 14:04:30 +00:00
function comments_link ( $file = '' , $echo = true ) {
global $id , $pagenow ;
2003-04-21 21:37:11 +00:00
global $querystring_start , $querystring_equal , $querystring_separator ;
if ( $file == '' ) $file = $pagenow ;
if ( $file == '/' ) $file = '' ;
2003-05-21 11:17:09 +00:00
if ( ! $echo ) return $file . $querystring_start . 'p' . $querystring_equal . $id . $querystring_separator . 'c' . $querystring_equal . '1#comments' ;
else echo $file . $querystring_start . 'p' . $querystring_equal . $id . $querystring_separator . 'c' . $querystring_equal . '1#comments' ;
2003-04-21 21:37:11 +00:00
}
2003-05-29 14:04:30 +00:00
function comments_popup_script ( $width = 400 , $height = 400 , $file = 'b2commentspopup.php' ) {
2003-04-21 21:37:11 +00:00
global $b2commentspopupfile , $b2trackbackpopupfile , $b2pingbackpopupfile , $b2commentsjavascript ;
$b2commentspopupfile = $file ;
$b2commentsjavascript = 1 ;
2003-05-29 14:04:30 +00:00
$javascript = " <script language='javascript' type='text/javascript'> \n <!-- \n function b2open (macagna) { \n window.open(macagna, '_blank', 'width= $width ,height= $height ,scrollbars=yes,status=yes'); \n } \n //--> \n </script> \n " ;
2003-04-21 21:37:11 +00:00
echo $javascript ;
}
2003-06-04 19:36:35 +00:00
function comments_popup_link ( $zero = 'No Comments' , $one = '1 Comment' , $more = '% Comments' , $CSSclass = '' , $none = 'Comments Off' ) {
global $id , $b2commentspopupfile , $b2commentsjavascript , $post , $wpdb , $tablecomments ;
2003-04-21 21:37:11 +00:00
global $querystring_start , $querystring_equal , $querystring_separator , $siteurl ;
2003-06-04 19:36:35 +00:00
$number = $wpdb -> get_var ( " SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id " );
if ( 0 == $number && 'closed' == $post -> comment_status ) {
echo $none ;
return ;
2003-04-21 21:37:11 +00:00
} else {
2003-06-04 19:36:35 +00:00
echo " <a href= \" $siteurl / " ;
if ( $b2commentsjavascript ) {
echo $b2commentspopupfile . $querystring_start . 'p' . $querystring_equal . $id . $querystring_separator . 'c' . $querystring_equal . '1' ;
2003-06-06 21:58:24 +00:00
echo '" onclick="b2open(this.href); return false"' ;
2003-06-04 19:36:35 +00:00
} else {
// if comments_popup_script() is not in the template, display simple comment link
comments_link ();
echo '"' ;
}
if ( ! empty ( $CSSclass )) {
echo ' class="' . $CSSclass . '"' ;
}
echo '>' ;
comments_number ( $zero , $one , $more );
echo '</a>' ;
2003-04-21 21:37:11 +00:00
}
}
function comment_ID () {
2003-05-29 14:04:30 +00:00
global $comment ;
echo $comment -> comment_ID ;
2003-04-21 21:37:11 +00:00
}
function comment_author () {
2003-05-29 14:04:30 +00:00
global $comment ;
echo stripslashes ( $comment -> comment_author );
2003-04-21 21:37:11 +00:00
}
function comment_author_email () {
2003-05-29 14:04:30 +00:00
global $comment ;
echo antispambot ( stripslashes ( $comment -> comment_author_email ));
2003-04-21 21:37:11 +00:00
}
2003-05-29 14:04:30 +00:00
function comment_author_link () {
global $comment ;
$url = trim ( stripslashes ( & $comment -> comment_author_url ));
$email = & $comment -> comment_author_email ;
$author = stripslashes ( & $comment -> comment_author );
$url = str_replace ( 'http://url' , '' , $url );
2003-06-08 10:12:50 +00:00
if ( empty ( $url ) && empty ( $email )) {
echo $author ;
return ;
}
2003-05-29 14:04:30 +00:00
echo '<a href="' ;
if ( $url ) {
$url = str_replace ( ';//' , '://' , $url );
$url = ( ! strstr ( $url , '://' )) ? 'http://' . $url : $url ;
$url = preg_replace ( '/&([^#])(?![a-z]{2,8};)/' , '&$1' , $url );
2003-06-08 10:15:17 +00:00
echo $url ;
2003-05-29 14:04:30 +00:00
} else {
2003-06-08 10:12:50 +00:00
echo 'mailto:' . $email ;
2003-05-29 14:04:30 +00:00
}
echo '" rel="external">' . $author . '</a>' ;
}
function comment_type ( $commenttxt = 'Comment' , $trackbacktxt = 'Trackback' , $pingbacktxt = 'Pingback' ) {
global $comment ;
if ( preg_match ( '|<trackback />|' , $comment -> comment_content )) echo $trackbacktxt ;
elseif ( preg_match ( '|<pingback />|' , $comment -> comment_content )) echo $pingbacktxt ;
else echo $commenttxt ;
}
2003-04-21 21:37:11 +00:00
function comment_author_url () {
2003-05-29 14:04:30 +00:00
global $comment ;
$url = trim ( stripslashes ( $comment -> comment_author_url ));
$url = str_replace ( ';//' , '://' , $url );
$url = ( ! strstr ( $url , '://' )) ? 'http://' . $url : $url ;
2003-04-21 21:37:11 +00:00
// convert & into &
2003-05-29 14:04:30 +00:00
$url = preg_replace ( '/&([^#])(?![a-z]{2,8};)/' , '&$1' , $url );
2003-04-21 21:37:11 +00:00
if ( $url != 'http://url' ) {
echo $url ;
}
}
function comment_author_email_link ( $linktext = '' , $before = '' , $after = '' ) {
2003-05-29 14:04:30 +00:00
global $comment ;
$email = $comment -> comment_author_email ;
2003-04-21 21:37:11 +00:00
if (( ! empty ( $email )) && ( $email != '@' )) {
$display = ( $linktext != '' ) ? $linktext : antispambot ( stripslashes ( $email ));
echo $before ;
echo '<a href="mailto:' . antispambot ( stripslashes ( $email )) . '">' . $display . '</a>' ;
echo $after ;
}
}
function comment_author_url_link ( $linktext = '' , $before = '' , $after = '' ) {
2003-05-29 14:04:30 +00:00
global $comment ;
$url = trim ( stripslashes ( $comment -> comment_author_url ));
$url = preg_replace ( '/&([^#])(?![a-z]{2,8};)/' , '&$1' , $url );
2003-04-21 21:37:11 +00:00
$url = ( ! stristr ( $url , '://' )) ? 'http://' . $url : $url ;
if (( ! empty ( $url )) && ( $url != 'http://' ) && ( $url != 'http://url' )) {
$display = ( $linktext != '' ) ? $linktext : stripslashes ( $url );
echo $before ;
echo '<a href="' . stripslashes ( $url ) . '" target="_blank">' . $display . '</a>' ;
echo $after ;
}
}
function comment_author_IP () {
2003-05-29 14:04:30 +00:00
global $comment ;
echo stripslashes ( $comment -> comment_author_IP );
2003-04-21 21:37:11 +00:00
}
function comment_text () {
2003-05-29 14:04:30 +00:00
global $comment ;
$comment_text = stripslashes ( $comment -> comment_content );
$comment_text = str_replace ( '<trackback />' , '' , $comment_text );
$comment_text = str_replace ( '<pingback />' , '' , $comment_text );
$comment_text = convert_chars ( $comment_text );
$comment_text = convert_bbcode ( $comment_text );
$comment_text = convert_gmcode ( $comment_text );
$comment_text = convert_smilies ( $comment_text );
$comment_text = make_clickable ( $comment_text );
$comment_text = balanceTags ( $comment_text );
$comment_text = apply_filters ( 'comment_text' , $comment_text );
echo $comment_text ;
2003-04-21 21:37:11 +00:00
}
function comment_date ( $d = '' ) {
2003-05-29 14:04:30 +00:00
global $comment , $dateformat ;
2003-04-21 21:37:11 +00:00
if ( $d == '' ) {
2003-05-29 14:04:30 +00:00
echo mysql2date ( $dateformat , $comment -> comment_date );
2003-04-21 21:37:11 +00:00
} else {
2003-05-29 14:04:30 +00:00
echo mysql2date ( $d , $comment -> comment_date );
2003-04-21 21:37:11 +00:00
}
}
function comment_time ( $d = '' ) {
2003-05-29 14:04:30 +00:00
global $comment , $timeformat ;
2003-04-21 21:37:11 +00:00
if ( $d == '' ) {
2003-05-29 14:04:30 +00:00
echo mysql2date ( $timeformat , $comment -> comment_date );
2003-04-21 21:37:11 +00:00
} else {
2003-05-29 14:04:30 +00:00
echo mysql2date ( $d , $comment -> comment_date );
2003-04-21 21:37:11 +00:00
}
}
/***** // Comment tags *****/
/***** TrackBack tags *****/
2003-05-29 14:04:30 +00:00
function trackback_url ( $display = true ) {
2003-05-24 21:50:22 +00:00
global $siteurl , $id ;
$tb_url = $siteurl . '/b2trackback.php/' . $id ;
2003-04-21 21:37:11 +00:00
if ( $display ) {
echo $tb_url ;
} else {
return $tb_url ;
}
}
2003-05-29 15:51:10 +00:00
function trackback_rdf ( $timezone = 0 ) {
2003-05-24 21:50:22 +00:00
global $siteurl , $id , $HTTP_SERVER_VARS ;
2003-04-21 21:37:11 +00:00
if ( ! stristr ( $HTTP_SERVER_VARS [ 'HTTP_USER_AGENT' ], 'W3C_Validator' )) {
echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ' . " \n " ;
echo ' xmlns:dc="http://purl.org/dc/elements/1.1/"' . " \n " ;
echo ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . " \n " ;
echo '<rdf:Description' . " \n " ;
echo ' rdf:about="' ;
permalink_single ();
echo '"' . " \n " ;
echo ' dc:identifier="' ;
permalink_single ();
echo '"' . " \n " ;
echo ' dc:title="' . addslashes ( get_the_title ()) . '"' . " \n " ;
echo ' trackback:ping="' . trackback_url ( 0 ) . '"' . " /> \n " ;
echo '</rdf:RDF>' ;
}
}
/***** // TrackBack tags *****/
/***** Permalink tags *****/
function permalink_anchor ( $mode = 'id' ) {
2003-05-29 15:51:10 +00:00
global $id , $post ;
2003-04-21 21:37:11 +00:00
switch ( strtolower ( $mode )) {
case 'title' :
2003-05-29 15:51:10 +00:00
$title = preg_replace ( '/[^a-zA-Z0-9_\.-]/' , '_' , $post -> post_title );
2003-04-21 21:37:11 +00:00
echo '<a name="' . $title . '"></a>' ;
break ;
case 'id' :
default :
2003-06-11 19:48:43 +00:00
echo '<a name="post-' . $id . '"></a>' ;
2003-04-21 21:37:11 +00:00
break ;
}
}
function permalink_link ( $file = '' , $mode = 'id' ) {
2003-05-29 15:51:10 +00:00
global $id , $post , $pagenow , $cacheweekly , $wpdb , $querycount ;
2003-04-21 21:37:11 +00:00
global $querystring_start , $querystring_equal , $querystring_separator ;
$file = ( $file == '' ) ? $pagenow : $file ;
switch ( strtolower ( $mode )) {
case 'title' :
2003-05-29 15:51:10 +00:00
$title = preg_replace ( '/[^a-zA-Z0-9_\.-]/' , '_' , $post -> post_title );
2003-04-21 21:37:11 +00:00
$anchor = $title ;
break ;
case 'id' :
default :
$anchor = $id ;
break ;
}
$archive_mode = get_settings ( 'archive_mode' );
switch ( $archive_mode ) {
case 'daily' :
2003-06-11 19:48:43 +00:00
echo $file . $querystring_start . 'm' . $querystring_equal . substr ( $post -> post_date , 0 , 4 ) . substr ( $post -> post_date , 5 , 2 ) . substr ( $postdata [ 'Date' ], 8 , 2 ) . '#post-' . $anchor ;
2003-04-21 21:37:11 +00:00
break ;
case 'monthly' :
2003-06-11 19:48:43 +00:00
echo $file . $querystring_start . 'm' . $querystring_equal . substr ( $post -> post_date , 0 , 4 ) . substr ( $post -> post_date , 5 , 2 ) . '#post-' . $anchor ;
2003-04-21 21:37:11 +00:00
break ;
case 'weekly' :
if (( ! isset ( $cacheweekly )) || ( empty ( $cacheweekly [ $postdata [ 'Date' ]]))) {
2003-05-29 15:51:10 +00:00
$cacheweekly [ $post -> post_date ] = $wpdb -> get_var ( " SELECT WEEK(' $post->post_date ') " );
++ $querycount ;
2003-04-21 21:37:11 +00:00
}
2003-06-11 19:48:43 +00:00
echo $file . $querystring_start . 'm' . $querystring_equal . substr ( $post -> post_date , 0 , 4 ) . $querystring_separator . 'w' . $querystring_equal . $cacheweekly [ $post -> post_date ] . '#post-' . $anchor ;
2003-04-21 21:37:11 +00:00
break ;
case 'postbypost' :
echo $file . $querystring_start . 'p' . $querystring_equal . $id ;
break ;
}
}
function permalink_single ( $file = '' ) {
2003-05-29 15:51:10 +00:00
global $id , $pagenow ;
2003-04-21 21:37:11 +00:00
global $querystring_start , $querystring_equal , $querystring_separator ;
if ( $file == '' )
2003-05-29 15:51:10 +00:00
$file = $pagenow ;
2003-04-21 21:37:11 +00:00
echo $file . $querystring_start . 'p' . $querystring_equal . $id . $querystring_separator . 'more' . $querystring_equal . '1' . $querystring_separator . 'c' . $querystring_equal . '1' ;
}
2003-05-29 15:51:10 +00:00
function permalink_single_rss ( $file = 'b2rss.php' ) {
global $id , $pagenow , $siteurl , $blogfilename ;
2003-04-21 21:37:11 +00:00
global $querystring_start , $querystring_equal , $querystring_separator ;
echo $siteurl . '/' . $blogfilename . $querystring_start . 'p' . $querystring_equal . $id . $querystring_separator . 'c' . $querystring_equal . '1' ;
}
/***** // Permalink tags *****/
// @@@ These aren't template tags, do not edit them
function start_b2 () {
2003-05-29 14:04:30 +00:00
global $post , $id , $postdata , $authordata , $day , $preview , $page , $pages , $multipage , $more , $numpages ;
2003-04-21 21:37:11 +00:00
global $preview_userid , $preview_date , $preview_content , $preview_title , $preview_category , $preview_notify , $preview_make_clickable , $preview_autobr ;
global $pagenow ;
global $HTTP_GET_VARS ;
if ( ! $preview ) {
2003-05-29 14:04:30 +00:00
$id = $post -> ID ;
2003-04-21 21:37:11 +00:00
} else {
$id = 0 ;
$postdata = array (
2003-06-08 00:15:39 +00:00
'ID' => 0 ,
2003-04-21 21:37:11 +00:00
'Author_ID' => $HTTP_GET_VARS [ 'preview_userid' ],
'Date' => $HTTP_GET_VARS [ 'preview_date' ],
'Content' => $HTTP_GET_VARS [ 'preview_content' ],
2003-04-24 01:04:42 +00:00
'Excerpt' => $HTTP_GET_VARS [ 'preview_excerpt' ],
2003-04-21 21:37:11 +00:00
'Title' => $HTTP_GET_VARS [ 'preview_title' ],
'Category' => $HTTP_GET_VARS [ 'preview_category' ],
2003-05-29 15:51:10 +00:00
'Notify' => 1
2003-04-21 21:37:11 +00:00
);
}
2003-05-29 15:51:10 +00:00
$authordata = get_userdata ( $post -> post_author );
$day = mysql2date ( 'd.m.y' , $post -> post_date );
$currentmonth = mysql2date ( 'm' , $post -> post_date );
$numpages = 1 ;
2003-04-21 21:37:11 +00:00
if ( ! $page )
2003-05-29 15:51:10 +00:00
$page = 1 ;
2003-04-21 21:37:11 +00:00
if ( isset ( $p ))
2003-05-29 15:51:10 +00:00
$more = 1 ;
$content = $post -> post_content ;
if ( preg_match ( '/<!--nextpage-->/' , $post -> post_content )) {
2003-04-21 21:37:11 +00:00
if ( $page > 1 )
2003-05-29 15:51:10 +00:00
$more = 1 ;
$multipage = 1 ;
$content = stripslashes ( $post -> post_content );
2003-04-21 21:37:11 +00:00
$content = str_replace ( " \n <!--nextpage--> \n " , '<!--nextpage-->' , $content );
$content = str_replace ( " \n <!--nextpage--> " , '<!--nextpage-->' , $content );
$content = str_replace ( " <!--nextpage--> \n " , '<!--nextpage-->' , $content );
2003-05-29 15:51:10 +00:00
$pages = explode ( '<!--nextpage-->' , $content );
$numpages = count ( $pages );
2003-04-21 21:37:11 +00:00
} else {
2003-05-29 15:51:10 +00:00
$pages [ 0 ] = stripslashes ( $post -> post_content );
$multipage = 0 ;
2003-04-21 21:37:11 +00:00
}
return true ;
}
function is_new_day () {
global $day , $previousday ;
if ( $day != $previousday ) {
return ( 1 );
} else {
return ( 0 );
}
}
function apply_filters ( $tag , $string ) {
global $b2_filter ;
if ( isset ( $b2_filter [ 'all' ])) {
$b2_filter [ 'all' ] = ( is_string ( $b2_filter [ 'all' ])) ? array ( $b2_filter [ 'all' ]) : $b2_filter [ 'all' ];
$b2_filter [ $tag ] = array_merge ( $b2_filter [ 'all' ], $b2_filter [ $tag ]);
$b2_filter [ $tag ] = array_unique ( $b2_filter [ $tag ]);
}
if ( isset ( $b2_filter [ $tag ])) {
$b2_filter [ $tags ] = ( is_string ( $b2_filter [ $tag ])) ? array ( $b2_filter [ $tag ]) : $b2_filter [ $tag ];
$functions = $b2_filter [ $tag ];
foreach ( $functions as $function ) {
$string = $function ( $string );
}
}
return $string ;
}
function add_filter ( $tag , $function_to_add ) {
global $b2_filter ;
if ( isset ( $b2_filter [ $tag ])) {
$functions = $b2_filter [ $tag ];
if ( is_array ( $functions )) {
foreach ( $functions as $function ) {
$new_functions [] = $function ;
}
} elseif ( is_string ( $functions )) {
$new_functions [] = $functions ;
}
/* this is commented out because it just makes PHP die silently
for no apparent reason
if ( is_array ( $function_to_add )) {
foreach ( $function_to_add as $function ) {
if ( ! in_array ( $function , $b2_filter [ $tag ])) {
$new_functions [] = $function ;
}
}
} else */ if ( is_string ( $function_to_add )) {
if ( !@ in_array ( $function_to_add , $b2_filter [ $tag ])) {
$new_functions [] = $function_to_add ;
}
}
$b2_filter [ $tag ] = $new_functions ;
} else {
$b2_filter [ $tag ] = array ( $function_to_add );
}
return true ;
}
?>