gambitph / Titan-Framework

The easiest to use WordPress option framework.
http://www.titanframework.net
377 stars 137 forks source link

fire compile option on field change #166

Open premiumsupport365 opened 10 years ago

premiumsupport365 commented 10 years ago

Hello , I am not sure if this option is available in titan. I have used redux for sometime and I used compiler in redux to store the values in separate file and included that with the output to perform custom functions.

I wonder if the same type of compiler option available with Titan framework. I saw the demo and impressed by the way titan is presented and made my mind to switch to Titan :+1:

bfintal commented 10 years ago

What to do you want to compile?

oherman commented 10 years ago

Please elaborate so we can find out what approach to use to implement it.

premiumsupport365 commented 10 years ago

Hello bfintal and oherman. Thanks for your reply, in redux they have provided an option to run the compiler when the value is changed. which will fire the event and I am using to fetch the values and write to custom file. for example see the lines below

// Function to test the compiler hook and demo CSS output. add_filter('redux/options/'.$this->args['opt_name'].'/compiler', array( $this, 'compiler_action' ), 10, 3);

This is a test function that will let you see when the compiler hook occurs. It only runs if a field set with compiler=>true is changed. function compiler_action($options, $css, $changed_values) { ...................... }

bfintal commented 10 years ago

So it's for including additional CSS? How about this function: http://www.titanframework.net/generate-css-automatically-for-your-options/

premiumsupport365 commented 10 years ago

Hi Mate, its not just CSS. this option actually fires a function when the value of the field is changed and saved. by using that I create css, js even custom functions to be stored in a custom file, as like dynamik gen [genesis child theme] does. Hope this makes sense.

we achieved that through redux using the function I mentioned in my previous comment and it is supplied by default in redux sample config file

bfintal commented 10 years ago

Ah, okay I get it. This would actually be helpful!

Perhaps a new hook tf_option_changed_{id} or tf_option_changed_type_{type} or tf_options_changed or maybe all of those.

I don't think this can be made applicable to options in meta boxes though