Convert PHP implementation to JS.
See pull-request on #1708
Most of the work here has been done and the new implementation is a big improvement. It's cleaner, it won't be memory bottleneck in themes that use many fields with postMessage and in all my tests cases is a lot faster and efficient.
The new implementation can be found on the postMessage-refactor branch
What we were doing before for postMessage: In v3.0.25 and before we were parsing the fields in PHP, checking all their arguments and then a script was generated and added inline. The previous implementation can be seen on https://github.com/aristath/kirki/blob/v3.0.25/modules/postmessage/class-kirki-modules-postmessage.php and if you take the time to examine that code you'll realize how messy it was, making it almost impossible to debug and improve.
What we're doing now: The new implementation will be completely JS and you can see it on https://github.com/aristath/kirki/blob/2e3c8cacf4ba7e2decee0c863f9ef11b3e4cfa99/modules/postmessage/postmessage.js
All fields are parsed in JS now, no custom scripts are generated or added inline, and it's all handled a lot cleaner.
I have tested some basic and some more complex scenarios and so far the new implementation seems to be working. I have not tested every field and scenario under the sun but this is a huge change and it will need lots of testing before it goes live.
That means that developers will need to test it with their themes and report anything that was working before and no longer is.
wishlists and feature requests will come later, after we get the JS implementation to be bug-free.
If you have a theme using Kirki and you use 'transport' => 'auto' or js_vars in your fields then please give this a test. Check the fields where you use live-updates in the customizer and make sure everything works as before. If it doesn't then provide a sample of the code that fails including the field-type, the output arguments and anything else that I can use to replicate your issue.
pinging @MapSteps @kodeoagency @rinkuyadav999 @blacksirius @Alanimus @janisf @notrealdev @minimaluminium @LebCit @carasmo @bawright @UsmanShahzad @vlthemes @tsquez @hellor0bot @manuelmoreale @munirkamal @allysonsouza @pingram3541 @daviedR @kmob2 @Micemade @anthonyryanrusso
From what I've seen in tickets on this repository you all use postMessage in some way, so testing this new implementation will help us move forward. It's currently on a separate branch so you can get it from https://github.com/aristath/kirki/tree/postMessage-refactor
Thank you all for helping me make Kirki what it is today by reporting bugs, issues, feature requests and improvements!
Hey @aristath
I tested integrating the branch to our theme which have bunch of settings that are using 'transport' => 'auto' and found out only one issue. The output media_query args is not working, I don't know if this is a bug or it isn't in the code yet inside postmessage.js.
I will keep using this branch and let you know if I find more issues.
Good work on refactoring the CSS post message and hopefully we can merge this soon.
@pkvillanueva thank you for testing this!
I just pushed a possible fix for the media-query issue on the postMessage-refactor branch, can you please test if that works for you?
@aristath I also tested some controls, it seems working fine. Thanks.
By the way, we have some custom controls and we need some filters in the plugin. @pkvillanueva will report and explain further.
@aristath
The media_query works well and we keep using the branch up until now and found no issue. There is one feature that doesn't exists from the old postMessage code and still not exists to this branch. Some developer (including us) create their own custom control then register to Kirki and I couldn't find a way to filter my custom control postMessage output. We have a new control that has similar data pattern of the kirki-typography and the problem is we couldn't pass our own case (control type) in here.
@aristath
I found another issue, the exclude in output arguments is not working.
@pkvillanueva @reardestani thank you both for testing this!
The
media_queryworks well and we keep using the branch up until now and found no issue. There is one feature that doesn't exists from the oldpostMessagecode and still not exists to this branch. Some developer (including us) create their own custom control then register to Kirki and I couldn't find a way to filter my custom control postMessage output. We have a new control that has similardatapattern of thekirki-typographyand the problem is we couldn't pass our own case (control type) in here.
Can you please post the code/filter you were using in other branches to add support for your custom postMessage implementation in your custom control? Once I know what you're trying to do I should be able to figure out a way to add compatibility for that in the new branch.
I found another issue, the exclude in output arguments is not working.
Support for the exclude argument was just added a few minutes ago in https://github.com/aristath/kirki/commit/64d70e722f1e54302843c33bb1ec5ee8bfc1652d
The postMessage-refactor branch was merged in develop so I'm closing this issue.
This will be included in the next release so please test your themes
Most helpful comment
pinging @MapSteps @kodeoagency @rinkuyadav999 @blacksirius @Alanimus @janisf @notrealdev @minimaluminium @LebCit @carasmo @bawright @UsmanShahzad @vlthemes @tsquez @hellor0bot @manuelmoreale @munirkamal @allysonsouza @pingram3541 @daviedR @kmob2 @Micemade @anthonyryanrusso
From what I've seen in tickets on this repository you all use
postMessagein some way, so testing this new implementation will help us move forward. It's currently on a separate branch so you can get it from https://github.com/aristath/kirki/tree/postMessage-refactorThank you all for helping me make Kirki what it is today by reporting bugs, issues, feature requests and improvements!