normalize() public static method

Normalize parameters for meta box
public static normalize ( array $meta_box ) : array
$meta_box array Meta box definition
return array $meta_box Normalized meta box
Example #1
0
 /**
  * Find field by field ID.
  * This function finds field in meta boxes registered by 'rwmb_meta_boxes' filter.
  *
  * @param  string $field_id Field ID
  * @return array|false Field params (array) if success. False otherwise.
  */
 static function find_field($field_id)
 {
     $meta_boxes = RWMB_Core::get_meta_boxes();
     foreach ($meta_boxes as $meta_box) {
         $meta_box = RW_Meta_Box::normalize($meta_box);
         foreach ($meta_box['fields'] as $field) {
             if ($field_id == $field['id']) {
                 return $field;
             }
         }
     }
     return false;
 }
 /**
  * Find field by field ID
  * This function finds field in meta boxes registered by 'wcqd_metabox_meta_boxes' filter
  * Note: if users use old code to add meta boxes, this function might not work properly
  *
  * @param  string $field_id Field ID
  *
  * @return array|false Field params (array) if success. False otherwise.
  */
 static function find_field($field_id)
 {
     // Get all meta boxes registered with 'wcqd_metabox_meta_boxes' hook
     $meta_boxes = apply_filters('wcqd_metabox_meta_boxes', array());
     // Find field
     foreach ($meta_boxes as $meta_box) {
         $meta_box = RW_Meta_Box::normalize($meta_box);
         foreach ($meta_box['fields'] as $field) {
             if ($field_id == $field['id']) {
                 return $field;
             }
         }
     }
     return false;
 }
Example #3
0
 /**
  * Hash all fields into an indexed array for search
  *
  * @param string $post_type Post type
  */
 public static function hash_fields($post_type)
 {
     self::$fields[$post_type] = array();
     $meta_boxes = RWMB_Core::get_meta_boxes();
     foreach ($meta_boxes as $meta_box) {
         $meta_box = RW_Meta_Box::normalize($meta_box);
         if (!in_array($post_type, $meta_box['post_types'])) {
             continue;
         }
         foreach ($meta_box['fields'] as $field) {
             if (!empty($field['id'])) {
                 self::$fields[$post_type][$field['id']] = $field;
             }
         }
     }
 }