Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • (Apparently the “allowed markup” isn’t working when you edit a post. <a href=”https://www.google.com/reader/public/atom/user/17079902422104787188/state/com.google/broadcast
    “>My google feed.)

    WordPress 2.5 – Full of win!

    Funny, I just spent about six hours hacking my way around this problem.

    The problem is mainly with MagpieRSS, which assumes you’d like to append all elements of a certain type to one another instead of maintaining them as separate elements — and to add insult to injury, appends all elements in subelements to one another. WordPress uses MagpieRSS to parse RSS feeds, even though there’s a dozen or so more modern libraries that they could’ve used that actually, you know, work.

    Hey, I’ve got a brilliant idea, let’s code like it’s 2000 and PHP4 just came out! No one uses this ‘multiple layer’ feature of XML! Whoever made the decision to use this library at automattic should be taken out back of the building and shot.

    Fantasies of revenge aside, here’s a description of the problem.

    Given a sample ATOM feed:

    <entry>
      <title>Foo, the foo of foos!</title>
      <source>
        <title>Foobar</title>
      </source>
     </entry>

    Note: <a href=”https://www.google.com/reader/public/atom/user/17079902422104787188/state/com.google/broadcast
    “>My actual google feed

    … Magpie collapses the title field in Atom based on it’s configuration, so you’ll end up with your item title being ‘Foo, the foo of foos!Foobar’.

    That’s easy to fix. Go into wp-includes/rss.php, and change the CONTENT_CONSTRUCTS array… remove title from the array. You’ll end up with two different titles — $item[‘title’] and $item[‘source_title’]. Gee, that’s intelligent.

    The links are a little harder to fix, because it does the same thing but through a different stupid hack. I honestly got tired of messing with a stupid hack and just made my own stupid hack to get around it. In rss.php, you’ll find these lines:

    elseif ($this->feed_type == ATOM and $el == 'link' )
            {
                if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
                {
                    $link_el = 'link';
                }
                else {
                    $link_el = 'link_' . $attrs['rel'];
                }
    
                $this->append($link_el, $attrs['href']);
            }

    That’s what we call a bad idea, mkay, kids? Don’t assume there’s only one ‘link’ element.

    The worse idea that I used to get around the bad idea is to add this to widgets.php inside the wp_widget_rss_output function (note the plusses):

    foreach ($rss->items as $item ) {
                 while ( strstr($item['link'], 'http') != $item['link'] ) {
                     $item['link'] = substr($item['link'], 1);
                 }
    +            if($secondhttp = strpos($item['link'],'http',5)) {
    +                $item['link'] = substr($item['link'],0,$secondhttp);
    +            }
                 $link = clean_url(strip_tags($item['link']));

    … mine now works. Yes, I realize that this hacks up the base code, but I wasn’t going to spend a full day with the retarded plugin API making my own.

    I’d post cleaner code, but I’m too pissed off at the egregious waste of the last four hours or so. Gonna go rub the puppy’s tummy.

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