WordPress.org

Ready to get started?Download WordPress

Forums

Override a pluggable function (5 posts)

  1. stravaiger
    Member
    Posted 8 years ago #

    Can anyone recommend best practice for overriding pluggable functions?

    Should the new function be put in wp-includes/pluggable-functions.php or in another file and then include that in pluggable-functions.php?

    thanks

  2. chaaban
    Member
    Posted 8 years ago #

    why dont you just make a new function ?

    if you dont want ... i think you can still search in wordpress and get the file where the function is located and edit it ...

  3. stravaiger
    Member
    Posted 8 years ago #

    Yes, a new function but where to store it? It would be nice to keep all overriding functions in a separate file, say /extensions/pluggable-functions.php and then, at the top of wp-includes/pluggable-functions.php:
    require_once(dirname(__FILE__).'/../extensions/pluggable-functions.php');

  4. chaaban
    Member
    Posted 8 years ago #

    Hummm ,

    i'm still new in wordpress .. but look what i did .

    i made a file under the plugin folder called it functions ... added the header that wordpress ask for plugins just the comments stuff and then something like this :

    if (! function_exists("my_function"))
    {
    function my_function () { }
    }

    i Enabled the plugin in the control panel and i could call this function without any prob from pages .

    Hope this help u .

    Good Luck

  5. stravaiger
    Member
    Posted 8 years ago #

    Hey, that's nice, thanks.

    Is there any way to hide a plugin in the plugin menu if a user is less than a certain level?

Topic Closed

This topic has been closed to new replies.

About this Topic