Multisite Global Sections using Pro Theme

Hi,

I would like to be possible to assign a global footer and/or header for the entire multisite using the Pro Theme.
I want to edit the footer in one place and it will be updated on the entire multisite.

I already asked if it’s possible here: https://theme.co/apex/forum/t/multisite-global-footer-using-pro-theme/47127
The answer was negative, but I’d like to look more into it.

A custom post type could be accessed on the network using switch_to_blog function: https://codex.wordpress.org/Function_Reference/switch_to_blog

I tried looking into the code of the header but I can’t find what is hooked into x_masthead ( <?php do_action( 'x_masthead' ); ?> )

Would this work for headers and footers?
In what file should I look to implement the switch_to_blog function?

Thank you.

Hi @carinaa,

I can give you some ideas, but what I’m about to share would be outside the scope of support we can offer. There are some technical challenges to making this work. I won’t be able to provide exact code but I can give you some ideas if you want to explore more of the possibilities here.

These two hooks can be found in class-header-assignments.php

cs_locate_header_assignment
cs_match_header_assignment

The “locate” runs early allowing you to interject an assignment before the default one is applied. The “match” hook will allow you to force a particular header ID. That will solve part of the problem because it will let you tell the builder the ID of any header you’ve created.

Now for the multisite part. The Header and Footer data are loaded at the same time in this function x_bars_setup_modules which is in pro/framework/functions/pro/bars/setup.php

This might be what you need to do:

add_action( 'x_late_template_redirect', function() {
  // switch to blog with header
}, 9 );

add_action( 'x_late_template_redirect', function() {
  // switch back
}, 11 );

The problem you’ll run into is that this simply lets you provide data from a different header. When it actually gets displayed it will be in the context of the current site. This means that if you for example have a navigation element and select a specific menu (not a location) it won’t be able to find that menu since it’s from another site. Same thing with Global Blocks - it won’t be able to find them. There are probably other challenges as well that I’m not thinking of at the moment.

All that being said, proceed with caution, but good luck!

Thank you very much.
I’ll see what I can come up with.

You’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.