Filter Hooks for Enclosures

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Filter Hooks for Enclosures

Dave Grijalva
Are there any filter hooks that I can use for the extra fields data?
Specifically, I want to be able to do some string replacements for an RSS
Enclosure (podcast).  Any ideas?

-dave
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Jamie Talbot
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Dave Grijalva wrote:
> Are there any filter hooks that I can use for the extra fields data?
> Specifically, I want to be able to do some string replacements for an RSS
> Enclosure (podcast).  Any ideas?
>

I added a ticket to Trac requesting the same thing for different elements of feeds this morning - at
the moment these hooks are actions which mean you can't alter anything that's already been added.
Turning them into filters would allow you to do replacements.  Plugins that use these hooks would
have to be modified to return the text they are presented with, however.

The ticket's just for the head sections of the feeds, but you could add a note on the need for other
areas of the feeds too.  Feeds were heavily discussed here recently, though I'm not sure that any
consensus was formed at the end of it.  Are we going to be updating the feeds structure and API
significantly in 2.1?  Is it worth the effort to work up a patch that buffers feed text and then
passes it to a filter, or this likely to all change?

http://trac.wordpress.org/ticket/2438

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD8IMorovxfShShFARAsz4AJ9ja6nlJJa5BAw+LV4oARCCUZS8AwCfVFAV
CESmGfRsNkCHEohXXEInDvg=
=od18
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Owen Winkler
Jamie Talbot wrote:
> The ticket's just for the head sections of the feeds, but you could add a note on the need for other
> areas of the feeds too.  Feeds were heavily discussed here recently, though I'm not sure that any
> consensus was formed at the end of it.  Are we going to be updating the feeds structure and API
> significantly in 2.1?  Is it worth the effort to work up a patch that buffers feed text and then
> passes it to a filter, or this likely to all change?

Here's an off-the-wall suggestion...

What if we built feeds as PHP objects, fed them through a filter, then
converted the object to XML?

There are some extant implementations of Object<->XML in PHP, so it
might not be too difficult a conversion.  Manipulating the feed XML via
DOM in a plugin would be swell.

Before I continue blathering about this, how much does this idea suck?

Owen

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Jamie Talbot
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Owen Winkler wrote:

> Here's an off-the-wall suggestion...
>
> What if we built feeds as PHP objects, fed them through a filter, then
> converted the object to XML?
>
> There are some extant implementations of Object<->XML in PHP, so it
> might not be too difficult a conversion.  Manipulating the feed XML via
> DOM in a plugin would be swell.
>
> Before I continue blathering about this, how much does this idea suck?
>
> Owen

I definitely like the feeds as objects idea.  A base feed class WPFeed with vars to hold all
available information that could be subtyped for different feed flavours, WPAtom, WPRSS each with
their own methods of using that data would be nice.  It would also be nicely future proof when the
next latest and greatest feed format comes along as it would only require a new class with its own
'print' method.

If converting to XML was a trivial task already implemented, that might be cool too.

Is there mileage in this?

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD8JQTrovxfShShFARApeQAJ48ZV2CKnAOMP18Y2o6EP8t/u+dCwCfdqcx
OBWgiV1obb0Tg5IeiX9XgWM=
=dNYv
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

David Chait
In reply to this post by Owen Winkler
http://comox.textdrive.com/pipermail/wp-hackers/2006-January/004111.html
http://comox.textdrive.com/pipermail/wp-hackers/2006-January/004101.html

There have been multiple calls here (in two threads) to switch over to
something like FeedCreator for maintaining the various feed formats.  Alex
presented FeedCreator originally, I gave it a +1, and in a separate thread
Mark and Kimmo basically both gave it approval as well (Kimmo uses it
already...).  FC looks like it uses the create-in-php,
output-in-whatever-format approach.

That should make for easier coding, less maintenance work per-feed, faster
enhancements.  We might have to 'adopt' the FC project to get it where we
want, but no need to start from scratch.

-d

----- Original Message -----
From: "Owen Winkler" <[hidden email]>
To: <[hidden email]>
Sent: Monday, February 13, 2006 9:01 AM
Subject: Re: [wp-hackers] Filter Hooks for Enclosures


| Jamie Talbot wrote:
| > The ticket's just for the head sections of the feeds, but you could add
a note on the need for other
| > areas of the feeds too.  Feeds were heavily discussed here recently,
though I'm not sure that any
| > consensus was formed at the end of it.  Are we going to be updating the
feeds structure and API
| > significantly in 2.1?  Is it worth the effort to work up a patch that
buffers feed text and then
| > passes it to a filter, or this likely to all change?
|
| Here's an off-the-wall suggestion...
|
| What if we built feeds as PHP objects, fed them through a filter, then
| converted the object to XML?
|
| There are some extant implementations of Object<->XML in PHP, so it
| might not be too difficult a conversion.  Manipulating the feed XML via
| DOM in a plugin would be swell.
|
| Before I continue blathering about this, how much does this idea suck?
|
| Owen

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Evan Broder
In reply to this post by Owen Winkler


