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 = apply_filters('the_content_rss', $content);
	if ( $cut && !$encode_html )
		$encode_html = 2;
	if ( 1== $encode_html ) {
		$content = wp_specialchars($content);
		$cut = 0;
	} elseif ( 0 == $encode_html ) {
		$content = make_url_footnote($content);
	} elseif ( 2 == $encode_html ) {
		$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;
	}
	$content = str_replace(']]>', ']]&gt;', $content);
	echo $content;
}
Exemple #2
0
/**
 * Display the post content for the feed.
 *
 * For encoding the html or the $encode_html parameter, there are three possible
 * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
 * encode special characters and automatically display all of the content. The
 * value of '2' will strip all HTML tags from the content.
 *
 * Also note that you cannot set the amount of words and not set the html
 * encoding. If that is the case, then the html encoding will default to 2,
 * which will strip all HTML tags.
 *
 * To restrict the amount of words of the content, you can use the cut
 * parameter. If the content is less than the amount, then there won't be any
 * dots added to the end. If there is content left over, then dots will be added
 * and the rest of the content will be removed.
 *
 * @package WordPress
 * @subpackage Feed
 * @since 0.71
 * @uses apply_filters() Calls 'the_content_rss' on the content before processing.
 * @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
 *		parameters.
 *
 * @deprecated 2.9.0
 * @deprecated Use the_content_feed()
 * @see the_content_feed()
 *
 * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
 * @param int|bool $stripteaser Optional. Default is 0.
 * @param string $more_file Optional.
 * @param int $cut Optional. Amount of words to keep for the content.
 * @param int $encode_html Optional. How to encode the content.
 */
