Refactoring of template tags to use filters, use TABS (!!!), and general cleanliness, which is next to godliness. Some get_settings improvements, less globals.

git-svn-id: http://svn.automattic.com/wordpress/trunk@885 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-02-17 04:56:29 +00:00
parent d1a3b1b896
commit 77421739db
8 changed files with 267 additions and 316 deletions

View File

@ -88,8 +88,6 @@ if (!isset($posts_per_page) || $posts_per_page == 0)
$posts_per_page = get_settings('posts_per_page'); $posts_per_page = get_settings('posts_per_page');
$what_to_show = get_settings('what_to_show'); $what_to_show = get_settings('what_to_show');
$archive_mode = get_settings('archive_mode'); $archive_mode = get_settings('archive_mode');
$dateformat = stripslashes(get_settings('date_format'));
$timeformat = stripslashes(get_settings('time_format'));
$time_difference = get_settings('time_difference'); $time_difference = get_settings('time_difference');
$use_gzipcompression = get_settings('gzipcompression'); $use_gzipcompression = get_settings('gzipcompression');

View File

@ -264,33 +264,37 @@ function url_to_postid($url = '') {
/* Options functions */ /* Options functions */
function get_settings($setting) { function get_settings($setting) {
global $wpdb, $cache_settings, $use_cache; global $wpdb, $cache_settings, $use_cache;
if (strstr($_SERVER['REQUEST_URI'], 'install.php')) { if (strstr($_SERVER['REQUEST_URI'], 'install.php')) {
return false; return false;
} }
if ((empty($cache_settings)) OR (!$use_cache)) { if ((empty($cache_settings)) OR (!$use_cache)) {
$settings = get_alloptions(); $settings = get_alloptions();
$cache_settings = $settings; $cache_settings = $settings;
} else { } else {
$settings = $cache_settings; $settings = $cache_settings;
} }
if (!isset($settings->$setting)) {
return false; if (!isset($settings->$setting)) {
} return false;
else { } else {
return $settings->$setting; return stripslashes($settings->$setting);
} }
} }
function get_alloptions() { function get_alloptions() {
global $tableoptions, $wpdb; global $tableoptions, $wpdb;
$options = $wpdb->get_results("SELECT option_name, option_value FROM $tableoptions"); $options = $wpdb->get_results("SELECT option_name, option_value FROM $tableoptions");
if ($options) { if ($options) {
foreach ($options as $option) { foreach ($options as $option) {
$all_options->{$option->option_name} = $option->option_value; // "When trying to design a foolproof system,
} // never underestimate the ingenuity of the fools :)"
} if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
return $all_options; $all_options->{$option->option_name} = $option->option_value;
}
}
return $all_options;
} }
function update_option($option_name, $newvalue) { function update_option($option_name, $newvalue) {
@ -1461,4 +1465,8 @@ function rewrite_rules($matches = '') {
return $rewrite; return $rewrite;
} }
?> function remove_slashes($string) {
return stripslashes(stripslashes($string));
}
?>

View File

@ -103,18 +103,13 @@ function the_category_rss($type = 'rss') {
foreach ($categories as $category) { foreach ($categories as $category) {
$category->cat_name = stripslashes(convert_chars($category->cat_name)); $category->cat_name = stripslashes(convert_chars($category->cat_name));
if ('rdf' == $type) { if ('rdf' == $type) {
echo "\n<dc:subject>$category->cat_name</dc:subject>"; echo "\n\t<dc:subject>$category->cat_name</dc:subject>";
} else { } else {
echo "\n<category>$category->cat_name</category>"; echo "\n\t<category>$category->cat_name</category>";
} }
} }
} }
function the_category_unicode() {
$category = get_the_category();
$category = apply_filters('the_category_unicode', $category);
echo convert_chars($category, 'unicode');
}
function get_the_category_by_ID($cat_ID) { function get_the_category_by_ID($cat_ID) {
global $tablecategories, $cache_categories, $use_cache, $wpdb; global $tablecategories, $cache_categories, $use_cache, $wpdb;
@ -127,7 +122,7 @@ function get_the_category_by_ID($cat_ID) {
return(stripslashes($cat_name)); return(stripslashes($cat_name));
} }
function get_category_parents($id, $link=FALSE, $separator=' / ', $nicename=FALSE){ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
global $tablecategories, $cache_categories; global $tablecategories, $cache_categories;
$chain = ""; $chain = "";
$parent = $cache_categories[$id]; $parent = $cache_categories[$id];
@ -145,10 +140,10 @@ function get_category_parents($id, $link=FALSE, $separator=' / ', $nicename=FALS
return $chain; return $chain;
} }
function get_category_children($id, $before=' / ', $after='') { function get_category_children($id, $before = '/', $after = '') {
global $tablecategories, $cache_categories; global $tablecategories, $cache_categories;
$c_cache=$cache_categories; // Can't do recursive foreach on a global, have to make a copy $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
$chain = ""; $chain = '';
foreach ($c_cache as $category){ foreach ($c_cache as $category){
if ($category->category_parent == $id){ if ($category->category_parent == $id){
$chain .= $before.$category->cat_ID.$after; $chain .= $before.$category->cat_ID.$after;
@ -158,7 +153,7 @@ function get_category_children($id, $before=' / ', $after='') {
return $chain; return $chain;
} }
function the_category_ID($echo=true) { function the_category_ID($echo = true) {
global $post; global $post;
if ($echo) if ($echo)
echo $post->post_category; echo $post->post_category;
@ -354,4 +349,4 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
} }
echo $thelist; echo $thelist;
} }
?> ?>

View File

@ -1,5 +1,30 @@
<?php <?php
// Default filters for these functions
add_filter('comment_author', 'remove_slashes', 5);
add_filter('comment_author', 'wptexturize');
add_filter('comment_author', 'convert_chars');
add_filter('comment_email', 'remove_slashes', 5);
add_filter('comment_email', 'antispambot', 5);
add_filter('comment_url', 'clean_url');
add_filter('comment_text', 'convert_chars');
add_filter('comment_text', 'make_clickable');
add_filter('comment_text', 'wpautop');
add_filter('comment_text', 'balanceTags');
add_filter('comment_text', 'convert_smilies', 20);
function clean_url($url) {
$url = str_replace('http://url', '', $url);
$url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $url);
$url = str_replace(';//', '://', $url);
$url = (!strstr($url, '://')) ? 'http://'.$url : $url;
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
return $url;
}
function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') { function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') {
global $id, $comment, $tablecomments, $wpdb; global $id, $comment, $tablecomments, $wpdb;
if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'"); if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
@ -70,224 +95,187 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com
} }
function comment_ID() { function comment_ID() {
global $comment; global $comment;
echo $comment->comment_ID; echo $comment->comment_ID;
} }
function comment_author() { function comment_author() {
global $comment; global $comment;
$author = stripslashes(stripslashes($comment->comment_author)); $author = apply_filters('comment_author', $comment->comment_author);
$author = apply_filters('comment_auther', $author); if (empty($author)) {
$author = convert_chars($author); echo 'Anonymous';
if (!empty($author)) { } else {
echo $comment->comment_author; echo $author;
} }
else {
echo "Anonymous";
}
} }
function comment_author_email() { function comment_author_email() {
global $comment; global $comment;
$email = stripslashes(stripslashes($comment->comment_author_email)); echo apply_filters('author_email', $comment->comment_author_email);
echo antispambot(stripslashes($comment->comment_author_email));
} }
function comment_author_link() { function comment_author_link() {
global $comment; global $comment;
$url = trim(stripslashes($comment->comment_author_url)); $url = apply_filters('comment_url', $comment->comment_author_url);
$email = stripslashes($comment->comment_author_email); $email = apply_filters('comment_email', $comment->comment_author_email);
$author = stripslashes($comment->comment_author); $author = apply_filters('comment_author', $comment->comment_author);
$author = convert_chars($author);
$author = wptexturize($author);
if (empty($author)) {
$author = "Anonymous";
}
$url = str_replace('http://url', '', $url); if (empty($url) && empty($email)) {
$url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $url); echo 'Anonymous';
if (empty($url) && empty($email)) { return;
echo $author; }
return;
} echo '<a href="';
echo '<a href="'; if ($url) {
if ($url) { echo $url;
$url = str_replace(';//', '://', $url); } else {
$url = (!strstr($url, '://')) ? 'http://'.$url : $url; echo 'mailto:'.antispambot($email);
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url); }
echo $url; echo '" rel="external">' . $author . '</a>';
} else {
echo 'mailto:'.antispambot($email);
}
echo '" rel="external">' . $author . '</a>';
} }
function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') {
global $comment; global $comment;
if (preg_match('|<trackback />|', $comment->comment_content)) echo $trackbacktxt; if (preg_match('|<trackback />|', $comment->comment_content))
elseif (preg_match('|<pingback />|', $comment->comment_content)) echo $pingbacktxt; echo $trackbacktxt;
else echo $commenttxt; elseif (preg_match('|<pingback />|', $comment->comment_content))
echo $pingbacktxt;
else
echo $commenttxt;
} }
function comment_author_url() { function comment_author_url() {
global $comment; global $comment;
$url = trim(stripslashes($comment->comment_author_url)); echo apply_filters('comment_url', $comment->comment_author_url);
$url = str_replace(';//', '://', $url);
$url = (!strstr($url, '://')) ? 'http://'.$url : $url;
// convert & into &amp;
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
$url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url);
if ($url != 'http://url') {
echo $url;
}
} }
function comment_author_email_link($linktext='', $before='', $after='') { function comment_author_email_link($linktext='', $before='', $after='') {
global $comment; global $comment;
$email = $comment->comment_author_email; $email = apply_filters('comment_email', $comment->comment_author_email);
if ((!empty($email)) && ($email != '@')) { if ((!empty($email)) && ($email != '@')) {
$display = ($linktext != '') ? $linktext : antispambot(stripslashes($email)); $display = ($linktext != '') ? $linktext : antispambot(stripslashes($email));
echo $before; echo $before;
echo '<a href="mailto:'.antispambot(stripslashes($email)).'">'.$display.'</a>'; echo "<a href='mailto:$email'>$display</a>";
echo $after; echo $after;
} }
} }
function comment_author_url_link($linktext='', $before='', $after='') { function comment_author_url_link($linktext='', $before='', $after='') {
global $comment; global $comment;
$url = trim(stripslashes($comment->comment_author_url)); $url = apply_filters('comment_url', $comment->comment_author_url);
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
$url = (!stristr($url, '://')) ? 'http://'.$url : $url; if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) {
$url = preg_replace('|[^a-z0-9-_.,/:]|i', '', $url); $display = ($linktext != '') ? $linktext : stripslashes($url);
if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) { echo $before;
$display = ($linktext != '') ? $linktext : stripslashes($url); echo "<a href='$url' rel='external'>$display</a>";
echo $before; echo $after;
echo '<a href="'.stripslashes($url).'" rel="external">'.$display.'</a>'; }
echo $after;
}
} }
function comment_author_IP() { function comment_author_IP() {
global $comment; global $comment;
echo stripslashes($comment->comment_author_IP); echo $comment->comment_author_IP;
} }
function comment_text() { function comment_text() {
global $comment; global $comment;
$comment_text = stripslashes($comment->comment_content); $comment_text = str_replace('<trackback />', '', $comment->comment_content);
$comment_text = str_replace('<trackback />', '', $comment_text); $comment_text = str_replace('<pingback />', '', $comment_text);
$comment_text = str_replace('<pingback />', '', $comment_text); echo apply_filters('comment_text', $comment_text);
$comment_text = convert_chars($comment_text);
$comment_text = convert_bbcode($comment_text);
$comment_text = convert_gmcode($comment_text);
$comment_text = make_clickable($comment_text);
$comment_text = balanceTags($comment_text,1);
$comment_text = apply_filters('comment_text', $comment_text);
$comment_text = convert_smilies($comment_text);
echo $comment_text;
} }
function comment_date($d='') { function comment_date($d='') {
global $comment, $dateformat; global $comment;
if ($d == '') { if ('' == $d) {
echo mysql2date($dateformat, $comment->comment_date); echo mysql2date(get_settings('date_format'), $comment->comment_date);
} else { } else {
echo mysql2date($d, $comment->comment_date); echo mysql2date($d, $comment->comment_date);
} }
} }
function comment_time($d='') { function comment_time($d='') {
global $comment, $timeformat; global $comment;
if ($d == '') { if ($d == '') {
echo mysql2date($timeformat, $comment->comment_date); echo mysql2date(get_settings('time_format'), $comment->comment_date);
} else { } else {
echo mysql2date($d, $comment->comment_date); echo mysql2date($d, $comment->comment_date);
} }
} }
function comments_rss_link($link_text='Comments RSS', $commentsrssfilename = 'wp-commentsrss2.php') { function comments_rss_link($link_text='Comments RSS', $commentsrssfilename = 'wp-commentsrss2.php') {
global $id; global $id;
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
if ('' != get_settings('permalink_structure')) { if ('' != get_settings('permalink_structure')) {
$url = trailingslashit(get_permalink()) . 'rss2/'; $url = trailingslashit(get_permalink()) . 'rss2/';
} else { } else {
$url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id; $url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id;
} }
$url = '<a href="'.$url.'">'.$link_text.'</a>'; echo "<a href='$url'>$link_text</a>";
echo $url;
} }
function comment_author_rss() { function comment_author_rss() {
global $comment; global $comment;
if (!empty($comment->comment_author)) { if (empty($comment->comment_author)) {
echo htmlspecialchars(strip_tags(stripslashes($comment->comment_author))); echo 'Anonymous';
} } else {
else { echo htmlspecialchars(apply_filters('comment_author', $comment->comment_author));
echo "Anonymous"; }
}
} }
function comment_text_rss() { function comment_text_rss() {
global $comment; global $comment;
$comment_text = stripslashes($comment->comment_content); $comment_text = str_replace('<trackback />', '', $comment->comment_content);
$comment_text = str_replace('<trackback />', '', $comment_text); $comment_text = str_replace('<pingback />', '', $comment_text);
$comment_text = str_replace('<pingback />', '', $comment_text); $comment_text = apply_filters('comment_text', $comment_text);
$comment_text = convert_chars($comment_text); $comment_text = strip_tags($comment_text);
$comment_text = convert_bbcode($comment_text); $comment_text = htmlspecialchars($comment_text);
$comment_text = convert_gmcode($comment_text); echo $comment_text;
$comment_text = convert_smilies($comment_text);
$comment_text = apply_filters('comment_text', $comment_text);
$comment_text = strip_tags($comment_text);
$comment_text = htmlspecialchars($comment_text);
echo $comment_text;
} }
function comment_link_rss() { function comment_link_rss() {
global $comment; global $comment;
echo get_permalink($comment->comment_post_ID).'#comments'; echo get_permalink($comment->comment_post_ID).'#comments';
} }
function permalink_comments_rss() { function permalink_comments_rss() {
global $comment; global $comment;
echo get_permalink($comment->comment_post_ID); echo get_permalink($comment->comment_post_ID);
} }
function trackback_url($display = true) { function trackback_url($display = true) {
global $siteurl, $id; global $id;
$tb_url = $siteurl.'/wp-trackback.php/'.$id; $tb_url = get_settings('siteurl') . '/wp-trackback.php/' . $id;
if ('' != get_settings('permalink_structure')) { if ('' != get_settings('permalink_structure')) {
$tb_url = trailingslashit(get_permalink()) . 'trackback/'; $tb_url = trailingslashit(get_permalink()) . 'trackback/';
} }
if ($display) { if ($display) {
echo $tb_url; echo $tb_url;
} else { } else {
return $tb_url; return $tb_url;
} }
} }
function trackback_rdf($timezone = 0) { function trackback_rdf($timezone = 0) {
global $siteurl, $id, $HTTP_SERVER_VARS; global $siteurl, $id, $HTTP_SERVER_VARS;
if (!stristr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'W3C_Validator')) { 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 '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
echo ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n"; xmlns:dc="http://purl.org/dc/elements/1.1/"
echo ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n"; xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
echo '<rdf:Description'."\n"; <rdf:Description rdf:about="';
echo ' rdf:about="'; permalink_single();
permalink_single(); echo '"'."\n";
echo '"'."\n"; echo ' dc:identifier="';
echo ' dc:identifier="'; permalink_single();
permalink_single(); echo '"'."\n";
echo '"'."\n"; echo ' dc:title="'.str_replace('--', '&#x2d;&#x2d;', addslashes(strip_tags(get_the_title()))).'"'."\n";
echo ' dc:title="'.str_replace('--', '&#x2d;&#x2d;', addslashes(strip_tags(get_the_title()))).'"'."\n"; echo ' trackback:ping="'.trackback_url(0).'"'." />\n";
echo ' trackback:ping="'.trackback_url(0).'"'." />\n"; echo '</rdf:RDF>';
echo '</rdf:RDF>'; }
}
} }
?> ?>

