Add single settings.

This commit is contained in:
Hoang Huu 2019-09-25 13:44:59 +07:00
parent b2f43caeb1
commit 0eae5ced4d
8 changed files with 130 additions and 66 deletions

View File

@ -425,6 +425,39 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab {
'default' => 8, 'default' => 8,
]; ];
$fields[] = [
'name' => esc_html__( 'Show Author box', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Author box in the single property page.', 'opalestate-pro' ),
'id' => 'enable_single_author_box',
'type' => 'switch',
'options' => [
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
],
];
$fields[] = [
'name' => esc_html__( 'Show Enquire form', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Enquire form in the single property page.', 'opalestate-pro' ),
'id' => 'enable_single_enquire_form',
'type' => 'switch',
'options' => [
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
],
];
$fields[] = [
'name' => esc_html__( 'Show Mortgage Calculator', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Mortgage Calculator in the single property page.', 'opalestate-pro' ),
'id' => 'enable_single_mortgage',
'type' => 'switch',
'options' => [
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
],
];
$fields[] = [ $fields[] = [
'name' => esc_html__( 'Related properties layout', 'opalestate-pro' ), 'name' => esc_html__( 'Related properties layout', 'opalestate-pro' ),
'desc' => esc_html__( 'Select a layout for related properties.', 'opalestate-pro' ), 'desc' => esc_html__( 'Select a layout for related properties.', 'opalestate-pro' ),

View File

@ -120,6 +120,9 @@ class Opalestate_Install {
$options['enable_single_floor_plans'] = 'on'; $options['enable_single_floor_plans'] = 'on';
$options['enable_single_views_statistics'] = 'on'; $options['enable_single_views_statistics'] = 'on';
$options['single_views_statistics_limit'] = 8; $options['single_views_statistics_limit'] = 8;
$options['enable_single_author_box'] = 'on';
$options['enable_single_enquire_form'] = 'on';
$options['enable_single_mortgage'] = 'on';
$options['enable_property_reviews'] = 'on'; $options['enable_property_reviews'] = 'on';
$options['enable_agency_reviews'] = 'on'; $options['enable_agency_reviews'] = 'on';

View File

@ -146,6 +146,9 @@ class Opalestate_Property {
'apartments', 'apartments',
'floor_plans', 'floor_plans',
'views_statistics', 'views_statistics',
'author_box',
'enquire_form',
'mortgage',
]; ];
foreach ( $keys as $key ) { foreach ( $keys as $key ) {

View File

@ -36,8 +36,9 @@ function opalestate_single_property_layout_default() {
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
// add_action( 'opalestate_single_property_sidebar', 'opalestate_property_request_viewing_button', 7 ); // add_action( 'opalestate_single_property_sidebar', 'opalestate_property_request_viewing_button', 7 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
}
add_filter( 'opalestate_thumbnail_nav_column', function () { add_filter( 'opalestate_thumbnail_nav_column', function () {
return 6; return 6;
@ -74,8 +75,10 @@ function opalestate_single_property_layout_v2() {
/// /// sidebar //////// /// /// sidebar ////////
if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
}
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v3', 10 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v3', 10 );
// add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form' , 12 ); // add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form' , 12 );
} }
@ -109,9 +112,10 @@ 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_author_v2', 5 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
///
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage' );
if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage' );
}
} }
/** /**
@ -142,8 +146,10 @@ 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_author_v2', 5 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
///
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
}
} }
/** /**
@ -169,12 +175,10 @@ function opalestate_single_property_layout_v5() {
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 );
// add_action( 'opalestate_after_single_property_summary', 'opalestate_property_author', 55 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 );
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 ); add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 ); add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 );
add_filter( 'opalestate_thumbnail_nav_column', function () { add_filter( 'opalestate_thumbnail_nav_column', function () {
return 10; return 10;
} ); } );
@ -182,9 +186,9 @@ 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_author_v2', 5 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
// add_action( 'opalestate_single_property_sidebar', 'opalestate_property_request_viewing_button', 7 ); if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); }
} }
@ -203,8 +207,9 @@ function opalestate_property_request_viewing_button( $islink = false ) {
</a>'; </a>';
} }
/// /**
add_action( 'opalestate_single_property_layout', 'opalestate_single_property_layout' ); * @param $layout
*/
function opalestate_single_property_layout( $layout ) { function opalestate_single_property_layout( $layout ) {
switch ( $layout ) { switch ( $layout ) {
case 'v2': case 'v2':
@ -224,7 +229,7 @@ function opalestate_single_property_layout( $layout ) {
break; break;
} }
} }
add_action( 'opalestate_single_property_layout', 'opalestate_single_property_layout' );
/** /**
* Forms * Forms
@ -264,12 +269,10 @@ if ( ! function_exists( "opalestate_login_register_form_popup" ) ) {
} }
add_action( 'wp_footer', 'opalestate_login_register_form_popup', 9 ); add_action( 'wp_footer', 'opalestate_login_register_form_popup', 9 );
/** /**
* Add "Custom" template to page attirbute template section. * Add "Custom" template to page attirbute template section.
*/ */
function opalestate_add_template_to_select( $post_templates, $wp_theme, $post, $post_type ) { function opalestate_add_template_to_select( $post_templates, $wp_theme, $post, $post_type ) {
// Add custom template named template-custom.php to select dropdown // Add custom template named template-custom.php to select dropdown
$post_templates['user-management.php'] = esc_html__( 'User Management', 'opalestate-pro' ); $post_templates['user-management.php'] = esc_html__( 'User Management', 'opalestate-pro' );
$post_templates['fullwidth-page.php'] = esc_html__( 'Opalestate Fullwidth', 'opalestate-pro' ); $post_templates['fullwidth-page.php'] = esc_html__( 'Opalestate Fullwidth', 'opalestate-pro' );
@ -298,13 +301,12 @@ function opalestate_load_plugin_template( $template ) {
} }
if ( $template == '' ) { if ( $template == '' ) {
throw new \Exception( 'No template found' ); throw new Exception( 'No template found' );
} }
return $template; return $template;
} }
add_filter( 'template_include', 'opalestate_load_plugin_template' ); add_filter( 'template_include', 'opalestate_load_plugin_template' );
add_action( 'opalestate_before_property_loop_item', 'opalestate_property_featured_label' ); add_action( 'opalestate_before_property_loop_item', 'opalestate_property_featured_label' );
add_action( 'opalestate_before_property_loop_item', 'opalestate_property_label' ); add_action( 'opalestate_before_property_loop_item', 'opalestate_property_label' );

View File

@ -1,6 +1,10 @@
<?php <?php
global $post; global $post;
if ( ! opalestate_get_option( 'enable_single_enquire_form' ) ) {
return;
}
$message = sprintf( __( 'Hi, I am interested in %s (Property ID: %s)', 'opalestate-pro' ), get_the_title(), get_the_ID() ); $message = sprintf( __( 'Hi, I am interested in %s (Property ID: %s)', 'opalestate-pro' ), get_the_title(), get_the_ID() );
$property_id = get_the_ID(); $property_id = get_the_ID();
@ -24,7 +28,7 @@ $id = 'send-enquiry-form';
name="contact-form"><?php echo esc_html__( 'Send message', 'opalestate-pro' ); ?></button> name="contact-form"><?php echo esc_html__( 'Send message', 'opalestate-pro' ); ?></button>
</form> </form>
<?php else : ?> <?php else : ?>
<div class="opalestate-box-content property-equire-form"> <div class="opalestate-box-content property-enquire-form">
<div class="opalestate-box"> <div class="opalestate-box">
<div class="property-equire-form-container"> <div class="property-equire-form-container">
<h5 class="contact-form-title"><?php echo $heading; ?></h5> <h5 class="contact-form-title"><?php echo $heading; ?></h5>

View File

@ -2,8 +2,13 @@
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
global $post, $property; global $post, $property;
if ( ! opalestate_get_option( 'enable_single_author_box' ) ) {
return;
}
$type = $property->get_author_type(); $type = $property->get_author_type();
$data = get_userdata( $post->post_author ); $data = get_userdata( $post->post_author );
$layout = ''; $layout = '';

View File

@ -4,47 +4,56 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
global $post, $property; global $post, $property;
$type = $property->get_author_type(); $type = $property->get_author_type();
$data = get_userdata( $post->post_author ); $data = get_userdata( $post->post_author );
$layout = 'list'; $layout = 'list';
switch ( $type ) { switch ( $type ) {
case 'hide': case 'hide':
return ; return;
break; break;
case 'agent' : case 'agent' :
$agent_id = $property->get_metabox_value( 'agent' ); $agent_id = $property->get_metabox_value( 'agent' );
$author_info = opalestate_load_template_path( 'single-property/user/author-member-box', $author_info = opalestate_load_template_path( 'single-property/user/author-member-box',
array( 'author' => $data, [
'id' => $agent_id , 'author' => $data,
'prefix' => OPALESTATE_AGENT_PREFIX, 'id' => $agent_id,
'picture' => '', 'prefix' => OPALESTATE_AGENT_PREFIX,
'type' => 'agent', 'picture' => '',
'hide_description' => true ) ); 'type' => 'agent',
break; 'hide_description' => true,
case 'agency' : ] );
$agency_id = $property->get_metabox_value( 'agency' ); break;
$author_info = opalestate_load_template_path( 'single-property/user/author-member-box', case 'agency' :
array( 'author' => $data, $agency_id = $property->get_metabox_value( 'agency' );
'id' => $agency_id , $author_info = opalestate_load_template_path( 'single-property/user/author-member-box',
'picture' => '', [
'type' => 'agency', 'author' => $data,
'hide_description' => true ) ); 'id' => $agency_id,
break; 'picture' => '',
default: 'type' => 'agency',
'hide_description' => true,
] );
break;
default:
$author_info = opalestate_load_template_path( 'single-property/user/author-user-box', array('author' => $data , 'hide_description' => true ), $layout ); $author_info = opalestate_load_template_path( 'single-property/user/author-user-box', [ 'author' => $data, 'hide_description' => true ], $layout );
break; break;
} }
?> ?>
<div class="opalestate-box-content property-agent-section"> <div class="opalestate-box-content property-agent-section">
<div class="opalestate-box"> <div class="opalestate-box">
<div class="author-content-box"> <?php if ( opalestate_get_option( 'enable_single_author_box' ) ) : ?>
<div class="property-agent-info"> <div class="author-content-box">
<?php echo wp_kses_post( $author_info ); ?> <div class="property-agent-info">
</div> <?php echo wp_kses_post( $author_info ); ?>
</div> </div>
<?php echo opalestate_load_template_path( 'messages/enquiry-form' , array('nowrap' => true) ); ?> </div>
</div> <?php endif; ?>
<?php if ( opalestate_get_option( 'enable_single_enquire_form' ) ) : ?>
<?php echo opalestate_load_template_path( 'messages/enquiry-form', [ 'nowrap' => true ] ); ?>
<?php endif; ?>
</div>
</div> </div>

View File

@ -46,14 +46,19 @@ switch ( $type ) {
<div class="opalestate-box"> <div class="opalestate-box">
<div class="author-content-box"> <div class="author-content-box">
<div class="opal-row"> <div class="opal-row">
<div class="col-lg-6 col-md-6"> <?php if ( opalestate_get_option( 'enable_single_author_box' ) ) : ?>
<div class="property-agent-info"> <div class="col-lg-6 col-md-6">
<?php echo wp_kses_post( $author_info ); ?> <div class="property-agent-info">
<?php echo wp_kses_post( $author_info ); ?>
</div>
</div> </div>
</div> <?php endif; ?>
<div class="col-lg-6 col-md-6">
<?php echo opalestate_load_template_path( 'messages/enquiry-form', [ 'nowrap' => true ] ); ?> <?php if ( opalestate_get_option( 'enable_single_enquire_form' ) ) : ?>
</div> <div class="col-lg-6 col-md-6">
<?php echo opalestate_load_template_path( 'messages/enquiry-form', [ 'nowrap' => true ] ); ?>
</div>
<?php endif; ?>
</div> </div>
</div> </div>
</div> </div>