Re: include() and duplicate function definition
| From: | Steve Staples | Date: | Wed, 03 Nov 2010 16:13:59 +0000 |
| Subject: | Re: include() and duplicate function definition | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309273@lists.php.net to get a copy of this message | ||
On Thu, 2010-11-04 at 00:00 +0800, David Nelson wrote:
> Hi Thijs, :-)
>
> On Wed, Nov 3, 2010 at 20:38, Thijs Lensselink <dev@lenss.nl> wrote:
> > 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.
>
> It's a WordPress issue. When theme updates become available from the
> original vendor, you can update them from within the admin backend. In
> that case, any hacks you've applied (such as removing a function) get
> overwritten. So the evangelized solution is to create a child theme.
> The child theme incorporates only files that you've added or changed,
> with the original parent theme being used for all others.
>
> Easy peasy if you want to *add* a function.
>
> But, if you want to *modify* a function, you're faced with the problem
> of the original function still being present in the parent theme files
> and of your having to define a function of the same name in your child
> theme (if you change the function name, you then have to hack other
> code further upstream, and the work involved becomes not worth the
> bother). Somehow, I would need to make my hacked function *replace*
> the original function, *without* touching the original function...
>
> It seems like that's not possible and I'll have to find another
> solution... unless my explanation gives you any good ideas?
>
> Just to put the dots on the I's, the original "actions.php" contains a
> lot of *other* functions that I don't want to touch, and that I do
> want to leave exposed to the updates process. It's just one single
> function I want to hack...
>
> Sticky problem, huh? :-)
>
> In any case, thanks for your kind help, :-)
>
> David Nelson
>
> P.S. Sorry about the direct mails: I keep forgetting to hit the
> "Replly to all" button.
>
I am curious on how this would work, if for some reason they were using
a different template? the function you want to "overwrite", wont be
used, and therefore, wouldn't your app/template/whatever be updated
improperly than waht you expect it to be?
Just curious...