I just created a WordPress plugin with a custom template that handles a $_GET request before the HTML code. Wordpress team is asking me to put this code inside a function.
I understand that for admin panel forms the way is to use
admin-post.php
or
add_action( 'admin_post_****', '****' );
But how do you handle a front-end form post (not that of admin panel). In what kind of a function should I put my template's $_GET or $_POST handling code. Because wordpress.org is not accepting my plugin without these request handles to be inside a function.
admin-post
is acceptable for front-end form processing, there are actions for both logged-in and not-logged-in users. It might help to explain what your form does exactly- are you adding data to the database, filtering a query, etc..