2

I don't know how to remove a specific function from a plugin.

My plugin is Photo-gallery.

I want to remove this function:

function spider_createpopup(url, current_view, width, height, duration, description, lifetime, lightbox_ctrl_btn_pos){
...
}

from the file \wp-content\plugins\photo-gallery\js\bwg_gallery_box.js

I've tried many things but nothing worked. Last thing i tried in my function.php is :

add_action('wp_enqueue_scripts', 'wp_deregister_script2', 100);


function wp_deregister_script2( ) {
  _wp_scripts_maybe_doing_it_wrong( bwg_gallery_box , bwg_gallery_box );

    wp_scripts()->remove( bwg_gallery_box );
}

But it's removing more than just spider_createpopup()

How can I do that?

Edit: I want to remove this function in some conditions, for example if the user in not logged in, so he can't use all the fonctionality of the plugin to see more pictures in the page.

3
  • You're calling maybe_doing_it_wrong on yourself ??
    – Rup
    Commented Dec 11, 2020 at 23:41
  • No, you can't just remove a single function from a script from WordPress: you can only load the whole script. (And some tricks aside you can't undeclare a function either.) Your best bet is going to be to edit that script, which probably means forking the plugin and giving it a different name so that automatic updates don't put the function back.
    – Rup
    Commented Dec 11, 2020 at 23:43
  • Why do you need to remove the function anyway? Can't you just ignore it?
    – Rup
    Commented Dec 11, 2020 at 23:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.