Browse files

Merge pull request #251 from infamouse/patch-1

normalize_field safe for 'post_type' => array(...)
  • Loading branch information...
2 parents b5ac988 + 074f06b commit 8e2778ad8a238ff854e9d2eeb70447daaab485cb @rilwis committed Mar 23, 2013
Showing with 9 additions and 4 deletions.
  1. +9 −4 inc/fields/posts.php
View
13 inc/fields/posts.php
@@ -49,12 +49,17 @@ static function html( $html, $meta, $field )
* @return array
*/
static function normalize_field( $field )
- {
- $pt_obj = get_post_type_object( $field['post_type'] );
+ {
+ $default_post_type = "Post";
+ if(is_string($field['post_type'])) {
+ $pt_obj = get_post_type_object( $field['post_type'] );
+ $default_post_type = $pt_obj->labels->singular_name;
+ }
+
$field = wp_parse_args( $field, array(
'post_type' => 'post',
'field_type' => 'select_advanced',
- 'default' => sprintf( __( 'Select a %s' , 'rwmb' ), $pt_obj->labels->singular_name ),
+ 'default' => sprintf( __( 'Select a %s' , 'rwmb' ), $default_post_type ),
'parent' => false,
'query_args' => array()
) );
@@ -132,4 +137,4 @@ static function get_options( $field )
return $options;
}
}
-}
+}

0 comments on commit 8e2778a

Please sign in to comment.