Is there a way to access one theme component’s settings from another theme component? It seems like
settings contains settings only for the theme component that it’s in.
If it’s not possible to access one theme component’s settings from another theme copmonent what is the best way to do that?
- have a single theme component?
- move settings into the primary theme (but are those available? I’ve not tested that yet).
Settings from different themes/theme-components are deliberately isolated. Having interdependencies between themes/theme-components makes them very difficult to develop and support.
As @Arkshine demonstrated, it is technically possible to hack your way to find the data, but I would STRONGLY recommend against it. The strategy will break if an admin changes the name of a theme in the admin panel, and is also quite likely to randomly break with future core changes.
My bad, I realized that the code I provided may not be reliable. I should really be careful about what I display here. Hacking is fun, but it lasts till it leads to unwanted usage and issues in the future.
Oh no worries at all @Arkshine - it’s always good to experiment. Having the
[details] note in your post is good to make sure people know the risks they’re taking
If sharing settings like this between plugins and/or theme components becomes a common requirement, then we can certainly work out some more robust options. Perhaps we can use this topic to lay out example use-cases.
My gut feel is that, if a theme is trying to use settings from another theme then… perhaps they should be merged into a single repository?
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.