[wp-hackers] Back on the plugin scene -- some questions

Peter Westwood peter.westwood at ftwr.co.uk
Sat Dec 29 11:41:38 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Stephanie Booth wrote:
> Hi folks,
>
> I'm back in the WordPress plugin hacking world, with a few questions.
Welcome back! - I'll answer the ones I can easily.
> 1. Print CSS
>
> I noticed that WP does not provide a print stylesheet out of the box
> (I thought it used to, but I may remember incorrectly -- depends on
> the theme, I guess). Anyway, I started looking around for existing
> plugins to add a print stylesheet before writing my own. I found WP
> Print <http://wordpress.org/extend/plugins/wp-print/> but it adds a
> print link and seems a bit heavy. All I want is basically to insert
> <link rel="stylesheet" type="text/css" href="/blah/print.css"
> media="print" title="Normal" /> in the header and provide a CSS file.
> So, sub-questions:
>
> - is there a plugin I missed that does roughly what I want?
> - does anybody know of pre-existing print stylesheets for the Sandbox
theme?
> - I see a few filters containing the word "stylesheet" here
> <http://codex.wordpress.org/Plugin_API/Filter_Reference#Template_Filters>
> but honestly, what they do seems a bit fuzzy according to the
> description (I'm not very knowledgable in how WP deals with
> stylesheets); what would the best way be to insert my line of HTML in
> the header -- assuming that editing the template manually is not an
> option?
Hooking into wp_head and outputting the html then is what you want to
do I believe.  This is how WordPress itself adds things to the theme
link the rsd link, generator (in 2.4), wlw manifest file etc.

> 2. Is feed or not?
>
> As described in this post
> <http://climbtothestars.org/archives/2007/12/04/ridding-wordpress-plugins-of-template-tags/>,
> I've modified the Similar Posts plugin to automatically add the
> similar posts links. I want them at the beginning of the content in
> the blog, but at the end of the post content in the feed. So, I wrote
> two different functions for that and then used this code for the
> hooks:
>
> if(is_feed()) {
>     add_action('the_content', 'sp_embed_feed_similar_posts');
> }else{
>     add_action('the_content', 'sp_embed_similar_posts');
>     }
>
> Unfortunately, this doesn't seem to work. In the feed, the similar
> posts are placed like in the main blog page, which means the second
> function was used. What am I missing here?
I suspect this is due to the fact that when you are calling add_action
the query has not yet run and so WordPress doesn't know if it is a
feed on not.
Move the check on is_feed into the function that is called when
the_content action occurs and all should be well.

hope these answers help

westi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iD8DBQFHdjJyVPRdzag0AcURAmlRAKDOhJCzfMkuRhXNrOvT9/rfv8zTEwCgxajz
ZQxiVKV3g7kHkiiOG3lrlGI=
=aFRP
-----END PGP SIGNATURE-----



More information about the wp-hackers mailing list