ThemeShaper Forums » Thematic

How to filter a plugin which doesn't use variables

(5 posts)
  • Started 8 months ago by talino
  • Latest reply from talino
  • This topic is resolved
  1. Hi all,

    I'm getting pretty comfortable with shaping up my Thematic child theme (at www.talino.org). However I'm having some difficulty with the Add To Any plugin (http://wordpress.org/extend/plugins/add-to-any/). I would like to add it in the .entry-utility div, but I can't figure out how to accomplish that.

    The plugin's admin page says the code to include is the following:

    echo '<ul class="addtoany_list">';
    if( function_exists('ADDTOANY_SHARE_SAVE_ICONS') ) ADDTOANY_SHARE_SAVE_ICONS( array("html_wrap_open" => "
    <li>", "html_wrap_close" => "</li>
    ") );
    if( function_exists('ADDTOANY_SHARE_SAVE_BUTTON') ) ADDTOANY_SHARE_SAVE_BUTTON( array("html_wrap_open" => "
    <li>", "html_wrap_close" => "</li>
    ") );
    echo '';

    I've tried filtering different steps in the Thematic code, such as thematic_postfooter, thematic_postfooter_postconnect & thematic_postfooter_postcategory, but no matter what I do the plugin outputs its own HTML whenever my filter is called, instead of where Thematic would place it, i.e. somewhere here:

    $postfooter = '<div class="entry-utility">' . $postcategory . $posttags . $postconnect;

    Is there any way to do this cleanly? I've been doing a lot of customizations in my functions.php and I would hate touching the framework files.

    Thanks for your help.

    Posted 8 months ago #
  2. Hi,

    from time to time it's helpful to look into a plugin's source.

    Use

    $button = array("output_buffering" => TRUE, "html_wrap_open" => "<li>", "html_wrap_close" => "</li>");

    With this information you should be able to create your filter.

    Chris

    Posted 8 months ago #
  3. I appreciate your reply for being more of a hint to a puzzle rather than a ready-made solution. However, I'll have to ask for another hint since I'm not sure of what you mean, and also because I'm just discovering the innards of Wordpress+Thematic: do you suggest that I modify the plugin so that it can apply my own filters to its output?

    The variable assignment in your code, from my understanding, doesn't achieve anything on its own since the ADDTOANY_SHARE_SAVE_BUTTON function isn't called, and I don't see how it helps getting that function to return a string instead of printing it.

    Thanks again for your help.

    Posted 8 months ago #
  4. What Chris probably meant was that you can use the output_buffering parameter to prevent the button from being echoed:

    if( function_exists('ADDTOANY_SHARE_SAVE_BUTTON') ) $button = ADDTOANY_SHARE_SAVE_BUTTON( array("output_buffering"=>TRUE, "html_wrap_open" => "< li >", "html_wrap_close" => "< /li >
    ") );

    After this echoing $button would print out the output from the plugin.

    Posted 8 months ago #
  5. Obviously. Should've figured it out myself, but didn't. Thanks a lot kari.patila (and Chris!).

    Posted 8 months ago #

RSS feed for this topic

Reply

You must log in to post.