if ( ! function_exists( 'es_get_the_property' ) ) { /** * Return property instance in loop. * * @param int $post * * @return Es_Property */ function es_get_the_property( $post = 0 ) { $post = get_post( $post ); return es_get_property( $post->ID ); } } if ( ! function_exists( 'es_get_the_user' ) ) { /** * Return user (Agent or Seller) instance in loop. * * @param int $post * * @return Es_User_Post */ function es_get_the_user( $post = 0 ) { $post = get_post( $post ); if ( user_can( $post->post_author, 'agent' ) ) { return es_get_agent( $post->ID ); } elseif ( user_can( $post->post_author, 'seller' ) ) { return es_get_seller( $post->ID ); } else { return null; } } } if ( ! function_exists( 'es_get_the_agent' ) ) { /** * Return agent instance in loop. * * @param int $post * * @return Es_Agent_Post */ function es_get_the_agent( $post = 0 ) { $post = get_post( $post ); return es_get_agent( $post->ID ); } } if ( ! function_exists( 'es_get_the_seller' ) ) { /** * Return seller instance in loop. * * @param int $post * * @return Es_Seller_Post */ function es_get_the_seller( $post = 0 ) { $post = get_post( $post ); return es_get_seller( $post->ID ); } } if ( ! function_exists( 'es_get_the_user_avatar_url' ) ) { /** * Return user (Agent or Seller) avatar URL. * * @param int $post_id * @param string $size * * @return mixed|void */ function es_get_the_user_avatar_url( $post_id = 0, $size = 'thumbnail' ) { $post_id = $post_id ? $post_id : get_the_ID(); if ( user_can( $post_id, 'agent' ) ) { return es_get_the_agent_avatar_url( $post_id, $size ); } elseif ( user_can( $post_id, 'seller' ) ) { return es_get_the_seller_avatar_url( $post_id, $size ); } return null; } } if ( ! function_exists( 'es_get_the_seller_avatar_url' ) ) { /** * Return seller avatar URL. * * @param int $post_id * @param string $size * * @return mixed|void */ function es_get_the_seller_avatar_url( $post_id = 0, $size = 'thumbnail' ) { $post_id = $post_id ? $post_id : get_the_ID(); if ( has_post_thumbnail( $post_id ) ) { $img = get_the_post_thumbnail_url( $post_id, $size ); } else { $img = es_seller_get_default_image_url(); } return apply_filters( 'es_get_the_seller_avatar_url', $img, $post_id, $size ); } } if ( ! function_exists( 'es_get_the_user_config' ) ) { /** * Get config for agent or seller. * * @param int $post_id * * @return mixed|void */ function es_get_the_user_config( $post_id = 0 ) { $post_id = $post_id ? $post_id : get_the_ID(); $config = array(); $entity = es_get_entity_by_id( $post_id ); if ( $entity && ! empty( $entity->user_id ) ) { foreach ( $entity->user_id as $user_id ) { if ( user_can( $user_id, 'agent' ) ) { $user = es_get_agent( $user_id ); $config[ $user_id ] = array( 'id' => $user_id, 'value' => $user_id, 'title' => get_the_title( $user_id ), 'subtitle' => $user->position, 'image' => es_get_the_agent_avatar( $user_id ), ); } elseif ( user_can( $user_id, 'seller' ) ) { $user = es_get_seller( $user_id ); $config[ $user_id ] = array( 'id' => $user_id, 'value' => $user_id, 'title' => get_the_title( $user_id ), 'subtitle' => 'Seller', // Customize subtitle for sellers 'image' => es_get_the_seller_avatar( $user_id ), ); } } } return apply_filters( 'es_get_the_user_config', $config, $post_id ); } } Page not found – Realzify