Update agent front end.

This commit is contained in:
Hoang Huu 2019-10-01 12:16:57 +07:00
parent 2121f291ea
commit 59e3459243
6 changed files with 40 additions and 28 deletions

@ -90,15 +90,20 @@ class Opalestate_Agent_Front {
* render_profile
*/
public function render_profile() {
$user_id = get_current_user_id();
$post_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
// Check if have not any relationship, create a new then update this meta value.
if ( ! $post_id || $post_id < 0 ) {
$this->on_set_role( $user_id );
}
$post_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
$post = get_post( $post_id );
if ( isset( $post->ID ) && $post->post_status != 'publish' ) {
opalestate_add_notice( "warning", esc_html__( 'You account is under reviewing! it take some time to process' ) );
add_action( "opalestate_profile_agency_form_before", "opalestate_print_notices" );
if ( isset( $post->ID ) && ( $post->post_status != 'publish' || $post->ID == get_the_ID() ) ) {
opalestate_add_notice( 'warning', esc_html__( 'You account is under reviewing! It take some time to process.', 'opalestate-pro' ) );
add_action( 'opalestate_profile_agency_form_before', 'opalestate_print_notices' );
}
$metaboxes = $this->render_front_form( [], $post_id );
@ -316,23 +321,23 @@ class Opalestate_Agent_Front {
}
public function agent_carousel ( $atts ) {
public function agent_carousel( $atts ) {
$atts = is_array( $atts ) ? $atts : [];
$layout = 'search-agency-form';
$default = array(
$default = [
'current_uri' => null,
'column' => 4,
'limit' => 12,
'paged' => 1,
'onlyfeatured' => 0,
'form' => $layout
);
'form' => $layout,
];
$atts = array_merge( $default, $atts );
return opalestate_load_template_path( 'shortcodes/agent-carousel' , $atts );
return opalestate_load_template_path( 'shortcodes/agent-carousel', $atts );
}
public function archives_query( $query ) {
@ -461,7 +466,6 @@ class Opalestate_Agent_Front {
'posts_per_page' => 10,
];
$args['meta_key'] = OPALESTATE_AGENT_PREFIX . 'user_id';
$args['meta_value'] = $user_id;
$args['meta_compare'] = '=';
@ -478,9 +482,10 @@ class Opalestate_Agent_Front {
}
public function create_agent( $args = [], $user_id ) {
$data = get_user_by( 'id', $user_id );
$post_title = sprintf( esc_html__( 'User ID: %s', 'opalestate-pro' ), $user_id );
$args = wp_parse_args( $args, [
'first_name' => $data->first_name,
'last_name' => $data->last_name,
@ -500,8 +505,14 @@ class Opalestate_Agent_Front {
'instagram' => '',
] );
if ( $args['first_name'] && $args['last_name'] ) {
$post_title = $args['first_name'] . ' ' . $args['last_name'];
} elseif ( isset( $data->display_name ) && $data->display_name ) {
$post_title = esc_html( $data->display_name );
}
$agent_id = wp_insert_post( [
'post_title' => $args['first_name'] && $args['last_name'] ? $args['first_name'] . ' ' . $args['last_name'] : esc_html__( 'User ID', 'opalestate-pro' ) . ': ' . $user_id,
'post_title' => $post_title,
'post_content' => '',
'post_excerpt' => '',
'post_type' => 'opalestate_agent',
@ -509,7 +520,6 @@ class Opalestate_Agent_Front {
'post_author' => $user_id,
], true );
do_action( 'opalesate_insert_user_agent', $agent_id );
return $agent_id;

@ -233,6 +233,8 @@ class Property_Api extends Base_Api {
$property['locations'] = $data->get_locations();
$property['amenities'] = $data->get_amenities();
$property['types'] = $data->get_types_tax();
$property['author_type'] = $data->get_author_type();
$property['author_data'] = $data->get_author_link();
return apply_filters( 'opalestate_api_properties_property', $property );

@ -454,7 +454,7 @@ class Opalestate_Property {
return '<a href="' . $data['link'] . '" aria-label="' . $data['name'] . '" class="author-link"><span aria-label="' . $data['name'] . '" class="author-avatar hint--top">' . $avatar . '</span><span class="author-name">' . $data['name'] . '</span></a>';
}
private function get_author_link() {
public function get_author_link() {
$image_id = get_user_meta( get_the_author_meta( 'ID' ), OPALESTATE_USER_PROFILE_PREFIX . 'avatar_id', true );
$related_id = get_user_meta( get_the_author_meta( 'ID' ), OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );

@ -50,7 +50,7 @@ switch ( $type ) {
break;
}
?>
<div class="opalestate-box-content property-agent-section">
<div class="opalestate-box-content property-agent-section property-author-v2">
<div class="opalestate-box">
<div class="author-content-box">
<div class="property-agent-info">

@ -44,7 +44,7 @@ switch ( $type ) {
break;
}
?>
<div class="opalestate-box-content property-agent-section">
<div class="opalestate-box-content property-agent-section property-author-v3">
<div class="opalestate-box">
<?php if ( opalestate_get_option( 'enable_single_author_box' , 'on' ) == 'on' ) : ?>
<div class="author-content-box">

@ -44,7 +44,7 @@ switch ( $type ) {
break;
}
?>
<div class="opalestate-box-content property-agent-section">
<div class="opalestate-box-content property-agent-section property-author-v1">
<div class="opalestate-box">
<div class="author-content-box">
<div class="opal-row">