The code for our plugin and theme is object oriented, meaning that all of the functions are located within classes and can’t be overridden. There are many benefits to object oriented programing and it’s actually a technique that’s widely used in themes and plugins.
Additionally, what you’re asking for is called a “pluggable function” and is kind of a WordPress relic. Core isn’t even adding them anymore. See… https://codex.wordpress.org/Pluggable_Functions
Is there something specific that you are trying to do? Maybe we can accomplish it with an action or filter. Let me know.
Ok, here’s what we’re currently trying to sort out.
You have a bunch of navigation placement options in Customizer, Nav Centered, Nav Bottom etc. I can find their corresponding .php files in /bb-theme/includes.
How could we create a “Nav Side” - i.e. we want the navigation to run vertically on the left hand side of all pages. We could create the code in /bb-theme-child/includes (I presume?) but how would we register Nav Side within the Customizer as an option?
That actually might be possible, but it’s going to take a fair amount of custom PHP and you’ll need to read up on WordPress’ Customizer API. Once you get an understating of how to work that into your child theme, you can use this to access the controls…
To be honest, that’s about as far as my knowledge goes when it comes to working with controls and settings that are already defined. You’ll need to do some digging to see how to add the new option. Once you get access to the control and add your left nav option, you can create a file in the includes directory called nav-left.php.
We added a custom menu widget to the left hand column within our page design. The problem is that your custom menu widget doesn’t appear to be programmed to be mobile/responsive? If it was (surely it should be?) then we wouldn’t have to try and create what I described above.
The custom menu widget isn’t ours, it’s just standard WordPress. We do have plans to build a menu module and even a left nav header layout, but that probably won’t be coming for a little while.
You don’t need to add an option to the customizer to build a left nav header layout. You can just choose any of the layouts (right for example) and then override the file for that (nav-right.php) in your child theme. Once you’ve done that you can build a left nav layout with some CSS/HTML.
Thanks, is there no simple way of renaming the option in the Customizer just to avoid confusion? So we can use nav-right.php and not have to change any of the calls, just really change the language?
It’s good to hear that you will consider making the custom menu widget mobile responsive, or a separate mobile responsive menu. Also a left-hand menu would be great, or at least a clearer tutorial on how we could create nav-left-sidebar.php and get that to show in Customizer - one of you guys must know the steps to do that? or is it just simply too complicated to explain in a tutorial?
Thanks, is there no simple way of renaming the option in the Customizer just to avoid confusion? So we can use nav-right.php and not have to change any of the calls, just really change the language?
Unfortunately, there isn’t. The only way WordPress provides to work with Customizer controls is through the Customizer API.
or is it just simply too complicated to explain in a tutorial?
Yea, it’s not as easy as it sounds. There’s going to be a lot of CSS/HTML involved when we end up implementing that piece.
Bonus additional question, now I’m digging in to hacking the Customizer, is it possible for us to declare our own version of your ‘includes/customizer-panel-header.php’ file in our child directory? Then we could add our option to this array:
I appreciate that’s only the start of the work, but that would get us started - I just need to know whether we can have our own version of that file in our child directory and whether the builder will use ours and override the default?
Bonus additional question, now I’m digging in to hacking the Customizer, is it possible for us to declare our own version of your ‘includes/customizer-panel-header.php’ file in our child directory?
Sorry for all the no answers! This is not possible as well. Additionally, you wouldn’t really want to do that as doing so would mean you wouldn’t get any updates we make to that file.
Your best bet here really is the Customizer API. It looks hard, but once you learn it, it’s actually fairly easy.
One thing is that we’re developers. A lot of replies seem to share the theme of “No we don’t allow that as we worry that you’ll not update the file” - but it’s our job, we are more than capable of being responsible for this - but you need to show us a bit more trust, perhaps? Ultimately newbie users aren’t going to be looking at doing this kind of stuff, so the only ones who would be affected if their child theme .php file became out of date, would naturally be those who are happier with these things.
In the meantime, Customizer looks pretty simple. What doesn’t look simple, and I can’t find much online about it, is how to add an additional drop-down entry to an existing customizer option. Furthermore, you guys are using your own mark-up for pushing to the customizer, via a FL Customizer function? Which of your team did all the cusotmizer work? I’m sure they could just advise on the mark-up for adding an additional record to a select drop down in Customizer. I can happily add whole Customizer options/sections etc.- but adding to an existing option seems tricksy.
It’s not that we don’t allow you, it’s just that a lot of what we talked about is how it’s done with the Customizer. You can override a lot of things in the theme by using a child theme, you just can’t override that. You’d get these same responses from many reputable theme developers.
I’d be surprised if you found a theme that did give you the ability to override their customizer logic. For example, have a look at the popular Make theme. Those guys are some of the top theme developers in the industry and even have themes on wordpress.com. Our Customizer code is very similar to theirs.
Hacking a parent theme is typically considered bad practice in the WordPress world. That’s why we have things in core like the Customizer API, filters and actions, so you don’t have to do that.
Furthermore, you guys are using your own mark-up for pushing to the customizer, via a FL Customizer function? Which of your team did all the cusotmizer work?
I actually wrote all of the customizer code, and again, putting it in its own class is fairly common, if not recommended.
I can happily add whole Customizer options/sections etc.- but adding to an existing option seems tricksy.
As I mentioned earlier I’m not familiar with how to add options to an existing dropdown. I know you can get access to existing controls, but my knowledge of how to modify them is limited. You might try posting on Stack Exchange and see if there is a developer that knows how to do that.