Wednesday, September 14, 2022

Wordpress plugin development: Book reading

How Plugins Interact with WordPress

WordPress features many different APIs for use in your plugin. Each API, or application programming interface, helps interact with WordPress in a different way. Following is a list of the main available APIs in WordPress and their function:

  • Plugin
  • Widgets
  • Shortcode
  • Settings
  • Options
  • Dashboard Widgets
  • Rewrite 
  • Transients 
  • Database


• Plugin — Provides a set of hooks that enable plugins access to specific parts of WordPress. WordPress  contains two different types of hooks: Actions and Filters. The Action hook enables you to trigger  custom plugin code at specific points during execution. For example, you can trigger a custom function to run after a user registers a user account in WordPress. The Filter hook to modifies text before adding or after retrieving from the database.

• Widgets — Create and manage widgets in your plugin. Widgets appear under the Appearance ⇒ Widgets screen and are available to add to any registered sidebar in your theme. The API enables multiple instances of the same widget to be used throughout your sidebars.

• Shortcode — Adds shortcode support to your plugin. A shortcode is a simple hook that enables you to call a PHP function by adding something such as [shortcode] to a post or page.

• HTTP — Sends HTTP requests from your plugin. 

This API retrieves content from an external URL or for submitting content to a URL. Currently you have five different ways to send an HTTP request. This API standardizes that process and tests each method prior to executing. Based on your server configuration, the API will use the appropriate method and  make the request.

• Settings — Inserts settings or a settings section for your plugin. The primary advantage to using the Settings API is security. All settings data is scrubbed, so you do not need to worry about cross site request forgery (CSRF) and cross site scripting (XSS) attacks when saving plugin settings.

• Options — Stores and retrieves options in your plugin. This API features the capability to create new options, update existing options, delete options, and retrieve any option already defined.

• Dashboard Widgets — Creates admin dashboard widgets. Widgets automatically appear on the Dashboard of WordPress and contain all standard customization features including minimize, drag/drop, and screen options for hiding.

• Rewrite — Creates custom rewrite rules in your plugin. This API enables you to add static end-points (/custom-page/), structure tags (%postname%), and add additional feed links (/feed/json/).

• Transients — Creates temporary options (cached data) in your plugins. This API is similar to the Options API, but all options are saved with an expiration time.

• Database — Accesses the WordPress database. This includes creating, updating, deleting, and  retrieving database records for use in your plugins.


No comments:

Post a Comment