本文整理汇总了PHP中RW_Meta_Box::get_class_name方法的典型用法代码示例。如果您正苦于以下问题:PHP RW_Meta_Box::get_class_name方法的具体用法?PHP RW_Meta_Box::get_class_name怎么用?PHP RW_Meta_Box::get_class_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RW_Meta_Box
的用法示例。
在下文中一共展示了RW_Meta_Box::get_class_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: field_meta
/**
* Get field meta value
* @param mixed $meta Meta value
* @param array $field Field parameters
* @return mixed
*/
public function field_meta($meta, $field)
{
if (empty($_GET['tag_ID'])) {
return $meta;
}
$term_id = intval($_GET['tag_ID']);
$single = $field['clone'] || !$field['multiple'];
$meta = get_term_meta($term_id, $field['id'], $single);
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
$meta = !$this->is_saved() && '' === $meta || array() === $meta ? $field['std'] : $meta;
// Escape attributes
$meta = call_user_func(array(RW_Meta_Box::get_class_name($field), 'esc_meta'), $meta);
// Make sure meta value is an array for clonable and multiple fields
if ($field['clone'] || $field['multiple']) {
if (empty($meta) || !is_array($meta)) {
/**
* Note: if field is clonable, $meta must be an array with values
* so that the foreach loop in self::show() runs properly
* @see self::show()
*/
$meta = $field['clone'] ? array('') : array();
}
}
return $meta;
}
示例2: meta
/**
* Get meta value
*
* @param int $post_id
* @param bool $saved
* @param array $field
*
* @return mixed
*/
static function meta($post_id, $saved, $field)
{
/**
* For special fields like 'divider', 'heading' which don't have ID, just return empty string
* to prevent notice error when displayin fields
*/
if (empty($field['id'])) {
return '';
}
/**
* Maybe set value from parent
*/
$post = get_post($post_id);
if ($post && $post->post_parent > 0) {
$property_inheritance = ud_get_wp_property('property_inheritance', array());
$type = get_post_meta($post_id, 'property_type', true);
if (isset($property_inheritance[$type]) && in_array($field['id'], $property_inheritance[$type])) {
$meta = get_post_meta($post->post_parent, $field['id'], !$field['multiple']);
}
}
if (!$meta) {
$meta = get_post_meta($post_id, $field['id'], !$field['multiple']);
}
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
$meta = !$saved && '' === $meta || array() === $meta ? $field['std'] : $meta;
// Escape attributes
$meta = call_user_func(array(RW_Meta_Box::get_class_name($field), 'esc_meta'), $meta);
return $meta;
}
示例3: end_html
/**
* Show end HTML markup for fields
* Do not show field description. Field description is shown before list of fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function end_html($meta, $field)
{
$button = $field['clone'] ? call_user_func(array(RW_Meta_Box::get_class_name($field), 'add_clone_button'), $field) : '';
// Closes the container
$html = "{$button}</div>";
return $html;
}
示例4: field_meta
/**
* Get field meta value
*
* @param mixed $meta Meta value
* @param array $field Field parameters
*
* @return mixed
*/
public function field_meta($meta, $field)
{
if (!$this->is_edit_screen()) {
return $meta;
}
$option_name = sanitize_text_field($this->page_args['option_name']);
$data = get_option($option_name);
if (empty($data)) {
$data = array();
}
if (!is_array($data)) {
$data = (array) $data;
}
$meta = isset($data[$field['id']]) ? $data[$field['id']] : $field['std'];
// Escape attributes
$meta = call_user_func(array(RW_Meta_Box::get_class_name($field), 'esc_meta'), $meta);
// Make sure meta value is an array for clonable and multiple fields
if ($field['clone'] || $field['multiple']) {
if (empty($meta) || !is_array($meta)) {
/**
* Note: if field is clonable, $meta must be an array with values
* so that the foreach loop in self::show() runs properly
* @see self::show()
*/
$meta = $field['clone'] ? array('') : array();
}
}
return $meta;
}
示例5: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
return sprintf('<input %s>
<a href="#" class="show-embed button">%s</a>
<span class="spinner"></span>
<div class="embed-code">%s</div>', self::render_attributes($attributes), $field['size'], __('Preview', 'meta-box'), $meta ? self::get_embed($meta) : '');
}
示例6: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$meta = (array) $meta;
$meta = implode(',', $meta);
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
$html = sprintf('<input %s>
<div class="rwmb-media-view" data-mime-type="%s" data-max-files="%s" data-force-delete="%s"></div>', self::render_attributes($attributes), $field['mime_type'], $field['max_file_uploads'], $field['force_delete'] ? 'true' : 'false');
return $html;
}
示例7: walk
/**
* Walk options
*
* @param mixed $meta
* @param array $field
* @param mixed $options
* @param mixed $db_fields
*
* @return string
*/
public static function walk($options, $db_fields, $meta, $field)
{
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
$walker = new RWMB_Select_Walker($db_fields, $field, $meta);
$output = sprintf('<select %s>', self::render_attributes($attributes));
$output .= $walker->walk($options, $field['flatten'] ? -1 : 0);
$output .= '</select>';
$output .= self::get_select_all_html($field);
return $output;
}
示例8: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$field_class = RW_Meta_Box::get_class_name($field);
$attributes = call_user_func(array($field_class, 'get_attributes'), $field, $meta);
$html = sprintf('<select %s>', self::render_attributes($attributes));
$html .= self::options_html($field, $meta);
$html .= '</select>';
$html .= self::get_select_all_html($field['multiple']);
return $html;
}
示例9: start_el
/**
* @see Walker::start_el()
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $object Item data object.
* @param int $depth Depth of item.
* @param int $current_object_id Item ID.
* @param array $args
*/
public function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0)
{
$label = $this->db_fields['label'];
$id = $this->db_fields['id'];
$meta = $this->meta;
$field = $this->field;
$field_class = RW_Meta_Box::get_class_name($field);
$attributes = call_user_func(array($field_class, 'get_attributes'), $field, $object->{$id});
$output .= sprintf('<li><label><input %s %s>%s</label>', RWMB_Field::render_attributes($attributes), checked(in_array($object->{$id}, $meta), 1, false), $object->{$label});
}
示例10: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$html = array();
$tpl = '<label><input %s %s> %s</label>';
$field_class = RW_Meta_Box::get_class_name($field);
foreach ($field['options'] as $value => $label) {
$attributes = call_user_func(array($field_class, 'get_attributes'), $field, $value);
$html[] = sprintf($tpl, self::render_attributes($attributes), checked($value, $meta, false), $label);
}
return implode(' ', $html);
}
示例11: walk
/**
* Walk options
*
* @param mixed $meta
* @param array $field
* @param mixed $options
* @param mixed $db_fields
*
* @return string
*/
public static function walk($options, $db_fields, $meta, $field)
{
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
$walker = new RWMB_Select_Walker($db_fields, $field, $meta);
$output = sprintf('<select %s>', self::render_attributes($attributes));
if (false === $field['multiple']) {
$output .= isset($field['placeholder']) ? "<option value=''>{$field['placeholder']}</option>" : '<option></option>';
}
$output .= $walker->walk($options, $field['flatten'] ? -1 : 0);
$output .= '</select>';
$output .= self::get_select_all_html($field);
return $output;
}
示例12: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
// Get parent field and filter to child field meta value
self::$meta = $meta;
add_filter('rwmb_field_meta', array(__CLASS__, 'child_field_meta'), 10, 3);
ob_start();
foreach ($field['fields'] as $child_field) {
$child_field['field_name'] = self::child_field_name($field['field_name'], $child_field['field_name']);
call_user_func(array(RW_Meta_Box::get_class_name($child_field), 'show'), $child_field, RWMB_Group::$saved);
}
// Remove filter to child field meta value and reset class's parent field's meta
remove_filter('rwmb_field_meta', array(__CLASS__, 'child_field_meta'));
self::$meta = null;
return ob_get_clean();
}
示例13: display_level
function display_level($options, $parent_id = 0, $active = false)
{
$id = $this->db_fields['id'];
$field = $this->field;
$meta = $this->meta;
$walker = new RWMB_Select_Walker($this->db_fields, $this->field, $this->meta);
$field_class = RW_Meta_Box::get_class_name($field);
$attributes = call_user_func(array($field_class, 'get_attributes'), $field, $meta);
$children = $options[$parent_id];
$output = sprintf('<div class="rwmb-select-tree %s" data-parent-id="%s"><select %s>', $active ? '' : 'hidden', $parent_id, RWMB_Field::render_attributes($attributes));
$output .= isset($field['placeholder']) ? "<option value=''>{$field['placeholder']}</option>" : '<option></option>';
$output .= $walker->walk($children, -1);
$output .= '</select>';
foreach ($children as $c) {
if (isset($options[$c->{$id}])) {
$output .= $this->display_level($options, $c->{$id}, in_array($c->{$id}, $meta) && $active);
}
}
$output .= '</div>';
return $output;
}
示例14: rwmb_the_field
/**
* Display the value of a field
*
* @param string $field_id Field ID. Required.
* @param array $args Additional arguments. Rarely used. See specific fields for details
* @param int|null $post_id Post ID. null for current post. Optional.
* @param bool $echo Display field meta value? Default `true` which works in almost all cases. We use `false` for the [rwmb_meta] shortcode
*
* @return string
*/
function rwmb_the_field($field_id, $args = array(), $post_id = null, $echo = true)
{
// Find field
$field = RWMB_Helper::find_field($field_id);
if (!$field) {
return '';
}
$output = call_user_func(array(RW_Meta_Box::get_class_name($field), 'the_value'), $field, $args, $post_id);
/**
* Allow developers to change the returned value of field
*
* @param mixed $value Field HTML output
* @param array $field Field parameter
* @param array $args Additional arguments. Rarely used. See specific fields for details
* @param int|null $post_id Post ID. null for current post. Optional.
*/
$output = apply_filters('rwmb_the_field', $output, $field, $args, $post_id);
if ($echo) {
echo $output;
}
return $output;
}
示例15: meta
/**
* Get post meta
*
* @param string $key Meta key. Required.
* @param int|null $post_id Post ID. null for current post. Optional
* @param array $args Array of arguments. Optional.
*
* @return mixed
*/
public static function meta($key, $args = array(), $post_id = null)
{
$post_id = empty($post_id) ? get_the_ID() : $post_id;
$args = wp_parse_args($args, array('type' => 'text', 'multiple' => false, 'clone' => false));
// Always set 'multiple' true for following field types
if (in_array($args['type'], array('checkbox_list', 'autocomplete', 'file', 'file_advanced', 'image', 'image_advanced', 'plupload_image', 'thickbox_image'))) {
$args['multiple'] = true;
}
$field = array('id' => $key, 'type' => $args['type'], 'clone' => $args['clone'], 'multiple' => $args['multiple']);
$class = RW_Meta_Box::get_class_name($field);
switch ($args['type']) {
case 'taxonomy_advanced':
if (empty($args['taxonomy'])) {
break;
}
$meta = get_post_meta($post_id, $key, !$args['multiple']);
$term_ids = wp_parse_id_list($meta);
// Allow to pass more arguments to "get_terms"
$func_args = wp_parse_args(array('include' => $term_ids, 'hide_empty' => false), $args);
unset($func_args['type'], $func_args['taxonomy'], $func_args['multiple']);
$meta = get_terms($args['taxonomy'], $func_args);
break;
case 'taxonomy':
$meta = empty($args['taxonomy']) ? array() : get_the_terms($post_id, $args['taxonomy']);
break;
case 'map':
$field = array('id' => $key, 'multiple' => false, 'clone' => false);
$meta = RWMB_Map_Field::the_value($field, $args, $post_id);
break;
case 'oembed':
$meta = RWMB_OEmbed_Field::the_value($field, $args, $post_id);
break;
default:
$meta = call_user_func(array($class, 'get_value'), $field, $args, $post_id);
break;
}
return apply_filters('rwmb_meta', $meta, $key, $args, $post_id);
}