Owen Winkler wrote:

> Here's an off-the-wall suggestion...
>
> What if we built feeds as PHP objects, fed them through a filter, then
> converted the object to XML?
>
> There are some extant implementations of Object<->XML in PHP, so it
> might not be too difficult a conversion.  Manipulating the feed XML
> via DOM in a plugin would be swell.
>
> Before I continue blathering about this, how much does this idea suck?
>
> Owen
+1, Owen. We'd just have to be careful to make sure it would work with
most PHP installations, i.e., not use the domxml extension in PHP,
because a) it's not installed by default and b) it's not included in PHP5.

Maybe if we adapted something in PEAR?

Also, Owen, this deals with all of the issues you talked about on your blog.

Good idea, IMHO

- Evan
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

RE: Filter Hooks for Enclosures

Denis de Bernardy
In reply to this post by Owen Winkler
> There are some extant implementations of Object<->XML in PHP, so it
> might not be too difficult a conversion.  Manipulating the
> feed XML via
> DOM in a plugin would be swell.
>
> Before I continue blathering about this, how much does this idea suck?

DOM/XML related stuff is far from being installed properly on most hosts,
and does not work the same in php4 and php5. I'd use a straightforward array
instead.

D.

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

David House
In reply to this post by David Chait
On 13/02/06, David Chait <[hidden email]> wrote:
> There have been multiple calls here (in two threads) to switch over to
> something like FeedCreator for maintaining the various feed formats.  Alex
> presented FeedCreator originally, I gave it a +1, and in a separate thread
> Mark and Kimmo basically both gave it approval as well (Kimmo uses it
> already...).  FC looks like it uses the create-in-php,
> output-in-whatever-format approach.

It's also a _lot_ of code (several hundred lines worth) that would
replace the mostly functional ~70 lines of code for feeds as present.

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Owen Winkler
In reply to this post by Denis de Bernardy
Denis de Bernardy wrote:

>> There are some extant implementations of Object<->XML in PHP, so it
>> might not be too difficult a conversion.  Manipulating the
>> feed XML via
>> DOM in a plugin would be swell.
>>
>> Before I continue blathering about this, how much does this idea suck?
>
> DOM/XML related stuff is far from being installed properly on most hosts,
> and does not work the same in php4 and php5. I'd use a straightforward array
> instead.

That's really more what I was suggesting.

There must be some class that would let us do something like this:

ob_start();
// Existing feed stuff
$xml = ob_get_clean();
$feed = new WPXmlDoc($xml);
$feed = apply_filters('feed_xml', $feed);
$feed->output();

...

add_filter('feed_xml', 'my_feed_xml');
function my_feed_xml($feed)
{
        $feed->data['rss'][0]['customtag'][0] = 'test';
        return $feed;
}

Or something.

Owen

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Jeff Minard
Owen Winkler wrote:
> $xml = ob_get_clean();
> $feed = new WPXmlDoc($xml);

There's a nightmare of a function ;)
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Owen Winkler
Jeff Minard wrote:
> Owen Winkler wrote:
>> $xml = ob_get_clean();
>> $feed = new WPXmlDoc($xml);
>
> There's a nightmare of a function ;)

I was hoping nobody would notice that.  :)

Actually, that's where the libraries I was suggesting come into play.
There are a couple that will parse XML down into an array or a set of
manageable PHP objects.  These can then be modified in code (rather than
manipulating strings and inserting doaction()s between every code line)
and output with a single $feed->output();

That's the advantage.

Otherwise, how can we satisfy every need to modify these feeds, since
they're not in editable space (wp-content)?

Owen

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Robert Deaton
In reply to this post by Evan Broder
On 2/13/06, Evan Broder <[hidden email]> wrote:
> Maybe if we adapted something in PEAR?

I think we should all pretend that you did not just say that.

--
--Robert Deaton
http://somethingunpredictable.com

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Rob-67
In reply to this post by Owen Winkler
Owen Winkler wrote:

