[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-themes v1.4.0 

Update to oik-themes v1.4.0 to support Full Site Editing (FSE) themes. FSE themes, which are currently experimental, deliver block based templates and template parts.

 ...
oik-clone v2.0.1 oik-clone v2.0.1 contains a fix for a 500 internal server error being produced when cloning content with certain taxonomy terms. ...
SB Chart block v0.1.1 

Update to SB Chart block v0.1.1 for improved enqueing of the chart.js Javascript and better colours in the Gutenberg palette.

 ...
Slog v1.3.1 

Update to Slog v1.3.1 for a new Driver tab and improved display of charts grouping Elapsed times.

 ...
SB-Chart-Block v0.0.8 SB-Chart-Block v0.0.8, a WordPress single block plugin, supports 4 different chart types; Line, Bar, Horizontal bar and Pie. ...

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: [email protected]

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-2021. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins