I need to add PHP and JS code in my site, but i was reading when the theme is upgraded, the code added into functions.php archive will delete. So, If I add the codes in Elements hooks, They will work good when the theme upgrade, or the codes will be deleted too?
I dont really create a child theme and i need to know if i can use in a safe way elements hooks !
JS Code: no problem adding them to a Hook.
PHP Code: This will depend on what that code does. For example if it is calling a template part then all should be fine. If its a Filter Hook function then no, this needs to go in child theme functions file or you can use the Code snippets plugin
1 – If I add JS or for example google analytics or tag manager codes in the hooks on elements, those codes will not be deleted with de upgrade theme, and can i add a snippets plugin with out a child theme?
2 – Can i create the child theme, add the PHP code with out plugin and copy the JS in the element’s hooks but working with the child theme?
Which of them are better?
I dont know if if you understood me ! Thanks for the support.