• Resolved spiderz

    (@spiderz)


    hello ??

    i just saw that there are many (new) filters and ways to customize SLB… but i am not able to find an example for using those functions/filters…

    for example, i want to disable SLB on the GALLERY shortcode… and I found there is now a filter defined since version 2.3:

    slb_exclude_shortcodes ($array of shortcodes to exclude)

    but how am i supposed to use it in “my functions.php”? what function do i have to filter (is it the_content?) like:

    addfilter (‘the_content’, ‘slb_exclude_shortcodes’, ?)

    i am a bit lost ??

    https://www.ads-software.com/plugins/simple-lightbox/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter spiderz

    (@spiderz)

    I tried using the shortcode “[slb_exclude]”, but it did not work.

    [slb_exclude] blabla [gallery] blalbla [/slb_exclude]

    I even tried with the latest beta version of SLB (2.4b3)

    Plugin Author Archetyped

    (@archetyped)

    Hi, here’s a couple resources on using filters in WordPress:

    But basically you hook into the filter like so:

    add_filter('slb_exclude_shortcodes', 'my_custom_callback_function');
    

    …where my_custom_callback_function is the name of your custom callback function that acts upon this filter.

    [slb_exclude] works as expected when testing your example on my end, but if you can provide a link to a page that exhibits the issue, I would be glad to take a closer look.

    Thread Starter spiderz

    (@spiderz)

    (Thank you! If i could sent you a private message – or even an email contact on your site – i would gladly send you a link.)

    I am not a complete WP beginner but I am having a hard time understanding the logic and figuring out the right code for this filter… You say that the arguments for this filter (slb_exclude_shortcodes) is one array with the shortcodes to exclude… How would I pass this array in the filter? (For example if I want to exclude the [gallery] shortcode? Would this work?

    my_custom_callback_function($args) {
    $args = array('gallery');
    return $args
    }
    add_filter('slb_exclude_shortcodes', 'my_custom_callback_function');
    Thread Starter spiderz

    (@spiderz)

    IMHO and as far as I am concerned, this topic is not resolved.

    Plugin Author Archetyped

    (@archetyped)

    Hi,

    Here’s the official PHP documentation on working with arrays. It explains how to add elements to an array far better than I could.

    Give that a read and let me know if you still have any questions on how to add custom shortcodes to the array of shortcodes to be excluded.

    Thread Starter spiderz

    (@spiderz)

    Hi,

    Thanks again. I don’t understand the spirit of your replies. Are you trying to teach people php? My problem is not with php, is with WP and this plugin… and I think I will give up now.

    I tried the code below (with the beta version) but it did not work for me :

    function my_custom_callback_function($array) {
    	$array[]='gallery';
        return $array;
    }
    add_filter( 'slb_exclude_shortcodes', my_custom_callback_function );

    + I also tried to use the following shortcode in posts [slb_exclude] but it just prints out the code, it does not process it.

    I am using a custom template, but with nothing weird, very few plugins and a relatively clean code.

    Plugin Author Archetyped

    (@archetyped)

    Using filters is an advanced WordPress technique, and as such requires working knowledge of how to use PHP. Your question was more related to how to access and modify arrays in PHP, not something specific to WordPress or SLB.

    Custom templates are where problems can occur if they are not set up according to WordPress standards. If you would like to post the template’s code, I would be glad to take a look.

    I am having t the same difficulties. If you could just share a sample showing how to disable SLB for a sample shortcode (e.g. the gallery) it would be really helpful for other people as well.

    Plugin Author Archetyped

    (@archetyped)

    Hi, hooks without official documentation should not be used. They may be for internal use only and can change at any time.

    When a hook is ready for public use, documentation will be provided along with examples.

    I was referring to the “slb_exclude_shortcodes” hook. Isn’t this officially available at this point?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘using the new filters’ is closed to new replies.