Is there any way to override a function?
Let's say I want to customize a function in template-functions.php to fit my needs, but since the file is updated frequently, I'd have to be extra careful when updating. Is it possible to have a custom-functions.php that overrides these specific functions?
jordi
Comments
If so when you say clone, where does the clone go and what do I edit so the system uses the clone?
Thanks
GW
I know to over-ride a function in functions.php you just clone it and place it in your themes functions.php file, but what about template-functions.php?
For example I want to remove the added styles used for front end editing, as I do not use this and having `zp_uneditable zp_uneditable_` on each text element is unnecessary. But that function is called in many places (82) so it is not just a case of clone that function and it will replace that one.
For the moment I just edit the function in template_functions.php, but it would be good if an over-ride feature could be added.
By that I mean if any file exists in the themes directory use that in place of the original, I am sure it could be just done by using something like the following at the top of the file,
`
<?php $filename = $_zp_themeroot.'/template_functions.php';
if (file_exists($filename)){
require_once($filename);
} else {
/* use the following original file */
}
?>
`
This way if you want to make edits or hack a core file, you simply clone that file and place a copy in your theme folder. ZP then checks for that file in your theme file and if it exists it uses that in place of the original file, if not it uses the original files contents. Now the clone file will need to be a full copy of the original. Of course when you update your ZP install you will also need to check to update your themes file as well.
Probably not the best solution but it is an option.
Another option would be for the theme functions.php file to be used as a file that holds all edited functions that are a copy by exact name of the original function, the system then checks for that function in the themes function file before it uses the function from the original file, but I would think that would be slower than having a clone of the whole file in the theme directory as suggested above.
Your thoughts?
GW
GW
Thanks
GW
I'm actually having a little bit of fun playing with the nightly builds and seeing what is new and of course what needs to be fixed.
Slightly off topic, but what is the line in the sand between making a post here about an issue versus making a ticket on bugtracker - the two seem to get inter-mixed if you know what I mean.
Cheers
GW
Probably we should discuss the tinyZenpage issue on the ticket from now on..;-)