The Goal: To replace the sidebar on all sites across my network with content loaded from a plugin, across all themes.
I need a way of over-riding the sidebar/main widget area on all sites across my network.
I have written a plugin which generates the sidebar with a function call, but how can I get this content to completely replace the sidebar? At present I can only call a hook as get_sidebar()
happens, not replace that action.
add_action('get_sidebar', 'my_get_sidebar', 11);
Additionally, this makes my sidebar appear on all sidebars on the page, I only want it to overwrite the main one (sidebar-one?) and have the others left blank.
You should look into having your sidebars utilize the remove action function.
Then you can remove a sidebar and replace it in a function any number of ways.
For instance (this examples using a conditional based on a page called some-page.
http://codex.wordpress.org/Function_Reference/remove_action
The
old_sidebar
andyour_function
is the name and the function name of the sidebar you want removed, you will have to look in your theme to find the actual values the theme author used ( usually in functions.php but not always).Also if the theme is hardcoded or does not create sidebars using hooks/actions this will not work.
not sure, but perhaps can the plugin Widget Logic be a good starting point to develop your function from?