Skip to content
Draft
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
28 changes: 28 additions & 0 deletions classes/fields/pick.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,34 @@ public function schema( $options = null ) {

}

/**
* @todo 2.8 Centralize the usage of this method. See PR #5540.
* {@inheritdoc}
*/
public function is_empty( $value = null ) {

$is_empty = false;

if ( is_array( $value ) ) {
foreach ( $value as $key => $val ) {
if ( $this->is_empty( $val ) ) {
unset( $value[ $key ] );
}
}
}

/**
* @todo Find a way to check for relationship type before comparing to `0` as this is still empty for posts/terms/users etc.
* Currently not possible since this method doesn't get any options passed as parameters.
*/
if ( empty( $value ) && '0' !== (string) $value ) {
$is_empty = true;
}

return $is_empty;

}

/**
* {@inheritdoc}
*/
Expand Down