Wordpress plugin for fetching and displaying users from REST API.
On activation, using hooks and registrations method WordPress provided, this plugin adds multiple functionalities. Such as:
-
Provides an administration field for the REST API link on the admin page. On installation, a default link is set. The plugins admin template includes the WordPress Settings API.
-
Creates an endpoint where we can find the plugin page:
- /carabus where can be found in your WordPress installation. EX: www.mywebsite.domain/carabus
- Ands two REST API endpoints:
- /wp-json/carabus/plugin/users list of the users from the API link you provide. USE: www.mywebsite.domain/wp-json/carabus/plugin/users
- /wp-json/carabus/plugin/user?id= full details of one particullary user. This is triggered when you clicked on a row on the user table. EX: www.mywebsite.domain/wp-json/carabus/plugin/user?id=1
-
HTTP Caching. To avoid multiple API requests send, the API response is saved in a database for 24h under _transient_users_api using WordPress transient function for storing data temporarily in the database.
-
Plugin Translation for various words. Languages provided: US and DE.
-
The plugin DOES not includes his assets on other pages other than his own.
Because this plugin was focused mainly on the backend, the frontend user table has been created dynamically using jQuery DataTables (assets provided). No external CSS code has been written because I do not see the point of doing this, looks decent. The details container is added using AJAX.
- PHP 7.3+
- PHPUNIT 7
- Wordpress 5.2+
Go to the plugin folder located in wp-content and open the terminal. Type this commands:
- mkdir carabus
- cd carabus/
- git init
- git remote add origin https://github.com/Hawksama/api_users.git
- git fetch --all
- composer update
Finish.
Under admin, under the menu, you can find the plugin name (Carabus).
An automated test has been made and using PHPUnit and testing the constructor from carabus.php. 1 test, 1 assertion.
This plugin is open source and released under the GNU license. See LICENSE file for more info.
This plugin has being developed under WordPress TwentyTwenty theme. Other themes, can have the container fullwidth because the 'alignwide' class used on container is not defined.