Skip to content

Commit

Permalink
Change Field_Registry::add_from_meta_box() to RW_Meta_Box::register_f…
Browse files Browse the repository at this point in the history
…ields()
  • Loading branch information
truongwp authored and rilwis committed Jul 12, 2017
1 parent 820bd56 commit 20b37be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions inc/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
13 changes: 0 additions & 13 deletions inc/field-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
13 changes: 13 additions & 0 deletions inc/meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 20b37be

Please sign in to comment.