Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Fixed regression with "multicheck" fields #651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helpers/cmb_Meta_Box_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ public function _set_field_defaults( $args ) {
$args['default'] = apply_filters( 'cmb_default_filter', $args['default'], $args, $this->object_type, $this->object_type );
$args['allow'] = 'file' == $args['type'] && ! isset( $args['allow'] ) ? array( 'url', 'attachment' ) : array();
$args['save_id'] = 'file' == $args['type'] && ! ( isset( $args['save_id'] ) && ! $args['save_id'] );
// $args['multiple'] = isset( $args['multiple'] ) ? $args['multiple'] : ( 'multicheck' == $args['type'] ? true : false );
$args['multiple'] = isset( $args['multiple'] ) ? $args['multiple'] : false;
$args['multiple'] = isset( $args['multiple'] ) ? $args['multiple'] : ( 'multicheck' == $args['type'] ? true : false );
// $args['multiple'] = isset( $args['multiple'] ) ? $args['multiple'] : false;
$args['repeatable'] = isset( $args['repeatable'] ) && $args['repeatable'] && ! $this->repeatable_exception( $args['type'] );
$args['inline'] = isset( $args['inline'] ) && $args['inline'] || false !== stripos( $args['type'], '_inline' );
$args['on_front'] = ! ( isset( $args['on_front'] ) && ! $args['on_front'] );
Expand Down
19 changes: 9 additions & 10 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,16 +657,15 @@ public static function save_field( $new_value, $field ) {
$name = $field->id();
$old = $field->get_data();

// if ( $field->args( 'multiple' ) && ! $field->args( 'repeatable' ) && ! $field->group ) {
// $field->remove_data();
// if ( ! empty( $new_value ) ) {
// foreach ( $new_value as $add_new ) {
// self::$updated[] = $name;
// $field->update_data( $add_new, $name, false );
// }
// }
// } else
if ( ! empty( $new_value ) && $new_value != $old ) {
if ( $field->args( 'multiple' ) && ! $field->args( 'repeatable' ) && ! $field->group ) {
$field->remove_data();
if ( ! empty( $new_value ) ) {
foreach ( $new_value as $add_new ) {
self::$updated[] = $name;
$field->update_data( $add_new, false );
}
}
} elseif ( ! empty( $new_value ) && $new_value != $old ) {
self::$updated[] = $name;
return $field->update_data( $new_value );
} elseif ( empty( $new_value ) ) {
Expand Down