> Jeff Minard wrote:
>> Owen Winkler wrote:
>>> $xml = ob_get_clean();
>>> $feed = new WPXmlDoc($xml);
>>
>> There's a nightmare of a function ;)
>
> I was hoping nobody would notice that.  :)
>
> Actually, that's where the libraries I was suggesting come into play.
> There are a couple that will parse XML down into an array or a set of
> manageable PHP objects.  These can then be modified in code (rather
> than manipulating strings and inserting doaction()s between every code
> line) and output with a single $feed->output();
>
> That's the advantage.
>
> Otherwise, how can we satisfy every need to modify these feeds, since
> they're not in editable space (wp-content)?
>
> Owen
>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
What are the best libraries for this, though? SimpleXML is fantastic but
PHP5 only, and the PEAR XML_(Un)Serializer class has been (in my
experience, anyway) pretty bad.

--
Rob Miller
http://robm.me.uk/ | http://kantian.co.uk/

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

David Chait
In reply to this post by David House
Didn't say it wasn't a sizeable library.  But we're talking about going from
a fixed file per feed type to pretty much any feed type desired (well,
that's been coded) via one translation call.  And I don't see how FC is
going to be that significantly heavier-weight than whatever brand-new stuff
Owen is dreaming about -- and FC is already established, used, tested.,
etc... ;)

Also, with WP-Cache in place, feeds would only be generated every N hours
anyway, so I'm not (personally) concerned about overhead (we are talking
about a bigger future version here...).

-d

----- Original Message -----
From: "David House" <[hidden email]>
To: <[hidden email]>
Sent: Monday, February 13, 2006 11:21 AM
Subject: Re: [wp-hackers] Filter Hooks for Enclosures


On 13/02/06, David Chait <[hidden email]> wrote:
> There have been multiple calls here (in two threads) to switch over to
> something like FeedCreator for maintaining the various feed formats.  Alex
> presented FeedCreator originally, I gave it a +1, and in a separate thread
> Mark and Kimmo basically both gave it approval as well (Kimmo uses it
> already...).  FC looks like it uses the create-in-php,
> output-in-whatever-format approach.

It's also a _lot_ of code (several hundred lines worth) that would
replace the mostly functional ~70 lines of code for feeds as present.


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Peter Westwood
In reply to this post by Owen Winkler
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Owen Winkler wrote:

> Denis de Bernardy wrote:
>>> There are some extant implementations of Object<->XML in PHP, so it
>>> might not be too difficult a conversion.  Manipulating the feed XML
>>> via DOM in a plugin would be swell.
>>>
>>> Before I continue blathering about this, how much does this idea suck?
>>
>> DOM/XML related stuff is far from being installed properly on most hosts,
>> and does not work the same in php4 and php5. I'd use a straightforward
>> array
>> instead.
>
> That's really more what I was suggesting.
>
> There must be some class that would let us do something like this:
>
> ob_start();
> // Existing feed stuff
> $xml = ob_get_clean();
> $feed = new WPXmlDoc($xml);
> $feed = apply_filters('feed_xml', $feed);
> $feed->output();
>
> ...
>
> add_filter('feed_xml', 'my_feed_xml');
> function my_feed_xml($feed)
> {
>     $feed->data['rss'][0]['customtag'][0] = 'test';
>     return $feed;
> }
>
> Or something.
>

Why not just makes feeds template items so that a user theme can have an
 rss template for example rss.php, atom.php etc. and this is used
instead of the builtin feed handler.

If we standardise on hooks for the main places a plugin would want to
add and let the enduser extend some more if necessary.

This allows people to customise feeds to any degree without having to
muck around with object buffers and building/throwing away huge object
structures for every feed request.

westi
- --
Peter Westwood
http://blog.ftwr.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD8PkNVPRdzag0AcURAq/UAJ4xRqnBytO6z+YlnX9qzqdyygw3TQCgo8ZF
VRoL1Z3ozz3u7U7ju7kbJuk=
=C/Ve
-----END PGP SIGNATURE-----

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Dave Grijalva
I don't really know if all that is necessary.  A lot could be done by just
tossing in some filter hooks here that are feed specific.  Like being able
to modify the link string, or the enclosure url, etc.  Being able to modify
a feed template would be nice, but there is a large potential there for
people to start breaking their feeds.  A lot can be done with the plugin api
that will make it safer for users to modify things by allowing someone else
to do the heavy lifting.

-dave

On 2/13/06, Peter Westwood <[hidden email]> wrote:

