[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog
You are here: Home / WordPress plugins from oik-plugins / FREE oik plugins / oik-fields – custom fields plugin / oik-fields – Implementing a new custom field

oik-fields – Implementing a new custom field

In this example we explain how the oik-mshot plugin extends the custom field types, adding the mshot field type.

Example mshot

This is an example of an “mshot”… produced using the [bw_mshot] shortcode. This plugin uses the WordPress mshots service to obtain these screen captures. The [bw_mshot] shortcode will dynamically display the latest (cached) image. The “mshot” field type is used to store the required URL, then perform “mshots” processing when the field is required to be displayed. In the current version there is no local cacheing of the image.

Initial load

When the oik-mshot plugin is loaded the following is executed:

You appear to be a bot. Output may be restricted


oikms_plugin_loaded();
 
This function attaches action and filter hooks.

You appear to be a bot. Output may be restricted


function oikms_plugin_loaded() {
  // "oik-fields" hooks
  add_action( "oik_pre_form_field", "oikms_pre_form_field" );
  add_action( "oik_pre_theme_field", "oikms_pre_theme_field" ); 
  // other "oik" hooks
  add_action( "oik_query_field_types", "oikms_query_field_types" );
  add_action( "oik_loaded", "oikms_loaded" );
  add_action( "admin_notices", "oikms_activation" );
  add_action( "oik_admin_menu", "oikms_admin_menu" );
}
 
Click on the links to visit each action / filter hook or the implementing APIs. Note: We’re showing all of the code here. The first two hooks are needed to allow a plugin to extend the supported field types. Below is a brief explanation of each action / filter.

  • oik_pre_form_field – action

Action hook advising plugins that it’s time to provide the functions to display the input form fields for any supported fields types. This hook is only invoked once – when it’s time to display form fields.

You appear to be a bot. Output may be restricted



/**
 * Implement "oik_pre_form_field" for oik-mshot
 */
function oikms_pre_form_field() {
  oik_require( "includes/oik-mshot.inc", "oik-mshot" );
}
 
oik-mshot simply loads the file that implements the functions. In the current implementation these are dynamically named hook functions.
  • bw_form_field_mshot() – Implement bw_form_field_ hook for "mshot"

  • oik_pre_theme_field – action

Action hook advising plugins that it’s time to provide the functions to theme any supported field types. This hook is only invoked one – when it’s time to theme fields.
  • bw_theme_field_mshot() – Theme an "mshot" field

The following hooks are not part of oik-fields processing.

  • oik_query_field_types – action

Note: This is actually a filter hook invoked by oik-types It requests plugins to identify the field types that they support, so that the end user can define a field of this type.

  • oik_loaded – action

Tells the plugin that the oik base plugin has been loaded. It’s therefore safe to define the [bw_mshot] shortcode as a lazy smart shortcode – using bw_register_shortcode().

  • oik_admin_menu – action

Used by this plugin to call oik_register_plugin_server() – advising the oik base plugin that this plugin’s updates do not come from wordpress.org but elsewhere.

See also

[bw_mshot]

Published: December 3, 2013 | Last updated: January 27, 2017

Information

Component:
Letters: O

Recent plugin updates

oik v4.9.2 Upgrade to oik v4.9.2 for support for PHP 8.1 and PHP 8.2. ...
oik-block v0.3.0 oik-block v0.3.0 no longer displays the Editor selection meta box ...
oik-blocks v1.4.3 Upgrade to oik-blocks v1.4.3 for PHP 8.2 support. ...
cookie-cat v1.4.6 Upgrade to cookie-cat v1.4.6 for PHP 8.1 & PHP 8.2 support. ...
oik-fields v1.54.0 oik-fields v1.54.0 caters for the deprecation of get_page_by_title() in WordPress 6.2. ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: oikplug@oik-plugins.com

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2023. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.3.1. PHP: 7.4.33. Memory limit: 768M