Lazza (@lazza)

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • @lazza

    Participant

    I have the same problem right now with bbPress 1.0.3. If you’re interested, you can put this piece of code before the “if ( $relevant ) ” line:

    <?php
    foreach ( $relevant as $elementKey => $bb_post ) {
    if(!($bb_post->post_text)) unset($relevant[$elementKey]);
    }
    ?>

    This deletes the relevant posts which are already in the recent posts, and so are broken.

    In reply to: All RSS Feeds Broken?

    @lazza

    Participant

    I think I’ve created a quite strong code for the RSS. It allows plugins to apply their filters (example: smilies!!!). It fixes problems with double apersand encoding and ” ” not working well with UTF-8. It also fixes the date of items which is not valid if you use localization, even if the options array sets “false” on “localize”.

    Feel free to try the code for yourself, it works with stock bbPress 1.0.2. You JUST need to put this content in your rss2.php (check the theme folder).

    <?php
    header( 'Content-Type: text/xml; charset=UTF-8' );
    echo '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "n";
    bb_generator( 'comment' );

    function datefix($buffer) {
    /*
    * fix della data in modo da tenerla in inglese, rispettando
    * le specifiche dei feed RSS
    */
    return gmdate('D, d M Y H:i:s +0000', $buffer);
    }

    function callback($buffer)
    {
    /*
    * sistema il codice rimuovendo la doppia codifica di "&" e
    * rimuove il carattere "&nbsp;" che crea problemi con UTF-8
    * in questo modo ho il testo del post dopo che i plugin (tipo
    * le faccine) hanno applicato le loro modifiche html e ritorno
    * il codice html senza entities ma in forma pura
    */

    $single = str_replace("&", "&", $buffer);
    $spaced = str_replace("&nbsp;", " ", $single);
    return html_entity_decode($spaced);
    }

    ?>
    <rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
    <title><?php echo $title; ?></title>
    <link><?php echo $link; ?></link>
    <description><![CDATA[<?php echo $description; ?>]]></description>
    <language><?php esc_html( bb_option('language') ); ?></language>
    <pubDate><?php echo gmdate('D, d M Y H:i:s +0000'); ?></pubDate>
    <?php bb_generator( 'rss2' ); ?>
    <textInput>
    <title><![CDATA[<?php _e('Search'); ?>]]></title>
    <description><![CDATA[<?php _e('Search all topics from these forums.'); ?>]]></description>
    <name>q</name>
    <link><?php bb_uri('search.php'); ?></link>
    </textInput>
    <atom:link href="<?php echo $link_self; ?>" rel="self" type="application/rss+xml" />

    <?php foreach ($posts as $bb_post) : ?>
    <item>
    <title><?php post_author(); ?> <?php _e('on')?> "<?php topic_title( $bb_post->topic_id ); ?>"</title>
    <link><?php post_link(); ?></link>
    <pubDate><?php

    ob_start("datefix");
    bb_post_time('U');
    ob_end_flush();

    ?></pubDate>
    <dc:creator><?php post_author(); ?></dc:creator>
    <guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid>
    <description><![CDATA[<?php

    ob_start("callback");
    post_text();
    ob_end_flush();

    ?>]]></description>
    </item>
    <?php endforeach; ?>

    </channel>
    </rss>

    Sorry for comments in italian.

    BTW @ yoyopop, I don’t remember in which topic, but I read on this forum that the problem is related to some plugins having extra spaces in their code before the opening “<?php” tag. Check it…

Viewing 2 replies - 1 through 2 (of 2 total)