The Hackadelic Sliding Notes Plugin– what a filter change can do

One of the best plu­g­ins which are out there belongs to a great owner known as The Hack­adelic and its his slid­ing Notes plu­gin(http://hackadelic.com/solutions/wordpress/sliding-notes).So, read­ing his post and just going to his web site is a pure enjoy­ment to every code/developer.

In short, the “Slid­ing Notes” plu­gin enables a post writer to but this kind of open/close “ajaxed” but­ton with info

here is an exam­ple of how it’s ren­dered (click on the link):

“click»

Ok.so we under­stand how to use his plu­gin , and the num­ber of com­ments in that post reflects the bug usage of oth­ers in that plugin.

when i started using his plu­gin, I needed to add dynamic data to the note.so, right from the begin­ing i under­stood i had to use using his plu­gin but  in a php style and not in a post writ­ing. obeis­llyy the way to use any short­code in word­press code is by call­ing the “do_shortcode” function.

So, here is an sim­ple exam­ple of using the do_shortcode :

<?php
echo do_shortcode("slider title=\"click me again\"]nore data...[/slider"); //remeber to put '[' and ']' at the begining and the end.
?>

So, lets assume i am edit­ing the single.php page and i want to add the dynamic data as a sli­de­note in the post.so what do we do?

 

Well, its quite a sim­ple answer:just look for the call of

 

 <?php the_content(); ?>

And then add the

<?php echo do_shortcode(put here the slideing shortcode) ?>

and that it.

So, up till here , noth­ing is quite new.you can read it on sev­eral of the arti­cle com­ments and get ti working.What i wanted to do was to add the short­code and make the slider appear before the con­tent of the post is ren­dered, so the first thing i tryed was putting the short­code before the “the_content” call.

how naive i was, It didnt worked.

So, i per­son­lly asked Hack­adelic how to do it and he throw me a hint that there are filters/hooks involved that don’t allow this kind of behavoir.

mmmm.so we need to dis­able that hook right?

 

i went straight to his code and i found this block of code in the hackadelic-sliding-notes/hackadelic-sliders.php:

function initPublic() {
        add_action('wp_print_scripts', array(&$this, 'enqueueScripts'));
        add_action('wp_head', array(&$this, 'embedPrologue'), 99);
        add_action('wp_footer', array(&$this, 'embedEpliogue'));
        add_filter('the_content', array(&$this, 'preProcessContent'), 10);
//remark this line to enable rendering before "the_content" call
        add_shortcode('slider', array(&$this, 'doShortcode'));
        add_filter('the_content', array(&$this, 'postProcessContent'), 12);
        // DO NOT preProcessContent with widget_text !
        add_filter('widget_text', array(&$this, 'postProcessContent'), 12);
    }

So, using the hint, i knew i was on the right track(include the fact that theere are none usage of add_filter call in any of the plu­gin files).Than i saw the 4th line (i high­t­light t) and i remarked it.

the result, is that we can put the sli­de­not short­code before the “the_content” call and it ren­dered and working.

Hope it was use­full to as it was to me.And Hackadelic!bravo on your plugins.

 

Pop­u­lar­ity: 4% [?]

Hello And welome to the office sur­vivor blog!Pow­ered by Hack­adelic Slid­ing Notes 1.6.5
Share

Related Posts

Comments

  1. pell grant says:

    Ter­rific work! This is the type of infor­ma­tion that should be shared around the web. Shame on the search engines for not posi­tion­ing this post higher!

  2. bazel says:

    this can be used only on sin­gle, not on cat­e­gory tem­plate. when in cat­e­gory it gets the con­tent form the first post an all others

    • yoavadler says:

      You are right.

      I intend to post an arti­cle about the slid­ing alternativs.i will take in con­si­daratin cat­e­gory templates.

Speak Your Mind

*

Please leave these two fields as-is:

Protected by Invisible Defender. Showed 403 to 8,524 bad guys.