Update agent front end.
This commit is contained in:
parent
2121f291ea
commit
59e3459243
@ -90,15 +90,20 @@ class Opalestate_Agent_Front {
|
|||||||
* render_profile
|
* render_profile
|
||||||
*/
|
*/
|
||||||
public function render_profile() {
|
public function render_profile() {
|
||||||
|
|
||||||
$user_id = get_current_user_id();
|
$user_id = get_current_user_id();
|
||||||
$post_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
|
$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 );
|
$post = get_post( $post_id );
|
||||||
|
|
||||||
if ( isset( $post->ID ) && $post->post_status != 'publish' ) {
|
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_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" );
|
add_action( 'opalestate_profile_agency_form_before', 'opalestate_print_notices' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$metaboxes = $this->render_front_form( [], $post_id );
|
$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 : [];
|
$atts = is_array( $atts ) ? $atts : [];
|
||||||
$layout = 'search-agency-form';
|
$layout = 'search-agency-form';
|
||||||
|
|
||||||
$default = array(
|
$default = [
|
||||||
'current_uri' => null,
|
'current_uri' => null,
|
||||||
'column' => 4,
|
'column' => 4,
|
||||||
'limit' => 12,
|
'limit' => 12,
|
||||||
'paged' => 1,
|
'paged' => 1,
|
||||||
'onlyfeatured' => 0,
|
'onlyfeatured' => 0,
|
||||||
'form' => $layout
|
'form' => $layout,
|
||||||
);
|
];
|
||||||
|
|
||||||
$atts = array_merge( $default, $atts );
|
$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 ) {
|
public function archives_query( $query ) {
|
||||||
@ -461,7 +466,6 @@ class Opalestate_Agent_Front {
|
|||||||
'posts_per_page' => 10,
|
'posts_per_page' => 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$args['meta_key'] = OPALESTATE_AGENT_PREFIX . 'user_id';
|
$args['meta_key'] = OPALESTATE_AGENT_PREFIX . 'user_id';
|
||||||
$args['meta_value'] = $user_id;
|
$args['meta_value'] = $user_id;
|
||||||
$args['meta_compare'] = '=';
|
$args['meta_compare'] = '=';
|
||||||
@ -478,9 +482,10 @@ class Opalestate_Agent_Front {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function create_agent( $args = [], $user_id ) {
|
public function create_agent( $args = [], $user_id ) {
|
||||||
|
|
||||||
$data = get_user_by( 'id', $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, [
|
$args = wp_parse_args( $args, [
|
||||||
'first_name' => $data->first_name,
|
'first_name' => $data->first_name,
|
||||||
'last_name' => $data->last_name,
|
'last_name' => $data->last_name,
|
||||||
@ -500,8 +505,14 @@ class Opalestate_Agent_Front {
|
|||||||
'instagram' => '',
|
'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( [
|
$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_content' => '',
|
||||||
'post_excerpt' => '',
|
'post_excerpt' => '',
|
||||||
'post_type' => 'opalestate_agent',
|
'post_type' => 'opalestate_agent',
|
||||||
@ -509,7 +520,6 @@ class Opalestate_Agent_Front {
|
|||||||
'post_author' => $user_id,
|
'post_author' => $user_id,
|
||||||
], true );
|
], true );
|
||||||
|
|
||||||
|
|
||||||
do_action( 'opalesate_insert_user_agent', $agent_id );
|
do_action( 'opalesate_insert_user_agent', $agent_id );
|
||||||
|
|
||||||
return $agent_id;
|
return $agent_id;
|
||||||
|
@ -233,6 +233,8 @@ class Property_Api extends Base_Api {
|
|||||||
$property['locations'] = $data->get_locations();
|
$property['locations'] = $data->get_locations();
|
||||||
$property['amenities'] = $data->get_amenities();
|
$property['amenities'] = $data->get_amenities();
|
||||||
$property['types'] = $data->get_types_tax();
|
$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 );
|
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>';
|
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 );
|
$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 );
|
$related_id = get_user_meta( get_the_author_meta( 'ID' ), OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
|
||||||
|
@ -50,7 +50,7 @@ switch ( $type ) {
|
|||||||
break;
|
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="opalestate-box">
|
||||||
<div class="author-content-box">
|
<div class="author-content-box">
|
||||||
<div class="property-agent-info">
|
<div class="property-agent-info">
|
||||||
|
@ -44,7 +44,7 @@ switch ( $type ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="opalestate-box-content property-agent-section">
|
<div class="opalestate-box-content property-agent-section property-author-v3">
|
||||||
<div class="opalestate-box">
|
<div class="opalestate-box">
|
||||||
<?php if ( opalestate_get_option( 'enable_single_author_box' , 'on' ) == 'on' ) : ?>
|
<?php if ( opalestate_get_option( 'enable_single_author_box' , 'on' ) == 'on' ) : ?>
|
||||||
<div class="author-content-box">
|
<div class="author-content-box">
|
||||||
|
@ -44,7 +44,7 @@ switch ( $type ) {
|
|||||||
break;
|
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="opalestate-box">
|
||||||
<div class="author-content-box">
|
<div class="author-content-box">
|
||||||
<div class="opal-row">
|
<div class="opal-row">
|
||||||
|
Loading…
Reference in New Issue
Block a user