当前位置: 首页>>代码示例>>PHP>>正文


PHP RWMB_Select_Field::normalize_field方法代码示例

本文整理汇总了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;
 }
开发者ID:ahmedelhadi,项目名称:TestProject,代码行数:41,代码来源:taxonomy.php

示例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);
     }
 }
开发者ID:ryanlabelle,项目名称:meta-box,代码行数:37,代码来源:post.php

示例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;
 }
开发者ID:phupx,项目名称:genco,代码行数:40,代码来源:taxonomy.php

示例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;
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:14,代码来源:select-advanced.php

示例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;
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:15,代码来源:select-advanced.php

示例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;
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:15,代码来源:select-advanced.php

示例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);
     }
 }
开发者ID:riopse,项目名称:meta-box,代码行数:21,代码来源:user.php

示例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);
     }
 }
开发者ID:jianqiangsong,项目名称:WordPress,代码行数:22,代码来源:user.php

示例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);
     }
 }
开发者ID:shrimp2t,项目名称:LearnPress,代码行数:25,代码来源:class.teacher.php

示例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);
     }
 }
开发者ID:crazyyy,项目名称:octagram,代码行数:30,代码来源:post.php

示例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);
 }
开发者ID:10asfar,项目名称:WordPress-the7-theme-demo-,代码行数:13,代码来源:metabox-fields.php


注:本文中的RWMB_Select_Field::normalize_field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。