Wednesday, June 22, 2022
HomeWordPress DevelopmentSeperate plugin and theme information

Seperate plugin and theme information


I’m in determined want of assist, relating to the next concern:

I would like to determine an API Connection to Salesforce, so {that a} person can search and retrieve sure knowledge out of Salesforce.
I assumed, {that a} plugin could be the only option, in order that the performance is just not depending on a sure theme.

Right here comes my concern:
I would like the search kind to be added through short-code, in order that it may be reused. To this point so good.
Then I gave the shape an motion attribute to name one other php file, which retrieves the entered knowledge to seek for, and listing the search outcomes.

Now after I name that second file, I get the error Name to undefined operate get_header().
However I would like the header of the chosen theme to be displayed on that web page, in order that the entire web site has the identical feel and appear.

It appears, as if I’m going horribly fallacious with my strategy.

My file construction seems as follows:

    wp-content
              --themes
                 -- myTheme

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

And that is how I add the shortcode for the shape to be displayed:

   /**
 * RETURN THE SEARCH FORM
 * @return string
 */
operate add_search_form() {



    $html="
    <div class="col-sm-6 col-md-offset-3 d-flex justify-content-center text-center form-column">

    <kind class="wdv_search_form w-75 mt-3" methodology="get" motion="wp-content/plugins/myPlugin/views/page-results.php">
        <div class="mb-2">
            <enter kind="textual content" class="form-control text-center" id="searchByLocation"
                   placeholder="Metropolis">
        </div>
        <div class="mb-2">
            <enter kind="textual content" class="form-control text-center" id="searchByName"
                   placeholder="Identify">
        </div>
        <div class="mb-2">
            <choose title="countryChoice" class="text-center">
                <possibility worth="EN">England</possibility>
            </choose>
        </div>

        <button kind="submit" class="btn btn-transparent text-light mt-3">GO</button>
    </kind>

</div>";

    echo $html;
}

add_shortcode( 'wdv_search_form', 'add_search_form' );

Is my strategy proper and what could be best-practice for my use-case?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments