Skip to content

Commit

Permalink
Changed to a mutch cleaner fix
Browse files Browse the repository at this point in the history
  • Loading branch information
frozzare committed Jun 4, 2015
1 parent 9bc3479 commit e10bf90
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/includes/properties/class-papi-property-relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public function get_sort_option( $post_id, $slug ) {
public static function get_sort_options() {
$sort_options = array();

$sort_options[__( 'Select', 'papi' )] = null;

$sort_options[__( 'Name (alphabetically)', 'papi' )] = function ( $a, $b ) {
return strcmp( strtolower( $a->post_title ), strtolower( $b->post_title ) );
};
Expand Down Expand Up @@ -150,11 +152,7 @@ public function html() {
<?php if ( $settings->show_sort_by ): ?>
<strong><?php _e( 'Sort by', 'papi' ); ?></strong>
<select name="_<?php echo $options->slug; ?>_sort_option">
<?php
$sort_options = array();
$sort_options[__( 'Select', 'papi' )] = '';
$sort_options = wp_parse_args( static::get_sort_options(), $sort_options );
foreach ( $sort_options as $key => $v ): ?>
<?php foreach ( static::get_sort_options() as $key => $v ): ?>
<option value="<?php echo $key; ?>" <?php echo $key == $sort_option ? 'selected="selected"' : ''; ?>><?php echo $key; ?></option>
<?php endforeach; ?>
</select>
Expand Down Expand Up @@ -215,7 +213,7 @@ public function sort_value( $value, $slug, $post_id ) {
$sort_option = $this->get_sort_option( $post_id, $slug );
$sort_options = static::get_sort_options();

if ( empty( $sort_option ) || ! isset( $sort_options[$sort_option] ) ) {
if ( empty( $sort_option ) || ! isset( $sort_options[$sort_option] ) || is_null( $sort_options[$sort_option] ) ) {
return $value;
}

Expand Down

0 comments on commit e10bf90

Please sign in to comment.