diff --git a/changelog.txt b/changelog.txt index d912cf65..e01ceed5 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ += 1.5.1 - 2020-06-01 = +* Added - Enable/Disable setting for each property. + = 1.5 - 2020-05-29 = * Added - Search properties in admin by SKU & Address. diff --git a/inc/property/class-metabox-property-admin.php b/inc/property/class-metabox-property-admin.php index 1813c421..b51de952 100755 --- a/inc/property/class-metabox-property-admin.php +++ b/inc/property/class-metabox-property-admin.php @@ -500,6 +500,17 @@ class Opalestate_Property_MetaBox { 'options' => $templates, 'description' => esc_html__( 'Select a layout to display full information of this property', 'opalestate-pro' ), ], + [ + 'name' => esc_html__( 'Show Mortgage Calculator', 'opalestate-pro' ), + 'id' => "{$prefix}enable_single_mortgage", + 'type' => 'select', + 'options' => [ + '' => esc_html__( 'Inherit', 'opalestate-pro' ), + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'description' => esc_html__( 'Show Mortgage Calculator', 'opalestate-pro' ), + ], ]; return apply_filters( 'opalestate_postype_property_metaboxes_fields_layout', $fields ); diff --git a/inc/template-hook-functions.php b/inc/template-hook-functions.php index 08516136..64845a9e 100755 --- a/inc/template-hook-functions.php +++ b/inc/template-hook-functions.php @@ -40,14 +40,19 @@ function opalestate_single_property_layout_default() { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); - if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { + $single_mortgage = get_post_meta( get_the_ID(), OPALESTATE_PROPERTY_PREFIX . 'enable_single_mortgage', true ); + + if ( $single_mortgage === 'on' ) { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } elseif ( $single_mortgage === '' ) { + if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { + add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } } add_filter( 'opalestate_thumbnail_nav_column', function () { return 6; } ); - } @@ -74,8 +79,14 @@ function opalestate_single_property_layout_v2() { add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 ); - if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { + $single_mortgage = get_post_meta( get_the_ID(), OPALESTATE_PROPERTY_PREFIX . 'enable_single_mortgage', true ); + + if ( $single_mortgage === 'on' ) { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } elseif ( $single_mortgage === '' ) { + if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { + add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } } add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v3', 10 ); @@ -112,8 +123,14 @@ function opalestate_single_property_layout_v3() { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); - if ( opalestate_get_option( 'enable_single_mortgage' , 'on' ) == 'on' ) { - add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage' ); + $single_mortgage = get_post_meta( get_the_ID(), OPALESTATE_PROPERTY_PREFIX . 'enable_single_mortgage', true ); + + if ( $single_mortgage === 'on' ) { + add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } elseif ( $single_mortgage === '' ) { + if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { + add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } } } @@ -148,8 +165,14 @@ function opalestate_single_property_layout_v4() { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); - if ( opalestate_get_option( 'enable_single_mortgage' , 'on' ) == 'on' ) { + $single_mortgage = get_post_meta( get_the_ID(), OPALESTATE_PROPERTY_PREFIX . 'enable_single_mortgage', true ); + + if ( $single_mortgage === 'on' ) { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } elseif ( $single_mortgage === '' ) { + if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { + add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } } } @@ -190,8 +213,14 @@ function opalestate_single_property_layout_v5() { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); - if ( opalestate_get_option( 'enable_single_mortgage' ,'on' ) == 'on' ) { + $single_mortgage = get_post_meta( get_the_ID(), OPALESTATE_PROPERTY_PREFIX . 'enable_single_mortgage', true ); + + if ( $single_mortgage === 'on' ) { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } elseif ( $single_mortgage === '' ) { + if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { + add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); + } } } @@ -336,19 +365,20 @@ add_action( 'opalestate_before_property_loop_item', 'opalestate_property_label' */ function opalestate_single_property_sidebar_widgets() { if ( is_active_sidebar( 'opalestate-single-property' ) ) : ?> -
$item ) { if ( preg_match( "#http#", $item['link'] ) ) { - $link = $item['link']; + $link = $item['link']; + $is_active = is_page( $item['id'] ) ? ' active' : ''; } else { - $link = $uri . '?tab=' . $item['link']; + $link = $uri . '?tab=' . $item['link']; + $is_active = isset( $_GET['tab'] ) && $current_tab == $item['link'] ? ' active' : ''; } - $output .= '