Re: include() and duplicate function definition
| From: | Thijs Lensselink | Date: | Wed, 03 Nov 2010 12:38:55 +0000 |
| Subject: | Re: include() and duplicate function definition | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309269@lists.php.net to get a copy of this message | ||
On Wed, 3 Nov 2010 19:53:52 +0800, David Nelson <commerce@traduction.biz> wrote:
Hi, :-) On Wed, Nov 3, 2010 at 19:29, Peter Lind <peter.e.lind@gmail.com> wrote:David, I re-read your original post. And noticed you include the function inside your child action.php Is there a special reason for that? You want to overwrite the original function in a child theme. probably to get different functionality. So why do you need the original function? Just create your action.php and define the same function. // include '../sometheme/functions/actions.php'; function foo($arg_1, $arg_2, /* ..., */ $arg_n) {That's not going to happen. My point was you could check in the original file if the function is defined and if not then define it.OK, thanks, Thijs and Peter, it looks like I'm trying to do something that is not currently possible in PHP. Time for some lateral thinking. :-) David Nelson
echo "All my new code.\n";} It's code duplication. But i don't think themes should have dependencies to one an other. You could also create a actions.php file outside the themes folder. wp-content/shared-functions/action.php And then in your themes do: theme 1 include "shared-function/action.php"; foo(); theme 2 include "shared-function/action.php"; foo();