Skip to content

Commit

Permalink
Eliminated the possiblity of unset array index warnings.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Brian Layman authored and Brian Layman committed Oct 30, 2019
1 parent 9bdd70a commit 9420588
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions inc/relationship/factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,35 @@ protected function normalize_side( $settings, $source, $label ) {
),
);

if ( isset( $settings['field']['bulk_clone'] ) && $settings['field']['bulk_clone'] ) {
$default['field']['ajax'] = false;
$default['field']['query_args']['posts_per_page'] = 200; // This default is an arbitrary of function/speed
}


if ( is_string( $settings ) ) {
$settings = array(
'field' => array(
'post_type' => $settings,
),
);
}
$settings = array_merge( $default, $settings );
$settings['meta_box'] = array_merge( $default['meta_box'], $settings['meta_box'] );
$settings['field'] = array_merge( $default['field'], $settings['field'] );

// Prevent warning message
if ( !isset( $settings['field'] ) ) {
$settings['field'] = array();
}

// Prevent warning message
if ( !isset( $settings['field']['query_args'] ) ) {
$settings['field']['query_args'] = array();
}

// Populate arrays defaults and overrides.
$settings = array_merge( $default, $settings );
$settings['meta_box'] = array_merge( $default['meta_box'], $settings['meta_box'] );
$settings['field'] = array_merge( $default['field'], $settings['field'] );
$settings['field']['query_args'] = array_merge( $default['field']['query_args'], $settings['field']['query_args'] );

$this->migrate_syntax( $settings );

Expand Down

0 comments on commit 9420588

Please sign in to comment.