本文整理汇总了PHP中RWMB_Select_Field类的典型用法代码示例。如果您正苦于以下问题:PHP RWMB_Select_Field类的具体用法?PHP RWMB_Select_Field怎么用?PHP RWMB_Select_Field使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RWMB_Select_Field类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
开发者ID:ryanlabelle,项目名称:meta-box,代码行数:37,代码来源:post.php
示例2: admin_enqueue_scripts
/**
* Enqueue scripts and styles
*/
public static function admin_enqueue_scripts()
{
RWMB_Input_List_Field::admin_enqueue_scripts();
RWMB_Select_Field::admin_enqueue_scripts();
RWMB_Select_Tree_Field::admin_enqueue_scripts();
RWMB_Select_Advanced_Field::admin_enqueue_scripts();
}
开发者ID:WPTie,项目名称:VRCore,代码行数:10,代码来源:object-choice.php
示例3: 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);
}
}
开发者ID:riopse,项目名称:meta-box,代码行数:21,代码来源:user.php
示例4: walk_select_tree
/**
* Walker for displaying select in tree format
*
* @param $meta
* @param $field
* @param $elements
* @param int $parent
* @param bool $active
*
* @return string
*/
static function walk_select_tree($meta, $field, $elements, $parent = 0, $active = false)
{
if (!isset($elements[$parent])) {
return;
}
$terms = $elements[$parent];
$field['options'] = self::get_options($terms);
$classes = array('rw-taxonomy-tree');
$classes[] = $active ? 'active' : 'disabled';
$classes[] = "rwmb-taxonomy-{$parent}";
$html = '<div class="' . implode(' ', $classes) . '">';
$html .= RWMB_Select_Field::html($meta, $field);
foreach ($terms as $term) {
$html .= self::walk_select_tree($meta, $field, $elements, $term->term_id, $active && in_array($term->term_id, $meta));
}
$html .= '</div>';
return $html;
}
开发者ID:ahmedelhadi,项目名称:TestProject,代码行数:29,代码来源:taxonomy.php
示例5: save
/**
* Save meta value
* If field is cloneable, value is saved as a single entry in DB
* Otherwise value is saved as multiple entries (for backward compatibility)
*
* TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
*
* @param $new
* @param $old
* @param $post_id
* @param $field
*/
static function save($new, $old, $post_id, $field)
{
return RWMB_Select_Field::save($new, $old, $post_id, $field);
}
开发者ID:shrimp2t,项目名称:LearnPress,代码行数:16,代码来源:class.teacher.php
示例6: admin_enqueue_scripts
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
wp_enqueue_style('rwmb-object-choice', RWMB_CSS_URL . 'object-choice.css', array(), RWMB_VER);
wp_enqueue_script('rwmb-object-choice', RWMB_JS_URL . 'object-choice.js', array(), RWMB_VER, true);
RWMB_Select_Field::admin_enqueue_scripts();
RWMB_Select_Advanced_Field::admin_enqueue_scripts();
}
开发者ID:ahmadawais,项目名称:meta-box,代码行数:12,代码来源:object-choice.php
示例7: the_value
/**
* Output the field value
* Display unordered list of option labels, not option values
*
* @param array $field Field parameters
* @param array $args Additional arguments. Not used for these fields.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string Link(s) to post
*/
static function the_value($field, $args = array(), $post_id = null)
{
return RWMB_Select_Field::the_value($field, $args, $post_id);
}
开发者ID:fkallevik,项目名称:meta-box,代码行数:14,代码来源:taxonomy.php
示例8: walk_select_tree
/**
* Walker for displaying select in treeformat
*
* @param $meta
* @param $field
* @param $elements
* @param int $parent
* @param string $parent_slug
* @param bool $active
*
* @return string
*/
static function walk_select_tree($meta, $field, $elements, $parent = 0, $parent_slug = '', $active = false)
{
if (!isset($elements[$parent])) {
return;
}
$terms = $elements[$parent];
$field['options'] = self::get_options($terms);
$hidden = $active ? 'active' : 'disabled';
$disabled = disabled($active, false, false);
$id = empty($parent_slug) ? '' : " id='rwmb-taxonomy-{$parent_slug}'";
$html = "<div{$id} class='rw-taxonomy-tree {$hidden}'>";
$html .= RWMB_Select_Field::html($html, $meta, $field);
foreach ($terms as $term) {
$html .= self::walk_select_tree($meta, $field, $elements, $term->term_id, $term->slug, in_array($term->slug, $meta) && $active) . '</li>';
}
$html .= '</div>';
return $html;
}
开发者ID:phupx,项目名称:genco,代码行数:30,代码来源:taxonomy.php
示例9: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$field['options'] = self::get_options($field);
return RWMB_Select_Field::html($meta, $field);
}
开发者ID:websideas,项目名称:aquila,代码行数:13,代码来源:meta-box-custom.php
示例10: 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;
}
开发者ID:thonysmith,项目名称:LearnPress,代码行数:14,代码来源:select-advanced.php
示例11: get_attributes
/**
* Get the attributes for a field
*
* @param array $field
* @param mixed $value
*
* @return array
*/
public static function get_attributes($field, $value = null)
{
$attributes = parent::get_attributes($field, $value);
$attributes['multiple'] = false;
$attributes['id'] = false;
return $attributes;
}
开发者ID:rilwis,项目名称:meta-box,代码行数:15,代码来源:select-tree.php
示例12: 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;
}
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:15,代码来源:select-advanced.php
示例13: 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;
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:15,代码来源:select-advanced.php
示例14: array
/**
* Get the attributes for a field
*
* @param array $field
* @param mixed value
*
* @return array
*/
static function get_attributes($field, $value = null)
{
$attributes = parent::get_attributes($field, $value);
$attributes = wp_parse_args($attributes, array('data-options' => wp_json_encode($field['js_options'])));
return $attributes;
}
开发者ID:fkallevik,项目名称:meta-box,代码行数:14,代码来源:select-advanced.php
注:本文中的RWMB_Select_Field类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论