## Seperate plugin and theme files

Question

I am in desperate need of help, regarding the following issue:

I need to establish an API Connection to Salesforce, so that a user can search and retrieve certain data out of Salesforce.
I thought, that a plugin would be the best choice, so that the functionality is not dependent on a certain theme.

Here comes my issue:
I want the search form to be added via short-code, so that it can be reused. So far so good.
Then I gave the form an action attribute to call another php file, which retrieves the entered data to search for, and list the search results.

Now when I call that second file, I get the error Call to undefined function get_header().
But I need the header of the selected theme to be displayed on that page, so that the whole website has the same look and feel.

It seems, as if I am going horribly wrong with my approach.

My file structure looks as follows:

    wp-content
--themes
-- myTheme

--plugins
--myPlugin
--views
--page-results.php


And this is how I add the shortcode for the form to be displayed:

   /**
* RETURN THE SEARCH FORM
* @return string
*/

$html=" <div class="col-sm-6 col-md-offset-3 d-flex justify-content-center text-center form-column"> <form class="wdv_search_form w-75 mt-3" method="get" action="wp-content/plugins/myPlugin/views/page-results.php"> <div class="mb-2"> <input type="text" class="form-control text-center" id="searchByLocation" placeholder="City"> </div> <div class="mb-2"> <input type="text" class="form-control text-center" id="searchByName" placeholder="Name"> </div> <div class="mb-2"> <select name="countryChoice" class="text-center"> <option value="EN">England</option> </select> </div> <button type="submit" class="btn btn-transparent text-light mt-3">GO</button> </form> </div>"; echo$html;
}



Is my approach right and what would be best-practice for my use-case?

0
3 months 2022-06-22T06:56:35-05:00 0 Answers 0 views 0