Git Product home page Git Product logo

remote-users's Introduction

Remote users

Plugin details

  • 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.

Description


This plugin provides custom hooks, filters, translation ready (pot but not included json) for remote users table with event driven data fetching logic.

Decisions


  1. The custom url is remote-users therefore it will look like http://domain.tld/remote-users/
  2. Used transient to store the API JSON response as an object, the reason behind this is transient support mixed data type
  3. For error handling used is_wp_error
  4. Used wp_safe_remote_head instead of wp_remote_head
  5. Used wp_safe_remote_get instead of wp_remote_get
  6. Fetched head then content to avoid overload for both requesting and responding servers
  7. Transient's expiry is calculated directly using cache tags of header data for details see private method setTransient of class Remote
  8. Didn't used wp_ajax_nopriv and wp_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
  9. 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 )
  10. Implemented deactivation hook to clear cache didn't used uninstall hook or file uninstall.php because not stored any persistent data
  11. Added table data using hook mechanism and render partial
  12. In JS click event ajax the data is not cached using local storage (if you like to do that please let me know)
  13. 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)
  14. Note plugin boilerplate was done using wp-cli's plugin scaffold
  15. 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
  16. Followed the WP suggestion to support last two versions

Installation


This section describes how to install the plugin and get it working.

e.g.

  1. Git clone inside the directory remote-users to the /wp-content/plugins/ directory
  2. Do composer update
  3. Activate the plugin through the 'Plugins' menu in WordPress

Changelog

0.1.0

  • Fetches remote users.
  • On click the anchor tag pops up user's contact info.

Hooks

Action

  1. remote-users/template/before-main-content
  2. remote-users/template/main-content
  3. remote-users/template/after-main-content

Filter

  1. remote-users/filter/page-title

Useful commands

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

remote-users's People

Contributors

gvgvgvijayan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.