Title: Only REST API
Author: Braad
Published: <strong>25 september 2015</strong>
Last modified: 7 december 2015

---

Plugins zoeken

Deze plugin **is niet getest met de laatste 3 grotere versies van WordPress**. Mogelijk
wordt het niet meer onderhouden of ondersteund. Ook kunnen er compatibiliteitsproblemen
ontstaan wanneer het wordt gebruikt met recentere versies van WordPress.

![](https://s.w.org/plugins/geopattern-icon/only-rest-api.svg)

# Only REST API

 Door [Braad](https://profiles.wordpress.org/braad/)

[Download](https://downloads.wordpress.org/plugin/only-rest-api.1.0.0.zip)

 * [Details](https://nl.wordpress.org/plugins/only-rest-api/#description)
 * [Beoordelingen](https://nl.wordpress.org/plugins/only-rest-api/#reviews)
 *  [Installatie](https://nl.wordpress.org/plugins/only-rest-api/#installation)
 * [Ontwikkeling](https://nl.wordpress.org/plugins/only-rest-api/#developers)

 [Ondersteuning](https://wordpress.org/support/plugin/only-rest-api/)

## Beschrijving

Got a WordPress install that serves only as the data layer and/or admin UI of your
web application?

This plugin will effectively turn off all default front end output, redirect all
front end urls to the main site url, and optionally display a message of your choice.
The message can be a simple plain text message or you can use the included filters
to completely control the HTML output.

All activity in the wp-admin and all requests for assets like images, scripts, files,
etc. will be unaffected by this plugin. Only requests that go through the `template_redirect`
action will be affected.

#### Message Output

Rather than contaminate the data structures you might be using for your application(
like posts and pages) this plugin includes a settings page with a simple textarea
box where you can save any basic message you want to show. The message content is
stored in the options table, and the textarea supports all the same HTML that you
can use in post content.

You can use the `only_rest_api_page_content` filter to include any custom HTML output
you want inside the `<body>` tags, or you can use the `only_rest_api_page_html` 
filter to completely replace all HTML output of the message page, including the `
<html>` and `<head>` tags.

There is also an `only_rest_api_page_css` filter that allows you to override the
5 lines of CSS this plugin includes to center the message on the page.

If you want a hook added or have a feature request let me know. Pull requests are
welcome [on Github](https://github.com/BraadMartin/only-rest-api).

#### Filter Examples

Use custom HTML inside the `<body>` tags:

    ```
    add_filter( 'only_rest_api_page_content', 'xxx_page_content' );
    function xxx_page_content( $content ) {

        $content = '<div class="custom-output">Sorry, I Only Speak REST. Please try again at a proper endpoint.</div>';

        return $content;
    }
    ```

Add custom CSS to the default output:

    ```
    add_filter( 'only_rest_api_page_css', 'xxx_page_css' );
    function xxx_page_css( $css ) {

        $css .= '.page-content { color: red; font-size: 72px; }';

        return $css;
    }
    ```

Replace the entire HTML output for the page:

    ```
    add_filter( 'only_rest_api_page_html', 'xxx_page_html' );
    function xxx_page_html( $html ) {

        ob_start();

        ?>
        <!doctype html>
        <html lang="">
            <head>
                <meta charset="utf-8">
                <meta http-equiv="x-ua-compatible" content="ie=edge">
                <title>Call me back over the REST API yo!</title>
                <meta name="description" content="">
                <meta name="viewport" content="width=device-width, initial-scale=1">
                <link rel="stylesheet" type="text/css" href="your-awesome-stylesheet.css">
                <script type="text/javascript">
                    // Do neat stuff...
                </script>
            </head>
            <body>
                <div class="page-content">
                    Ain't nobody got time for non-REST API requests. Please try again at a proper endpoint. :)
                </div>
            </body>
        </html>
        <?php

        $html = ob_get_clean();

        return $html;
    }
    ```

## Schermafbeeldingen

 * [[
 * Customizable message shown on the front end for non-REST API requests

## Installatie

#### Handmatige installatie

 1. Upload the entire `/only-rest-api` directory to the `/wp-content/plugins/` directory.
 2. Activate Only REST API through the ‘Plugins’ menu in WordPress.

#### Better Installation

 1. Go to Plugins > Add New in your WordPress admin and search for Only REST API.
 2. Click Install.

## FAQ

  Will this plugin affect assets like images, stylesheets, files, etc?

No, this plugin hooks into the `template_redirect` action, which only fires when
a front end page of some kind is being served.

  Does the plugin work with both v1 and v2 of the WP REST API?

Yes! This plugin supports both versions of the WP REST API and will support the 
final version that gets merged into core.

## Beoordelingen

Er zijn geen beoordelingen voor deze plugin.

## Bijdragers & ontwikkelaars

“Only REST API” is open source software. De volgende personen hebben bijgedragen
aan deze plugin.

Bijdragers

 *   [ Braad ](https://profiles.wordpress.org/braad/)

[Vertaal “Only REST API” in je eigen taal.](https://translate.wordpress.org/projects/wp-plugins/only-rest-api)

### Interesse in ontwikkeling?

[Bekijk de code](https://plugins.trac.wordpress.org/browser/only-rest-api/), haal
de [SVN repository](https://plugins.svn.wordpress.org/only-rest-api/) op, of abonneer
je op het [ontwikkellog](https://plugins.trac.wordpress.org/log/only-rest-api/) 
via [RSS](https://plugins.trac.wordpress.org/log/only-rest-api/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.0.0

 * First Release

## Meta

 *  Versie **1.0.0**
 *  Laatst geüpdatet **10 jaar geleden**
 *  Actieve installaties **30+**
 *  WordPress versie ** 4.0 of nieuwer **
 *  Getest t/m **4.4.34**
 *  Taal
 * [English (US)](https://wordpress.org/plugins/only-rest-api/)
 * Tags
 * [api](https://nl.wordpress.org/plugins/tags/api/)[JSON](https://nl.wordpress.org/plugins/tags/json/)
   [only](https://nl.wordpress.org/plugins/tags/only/)[rest](https://nl.wordpress.org/plugins/tags/rest/)
 *  [Geavanceerde weergave](https://nl.wordpress.org/plugins/only-rest-api/advanced/)

## Waarderingen

Er zijn nog geen beoordelingen ingediend.

[Your review](https://wordpress.org/support/plugin/only-rest-api/reviews/#new-post)

[Bekijk alle beoordelingen](https://wordpress.org/support/plugin/only-rest-api/reviews/)

## Bijdragers

 *   [ Braad ](https://profiles.wordpress.org/braad/)

## Ondersteuning

Iets te melden? Hulp nodig?

 [Het supportforum bekijken](https://wordpress.org/support/plugin/only-rest-api/)

## Doneren

Wil je de groei van deze plugin ondersteunen?

 [ Doneer aan deze plugin ](http://braadmartin.com/)