Skip to content

Commit

Permalink
fix: minor bug fixes (#21)
Browse files Browse the repository at this point in the history
* fix: avoid a PHP warning when updating a non-single meta value

* fix: "listing type" should be a sort option by default

* refactor: remove unnecessary isset() call
  • Loading branch information
dkoo authored Dec 18, 2020
1 parent 6c47a17 commit 5f90bc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions includes/newspack-listings-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function get_data_from_blocks( $blocks, $source ) {
}

// If the source has 'single' specified, only get data from the first found block instance.
if ( $source['single'] ) {
if ( ! empty( $source['single'] ) ) {
$matching_blocks = array_slice( $matching_blocks, 0, 1 );
}

Expand Down Expand Up @@ -138,7 +138,7 @@ function get_data_from_blocks( $blocks, $source ) {
}

// If the source has 'single' specified, only return data from the first found block instance.
if ( $source['single'] ) {
if ( ! empty( $source['single'] ) ) {
return array_shift( $data );
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar-query-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class QueryControls extends Component {
}

// Enable listing type option only if there's more than one listing type in the list.
if ( 'any' === type ) {
if ( 'any' === type || ! type ) {
sortOptions.push( { label: __( 'Listing Type', 'newspack-listings' ), value: 'type' } );
}

Expand Down

0 comments on commit 5f90bc7

Please sign in to comment.