本文整理汇总了PHP中cmb_Meta_Box::nonce_added方法的典型用法代码示例。如果您正苦于以下问题:PHP cmb_Meta_Box::nonce_added方法的具体用法?PHP cmb_Meta_Box::nonce_added怎么用?PHP cmb_Meta_Box::nonce_added使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmb_Meta_Box
的用法示例。
在下文中一共展示了cmb_Meta_Box::nonce_added方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show_form
/**
* Loops through and displays fields
* @since 1.0.0
* @param array $meta_box Metabox config array
* @param int $object_id Object ID
* @param string $object_type Type of object being saved. (e.g., post, user, or comment)
*/
public static function show_form($meta_box, $object_id = 0, $object_type = '')
{
$meta_box = self::set_mb_defaults($meta_box);
// Set/get type
$object_type = self::set_object_type($object_type ? $object_type : self::set_mb_type($meta_box));
// Set/get ID
$object_id = self::set_object_id($object_id ? $object_id : self::get_object_id());
// Add nonce only once per page.
if (!self::$nonce_added) {
wp_nonce_field(self::nonce(), 'wp_meta_box_nonce', false, true);
self::$nonce_added = true;
}
// Use nonce for verification
echo "\n<!-- Begin CMB Fields -->\n";
do_action('cmb_before_table', $meta_box, $object_id, $object_type);
echo '<table class="form-table cmb_metabox">';
foreach ($meta_box['fields'] as $field_args) {
$field_args['context'] = $meta_box['context'];
if ('group' == $field_args['type']) {
if (!isset($field_args['show_names'])) {
$field_args['show_names'] = $meta_box['show_names'];
}
self::render_group($field_args);
} else {
$field_args['show_names'] = $meta_box['show_names'];
// Render default fields
$field = new cmb_Meta_Box_field($field_args);
$field->render_field();
}
}
echo '</table>';
do_action('cmb_after_table', $meta_box, $object_id, $object_type);
echo "\n<!-- End CMB Fields -->\n";
}
示例2: show_form
/**
* Loops through and displays fields
* @since 1.0.0
* @param array $meta_box Metabox config array
* @param int $object_id Object ID
* @param string $object_type Type of object being saved. (e.g., post, user, or comment)
*/
public static function show_form($meta_box, $object_id = 0, $object_type = '')
{
$meta_box = self::set_mb_defaults($meta_box);
// Set/get type
$object_type = self::set_object_type($object_type ? $object_type : self::set_mb_type($meta_box));
// Set/get ID
$object_id = self::set_object_id($object_id ? $object_id : self::get_object_id());
// Add nonce only once per page.
if (!self::$nonce_added) {
// Use nonce for verification
wp_nonce_field(self::nonce(), 'wp_meta_box_nonce', false, true);
self::$nonce_added = true;
}
echo "\n<!-- Begin CMB Fields -->\n";
/**
* Hook before form table begins
*
* @param array $meta_box Metabox config array
* @param int $object_id The ID of the current object
* @param string $object_type The type of object you are working with.
* Usually `post` (this applies to all post-types).
* Could also be `comment`, `user` or `options-page`.
*/
do_action('cmb_before_table', $meta_box, $object_id, $object_type);
echo '<table class="form-table cmb_metabox">';
foreach ($meta_box['fields'] as $field_args) {
$field_args['context'] = $meta_box['context'];
if ('group' == $field_args['type']) {
if (!isset($field_args['show_names'])) {
$field_args['show_names'] = $meta_box['show_names'];
}
self::render_group($field_args);
} else {
$field_args['show_names'] = $meta_box['show_names'];
// Render default fields
$field = new cmb_Meta_Box_field($field_args);
$field->render_field();
}
}
echo '</table>';
/**
* Hook after form table has been rendered
*
* @param array $meta_box Metabox config array
* @param int $object_id The ID of the current object
* @param string $object_type The type of object you are working with.
* Usually `post` (this applies to all post-types).
* Could also be `comment`, `user` or `options-page`.
*/
do_action('cmb_after_table', $meta_box, $object_id, $object_type);
echo "\n<!-- End CMB Fields -->\n";
}