Facebook Twitter

Plugin API ? WordPress Codex. Plugin API Languages: বাংলা • English • Español • Français • 日本語 • 한국어 • Português do Brasil • ไทย • 中文(简体) • Русский • (Add your language) Introduction This page documents the API (Application Programming Interface) hooks available to WordPress plugin developers, and how to use them.

Plugin API ? WordPress Codex

This article assumes you have already read Writing a Plugin, which gives an overview (and many details) of how to develop a plugin. This article is specifically about the API of "Hooks", also known as "Filters" and "Actions", that WordPress uses to set your plugin in motion. These hooks may also be used in themes, as described here. Hooks, Actions and Filters Hooks are provided by WordPress to allow your plugin to 'hook into' the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. You can sometimes accomplish the same goal with either an action or a filter. Function Reference Actions Modify database data.

Settings API. Settings API Languages: English • 日本語 • Português do Brasil • 中文(简体) • (Add your language) Overview The Settings API, added in WordPress 2.7, allows admin pages containing settings forms to be managed semi-automatically. It lets you define settings pages, sections within those pages and fields within the sections. New settings pages can be registered along with sections and fields inside them. Organizing registration and validation of fields still requires some effort from developers using the Settings API, but avoids a lot of complex debugging of underlying options management. NOTE: When using the Settings API, the form posts to wp-admin/options.php which provides fairly strict capabilities checking. The functions are found in wp-admin/includes/plugin.php and wp-admin/includes/template.php Function Reference Adding Setting Fields NOTE: You MUST register any options you use with add_settings_field() or they won't be saved and updated automatically.

Dashboard Widgets API. Dashboard Widgets API Languages: English • Русский • (Add your language) The Dashboard Widgets API (added in WP 2.7) makes it very simple to add new widgets to the administration dashboard. Doing so requires working knowledge of PHP and the WordPress Plugin API, but to plugin or theme authors familiar with hooking actions and filters it only takes a few minutes and can be a great way to make your plugin even more useful. Overview The Function The main tool needed to add Dashboard Widgets is the wp_add_dashboard_widget() function. Usage: wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) $widget_id - an identifying slug for your widget. The Action To run the function you will need to hook into the action 'wp_dashboard_setup' via add_action().

Examples Add an Example Widget Here's an example of a very basic dashboard widget. Advanced: Forcing your widget to the top Unfortunately this only works for people who have never re-ordered their widgets. Related. Shortcode API ? WordPress Codex. Shortcode API Languages: English • Italiano • 日本語 • Português do Brasil • Русский • (Add your language) The Shortcode API Introduced in WordPress 2.5 is the Shortcode API, a simple set of functions for creating macro codes for use in post content.

Shortcode API ? WordPress Codex

For instance, the following shortcode (in the post/page content) would add a photo gallery into the page: [gallery] It enables plugin developers to create special kinds of content (e.g. forms, content generators) that users can attach to certain pages by adding the corresponding shortcode into the page text. The Shortcode API makes it easy to create shortcodes that support attributes like this: [gallery id="123" size="medium"] The API handles all the tricky parsing, eliminating the need for writing a custom regular expression for each shortcode. As a quick start for those in a hurry, here's a minimal example of the PHP code required to create a shortcode: This will create [foobar] shortcode that returns as: foo and bar With attributes: Overview Output.