0

This might be a stupid question. But I thought to ask it here.

It is really bad changing core file and I know that there are actions and filters in WordPress. But there are some limitations.

So why WordPress Core Functions Not Using function_exists()? I mean something like below example in core files.

if(!function_exists('wp_insert_post')){
    function wp_insert_post( $postarr, $wp_error = false ) {

        //Core Code

    }
}

Then give a way to run PHP file before core files. So any developer can modify the core files without changing core files.

  • Are you trying to modify a certain core behavior? – birgire Jul 17 '17 at 11:52
  • @birgire No, I just asked it because I was wondering to know why WordPress team does not allow that feature and I got a answer from Rarst. Thanks :-) – I am the Most Stupid Person Jul 17 '17 at 12:10
5

Some do, a number of core functions is specifically designated pluggable and contained in pluggable.php for exactly this purpose.

It is also quite a messy approach and is often regretted it’s a thing at all.

The problems are loosely:

  • the replacement works exactly once;
  • letting extensions mess with core definitions can lead to very volatile results.

The problem with letting developers modify core files is often not how to allow this, but how to make it unnecessary. The latter is much more reasonable approach and basis for WP’s strong extensibility and success of its hooks API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.