Customizing TSML via Wordpress Action Hook #1590
Replies: 3 comments 1 reply
-
thanks for the insight! another option i've found that works in some cases is to add customizations to |
Beta Was this translation helpful? Give feedback.
-
Another option to keep your customizations safe during updates is to create a child theme. The child theme inherits the look and functionality of its parent but does not get changed during theme updates. You would add your changes to the child's |
Beta Was this translation helpful? Give feedback.
-
Could i ask the type of adjustments you've achieved this way? I used to adjust the meeting details pages (old version TSML) but haven't found a route to reapply these adjustments. Are you applying adjustments to the main list, or meeting detail view? Thank you for sharing. |
Beta Was this translation helpful? Give feedback.
-
TL;DR
If you are running your TSML customizations off a Wordpress action hook, you need to use the
init
hook to get them to take effect properly. Until a recent release, you could have used theafter_setup_theme
hook, but no more.Long version:
I recently debugged and resolved a problem customizing TSML, and wanted to share the resolution in case others have the same issue.
In the TSML FAQ, a number of references are made to customizing TSML by adding snippets to your
functions.php
file. I don't like to put code in that file, because it is often updated during theme and other site updates, so custom code often gets lost. Instead, I inject my custom code using the free version of the Code Snippets plugin.Code injected using Snippets is executed when the snippet plugin loads, which is generally not when you want your customization code to execute. To get it to execute at the right time, you write your snippet so that it runs your code from one of the Wordpress Action Hooks, like this:
In fact, this is exactly what my snippet looked like, and it was working great until a few releases ago, when it suddenly stopped working. My overrides of things like meeting types and their descriptions were no longer showing up on my site. Instead, I was getting the default meeting types and descriptions.
After some debugging, I figured out that the hook I was using (
after_setup_theme
), which had been running after TSML initialization, was now running before TSML initialization. Thus, my changes were being overwritten by the TSML default values. The fix was to run on theinit
hook instead of theafter_setup_theme
hook. With that one change, everything is working perfectly again. That is, instead of the code above, my code now looks like this:Beta Was this translation helpful? Give feedback.
All reactions