Awesome Users Plugin
A WordPress plugin to list external users into a virtual page.
by Raphael Batagini · github.com/raphaelbatagini/awesome-users-plugin · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/raphaelbatagini/awesome-users-plugin/releases/download/1.0.0/awesome-users.zipA WordPress plugin to list external users into a virtual page.
Table of Contents
- Technologies
- Plugin usage
- Install
- Interacting with plugin code
- Changelog
- License
- Improvements to be done
Technologies
- PHP 7.4+ - At the moment the most recent version of PHP supported by WordPress;
- WordPress 6+ - The latest version of WordPress which gives us support for some front-end resources described below;
- Composer 2 - The latest version of Composer;
- PHPUnit 9.5 - The latest version supported by PHP previous to version 8;
- Mockery 1.5 - Mock classes out of the PHPUnit default scope;
- WP_Mock 0.5 - Mock WordPress user functions;
- FakerPHP 1.2 - Generate unit tests random data making tests results more reliable;
- NodeJS 14.0+ - Dependency for the front-end resources listed below;
- Webpack 5.75 - Manage front-end build process;
- Babel 7.20 - Transpile React code to ES5;
- React 17.0 - Javascript library used to consume the plugin APIs asynchronous. Has not been installed apart of WordPress as explained below;
- WordPress Dependency Extration Webpack Plugin 4.5 - Webpack plugin to allow consuming WordPress front-end resources, like React and its components, importing then as modules in others Javascript files.
Plugin usage
API endpoints
This plugin expose two API endpoints to deal with users. They are:
- Users List - /wp-json/awesome-users/v1/list
- User Details - /wp-json/awesome-users/v1/details/{user_id}
Front-end
The plugin front-end page can be found at this URL:
https://YOUR_WEBSITE.COM/my-awesome-users
Cache
The plugin makes use of WP_Object_Cache when doing external http requests, so it's completely viable to work with persistent cache plugins and tools like Redis or Memcached if you want more performance.
The cache can be easy applied to another functions just using the CacheTool utility like the example below:
$result = CacheTool::execute('key', function () {
return someSlowProcess();
});
The closure will only be executed if the key is not cached.
Install
Composer dependencies
Use the command below to install and load composer dependencies:
$ composer install
NPM dependencies
Use the command below to install NPM dependencies and generate front-end assets:
$ npm run build
Download
You can also download the plugin from the repository releases here.
Interacting with plugin code
Checking code standards
$ vendor/bin/phpcs
Executing unit tests
$ vendor/bin/phpunit
Change Log
The plugin change log can be found here.
License
The plugin license can be found here.
Improvements to be done
- Increase unit tests coverage;
- Add SASS and use it to style the plugin page;
- Create an NPM dev script with hot reload support;
- Change front-end build to support JSX extension and TypeScript.
Releases
1 release. Each count is every asset in that release; expand a row for the breakdown.