本文整理汇总了PHP中cmb_Meta_Box::set_mb_defaults方法的典型用法代码示例。如果您正苦于以下问题:PHP cmb_Meta_Box::set_mb_defaults方法的具体用法?PHP cmb_Meta_Box::set_mb_defaults怎么用?PHP cmb_Meta_Box::set_mb_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmb_Meta_Box
的用法示例。
在下文中一共展示了cmb_Meta_Box::set_mb_defaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_form
/**
* Displays form markup
* @since 0.1.3
* @param int $term_id Term ID
*/
public function display_form($term_id)
{
if (!class_exists('cmb_Meta_Box')) {
return;
}
$this->do_override_filters($term_id);
// Fill in the mb defaults
$meta_box = cmb_Meta_Box::set_mb_defaults($this->fields());
// Make sure that our object type is explicitly set by the metabox config
cmb_Meta_Box::set_object_type(cmb_Meta_Box::set_mb_type($meta_box));
// Add object id to the form for easy access
printf('<input type="hidden" name="term_opt_name" value="%s">', $this->id($term_id));
// Show cmb form
cmb_print_metabox($meta_box, $this->id($term_id));
}
示例2: cmb_metabox_form
/**
* Display a metabox form & save it on submission
* @since 1.0.0
* @param array $meta_box Metabox config array
* @param int $object_id Object ID
* @param boolean $return Whether to return or echo form
* @return string CMB html form markup
*/
function cmb_metabox_form($meta_box, $object_id, $echo = true)
{
$meta_box = cmb_Meta_Box::set_mb_defaults($meta_box);
// Make sure form should be shown
if (!apply_filters('cmb_show_on', true, $meta_box)) {
return '';
}
// Make sure that our object type is explicitly set by the metabox config
cmb_Meta_Box::set_object_type(cmb_Meta_Box::set_mb_type($meta_box));
// Save the metabox if it's been submitted
// check permissions
// @todo more hardening?
if (isset($_POST['submit-cmb'], $_POST['object_id'], $_POST['wp_meta_box_nonce']) && wp_verify_nonce($_POST['wp_meta_box_nonce'], cmb_Meta_Box::nonce()) && $_POST['object_id'] == $object_id) {
cmb_save_metabox_fields($meta_box, $object_id);
}
// Show specific metabox form
// Get cmb form
ob_start();
cmb_print_metabox($meta_box, $object_id);
$form = ob_get_contents();
ob_end_clean();
$form_format = apply_filters('cmb_frontend_form_format', '<form class="cmb-form" method="post" id="%s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%s">%s<input type="submit" name="submit-cmb" value="%s" class="button-primary"></form>', $object_id, $meta_box, $form);
$form = sprintf($form_format, $meta_box['id'], $object_id, $form, __('Save'));
if ($echo) {
echo $form;
}
return $form;
}