0

I have a function right now in my functions.php file that display a contact form on the frontend, also checks the user data and send an email, so the question is, should I leave this just where it is ( functions.php ) ?? or include it in a plugin. I have to say that until now the mentioned form is attach to the theme functionality, for example it uses the colors selected by the user on the customize screen, but I want to know if in this case belongs to the “plugin territory”, thank you very much!

1 Answer 1

0

This depends a lot on the context.

Normally, I would say that the form should be in a plugin.

The rule of thumbs is that if it's a functionality that could still be needed when the theme is deactivated, then it should go into a plugin.

Now for your specific case, if using the customizer, would set options that could potentially break your form if the theme should be changed, then you should keep it in your theme's functions.php.

But, I would still argue that it should go into a plugin and you should make sure that, in the eventuality that the theme is changed, you set default values to the form to replace the customizer options.

Because chances are that even if the theme is changed, you'd still want the contact form to be active.

1
  • 1
    Sounds logic to me, it looks like i should adapt the contact form to a plugin way, like you say, thank you very much @bynicolas!!
    – Roberto
    Commented May 13, 2017 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.