/add-metabox-tab.php Secret
Last active
August 29, 2015 14:20
Adding a Settings metabox tab (in 1.8+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example of adding a metabox used in GravityView Maps metabox | |
* You can also add a filter to `gravityview/metaboxes/default` and modify the default metaboxes, but | |
* that will only work for 1.8+ | |
*/ | |
function example_register_metabox() { | |
$m = array( | |
'id' => 'maps_settings', | |
'title' => __( 'Maps', 'gravityview-maps' ), | |
'callback' => array( $this, 'render_metabox' ), | |
'icon-class' => 'dashicons-location-alt', | |
'file' => '', | |
'callback_args' => '', | |
'screen' => 'gravityview', | |
'context' => 'side', | |
'priority' => 'default', | |
); | |
if( class_exists('GravityView_Metabox_Tab') ) { | |
$metabox = new GravityView_Metabox_Tab( $m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args'] ); | |
GravityView_Metabox_Tabs::add( $metabox ); | |
} else { | |
add_meta_box( 'gravityview_'.$m['id'], $m['title'], $m['callback'], $m['screen'], $m['context'], $m['priority'] ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment