Skip to content

Commit 9420588

Browse files
Brian LaymanBrian Layman
Brian Layman
authored and
Brian Layman
committed
Eliminated the possiblity of unset array index warnings.
Because query_args is now a sub-array under fields, it too needed to be merged with the defaults. Added code to prevent ajax being active by default (commit wpmetabox@7d91f9b ) with the bulk_clone feature of wpmetabox/meta-box#1331
1 parent 9bdd70a commit 9420588

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

inc/relationship/factory.php

+22-3
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,35 @@ protected function normalize_side( $settings, $source, $label ) {
150150
),
151151
);
152152

153+
if ( isset( $settings['field']['bulk_clone'] ) && $settings['field']['bulk_clone'] ) {
154+
$default['field']['ajax'] = false;
155+
$default['field']['query_args']['posts_per_page'] = 200; // This default is an arbitrary of function/speed
156+
}
157+
158+
153159
if ( is_string( $settings ) ) {
154160
$settings = array(
155161
'field' => array(
156162
'post_type' => $settings,
157163
),
158164
);
159165
}
160-
$settings = array_merge( $default, $settings );
161-
$settings['meta_box'] = array_merge( $default['meta_box'], $settings['meta_box'] );
162-
$settings['field'] = array_merge( $default['field'], $settings['field'] );
166+
167+
// Prevent warning message
168+
if ( !isset( $settings['field'] ) ) {
169+
$settings['field'] = array();
170+
}
171+
172+
// Prevent warning message
173+
if ( !isset( $settings['field']['query_args'] ) ) {
174+
$settings['field']['query_args'] = array();
175+
}
176+
177+
// Populate arrays defaults and overrides.
178+
$settings = array_merge( $default, $settings );
179+
$settings['meta_box'] = array_merge( $default['meta_box'], $settings['meta_box'] );
180+
$settings['field'] = array_merge( $default['field'], $settings['field'] );
181+
$settings['field']['query_args'] = array_merge( $default['field']['query_args'], $settings['field']['query_args'] );
163182

164183
$this->migrate_syntax( $settings );
165184

0 commit comments

Comments
 (0)