Skip to main content

GravityView_Metabox_Tab

The class for a metabox tab in the GravityView View Settings metabox

See Also

Since: 1.8

Source: includes/admin/metaboxes/class-gravityview-metabox-tab.php:10

Details

  • Kind: class
  • Namespace: (global)

Properties

PropertyTypeDescription
$idString for use in the 'id' attribute of tags.
$titleTitle of the meta box.
$callbackFunction that fills the box with the desired content. The function should echo its output.
$screenOptional. The screen on which to show the box (like a post type, 'link', or 'comment'). Default is the current screen.
$contextOptional. The context within the screen where the boxes should display.
$priorityOptional. The priority within the context where the boxes should show ('high', 'low'). Default 'default'.
$callback_argsOptional. Data that should be set as the $args property of the box array (which is the second parameter passed to your callback). Default null.
$render_template_filestringDefine a file stored in the partials directory to render the output
$icon_class_namestringCSS class for the tab icon
$extra_nav_classstringCSS class to append to the navigation tab.

Methods

MethodDescription
__construct()Create a new metabox tab
parse_icon_class_name()If the name of the CSS class has dashicon in it, add the dashicons prefix
render()Render the tab

Method Reference

__construct()

function __construct( $id, $title='', $file='', $icon_class_name='', $callback='', $callback_args=[] )

Create a new metabox tab

Parameters

NameTypeDefaultDescription
$idstring Metabox HTML ID, without gravityview_ prefix
$titlestring''Name of the metabox. Shown in the tab.
$filestring''The file name of a file stored in the /gravityview/includes/admin/metaboxes/views/ directory to render the metabox output, or the full path to a file. If defined, callback is not used.
$icon_class_namestring''Icon class used in vertical tabs. Supports non-dashicon. If dashicons, no need for dashicons prefix
$callbackstring''Function to render the metabox, if $file is not defined.
$callback_argsarray[]Arguments passed to the callback

Returns

  • void

Since: 1.8

Source: includes/admin/metaboxes/class-gravityview-metabox-tab.php:115

parse_icon_class_name()

function parse_icon_class_name( $icon_class_name='' )

If the name of the CSS class has dashicon in it, add the dashicons prefix

Parameters

NameTypeDefaultDescription
$icon_class_namestring''Passed class name

Returns

  • string — sanitized CSS class

Since: 1.8

Source: includes/admin/metaboxes/class-gravityview-metabox-tab.php:134

render()

function render( $post )

Render the tab

If the $file parameter was passed when registering a new GravityView_Metabox_Tab, then the file is included.

The include checks for a full file path first, and if a file exists, use that file. If the file doesn't exist, then the code looks inside the [gravityview]/includes/admin/metaboxes/views/ dir.

Finally, if there's no file specified, but there's a $callback parameter specified, use the callback.

Parameters

NameTypeDefaultDescription
$postWP_PostCurrently edited post object

Since: 1.8

Source: includes/admin/metaboxes/class-gravityview-metabox-tab.php:158