[wp-hackers] PHP Include Question - Best Practice

ProDevStudio prodevstudio at gmail.com
Sun Feb 14 08:20:01 UTC 2010

Hi Michael,

One way to do this would be to check is image_resize() has not already been
defined then include the image.php.

for example:

function foo() {
    if (!function_exists('image_resize')) {
        include_once(ABSPATH . WPINC . '/image.php');
    //more code here

In terms of performance issue one would reduce the number of call to
include_once if it was loaded already.

I would be interested in seeing others take on this.

Kind Regards,
Azizur Rahman

Do you need cost effective web hosting solution and Domain name try

On Sun, Feb 14, 2010 at 4:03 AM, <michael at mfields.org> wrote:

> Hi. I'm putting together a small collection of functions that extend
> WordPress' image handling functionality. One of the functions returns a
> custom intermediate image size if one is found and has a parameter which
> (if set to true) will attempt to create the image using image_resize() - a
> core function.
> In the event that the function needs to create a new intermediate size,
> '/wp-admin/includes/image.php' needs to be included which leads me to this
> question:
> "Is there any performance penalty for using include_once() in a function
> that will most likely be called many times during the duration of a
> script?"
> It makes sense to me to only include the file if the function is set to
> create a new intermediate image, but if this could effect performance, I
> would rather just include it once outside of the function which uses it.
> Thanks!
> Mike
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list