humanmade/see-in-rest-api

Quickly request the current resource off the WordPress REST API via the WordPress admin bar.

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 9

Watchers: 21

Forks: 1

Open Issues: 0

Type:wordpress-plugin

1.0.0 2021-03-16 10:28 UTC

This package is auto-updated.

Last update: 2024-11-18 15:08:43 UTC


README

Quickly request the current resource off the WordPress REST API via the WordPress admin bar.

Introduction

This plugin adds a new node to the WordPress admin bar, See in REST API, that allows for requesting the current resource off the WordPress REST API. This works both in the WordPress admin and on the front end of your site.

Supported resources:

  • posts (including attachments);
  • terms;
  • users (including your profile).

The plugin does not perform any checks around permissions. If a resource is not available or readable, you will find out after you clicked the link. 🙂

Installation

Requirements:

  • PHP 7.2 or higher;
  • WordPress 5.5 or higher.

Install with Composer:

composer require humanmade/see-in-rest-api

This plugin follows Semantic Versioning.

Usage

PHP Filters

see_in_rest_api.rest_url

This filter allows the user to modify the URL that the admin bar node will link to.

Arguments:

  • $rest_url (string): REST API URL for the current resource.

Usage Example:

// Show the See in REST API admin bar node for administrators only.
add_filter( 'see_in_rest_api.rest_url', function ( string $rest_url ): string {

	return current_user_can( 'manage_options' ) ? $rest_url : '';
} );

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.