A plugin for a very basic private plugin registry, designed to be a back-end for the RS Updater plugin.
Description
This plugin turns a WordPress installation into a very basic WordPress plugin registry. Together with the RS Updater plugin, plugins can be updated automatically, just like with the real WordPress plugin registry.
This plugin implements the server side of the plugin registry, while RS Updater handles the client side.
There are also some utility end-points for plugin developers, for generating meta-data and readme text from the information on the site.
Plugins
A custom post type named Plugins (internal name rsplugin
) serves as the plugin registry. The plugin posts has tags, categories and a custom taxonomy for requirements.
The slug of each plugin post should match the slug of the plugins, and the uploaded files (see later).
The term slugs of the Requirements taxonomy should match valid plugin slugs, to indicate plugin dependencies as introduced in WordPress 6.5.
Plugin meta data — /meta/ end-point
Meta data for a plugin can be generated in JSON by adding /meta/
to the end of the permalink of any plugin post.
This can be used by developer scripts to automatically update program headers and what not.
Plugin name is the post title, description is the post excerpt, text domain is post slug.
Author information (name, email, home page) comes from the user profile of the author of the plugin post.
Tags are taken from the plugin post’s tags.
If there are requirements, they’re added as the Requires Plugins
header.
The Update URI header is set to the site URL, unless the plugin is in the WordPress Plugin Registry category. This is to avoid updates from the official plugin registry if there is a name conflict.
Other fields have default values,which can be changed on the settings page.
Any query string arguments passed to the /meta/
end-point will be merged with the output, which can override or add values.
In particular, the plugin site generally don’t know about current and stable versions, which can be included in the JSON output to simplify developer scripts.
I used this to automatically update the header comment in plugin files, using version numbers extracted from a git repository.
Readme files — /readme/ end-point
Readme.txt files can be generated based on the content of the plugin post, by adding /readme/
to the end of the permalink of any plugin post.
By keeping the content simple, and inserting the correct headers, getting a valid readme.txt file is a breeze.
The meta data is generated as above, including additional values from the URL.
A stable tag can be specified on the URL as an additional path element, as in /readme/3.4/
.
Anything after a –more– marker in the post content is ignored. This is the “Read more” block in the block editor.
WordPress Updates API
The plugin supplies two more end-points which are used by the RS Updater plugin on the client side.
Plugin index
The top-level /plugin-index/
end-point generates a JSON list of all versions of all available plugins in the format needed by the WordPress Updates API.
This is used by the RS Updater plugin to check if there are updated versions available of installed plugins, and for a very basic search-by-slug function.
Plugin info
The /info/
end-point generates the JSON meta-data needed by the Updates API to display information about the plugins in various places.
For icons and banner images, see below.
The numbers of ratings and installations are entire fictitious.
Plugin icons and banners
Icons and banners for WordPress plugins have very specific size requirements, which this plugin uses to find icons and banners automatically.
Any image (jpeg, gif, png or avif) with the right size is a potential icon or banner. The plugin first searches for images uploaded to the plugin post itself, then for images uploaded on an eventual site front page, and finally for unattached images.
Icons are 128x128px or 256x256px, while banners are 772x250px or 1544x500px.
Plugin file storage
The plugin expects all plugin ZIP files to reside in a download
folder in the document root of the site.
There are no provisions for uploading new versions. I use scp(1) to copy the ZIP file to the server.
The files should be consistently named as slug-VERSION.zip.
Files in a different format or without a matching plugin post will be silently ignored.
WP cli interface
There’s a rudimentary command line interface, mostly for testing.
- wp rswp downloads — show the plugin index in JSON
- wp rswp media slug — show the icons and banners located for a plugin
- wp rswp meta slug — show the generated JSON meta data — override values can be given on the command line
- wp rswp readme slug — show the generated readme text in markdown format
Oddities
- Plugins are by default tested up to the version of WordPress running on the plugin site, so keep it updated.
Installation
This plugin is intended for a dedicated WordPress installation. It has not been tested in other circumstances. You can, however, publish post and pages without any problems.
Start with a fresh WordPress installation, and install the RS Base Plugin first, and then this plugin. In WordPress 6.5 and later it cannot go wrong.
Adjust the plugin settings, but the defaults will work.
Create a download
folder in the web site document root, where WordPress is installed, and upload your plugin ZIP files there. Depending on how you intend to upload your files, this folder might have different permission from the rest of the files.
For each plugin, create a page under Plugins. The slug of the page should match the slug of your ZIP files for the plugin.
Add tags, categories, featured image and excerpt as for any other post. Tags become keywords for the plugins.
Upload icons and banners. You can have specific media for each plugin, and fallback media uploaded on the front page or left unattached. Take care to use the correct image sizes.
In the content write an introductory paragraph, and then H2 headers for the sections Description, Installation, and Changelog. Material which shouldn’t go into the readme.txt file should come after a “More” block. The same content is used on the plugin popup where the plugins are installed.
The introductory paragraph will appear in the readme file, but not in the plugin popup in the WordPress plugin manager, client side.
If you have inter-plugin dependencies, add them to the Requirements taxonomy, making sure the slugs match between plugin posts and taxonomy terms.
Changelog
1.1
- Added settings page with some global defaults for plugin meta-data.
- Search for banners and icons automatically for each plugin, based on media sizes.
1.0
- First public version
Download
This plugin requires the RS Base Plugin to work: Download stable version 1.14.11.
Leave a Reply