GetSimple Support Forum
Sitewide Custom Functions - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Sitewide Custom Functions (/showthread.php?tid=4583)



Sitewide Custom Functions - meepmeep - 2013-04-03

Is there a way to include sitewide custom functions? I know some themes include custom function files but I want something that will extend beyond specific themes.

Ideally, I don't want to change GS code (since it'll get overwritten at upgrade). But if push comes to shove, I'll do it.

If editing GS code is the only way to go, is there a file that gets called by the entire site? Ideally, I'd add an include statement in a single file.


RE: Sitewide Custom Functions - Carlos - 2013-04-03

Create a plugin like:

PHP Code:
<?php
$thisfile 
basename(__FILE__".php");
register_plugin(
    
$thisfile,
    
'Sitewide custom functions',
    
'0.1',
    
'Author name',
    
'#',
    
'Sitewide custom functions. Do not deactivate!'
);

function 
sitewide_function1() {
//...
}
// end 

and insert your custom functions there. Save as sitewide.php (or whatever you prefer) and activate the plugin. They will be available to all themes.


RE: Sitewide Custom Functions - meepmeep - 2013-04-03

(2013-04-03, 16:58:56)Carlos Wrote: Create a plugin like:

Dang, it didn't occur to me to use a plugin. Bravo! Thank you.


RE: Sitewide Custom Functions - shawn_a - 2013-04-03

You can also use a component and load it up in your theme.

But ideally you use the themes functions.php