Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#30084 closed defect (bug) (invalid)

Theme Customizer seems to bypass all other hooks

Reported by: usabilityidealist's profile usability.idealist Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Customize Keywords: reporter-feedback
Focuses: Cc:


I'm currently developing a theme which makes excessive use of the Theme Customization API. It also implements a Color Scheme system, which is aimed to be enhanced with plugins (read: LESS dynamic compilation).

All is well when these plugins are activated, but NOT so, if they are disabled. The Theme Customizer seems to bypass all included classes, which are initialized via regular action hooks (read: init and after_setup_theme) and only runs "its" own hooks - which results in the following Fatal Error:

 Fatal error: Call to undefined method cc2_ColorSchemes::get_color_schemes() in /opt/lampp/htdocs/wp-plain-vanilla/wp-content/themes/cc2/includes/schemes/libs/functions.php on line 38

Current commit of the theme at Github:

Normally, you might do an include check and if it fails, include the missing functions + classes, but as they are build with enhance-ability in mind (global variables, which will be rewritten if plugins are present), the non-firing hooks become a big nasty issue :-(

A bit of documentation might help ironing out this problem; eg. something like a "Actions Run During an Theme Customizer Request" run-through in the Codex.

Thanks in advance,
cu, w0lf.

Change History (5)

#1 follow-up: @ocean90
10 years ago

  • Component changed from Themes to Customize
  • Focuses ui administration removed
  • Keywords reporter-feedback added

I don't understand your issue, can you please explain it further? Maybe add some code examples (and not the whole theme)?

#2 in reply to: ↑ 1 @usability.idealist
10 years ago

Replying to ocean90:

I don't understand your issue, can you please explain it further? Maybe add some code examples (and not the whole theme)?

Sorry, bit too much work these days.

So. I've implemented a Color Scheme system, which is being enhanced with plugins. This is basically a class with some supplementing functions (mostly wrappers). It's initialized using a seperate hook:

.. which in itself is hooked, or was hooked, to "after_setup_theme":

Now comes the big fat BUT: It's supplementary functions are also being used inside the Customizer call - and are supposed to work flawlessy .. But then I noticed that the initialization of the base class somehow failed.

So I tried out several hooks, starting from init, admin_init, up to the Customizer init hook itself, even trying out a partial rewrite so the Color Scheme class gets initialized directly (leading to a whole iota of other issues) ..

... but, no matter which hook I chose, how hard I tried - it didn't initialize.

So to handle this issue, I created a pretty nasty piece of work-around: Using a global object and test in every place whether it's already set or not - and in the latter case, initializing the class again. Which somehow works, but well .. it's not reliable enhanceable anymore. I ironed out most issues, including an issue with the theme class being initialized before the plugin (extending) class (!), sometimes partially reinventing the wheel.

cu, w0lf.

#3 @DrewAPicture
9 years ago

  • Focuses docs removed

#4 @celloexpressions
8 years ago

  • Keywords close added

Both the init and after_setup_themes hooks run when the customizer is loaded, as with any WordPress page load (wp-admin-specific hooks may not all run). I'm guessing this may be an issue with something in this specific theme, and probably something in that class that's preventing it from initializing properly. Can you reproduce this issue in another theme using these hooks (most of the Twenty themes do)?

#5 @westonruter
8 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing due to inactivity.

Note: See TracTickets for help on using tickets.