Coder Social home page Coder Social logo

quickrest's Introduction

QuickREST

A WordPress plugin which speeds up REST API requests by selective loading of plugins.

Installation

QuickRest needs to be installed as a Must Use plugin.

Install via Composer (composer require deliciousmedia/quickrest), or just clone/copy the files to your mu-plugins folder.

Usage

By default, the plugin will prevent any regular WordPress plugins from loading when a request is made to any REST API endpoint.

Plugins can be enabled on a per-namespace basis by filtering quickrest_plugin_map, for example:

function my_plugin_map_function( $map ) {
  $new_map = [
    'someplugin' => [ 'some-plugin/some-plugin.php' ],
    'wp'         => [ 'plugin-one/plugin-one.php', 'plugin-two/plugin-two.php' ]
   ];
  return array_merge_recursive( $map, $new_map );
}
add_filter( 'quickrest_plugin_map', 'my_plugin_map_function', 15, 1 );

If nothing exists within the array for the current namespace, the plugin will fallback to the _default element which you can choose to enable.

If you want the default (or any other plugin) to load all active plugins, you can do this:

add_filter(
  'quickrest_plugin_map',
  function( $map ) {
    // Remove our filter so we don't get stuck in a loop when getting the active_plugins option.
    remove_filter( 'option_active_plugins', 'quickrest_filter_plugins', PHP_INT_MAX - 1 );
    $new_map = [
      '_default' => get_option( 'active_plugins' ),
    ];
    add_filter( 'option_active_plugins', 'quickrest_filter_plugins', PHP_INT_MAX - 1 );
    return array_merge_recursive( $map, $new_map );
  },
  10,
  1
);

Built by the team at Delicious Media, a specialist WordPress development agency based in Sheffield, UK.

quickrest's People

Contributors

davepullig avatar

Stargazers

Sanz avatar Rihards Mantejs avatar Anouar Aissaoui avatar Christopher Hill avatar Leho Kraav avatar Robbert Langezaal avatar Eng Siang avatar SOAL Abdeldjallil avatar  avatar Ben Sibley avatar  avatar Mindaugas Budreika avatar İsmail Görkem Kara avatar Zimmer avatar Shiva Poudel avatar Jake Peterson avatar Valerii Vasyliev avatar Paweł Kopociński avatar Sébastien Dumont avatar Brandon Hubbard avatar Muhammed Kahraman avatar

Watchers

Leho Kraav avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.