本文整理汇总了PHP中cmb_Meta_Box::get_object_type方法的典型用法代码示例。如果您正苦于以下问题:PHP cmb_Meta_Box::get_object_type方法的具体用法?PHP cmb_Meta_Box::get_object_type怎么用?PHP cmb_Meta_Box::get_object_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmb_Meta_Box
的用法示例。
在下文中一共展示了cmb_Meta_Box::get_object_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Setup our class vars
* @since 1.1.0
* @param object $field A CMB field object
* @param mixed $value Field value
*/
public function __construct($field, $value)
{
$this->field = $field;
$this->value = $value;
$this->object_id = cmb_Meta_Box::get_object_id();
$this->object_type = cmb_Meta_Box::get_object_type();
}
示例2: __construct
/**
* Constructs our field object
* @since 1.1.0
* @param array $field_args Field arguments
* @param array $group_field (optional) Group field object
*/
public function __construct($field_args, $group_field = null)
{
$this->object_id = cmb_Meta_Box::get_object_id();
$this->object_type = cmb_Meta_Box::get_object_type();
$this->group = !empty($group_field) ? $group_field : false;
$this->args = $this->_set_field_defaults($field_args);
// Allow an override for the field's value
// (assuming no one would want to save 'cmb_no_override_val' as a value)
$this->value = apply_filters('cmb_override_meta_value', 'cmb_no_override_val', $this->object_id, $this->args(), $this->object_type, $this);
// If no override, get our meta
$this->value = 'cmb_no_override_val' === $this->value ? $this->get_data() : $this->value;
}
示例3: check_page_template
/**
* Add metaboxes for an specific Page Template
* @since 1.0.0
* @param bool $display To display or not
* @param array $meta_box Metabox config array
* @return bool Whether to display this metabox on the current page.
*/
public static function check_page_template($display, $meta_box)
{
if (!isset($meta_box['show_on']['key']) || 'page-template' !== $meta_box['show_on']['key']) {
return $display;
}
$object_id = cmb_Meta_Box::get_object_id();
if (!$object_id || cmb_Meta_Box::get_object_type() !== 'post') {
return false;
}
// Get current template
$current_template = get_post_meta($object_id, '_wp_page_template', true);
// See if there's a match
if ($current_template && in_array($current_template, (array) $meta_box['show_on']['value'])) {
return true;
}
return false;
}
示例4: default_sanitization
/**
* Default fallback sanitization method. Applies filters.
* @since 1.0.2
* @param mixed $meta_value Meta value
* @param array $field Field config array
*/
public static function default_sanitization($meta_value, $field)
{
$object_type = cmb_Meta_Box::get_object_type();
$object_id = cmb_Meta_Box::get_object_id();
// Allow field type validation via filter
$updated = apply_filters('cmb_validate_' . $field['type'], null, $meta_value, $object_id, $field, $object_type);
if (null != $updated) {
return $updated;
}
// we'll fallback to 'sanitize_text_field', or 'wp_kses_post`
switch ($field['type']) {
case 'wysiwyg':
// $cb = 'wp_kses';
// break;
// $cb = 'wp_kses';
// break;
case 'textarea_small':
$cb = array('cmb_Meta_Box_Sanitize', 'textarea');
break;
default:
$cb = 'sanitize_text_field';
break;
}
// Handle repeatable fields array
if (is_array($meta_value)) {
foreach ($meta_value as $key => $value) {
$meta_value[$key] = call_user_func($cb, $value);
}
} else {
$meta_value = call_user_func($cb, $meta_value);
}
return $meta_value;
}
示例5: __call
/**
* Default fallback if field's 'sanitization_cb' is NOT defined, or field type does not have a corresponding validation method
* @since 1.0.0
* @param string $name Non-existent method name
* @param array $arguments All arguments passed to the method
*/
public function __call($name, $arguments)
{
list($meta_value, $field) = $arguments;
// Handle repeatable fields array
if (is_array($meta_value)) {
foreach ($meta_value as $key => $value) {
// Allow field type validation via filter
$updated = apply_filters('cmb_validate_' . $field['type'], $value, cmb_Meta_Box::get_object_id(), $field, cmb_Meta_Box::get_object_type());
if ($updated === $value) {
// If nothing changed, we'll fallback to 'sanitize_text_field'
$updated = sanitize_text_field($value);
}
$meta_value[$key] = $updated;
}
} else {
switch ($field['type']) {
case 'wysiwyg':
case 'textarea_small':
return self::textarea($meta_value);
default:
// Allow field type validation via filter
$updated = apply_filters('cmb_validate_' . $field['type'], $meta_value, cmb_Meta_Box::get_object_id(), $field, cmb_Meta_Box::get_object_type());
if ($updated === $meta_value) {
// If nothing changed, we'll fallback to 'sanitize_text_field'
return sanitize_text_field($meta_value);
}
return $updated;
}
}
return $meta_value;
}