bobbingwide / oik-loader

WordPress Must Use plugin to load required plugins
0 stars 0 forks source link

edd-api=products requests need Easy-Digital-Downloads to be loaded #7

Closed bobbingwide closed 5 years ago

bobbingwide commented 5 years ago

When using the Downloads block from EDD-Blocks requests to load the products are of the form /?edd-api=products&number=9&order=DESC&orderby=price&category=&_locale=user.

When Easy Digital Downloads is not activated the Downloads block will not display anything.

Is it possible to start up Easy Digital Downloads to satisfy this request?

bobbingwide commented 5 years ago

The answer is yes. I originally added some hard coded logic in a new function in oik-loader-mu.php called oik_loader_mu_query_plugins_for_query(). This contained a hard coded check on for the edd-api query parm.

    $plugins = null;
    $querystring = $_SERVER[ 'QUERY_STRING'];
    $parms = [];
    if ( $querystring ) {
        parse_str($querystring, $parms);
    }
    if ( isset( $parms['edd-api'])) {
        $plugins[] = 'easy-digital-downloads/easy-digital-downloads.php';
    }

Then after investingating #8 I changed the logic to build the $page parameter to oik_loader_mu_query_plugins() from the first query parameter's key and value. This allows the entry to be included in the oik-loader.site.csv file. Now we need to improve the logic that builds this file to append the contents of an option field on the oik-loader admin page. And that solution will satisfy both this and #8.

bobbingwide commented 5 years ago

In the first (prototype) version I've simply added logic to append the contents of a file called oik-loader-extras.csv, which exists in the mu-plugins directory and can be used by all sites in the network. The simple reasoning is that it only really needs to be built once. If a bad actor does decide to mess with the system then some plugins may get loaded in subdomains where they're not expected but the system shouldn't fall to its knees.