View File

@ -204,7 +204,7 @@ function get_archives_link($url, $text, $format = "html", $before = "", $after =
} }
function get_archives($type='', $limit='', $format='html', $before = "", $after = "", $show_post_count = false) { function get_archives($type='', $limit='', $format='html', $before = "", $after = "", $show_post_count = false) {
global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename; global $tableposts, $time_difference, $siteurl, $blogfilename;
global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week; global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week;
if ('' == $type) { if ('' == $type) {
@ -234,9 +234,9 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after
$archive_week_end_date_format = 'Y/m/d'; $archive_week_end_date_format = 'Y/m/d';
if (!$archive_date_format_over_ride) { if (!$archive_date_format_over_ride) {
$archive_day_date_format = $dateformat; $archive_day_date_format = get_settings('date_format');
$archive_week_start_date_format = $dateformat; $archive_week_start_date_format = get_settings('date_format');
$archive_week_end_date_format = $dateformat; $archive_week_end_date_format = get_settings('date_format');
} }
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
@ -502,12 +502,12 @@ function the_date_xml() {
} }
function the_date($d='', $before='', $after='', $echo = true) { function the_date($d='', $before='', $after='', $echo = true) {
global $id, $post, $day, $previousday, $dateformat, $newday; global $id, $post, $day, $previousday, $newday;
$the_date = ''; $the_date = '';
if ($day != $previousday) { if ($day != $previousday) {
$the_date .= $before; $the_date .= $before;
if ($d=='') { if ($d=='') {
$the_date .= mysql2date($dateformat, $post->post_date); $the_date .= mysql2date(get_settings('date_format'), $post->post_date);
} else { } else {
$the_date .= mysql2date($d, $post->post_date); $the_date .= mysql2date($d, $post->post_date);
} }
@ -523,9 +523,9 @@ function the_date($d='', $before='', $after='', $echo = true) {
} }
function the_time($d='', $echo = true) { function the_time($d='', $echo = true) {
global $id, $post, $timeformat; global $id, $post;
if ($d=='') { if ($d=='') {
$the_time = mysql2date($timeformat, $post->post_date); $the_time = mysql2date(get_settings('time_format'), $post->post_date);
} else { } else {
$the_time = mysql2date($d, $post->post_date); $the_time = mysql2date($d, $post->post_date);
} }

View File

@ -1,5 +1,19 @@
<?php <?php
// Default filters
add_filter('the_title', 'convert_chars');
add_filter('the_title', 'trim');
add_filter('the_title_rss', 'strip_tags');
add_filter('the_content', 'convert_smilies');
add_filter('the_content', 'convert_chars');
add_filter('the_content', 'wpautop');
add_filter('the_excerpt', 'convert_smilies');
add_filter('the_excerpt', 'autop');
add_filter('the_excerpt', 'convert_chars');
add_filter('the_excerpt', 'wpautop');
function get_the_password_form() { function get_the_password_form() {
$output = "<form action='" . get_settings('siteurl') . "/wp-pass.php' method='post'> $output = "<form action='" . get_settings('siteurl') . "/wp-pass.php' method='post'>
@ -7,115 +21,87 @@ function get_the_password_form() {
<p><label>Password: <input name='post_password' type='text' size='20' /></label> <input type='submit' name='Submit' value='Submit' /></p> <p><label>Password: <input name='post_password' type='text' size='20' /></label> <input type='submit' name='Submit' value='Submit' /></p>
</form> </form>
"; ";
return $output; return $output;
} }
function the_ID() { function the_ID() {
global $id; global $id;
echo $id; echo $id;
} }
function the_title($before = '', $after = '', $echo = true) { function the_title($before = '', $after = '', $echo = true) {
$title = get_the_title(); $title = get_the_title();
$title = convert_smilies($title); if (!empty($title)) {
if (!empty($title)) { $title = apply_filters('the_title', $before . $title . $after);
$title = convert_chars($before.$title.$after); if ($echo)
$title = apply_filters('the_title', $title); echo $title;
if ($echo) else
echo $title; return $title;
else }
return $title;
}
}
function the_title_rss() {
$title = get_the_title();
$title = strip_tags($title);
if (trim($title)) {
echo convert_chars($title, 'unicode');
}
}
function the_title_unicode($before='',$after='') {
$title = get_the_title();
$title = convert_bbcode($title);
$title = convert_gmcode($title);
if ($title) {
$title = convert_chars($before.$title.$after);
$title = apply_filters('the_title_unicode', $title);
echo $title;
}
}
function get_the_title() {
global $post;
$output = stripslashes($post->post_title);
if (!empty($post->post_password)) { // if there's a password
$output = 'Protected: ' . $output;
}
return $output;
} }
function the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') { function the_title_rss() {
$title = get_the_title();
$title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title):
echo $title;
}
function get_the_title() {
global $post;
$output = stripslashes($post->post_title);
if (!empty($post->post_password)) { // if there's a password
$output = 'Protected: ' . $output;
}
return $output;
}
function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file); $content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = convert_bbcode($content);
$content = convert_gmcode($content);
$content = convert_smilies($content);
$content = convert_chars($content, 'html');
$content = apply_filters('the_content', $content); $content = apply_filters('the_content', $content);
echo $content; echo $content;
} }
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
$content = get_the_content($more_link_text, $stripteaser, $more_file); $content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = convert_bbcode($content); $content = apply_filters('the_content', $content);
$content = convert_gmcode($content); if ($cut && !$encode_html) {
$content = convert_chars($content, 'unicode'); $encode_html = 2;
if ($cut && !$encode_html) { }
$encode_html = 2; if ($encode_html == 1) {
} $content = htmlspecialchars($content);
if ($encode_html == 1) { $cut = 0;
$content = htmlspecialchars($content); } elseif ($encode_html == 0) {
$cut = 0; $content = make_url_footnote($content);
} elseif ($encode_html == 0) { } elseif ($encode_html == 2) {
$content = make_url_footnote($content); $content = strip_tags($content);
} elseif ($encode_html == 2) { }
$content = strip_tags($content); if ($cut) {
} $blah = explode(' ', $content);
if ($cut) { if (count($blah) > $cut) {
$blah = explode(' ', $content); $k = $cut;
if (count($blah) > $cut) { $use_dotdotdot = 1;
$k = $cut; } else {
$use_dotdotdot = 1; $k = count($blah);
} else { $use_dotdotdot = 0;
$k = count($blah); }
$use_dotdotdot = 0; for ($i=0; $i<$k; $i++) {
} $excerpt .= $blah[$i].' ';
for ($i=0; $i<$k; $i++) { }
$excerpt .= $blah[$i].' '; $excerpt .= ($use_dotdotdot) ? '...' : '';
} $content = $excerpt;
$excerpt .= ($use_dotdotdot) ? '...' : ''; }
$content = $excerpt; echo $content;
}
echo $content;
} }
function the_content_unicode($more_link_text='(more...)', $stripteaser=0, $more_file='') { function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = convert_bbcode($content);
$content = convert_gmcode($content);
$content = convert_smilies($content);
$content = convert_chars($content, 'unicode');
$content = apply_filters('the_content_unicode', $content);
echo $content;
}
function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') {
global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages; global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages;
global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; global $HTTP_SERVER_VARS, $preview, $cookiehash;
global $querystring_start, $querystring_equal, $querystring_separator;
global $pagenow; global $pagenow;
$output = ''; $output = '';
if (!empty($post->post_password)) { // if there's a password if (!empty($post->post_password)) { // if there's a password
if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie if ($_COOKIE['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie
$output = get_the_password_form(); $output = get_the_password_form();
return $output; return $output;
} }
@ -148,20 +134,13 @@ function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file
} }
function the_excerpt() { function the_excerpt() {
$excerpt = get_the_excerpt(); echo apply_filters('the_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) { function the_excerpt_rss($cut = 0, $encode_html = 0) {
$output = get_the_excerpt(true); $output = get_the_excerpt(true);
$output = convert_bbcode($output);
$output = convert_gmcode($output); $output = convert_chars($output);
$output = convert_chars($output, 'unicode');
if ($cut && !$encode_html) { if ($cut && !$encode_html) {
$encode_html = 2; $encode_html = 2;
} }
@ -192,23 +171,13 @@ function the_excerpt_rss($cut = 0, $encode_html = 0) {
echo $output; echo $output;
} }
function the_excerpt_unicode() {
$excerpt = get_the_excerpt();
$excerpt = convert_bbcode($excerpt);
$excerpt = convert_gmcode($excerpt);
$excerpt = convert_smilies($excerpt);
$excerpt = convert_chars($excerpt, 'unicode');
$excerpt = apply_filters('the_excerpt_unicode', $excerpt);
echo $excerpt;
}
function get_the_excerpt($fakeit = true) { function get_the_excerpt($fakeit = true) {
global $id, $post; global $id, $post;
global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash; global $HTTP_SERVER_VARS, $preview, $cookiehash;
$output = ''; $output = '';
$output = stripslashes($post->post_excerpt); $output = stripslashes($post->post_excerpt);
if (!empty($post->post_password)) { // if there's a password if (!empty($post->post_password)) { // if there's a password
if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie if ($_COOKIE['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie
$output = "There is no excerpt because this is a protected post."; $output = "There is no excerpt because this is a protected post.";
return $output; return $output;
} }

View File

@ -268,9 +268,6 @@ foreach($wpsmiliestrans as $smiley => $img) {
// Some default filters // Some default filters
add_filter('all', 'wptexturize'); add_filter('all', 'wptexturize');
add_filter('the_content', 'wpautop');
add_filter('comment_text', 'wpautop');
add_filter('the_excerpt', 'wpautop');
// Uncomment the following for Textile support // Uncomment the following for Textile support
// include_once('textile.php'); // include_once('textile.php');

View File

@ -49,10 +49,6 @@ require_once (ABSPATH . WPINC . '/kses.php');
// accessing a single global $all_settings var // accessing a single global $all_settings var
if (!strstr($_SERVER['REQUEST_URI'], 'install.php') && !strstr($_SERVER['REQUEST_URI'], 'wp-admin/import')) { if (!strstr($_SERVER['REQUEST_URI'], 'install.php') && !strstr($_SERVER['REQUEST_URI'], 'wp-admin/import')) {
$siteurl = get_settings('siteurl'); $siteurl = get_settings('siteurl');
// "When trying to design a foolproof system,
// never underestimate the ingenuity of the fools :)"
$siteurl = preg_replace('|/+$|', '', $siteurl);
$blogfilename = get_settings('blogfilename'); $blogfilename = get_settings('blogfilename');
$blogname = get_settings('blogname'); $blogname = get_settings('blogname');
$blogdescription = get_settings('blogdescription'); $blogdescription = get_settings('blogdescription');