diff --git a/inc/core.php b/inc/core.php index f411de59d..4e5af2ed9 100644 --- a/inc/core.php +++ b/inc/core.php @@ -44,11 +44,11 @@ public function plugin_links( $links ) { public function register_meta_boxes() { $configs = apply_filters( 'rwmb_meta_boxes', array() ); $meta_boxes = rwmb_get_registry( 'meta_box' ); - $fields = rwmb_get_registry( 'field' ); + foreach ( $configs as $config ) { $meta_box = rwmb_get_meta_box( $config ); $meta_boxes->add( $meta_box ); - $fields->add_from_meta_box( $meta_box ); + $meta_box->register_fields(); } } diff --git a/inc/field-registry.php b/inc/field-registry.php index 1dcfbe883..e39d184ab 100644 --- a/inc/field-registry.php +++ b/inc/field-registry.php @@ -17,19 +17,6 @@ class RWMB_Field_Registry { */ private $data = array(); - /** - * Add all fields in a meta box to the registry. - * - * @param RW_Meta_Box $meta_box Meta box object. - */ - public function add_from_meta_box( RW_Meta_Box $meta_box ) { - foreach ( $meta_box->fields as $field ) { - foreach ( $meta_box->post_types as $post_type ) { - $this->add( $field, $post_type ); - } - } - } - /** * Add a single field to the registry. * diff --git a/inc/meta-box.php b/inc/meta-box.php index 3d1648d00..42f8a8028 100644 --- a/inc/meta-box.php +++ b/inc/meta-box.php @@ -65,6 +65,19 @@ public function __construct( $meta_box ) { } } + /** + * Add fields to field registry. + */ + public function register_fields() { + $field_registry = rwmb_get_registry( 'field' ); + + foreach ( $this->post_types as $post_type ) { + foreach ( $this->fields as $field ) { + $field_registry->add( $field, $post_type ); + } + } + } + /** * Conditional check for whether initializing meta box. *