After further testing, I’ve learned that Appearance > Customize worked in 4.0.2 and failed in 4.1.2. I see that admin/js/customize-controls.js changed in 4.1.1, so I presume that’s where the bug was introduced.
Have you tried deactivating all plugins to rule that out?
Yes, I’m running on a development site and all plugins are deactivated. Somehow every section and every control I manually created is being perceived as not “active”.
When the page loads, my sections initially display, but then the ‘ready’ event is triggered on the api.PreviewFrame, and its passed some ‘data’ that has elements activePanels, activeSections and activeControls. All of WordPress’s native panels, sections and controls are in that data structure and none of mine are. That data structure seems to be emitted by WP_Customize_Manager::customize_preview_settings()
, but when I view source on the page the data structure doesn’t look at all like I think it should look based on that PHP code. And yet when I step into the Javascript code data
has the expected structure.
It looks like in 4.1 a new method was added to WP_Customize_Section
, active()
. Looking at the PHP code I’m guessing that I have to add a filter for customize_section_active
to say the my sections are active. Maybe I have to do the same for all my controls as well. If that’s true, what a royal PITA it is.
Upon further investigation, it appears hiding all my stuff by default was “an improvement in 4.0”. See the Contextual Controls section of the Customizer Improvements in 4.0 article. Apparently now, for every control I add, I need to pass an active_callback
function that returns true when the user is previewing a “context” in which I want my control to be active. For some unfathomable reason, if I fail to provide that callback, say, because it never existed before, the default return value for active()
is false. Meaning all my custom stuff disappears by default. Not exactly backwards compatible there. 🙁
Actually, that didn’t do it. Still trying.
Curious if you are using is_admin()
on your code. I forgot that there was a ticket created for missing sections: https://core.trac.wordpress.org/ticket/30387
The code in the function that adds all the sections and controls was not wrapped in is_admin()
, but attaching the function to the customize_register
action was, i.e.
if ( is_admin() ) {
add_action('customize_register', array($this, 'admin_theme_options'));
}
When I moved that add_action()
call outside the if
everything works again.
THANK YOU!!! I would’ve never thought of that.
You are most welcome! 🙂
I’m glad you got it working!
Jose Castaneda, you are the Shizzle!
Thanks!