>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Owen Winkler wrote:
> > Denis de Bernardy wrote:
> >>> There are some extant implementations of Object<->XML in PHP, so it
> >>> might not be too difficult a conversion.  Manipulating the feed XML
> >>> via DOM in a plugin would be swell.
> >>>
> >>> Before I continue blathering about this, how much does this idea suck?
> >>
> >> DOM/XML related stuff is far from being installed properly on most
> hosts,
> >> and does not work the same in php4 and php5. I'd use a straightforward
> >> array
> >> instead.
> >
> > That's really more what I was suggesting.
> >
> > There must be some class that would let us do something like this:
> >
> > ob_start();
> > // Existing feed stuff
> > $xml = ob_get_clean();
> > $feed = new WPXmlDoc($xml);
> > $feed = apply_filters('feed_xml', $feed);
> > $feed->output();
> >
> > ...
> >
> > add_filter('feed_xml', 'my_feed_xml');
> > function my_feed_xml($feed)
> > {
> >     $feed->data['rss'][0]['customtag'][0] = 'test';
> >     return $feed;
> > }
> >
> > Or something.
> >
>
> Why not just makes feeds template items so that a user theme can have an
> rss template for example rss.php, atom.php etc. and this is used
> instead of the builtin feed handler.
>
> If we standardise on hooks for the main places a plugin would want to
> add and let the enduser extend some more if necessary.
>
> This allows people to customise feeds to any degree without having to
> muck around with object buffers and building/throwing away huge object
> structures for every feed request.
>
> westi
> - --
> Peter Westwood
> http://blog.ftwr.co.uk
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFD8PkNVPRdzag0AcURAq/UAJ4xRqnBytO6z+YlnX9qzqdyygw3TQCgo8ZF
> VRoL1Z3ozz3u7U7ju7kbJuk=
> =C/Ve
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

David House
On 13/02/06, Dave Grijalva <[hidden email]> wrote:
> I don't really know if all that is necessary.  A lot could be done by just
> tossing in some filter hooks here that are feed specific.  Like being able
> to modify the link string, or the enclosure url, etc.  Being able to modify
> a feed template would be nice, but there is a large potential there for
> people to start breaking their feeds.  A lot can be done with the plugin api
> that will make it safer for users to modify things by allowing someone else
> to do the heavy lifting.

+1

I think that with enough template tags we can make creating new feeds
easy. With enough hooks, we can make editing existing ones easy as
well. No need to add to WP's already large core.

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Dave Grijalva
I agree with that.  I'm just looking for some hooks.

In the meantime, I'd like to be able to make my plugin work without any
modification to the wp source.  Are there any hooks available for the
beginning and end of a feed generation?

-dave

On 2/13/06, David House <[hidden email]> wrote:

>
> On 13/02/06, Dave Grijalva <[hidden email]> wrote:
> > I don't really know if all that is necessary.  A lot could be done by
> just
> > tossing in some filter hooks here that are feed specific.  Like being
> able
> > to modify the link string, or the enclosure url, etc.  Being able to
> modify
> > a feed template would be nice, but there is a large potential there for
> > people to start breaking their feeds.  A lot can be done with the plugin
> api
> > that will make it safer for users to modify things by allowing someone
> else
> > to do the heavy lifting.
>
> +1
>
> I think that with enough template tags we can make creating new feeds
> easy. With enough hooks, we can make editing existing ones easy as
> well. No need to add to WP's already large core.
>
> --
> -David House, [hidden email], http://xmouse.ithium.net
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Jamie Talbot
In reply to this post by Jamie Talbot
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jamie Talbot wrote:

> I definitely like the feeds as objects idea.  A base feed class WPFeed with vars to hold all
> available information that could be subtyped for different feed flavours, WPAtom, WPRSS each with
> their own methods of using that data would be nice.  It would also be nicely future proof when the
> next latest and greatest feed format comes along as it would only require a new class with its own
> 'print' method.
>
> If converting to XML was a trivial task already implemented, that might be cool too.
>
> Is there mileage in this?
>
> Jamie.
>
> --
> http://jamietalbot.com

Well, even if I took this *totally* out of context and even if there isn't mileage in it, I went
ahead anyway and wrote a prototype class based feed structure and the rationale for it.  Owen's
already left a comment giving his thoughts, I wonder if you might do the same?

http://jamietalbot.com/archives/2006/02/15/the-case-for-feeds-as-classes/

Cheers,

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD8yM2rovxfShShFARAqnLAKCQeXjth4rbjMdWIYaE/TMkZhD9EwCePyST
bMZF8eJqPmq8IyP/dloj4NE=
=msCh
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Filter Hooks for Enclosures

Alex King-3
Why re-invent the wheel then there is already FeedCreator out there  
(which would give us support for more formats to boot)?

Cheers,
--Alex

Personal             Business               FeedLounge
http://alexking.org  http://kingdesign.net  http://feedlounge.com



On Feb 15, 2006, at 5:48 AM, Jamie Talbot wrote:

> I went ahead anyway and wrote a prototype class based feed  
> structure and the rationale for it.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
12