I faced the same situation. Customize_save works before the parameters are saved, so it will exit. I emailed Otto (ottodestruct.com) about this.
The solution that I have right now is as follows:
add_action('customize_save', 'regenCSS', 100); function regenCSS( $wp_customize ) { checkCSSRegen(); // Checks if I need to regen and does so set_theme_mod('regen-css', time()+3); // Waits 3 seconds until everything is saved } function checkCSSRegen() { if (get_theme_mod('regen-css') != "" && get_theme_mod('regen-css') < time()) { makecss(); remove_theme_mod('regen-css'); } }
I also add an extra checkCSSRegen (); to my customize_controls_init function.
Again, this is a little hack. Unfortunately, this is the best I can find to do at that time.
Another option is to use the ajax response, which is just a php file ping. It looks more like a hack than that.
Another quick hack would be to make a javascript action, which, when you press the save button, causes the timer to delay the call to the PHP file that starts compilation. This is VERY shitty for me.
The only drawback of the above is that if the user does not reboot or another value is not saved, you may not get all the values ββyou need.
Anyone else have an idea?
** Update ** Just added the following query to the Wordpress team. Hope we get it there.
http://wordpress.org/ideas/topic/do-customize_save-action-hook-after-the-settings-are-saved?replies=3#post-24853
* Update 2 * It looks like it will be in version 3.6 as customize_save_after. Guess a few tweets and sample code that can happen even with the Wordpress team .;)