Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sitewide Custom Functions
#1
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.
Reply
#2
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.
Reply
#3
(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.
Reply
#4
You can also use a component and load it up in your theme.

But ideally you use the themes functions.php
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)