Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Best practice to define custom theme options?

0 votes
asked Feb 7 in Themes by q2apro

I am running a brother site of my main site. To reduce administration I am using for both the same plugins and themes.

For the theme options, I needed different colors (was able to do specific options by SCSS includes) and logos. Easy.

But when it comes to the qa-theme.php I am a bit stuck.

It seems that I cannot include('custom-file.php'); in the class qa_html_theme extends qa_html_theme_base {...} to access those variables (options) globally.

It seems that I can do so only in the functions(), which requires several includes of several files.

Is there any other option?

PS: Unfortunately, there is no way to define "custom fields" for the theme. And I do not want to create a separate plugin for each theme. It just doesnt feel right.

Q2A version: 1.8.0

1 Answer

+1 vote
answered Feb 7 by pupi1985

If you don't want to change the code, then you have to store the changes in the database. This makes a lot of sense because you have exactly the same code in many sites, each with its own configuration.

The second approach for not having to modify a plugin, theme or core files would be to set some constants in the qa_config.php file. That file is intended to have different configurations in a per-site basis so it is not a big deal to have some extra stuff in there and it will survive Q2A upgrades.

commented Feb 8 by pupi1985
That should be the most appropriate approach if you REALLY need the UI. I didn't mention it because you explicitly said "I do not want to create a separate plugin" :)
commented Feb 8 by q2apro
"the most appropriate approach" with q2a v1.8.0 and prior. Maybe in 1.9 it's not necessary anymore :) ...