Virtual
field type to define a virtual field.
Supported virtual field types
oik-fields provides two virtual fields which you can use with thefields=
parameter for shortcodes that supports it.
Name | Title | Notes |
---|---|---|
file_size | File size | Displays the file size in bytes of an attachment |
dimensions | Dimensions | Displays the width and height of an attached image |
Sample code
In this example, taken from oik-shortcodes we create avirtual
field called _oik_sc_the_title_cb which is a checkbox indicating whether or not a shortcode will be expanded during the_title filter processing.
You appear to be a bot. Output may be restricted
$the_title_args = array( "#callback" => "bw_get_shortcode_expands_in_titles" , "#parms" => "_oik_sc_code" , "#plugin" => "oik" , "#file" => "shortcodes/oik-codes.php" , "#form" => false , "#hint" => "virtual field" ); bw_register_field( "_oik_sc_the_title_cb", "virtual", "Expands in 'the_title'?", $the_title_args ); bw_register_field_for_object_type( "_oik_sc_the_title_cb", "oik_shortcodes" );
Form display
When displayed in the Fields meta boxbw_fields display
When displayed by [bw_fields] it appears like this.Notes
Related
- bw_form_field_virtual() – Implement bw_form_field_ hook for ‘virtual’ field
- bw_get_shortcode_expands_in_titles() – Return Yes / No to indicate if a shortcode expands in titles
- bw_theme_field_virtual() – Theme a field of type ‘virtual’