[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-css v2.1.0 Update to oik-css v2.1.0 for the ability to style CSS and GeSHi output in documentation. ...
oik-types v2.3.0 Update to oik-types v2.3.0 for improved control over sort order on archives ...
UK-tides v3.1.0 UK-tides v3.1.0 now supports several additional ports. It's built with latest wp-scripts and shared libraries and tested with WordPress 6.1. ...
oik v4.8.2 Upgrade to oik v4.8.2 if you installed oik v4.8.1 from wordpress.org and found that the blocks were missing from the editor. ...
sb-chart-block v1.1.0 sb-chart-block v1.1.0 now uses chart.js v3.9.1. Tested with WordPress 6.0.1 and Gutenberg 13.8.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.1.1. PHP: 7.4.33. Memory limit: 768M