function the_content_rss($more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $cut = 0, $encode_html = 0)
{
    _deprecated_function(__FUNCTION__, '2.9', 'the_content_feed');
    $content = get_the_content($more_link_text, $stripteaser, $more_file);
    $content = apply_filters('the_content_rss', $content);
    if ($cut && !$encode_html) {
        $encode_html = 2;
    }
    if (1 == $encode_html) {
        $content = esc_html($content);
        $cut = 0;
    } elseif (0 == $encode_html) {
        $content = make_url_footnote($content);
    } elseif (2 == $encode_html) {
        $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;
        }
        /** @todo Check performance, might be faster to use array slice instead. */
        for ($i = 0; $i < $k; $i++) {
            $excerpt .= $blah[$i] . ' ';
        }
        $excerpt .= $use_dotdotdot ? '...' : '';
        $content = $excerpt;
    }
    $content = str_replace(']]>', ']]&gt;', $content);
    echo $content;
}
function the_excerpt_rss($cut = 0, $encode_html = 0)
{
    global $blog_charset;
    $output = get_the_excerpt(true);
    $output = convert_bbcode($output);
    $output = convert_gmcode($output);
    $output = convert_chars($output, 'unicode');
    if ($cut && !$encode_html) {
        $encode_html = 2;
    }
    if ($encode_html == 1) {
        $output = htmlspecialchars($output);
        $cut = 0;
    } elseif ($encode_html == 0) {
        $output = make_url_footnote($output);
    } elseif ($encode_html == 2) {
        $output = htmlspecialchars(strip_tags($output));
    }
    if ($cut) {
        $excerpt = '';
        $blah = explode(' ', $output);
        if (count($blah) > $cut) {
            $k = $cut;
            $use_dotdotdot = 1;
        } else {
            $k = count($blah);
            $use_dotdotdot = 0;
        }
        for ($i = 0; $i < $k; $i++) {
            $excerpt .= $blah[$i] . ' ';
        }
        $excerpt .= $use_dotdotdot ? '...' : '';
        $output = $excerpt;
    }
    $rss_charset = wp_get_rss_charset();
    if ($blog_charset != $rss_charset) {
        echo mb_convert_encoding($output, $rss_charset, $blog_charset);
    } else {
        echo $output;
    }
}
function the_excerpt_rss($cut = 0, $encode_html = 0)
{
    $output = apply_filters('the_excerpt', get_the_excerpt(true));
    if ($cut && !$encode_html) {
        $encode_html = 2;
    }
    if ($encode_html == 1) {
        $output = htmlspecialchars($output);
        $cut = 0;
    } elseif ($encode_html == 0) {
        $output = make_url_footnote($output);
    } elseif ($encode_html == 2) {
        $output = htmlspecialchars(strip_tags($output));
    }
    if ($cut) {
        $excerpt = '';
        $blah = explode(' ', $output);
        if (count($blah) > $cut) {
            $k = $cut;
            $use_dotdotdot = 1;
        } else {
            $k = count($blah);
            $use_dotdotdot = 0;
        }
        for ($i = 0; $i < $k; $i++) {
            $excerpt .= $blah[$i] . ' ';
        }
        $excerpt .= $use_dotdotdot ? '...' : '';
        $output = $excerpt;
    }
    $output = str_replace(']]>', ']]&gt;', $output);
    echo wp_convert_rss_charset(apply_filters('the_excerpt_rss', $output));
}
function the_content_rss($more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $cut = 0, $encode_html = 0)
{
    $content = get_the_content($more_link_text, $stripteaser, $more_file);
    $content = convert_bbcode($content);
    $content = convert_gmcode($content);
    $content = convert_chars($content, 'unicode');
    if ($cut && !$encode_html) {
        $encode_html = 2;
    }
    if ($encode_html == 1) {
        $content = htmlspecialchars($content);
        $cut = 0;
    } elseif ($encode_html == 0) {
        $content = make_url_footnote($content);
    } elseif ($encode_html == 2) {
        $content = strip_tags($content);
    }
    if ($cut) {
        $blah = explode(' ', $content);
        if (count($blah) > $cut) {
            $k = $cut;
            $use_dotdotdot = 1;
        } else {
            $k = count($blah);
            $use_dotdotdot = 0;
        }
        for ($i = 0; $i < $k; $i++) {
            $excerpt .= $blah[$i] . ' ';
        }
        $excerpt .= $use_dotdotdot ? '...' : '';
        $content = $excerpt;
    }
    echo $content;
}
Exemple #6
0
function rss_update($blog_ID, $num_posts = "", $file = "./b2rss.xml")
{
    global $use_rss, $b2_version, $querystring_start, $querystring_equal, $querystring_separator;
    global $admin_email, $blogname, $siteurl, $blogfilename, $blogdescription, $posts_per_rss, $rss_language;
    global $tableposts, $postdata, $row;
    if ($rss_language == '') {
        $rss_language = 'en';
    }
    if ($use_rss) {
        $num_posts = $num_posts == "" ? $posts_per_rss : 5;
        $date_now = gmdate("D, d M Y H:i:s") . " GMT";
        # let's build the rss file
        $rss = '';
        $rss .= '<?xml version="1.0"?' . ">\n";
        $rss .= "<!-- generator=\"b2/{$b2_version}\" -->\n";
        $rss .= "<rss version=\"0.92\">\n";
        $rss .= "\t<channel>\n";
        $rss .= "\t\t<title>" . convert_chars(strip_tags(get_bloginfo("name")), "unicode") . "</title>\n";
        $rss .= "\t\t<link>" . convert_chars(strip_tags(get_bloginfo("url")), "unicode") . "</link>\n";
        $rss .= "\t\t<description>" . convert_chars(strip_tags(get_bloginfo("description")), "unicode") . "</description>\n";
        $rss .= "\t\t<lastBuildDate>{$date_now}</lastBuildDate>\n";
        $rss .= "\t\t<docs>http://backend.userland.com/rss092</docs>\n";
        $rss .= "\t\t<managingEditor>{$admin_email}</managingEditor>\n";
        $rss .= "\t\t<webMaster>{$admin_email}</webMaster>\n";
        $rss .= "\t\t<language>{$rss_language}</language>\n";
        $now = date('Y-m-d H:i:s', time() + $time_difference * 3600);
        $sql = "SELECT * FROM {$tableposts} WHERE post_date <= '{$now}' AND post_category > 0 ORDER BY post_date DESC LIMIT {$num_posts}";
        $result = mysql_query($sql) or die("Your SQL query: <br />{$sql}<br /><br />MySQL said:<br />" . mysql_error());
        while ($row = mysql_fetch_object($result)) {
            $id = $row->ID;
            $postdata = get_postdata2($id);
            $rss .= "\t\t<item>\n";
            $rss .= "\t\t\t<title>" . convert_chars(strip_tags(get_the_title()), "unicode") . "</title>\n";
            //		we could add some specific RSS here, but not yet. uncomment if you wish, it's functionnal
            //			$rss .= "\t\t\t<category>".convert_chars(strip_tags(get_the_category()),"unicode")."</category>\n";
            $content = stripslashes($row->post_content);
            $content = explode("<!--more-->", $content);
            $content = $content[0];
            $rss .= "\t\t\t<description>" . convert_chars(make_url_footnote($content), "unicode") . "</description>\n";
            $rss .= "\t\t\t<link>" . htmlentities("{$siteurl}/{$blogfilename}" . $querystring_start . 'p' . $querystring_equal . $row->ID . $querystring_separator . 'c' . $querystring_equal . '1') . "</link>\n";
            $rss .= "\t\t</item>\n";
        }
        $rss .= "\t</channel>\n";
        $rss .= "</rss>";
        $f = @fopen("{$file}", "w+");
        if ($f) {
            @fwrite($f, $rss);
            @fclose($f);
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Exemple #7
0
function sideblog_excerpt($content, $cut = 0, $encode_html = 0)
{
    if ($cut && !$encode_html) {
        $encode_html = 2;
    }
    if ($encode_html == 1) {
        $content = wp_specialchars($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;
    }
    $content = str_replace(']]>', ']]&gt;', $content);
    return $content;
}