Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Creating Plugins

  • WordPress Codex - Writing a Plugin
  • WordPress Codex - Plugin API
    • 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. There are two kinds of hooks:

      • Actions

      • Filters

    • You can sometimes accomplish the same goal with either an action or a filter. For example, if you want your plugin to change the text of a post, you might add an action function to publish_post (so the post is modified as it is saved to the database), or a filter function to the_content (so the post is modified as it is displayed in the browser screen).
    • Actions

      • Actions are triggered by specific events that take place in WordPress, such as publishing a post, changing themes, or displaying an administration screen. An Action is a custom PHP function defined in your plugin (or theme) and hooked, i.e. set to respond, to some of these events. Actions usually do one or more of the following:

        • Modify database data.

        • Send an email message.

        • Modify the generated administration screen or front-end page sent to a user browser.

      • The basic steps to make this happen (described in more detail below) are:

        • Create a PHP function that should execute when a specific WordPress event occurs, in your plugin file.

        • Hook this function to the event by using the add_action() function.

        • Put your PHP function in a plugin file, and activate it.


    • Filters
      • Filters are functions that WordPress passes data through, at certain points in execution, just before taking some action with the data (such as adding it to the database or sending it to the browser screen). Filters sit between the database and the browser (when WordPress is generating pages), and between the browser and the database (when WordPress is adding new posts and comments to the database); most input and output in WordPress passes through at least one filter. WordPress does some filtering by default, and your plugin can add its own filtering.

      • The basic steps to add your own filters to WordPress (described in more detail below) are:

        • Create the PHP function that filters the data.

        • Hook to the filter in WordPress, by calling add_filter().

        • Put your PHP function in a plugin file, and activate it.

Actions

Tasks

  • Remove the sidebar when the user is on mobile.

...