Skip to content

Commit

Permalink
Fix group field display, broken in 2.0.3. Closes CMB2#255
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Mar 17, 2015
1 parent 14f403d commit 8ffbea4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.

*

## 2.0.5 - 2015-03-17

### Bug Fixes

* Fix grouped fields display (first field was being repeated), broken in 2.0.3.

## 2.0.4 - 2015-03-16

### Enhancements
Expand Down
14 changes: 7 additions & 7 deletions includes/CMB2.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function render_group( $args ) {

if ( ! empty( $group_val ) ) {

foreach ( $group_val as $iterator => $field_id ) {
foreach ( $group_val as $field_group->index => $field_id ) {
$this->render_group_row( $field_group, $remove_disabled );
}
} else {
Expand Down Expand Up @@ -689,17 +689,17 @@ public function prop( $property, $fallback = null ) {
* Add a field to the metabox
* @since 2.0.3
* @param mixed $field Metabox field id or field config array or CMB2_Field object
* @param CMB2_Field object $group_field (optional) CMB2_Field object (group parent)
* @param CMB2_Field object $field_group (optional) CMB2_Field object (group parent)
* @return mixed CMB2_Field object (or false)
*/
public function get_field( $field, $group_field = null ) {
public function get_field( $field, $field_group = null ) {
if ( is_a( $field, 'CMB2_Field' ) ) {
return $field;
}

$field_id = is_string( $field ) ? $field : $field['id'];

$parent_field_id = ! empty( $group_field ) ? $group_field->id() : '';
$parent_field_id = ! empty( $field_group ) ? $field_group->id() : '';
$ids = $this->get_field_ids( $field_id, $parent_field_id, true );

if ( ! $ids ) {
Expand All @@ -708,18 +708,18 @@ public function get_field( $field, $group_field = null ) {

list( $field_id, $sub_field_id ) = $ids;

$index = implode( '', $ids );
$index = implode( '', $ids ) . ( $field_group ? $field_group->index : '' );
if ( array_key_exists( $index, $this->fields ) ) {
return $this->fields[ $index ];
}

$field_array = $this->prop( 'fields' );

// Check if group is passed and if fields were added in the old-school fields array
$args = $group_field && ( $sub_field_id || 0 === $sub_field_id )
$args = $field_group && ( $sub_field_id || 0 === $sub_field_id )
? array(
'field_args' => $field_array[ $field_id ]['fields'][ $sub_field_id ],
'group_field' => $group_field,
'group_field' => $field_group,
)
: array(
'field_args' => is_array( $field ) ? array_merge( $field, $field_array[ $field_id ] ) : $field_array[ $field_id ],
Expand Down
8 changes: 4 additions & 4 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Bill Erickson (@billerickson / billerickson.net)
* Andrew Norcross (@norcross / andrewnorcross.com)
*
* Version: 2.0.4
* Version: 2.0.5
*
* Text Domain: cmb2
* Domain Path: languages
Expand Down Expand Up @@ -42,12 +42,12 @@
or things might explode!
*************************************************************************/

if ( ! class_exists( 'cmb2_bootstrap_204_trunk', false ) ) {
if ( ! class_exists( 'cmb2_bootstrap_205', false ) ) {

/**
* Check for newest version of CMB
*/
class cmb2_bootstrap_204_trunk {
class cmb2_bootstrap_205 {

/**
* Current version number
Expand Down Expand Up @@ -128,6 +128,6 @@ public function l10ni18n() {
}

}
cmb2_bootstrap_204_trunk::go();
cmb2_bootstrap_205::go();

} // class exists check
6 changes: 3 additions & 3 deletions languages/cmb2.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# This file is distributed under the same license as the CMB2 package.
msgid ""
msgstr ""
"Project-Id-Version: CMB2 2.0.4\n"
"Project-Id-Version: CMB2 2.0.5\n"
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/cmb2\n"
"POT-Creation-Date: 2015-03-16 20:04:30+00:00\n"
"POT-Creation-Date: 2015-03-17 14:35:40+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2015-3-16 20:4+240\n"
"PO-Revision-Date: 2015-3-17 14:35+240\n"
"Last-Translator: WebDevStudios [email protected]\n"
"Language-Team: WebDevStudios [email protected]\n"
"X-Generator: grunt-wp-i18n 0.4.9\n"
Expand Down
17 changes: 12 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
**Tags:** metaboxes, forms, fields, options, settings
**Requires at least:** 3.8.0
**Tested up to:** 4.1.0
**Stable tag:** 2.0.4
**Stable tag:** 2.0.5
**License:** GPLv2 or later
**License URI:** [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)

Expand Down Expand Up @@ -92,18 +92,25 @@ If including the library in your plugin or theme:
2. Edit to only include the fields you need and rename the functions (CMB2 directory should be left unedited in order to easily update the library).
4. Profit.

## 2.0.4
## Most Recent Changes - 2.0.4, 2.0.5

### Enhancements
#### 2.0.5 - 2015-03-17

##### Bug Fixes

* Fix grouped fields display (first field was being repeated), broken in 2.0.3.

#### 2.0.4 - 2015-03-16

##### Enhancements

* `select`, `radio`, `radio_inline` field types now all accept the `'show_option_none'` field parameter. This parameter allows you to set the text to display for showing a 'no selection' option. Default will be `false`, which means a 'none' option will not be added. Set to `true` to use the default text, 'None', or specify another value, i.e. 'No selection'.

### Bug Fixes
##### Bug Fixes

* Fix back-compatibility when adding group field sub-fields via old array method (vs using the `CMB2:add_group_field()` method). Thanks to [norcross](https://github.com/norcross) for reporting.
* Fix occasional jQuery issues with group-field indexes.


**[View complete changelog](https://github.com/WebDevStudios/CMB2/blob/master/CHANGELOG.md)**

## Known Issues
Expand Down
31 changes: 20 additions & 11 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://webdevstudios.com
Tags: metaboxes, forms, fields, options, settings
Requires at least: 3.8.0
Tested up to: 4.1.2
Stable tag: 2.0.4
Stable tag: 2.0.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -66,13 +66,21 @@ A complete list of all our awesome contributors found here: [github.com/WebDevSt
* [Github project page](https://github.com/webdevstudios/CMB2)
* [Documentation (GitHub wiki)](https://github.com/webdevstudios/CMB2/wiki)

### Most Recent Changes - 2.0.4
### Most Recent Changes - 2.0.4, 2.0.5

### Enhancements
#### 2.0.5 - 2015-03-17

##### Bug Fixes

* Fix grouped fields display (first field was being repeated), broken in 2.0.3.

#### 2.0.4 - 2015-03-16

##### Enhancements

* `select`, `radio`, `radio_inline` field types now all accept the `'show_option_none'` field parameter. This parameter allows you to set the text to display for showing a 'no selection' option. Default will be `false`, which means a 'none' option will not be added. Set to `true` to use the default text, 'None', or specify another value, i.e. 'No selection'.

### Bug Fixes
##### Bug Fixes

* Fix back-compatibility when adding group field sub-fields via old array method (vs using the `CMB2:add_group_field()` method). Thanks to [norcross](https://github.com/norcross) for reporting.
* Fix occasional jQuery issues with group-field indexes.
Expand Down Expand Up @@ -109,6 +117,12 @@ FAQ's usually end up in the [github wiki](https://github.com/WebDevStudios/CMB2/

== Changelog ==

### 2.0.5 - 2015-03-17

#### Bug Fixes

* Fix grouped fields display (first field was being repeated), broken in 2.0.3.

### 2.0.4 - 2015-03-16

#### Enhancements
Expand Down Expand Up @@ -395,13 +409,8 @@ It is now passed a null value vs saved value. If null is returned, default sanit

== Upgrade Notice ==

### 2.0.4 - 2015-03-16

#### Enhancements

* `select`, `radio`, `radio_inline` field types now all accept the `'show_option_none'` field parameter. This parameter allows you to set the text to display for showing a 'no selection' option. Default will be `false`, which means a 'none' option will not be added. Set to `true` to use the default text, 'None', or specify another value, i.e. 'No selection'.
### 2.0.5 - 2015-03-17

#### Bug Fixes

* Fix back-compatibility when adding group field sub-fields via old array method (vs using the `CMB2:add_group_field()` method). Thanks to [norcross](https://github.com/norcross) for reporting.
* Fix occasional jQuery issues with group-field indexes.
* Fix grouped fields display (first field was being repeated), broken in 2.0.3.

0 comments on commit 8ffbea4

Please sign in to comment.