From 5af63726c31085d8b3b8486093a4920db15af17e Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 10:58:21 +0700 Subject: [PATCH] Fix order settings. --- inc/admin/settings/property.php | 6 +++--- inc/property/class-metabox-property-admin.php | 19 ++++++++----------- inc/property/class-opalestate-search.php | 4 ++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/inc/admin/settings/property.php b/inc/admin/settings/property.php index 2f067503..3ab8aeba 100755 --- a/inc/admin/settings/property.php +++ b/inc/admin/settings/property.php @@ -168,10 +168,10 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab { 'desc' => esc_html__( 'Show featured first in page result, as default Newest is showed', 'opalestate-pro' ), 'type' => 'switch', 'options' => [ - 0 => esc_html__( 'Disable', 'opalestate-pro' ), - 1 => esc_html__( 'Enable', 'opalestate-pro' ), + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), ], - 'default' => 0, + 'default' => 'off', ]; $fields[] = [ 'name' => esc_html__( 'Minimum of Search Price', 'opalestate-pro' ), diff --git a/inc/property/class-metabox-property-admin.php b/inc/property/class-metabox-property-admin.php index d7ab80e1..a791201e 100755 --- a/inc/property/class-metabox-property-admin.php +++ b/inc/property/class-metabox-property-admin.php @@ -177,10 +177,10 @@ class Opalestate_Property_MetaBox { 'id' => $prefix . 'featured', 'type' => 'switch', 'options' => [ - 0 => esc_html__( 'No', 'opalestate-pro' ), - 1 => esc_html__( 'Yes', 'opalestate-pro' ), + 'on' => esc_html__( 'Yes', 'opalestate-pro' ), + 'off' => esc_html__( 'No', 'opalestate-pro' ), ], - 'default' => 0, + 'default' => 'off', ], [ 'name' => esc_html__( 'Property SKU', 'opalestate-pro' ), @@ -206,17 +206,14 @@ class Opalestate_Property_MetaBox { 'id' => $prefix . 'enablemapview', 'type' => 'switch', 'options' => [ - 1 => esc_html__( 'Yes', 'opalestate-pro' ), - 0 => esc_html__( 'No', 'opalestate-pro' ), + 'on' => esc_html__( 'Yes', 'opalestate-pro' ), + 'off' => esc_html__( 'No', 'opalestate-pro' ), ], ], [ 'name' => esc_html__( 'Address', 'opalestate-pro' ), 'id' => $prefix . 'address', 'type' => 'textarea_small', - 'attributes' => [ - 'required' => 'required', - ], ], [ 'id' => "{$prefix}video", @@ -270,10 +267,10 @@ class Opalestate_Property_MetaBox { 'id' => $prefix . 'price_oncall', 'type' => 'switch', 'options' => [ - 0 => esc_html__( 'No', 'opalestate-pro' ), - 1 => esc_html__( 'Yes', 'opalestate-pro' ), + 'on' => esc_html__( 'Yes', 'opalestate-pro' ), + 'off' => esc_html__( 'No', 'opalestate-pro' ), ], - 'default' => 0, + 'default' => 'off', ], ]; diff --git a/inc/property/class-opalestate-search.php b/inc/property/class-opalestate-search.php index e29810d1..f1ce4341 100755 --- a/inc/property/class-opalestate-search.php +++ b/inc/property/class-opalestate-search.php @@ -245,6 +245,10 @@ class OpalEstate_Search { $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . $ksearchs[0]; $args['orderby'] = 'meta_value_num'; $args['order'] = $ksearchs[1]; + } elseif ( 'on' == opalestate_options( 'show_featured_first', 'off' ) ) { + $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . 'featured'; + $args['orderby'] = 'meta_value_num'; + $args['order'] = 'DESC'; } $metas = Opalestate_Property_MetaBox::metaboxes_info_fields();