plugin / openpub-internal-data
OpenPub Internal Data Plugin
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 1
Type:wordpress-plugin
pkg:composer/plugin/openpub-internal-data
Requires
- php: ^7.0|^8.0
- plugin/openpub-base: ^3.0
- wpackagist-plugin/cmb2: 2.11.*
Requires (Dev)
- 10up/wp_mock: ~0.5
- friendsofphp/php-cs-fixer: ^2.18
- mockery/mockery: ^1.5
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2026-01-29 15:44:25 UTC
README
This plugin is inspired by the pdc-internal-products plugin
Core functionality
The plugin adds private fields to openpub items and includes them with authenticated requests.
// ... "internal-data": [ { "title": "This is internal data, only visible when authenticated", "content": "<p>With html, editable in gutenberg</p>\n" } ], "links": [], // ...
Notable difference!
The plugin does not create endpoints for /internal products, and merely acts as a proxy for the base plugin. The plugin handles any incoming openpub request, and if the request is authenticated the plugin will include internal data.
Setup
You will have to edit the portal codebase to include basic auth credentials when a user is logged in.
One of the methods is to create a new singleton looking like this:
// OpenPubServiceProvider.php $this->app->singleton('openpub.items.internal', function ($app) { $config = [ 'base_uri' => env('OPENPUB_ENDPOINT'), ]; if (env('OPENPUB_APPLICATION_USERNAME') && env('OPENPUB_APPLICATION_PASSWORD')) { $config['auth'] = [ env('OPENPUB_APPLICATION_USERNAME'), env('OPENPUB_APPLICATION_PASSWORD'), ]; } return new Repository(new Client($config)); });
And make sure to use this when the user is authenticated, for example like this:
// OpenPubController.php public function show(Request $request, $title) { if (\is_user_logged_in()) { $repository = app()->make('openpub.items.internal'); } else { $repository = app()->make('openpub.items'); } // etc
Auth
Similar to pdc-internal-products this plugin uses application passwords to validate authenticated users. You can create an application password in the admin dashboard, see the wp docs
Provide the credentials in the .env file of the portal using
OPENPUB_APPLICATION_USERNAME= OPENPUB_APPLICATION_PASSWORD=
Make sure your credentials are valid, else the request will result in a 401 and the pub item will not be displayed.