Encapsulation – computer_programming
-
I found this
https://contactform7.com/2017/06/07/on-sent-ok-is-deprecated/It completely goes against
https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)I’m trying hard to imagine why each time I add a new form I’d need to change a php file as well. Or if I copy a form to another site I have to remember there’s a line in a php somewhere.
Imagine the code on a site
document.addEventListener( 'wpcf7mailsent', function( event ) { if ( '123' == event.detail.contactFormId ) { ga( 'send', 'event', 'Contact Form', 'submit' ); } if ( '432' == event.detail.contactFormId ) { ga( 'send', 'event', 'Something else', 'submit' ); } if ( '634' == event.detail.contactFormId ) { "location = '/redirect2/';" do(something); } if ( '24' == event.detail.contactFormId ) { "location = '/redirect1/';" } if ( '452' == event.detail.contactFormId ) { fbq('track', 'Lead', 'hslo'); } }, false );
Oh I need to change the “haircut” form to do this. Oh which id is it? Where is it in the code?
What if you use this theme for (gasp) TWO+ sites? What if they have the same id? What if I’m trying to find which form ‘452’ is and now I’ll need to open 10 forms on 3 sites and see which has the id?
It is very strange you have chosen to do this. Next would you do the same to the ‘mail’ tab? And we’ll have a huge function to do mailing? No, it would make no sense. This makes no sense.
functions.php is NOT meant for site specific code. I’m not going to litter my site with dirty code like this. There has to be a better way.
- The topic ‘Encapsulation – computer_programming’ is closed to new replies.