本文整理汇总了PHP中RWMB_Select_Field::normalize_field方法的典型用法代码示例。如果您正苦于以下问题:PHP RWMB_Select_Field::normalize_field方法的具体用法?PHP RWMB_Select_Field::normalize_field怎么用?PHP RWMB_Select_Field::normalize_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RWMB_Select_Field
的用法示例。
在下文中一共展示了RWMB_Select_Field::normalize_field方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalize_field
/**
* Add default value for 'taxonomy' field
*
* @param $field
*
* @return array
*/
static function normalize_field($field)
{
$default_args = array('hide_empty' => false);
// Set default args
$field['options']['args'] = !isset($field['options']['args']) ? $default_args : wp_parse_args($field['options']['args'], $default_args);
$tax = get_taxonomy($field['options']['taxonomy']);
$field['placeholder'] = empty($field['placeholder']) ? sprintf(__('Select a %s', 'framework'), $tax->labels->singular_name) : $field['placeholder'];
switch ($field['options']['type']) {
case 'select_advanced':
$field = RWMB_Select_Advanced_Field::normalize_field($field);
break;
case 'checkbox_list':
case 'checkbox_tree':
$field = RWMB_Checkbox_List_Field::normalize_field($field);
break;
case 'select':
case 'select_tree':
$field = RWMB_Select_Field::normalize_field($field);
break;
default:
$field['options']['type'] = 'select';
$field = RWMB_Select_Field::normalize_field($field);
}
if (in_array($field['options']['type'], array('checkbox_tree', 'select_tree'))) {
if (isset($field['options']['args']['parent'])) {
$field['options']['parent'] = $field['options']['args']['parent'];
unset($field['options']['args']['parent']);
} else {
$field['options']['parent'] = 0;
}
}
$field['field_name'] = "{$field['id']}[]";
return $field;
}
示例2: normalize_field
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field = wp_parse_args($field, array('post_type' => 'post', 'field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
/**
* Set default placeholder
* - If multiple post types: show 'Select a post'
* - If single post type: show 'Select a %post_type_name%'
*/
if (empty($field['placeholder'])) {
$label = __('Select a post', 'meta-box');
if (is_string($field['post_type']) && post_type_exists($field['post_type'])) {
$post_type_object = get_post_type_object($field['post_type']);
$label = sprintf(__('Select a %s', 'meta-box'), $post_type_object->labels->singular_name);
}
$field['placeholder'] = $label;
}
if ($field['parent']) {
$field['multiple'] = false;
$field['field_name'] = 'parent_id';
}
$field['query_args'] = wp_parse_args($field['query_args'], array('post_type' => $field['post_type'], 'post_status' => 'publish', 'posts_per_page' => -1));
switch ($field['field_type']) {
case 'select':
return RWMB_Select_Field::normalize_field($field);
break;
case 'select_advanced':
default:
return RWMB_Select_Advanced_Field::normalize_field($field);
}
}
示例3: normalize_field
/**
* Add default value for 'taxonomy' field
*
* @param $field
*
* @return array
*/
static function normalize_field($field)
{
$default_args = array('hide_empty' => false);
//Set default args
$field['options']['args'] = !isset($field['options']['args']) ? $default_args : wp_parse_args($field['options']['args'], $default_args);
//Field name be an array by default
$field['field_name'] = "{$field['id']}[]";
switch ($field['options']['type']) {
case 'select_advanced':
$field = RWMB_Select_Advanced_Field::normalize_field($field);
break;
case 'checkbox_list':
case 'checkbox_tree':
$field = RWMB_Checkbox_List_Field::normalize_field($field);
break;
case 'select':
case 'select_tree':
$field = RWMB_Select_Field::normalize_field($field);
break;
default:
$field['options']['type'] = 'select';
$field = RWMB_Select_Field::normalize_field($field);
}
if (in_array($field['options']['type'], array('checkbox_tree', 'select_tree'))) {
if (isset($field['options']['args']['parent'])) {
$field['options']['parent'] = $field['options']['args']['parent'];
unset($field['options']['args']['parent']);
} else {
$field['options']['parent'] = 0;
}
}
return $field;
}
示例4: array
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field = parent::normalize_field($field);
$field = wp_parse_args($field, array('js_options' => array()));
$field['js_options'] = wp_parse_args($field['js_options'], array('allowClear' => true, 'width' => 'resolve', 'placeholder' => $field['placeholder']));
return $field;
}
示例5: array
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field = parent::normalize_field($field);
$field = wp_parse_args($field, array('js_options' => array()));
$field['js_options'] = wp_parse_args($field['js_options'], array('allowClear' => true, 'width' => 'resolve', 'placeholder' => empty($field['std']) ? __('Select a value', 'rwmb') : $field['std']));
$field['std'] = '';
return $field;
}
示例6: array
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field = wp_parse_args($field, array('js_options' => array()));
$field['js_options'] = wp_parse_args($field['js_options'], array('allowClear' => true, 'width' => 'resolve', 'placeholder' => __('Select a value', 'rwmb')));
$field['default'] = isset($field['default']) ? $field['default'] : $field['js_options']['placeholder'];
$field = parent::normalize_field($field);
return $field;
}
示例7: normalize_field
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field = wp_parse_args($field, array('field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
$field['std'] = empty($field['std']) ? __('Select an user', 'meta-box') : $field['std'];
$field['query_args'] = wp_parse_args($field['query_args'], array('orderby' => 'display_name', 'order' => 'asc', 'role' => '', 'fields' => 'all'));
switch ($field['field_type']) {
case 'select':
return RWMB_Select_Field::normalize_field($field);
break;
case 'select_advanced':
default:
return RWMB_Select_Advanced_Field::normalize_field($field);
}
}
示例8: normalize_field
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$default_post_type = __('用户', 'rwmb');
$field = wp_parse_args($field, array('field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
$field['std'] = empty($field['std']) ? sprintf(__('已选择 %s', 'rwmb'), $default_post_type) : $field['std'];
$field['query_args'] = wp_parse_args($field['query_args'], array('orderby' => 'display_name', 'order' => 'asc', 'role' => '', 'fields' => 'all'));
switch ($field['field_type']) {
case 'select':
return RWMB_Select_Field::normalize_field($field);
break;
case 'select_advanced':
default:
return RWMB_Select_Advanced_Field::normalize_field($field);
}
}
示例9: normalize_field
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$default_post_type = __('Post', 'meta-box');
$field = wp_parse_args($field, array('field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
$field['std'] = empty($field['std']) ? sprintf(__('Select a %s', 'meta-box'), $default_post_type) : $field['std'];
if ($field['parent']) {
$field['multiple'] = false;
$field['field_name'] = 'parent_id';
}
switch ($field['field_type']) {
case 'select':
return RWMB_Select_Field::normalize_field($field);
break;
case 'select_advanced':
default:
return RWMB_Select_Advanced_Field::normalize_field($field);
}
}
示例10: normalize_field
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$default_post_type = __('Post', 'rwmb');
if (is_string($field['post_type'])) {
$post_type_object = get_post_type_object($field['post_type']);
$default_post_type = $post_type_object->labels->singular_name;
}
$field = wp_parse_args($field, array('post_type' => 'post', 'field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
$field['std'] = empty($field['std']) ? sprintf(__('Select a %s', 'rwmb'), $default_post_type) : $field['std'];
if ($field['parent']) {
$field['multiple'] = false;
$field['field_name'] = 'parent_id';
}
$field['query_args'] = wp_parse_args($field['query_args'], array('post_type' => $field['post_type'], 'post_status' => 'publish', 'posts_per_page' => -1));
switch ($field['field_type']) {
case 'select':
return RWMB_Select_Field::normalize_field($field);
break;
case 'select_advanced':
default:
return RWMB_Select_Advanced_Field::normalize_field($field);
}
}
示例11: normalize_field
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field = wp_parse_args($field, array('post_status' => 'publish'));
$field['std'] = empty($field['std']) ? _x('Select a Page', 'pages', 'the7mk2') : $field['std'];
return RWMB_Select_Field::normalize_field($field);
}