I have variables set up at the beginning of functions.php like:
$shortname = "ve";
$mytheme_template_dir = get_bloginfo('template_directory');
etc..whatev I need. I have like 8 files I use to put functions into….using these variables is easier to use/remember
then I use $shortname, or the others all over the place… like in option arrays
array(
'name' => __( 'Colour Scheme', 'voodoo_lion' ),
"desc" => __( 'Select the colour scheme for the theme', 'voodoo_lion' ),
"id" => $shortname."_color_scheme",
"type" => "select",
"options" => array( "","default", "reds"/*, "black", "purple"*/ ),
"std" => "reds"
),
or functions
function mytheme_css_and_scripts() {
global $mytheme_template_dir;
Thread Starter
ext103
(@ext103)
thanks for the reply, but doesnt really help me.
i too have a lot of different files linked with functions (shortcodes/help/widgets/general/optionspage/etc)
i was hoping i could implement something similar to the $shortname for my entire functions files.
right know i have a theme im working on called “press3”
so my functions look like this
function press_3_widget_load
function press_3_register_sidebar
function_press_3_options_page
etc.
when i want to create a new theme, i need to go through all of these files and change the press_3 part to whatever relates to the new theme.
but if i could set something up like the shortname you mentioned, i would only have to change the original
&themename =
and all functions would work and be named specific to new theme.
maybe if this isnt possible i could add in a str replace function right at the begining of the original functions.php file???
I thought that’s what I was saying?
I define $shortname as ve in my theme, right at the top of functions.php….. then I use $shortname all over the theme
If I was to move a bunch of the functions and arrays to a new theme, all I would have to do is rename $shortname to something else and it would work just fine
Thread Starter
ext103
(@ext103)
yes i know, but you use it within a function, not to name a function.
function $shortname.setup(){
}
the above code doesnt work.
Ah, I see! Sorry, wasn’t reading totally straight
Why do you need the functions renamed for each theme out of curiosity?
Since only one theme can be active, the functions can’t conflict with each other….so they can always have the same name theme to theme….
If just for naming sake…. instead of naming my functions after my theme, I name them after my company….
Like my company is The Voodoo Empire, so all my functions are named voodoo_something
I just use them like that throughout all my themes. Just not sure if there is a certain functionality you are after here?
Thread Starter
ext103
(@ext103)
its not for specific use, its just a suggestion i got from a theme reviewer last time i submitted my theme.
they said the functions should describe what they do (ie press_3_load_sidebar_1)
i think i may go through and do as you suggested, name functions on a different basis.
i may use your $shortname method for text domain/translation though.
do i have to call “global” inside each function i call these?
you call global to grab variables from outside the function
http://www.thewebsqueeze.com/web-design-tutorials/writing-functions-in-php-global-variable.html
here’s a decent article on global variables