- Contributors: Vijayan G
- Tags: remote, interview
- Requires at least: 5.5
- Tested up to: 5.7
- Requires PHP: 7.3
- Stable tag: 0.1.0
- License: GPLv2 or later
- License URI: https://www.gnu.org/licenses/gpl-2.0.html
This plugin is used to fetch the remote users through 3rd party API.
This plugin provides custom hooks, filters, translation ready (pot but not included json) for remote users table with event driven data fetching logic.
- The custom url is
remote-users
therefore it will look like http://domain.tld/remote-users/ - Used transient to store the API JSON response as an object, the reason behind this is transient support mixed data type
- For error handling used
is_wp_error
- Used
wp_safe_remote_head
instead ofwp_remote_head
- Used
wp_safe_remote_get
instead ofwp_remote_get
- Fetched head then content to avoid overload for both requesting and responding servers
- Transient's expiry is calculated directly using cache tags of header data for details see private method
setTransient
of class Remote - Didn't used
wp_ajax_nopriv
andwp_ajax
hooks instead of that directly fetched in JS the reason is the data are publicly available so instead of abstract and show only necessary key-value directly fetched - Constants are place in their respective context instead of centralize it in common file (mostly I place all constants in an array instead of using const or define therefore using
wp_json_encode
and pass it to JS through the function wp_add_inline_script ) - Implemented deactivation hook to clear cache didn't used uninstall hook or file
uninstall.php
because not stored any persistent data - Added table data using hook mechanism and render partial
- In JS click event ajax the data is not cached using local storage (if you like to do that please let me know)
- Didn't focused in any UI enhancement (but verified in twentytwentyone the table was responsive and lagging of marging and padding but I can able to do that)
- Note plugin boilerplate was done using wp-cli's plugin scaffold
- For template passed data using global variable the reason is the argument passing is applicable in themes template only Passing arguments to template files in WordPress 5.5
- Followed the WP suggestion to support last two versions
This section describes how to install the plugin and get it working.
e.g.
- Git clone inside the directory
remote-users
to the/wp-content/plugins/
directory - Do
composer update
- Activate the plugin through the 'Plugins' menu in WordPress
0.1.0
- Fetches remote users.
- On click the anchor tag pops up user's contact info.
remote-users/template/before-main-content
remote-users/template/main-content
remote-users/template/after-main-content
remote-users/filter/page-title
Context | Command |
---|---|
WP CLI -> Rewrite API | wp rewrite list --match="remote-users" |
WP CLI -> Transient API | wp transient get 'vg-remote-users' |
Composer | composer update |
Coding Standard | vendor/bin/phpcs --standard="Inpsyde" ./remote-users.php ./inc ./templates |
Coding Beautifier | vendor/bin/phpcbf --standard="Inpsyde" ./remote-users.php ./inc ./templates |
Testing -> Unit Testing | vendor/bin/phpunit |