Update dashboard.

This commit is contained in:
Hoang Huu 2019-09-25 08:44:27 +07:00
parent 0611233dee
commit 585df648b9
10 changed files with 166 additions and 161 deletions

View File

@ -132,7 +132,7 @@ class Opalestate_Admin_Agency {
$tabs_setting['tabs'][] = array( $tabs_setting['tabs'][] = array(
'id' => 'p-socials', 'id' => 'p-socials',
'icon' => 'dashicons-admin-home', 'icon' => 'dashicons-share',
'title' => esc_html__( 'Socials', 'opalestate-pro' ), 'title' => esc_html__( 'Socials', 'opalestate-pro' ),
'fields' => $metabox->get_social_fields( $prefix ) 'fields' => $metabox->get_social_fields( $prefix )
); );

View File

@ -84,7 +84,7 @@ class Opalestate_Admin_Agent {
$tabs_setting['tabs'][] = [ $tabs_setting['tabs'][] = [
'id' => 'p-socials', 'id' => 'p-socials',
'icon' => 'dashicons-admin-home', 'icon' => 'dashicons-share',
'title' => esc_html__( 'Socials', 'opalestate-pro' ), 'title' => esc_html__( 'Socials', 'opalestate-pro' ),
'fields' => $metabox->get_social_fields( $prefix ), 'fields' => $metabox->get_social_fields( $prefix ),
]; ];
@ -105,11 +105,9 @@ class Opalestate_Admin_Agent {
} }
public function save_post( $post_id, $post, $update ) { public function save_post( $post_id, $post, $update ) {
///
$post_type = get_post_type( $post_id ); $post_type = get_post_type( $post_id );
if ( $post_type == 'opalestate_agent' ) { if ( $post_type == 'opalestate_agent' ) {
if ( isset( $_POST[ OPALESTATE_AGENT_PREFIX . 'user_id' ] ) && absint( $_POST[ OPALESTATE_AGENT_PREFIX . 'user_id' ] ) ) { if ( isset( $_POST[ OPALESTATE_AGENT_PREFIX . 'user_id' ] ) && absint( $_POST[ OPALESTATE_AGENT_PREFIX . 'user_id' ] ) ) {
$user_id = absint( $_POST[ OPALESTATE_AGENT_PREFIX . 'user_id' ] ); $user_id = absint( $_POST[ OPALESTATE_AGENT_PREFIX . 'user_id' ] );
update_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', $post_id ); update_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', $post_id );

View File

@ -108,7 +108,7 @@ class OpalEstate_Admin_User{
$tabs_setting['tabs'][] = array( $tabs_setting['tabs'][] = array(
'id' => 'p-socials', 'id' => 'p-socials',
'icon' => 'dashicons-admin-home', 'icon' => 'dashicons-share',
'title' => esc_html__( 'Socials', 'opalestate-pro' ), 'title' => esc_html__( 'Socials', 'opalestate-pro' ),
'fields' => $metabox->get_social_fields( $prefix ), 'fields' => $metabox->get_social_fields( $prefix ),
); );

View File

@ -83,7 +83,7 @@ class Opalestate_Agency_MetaBox extends Opalestate_User_MetaBox {
'title' => esc_html__( 'Name and Description', 'opalestate-pro' ), 'title' => esc_html__( 'Name and Description', 'opalestate-pro' ),
'object_types' => [ 'opalestate_property' ], 'object_types' => [ 'opalestate_property' ],
'context' => 'normal', 'context' => 'normal',
'object_types' => [ 'user' ], // Tells CMB2 to use user_meta vs post_meta 'object_types' => [ 'user' ],
'priority' => 'high', 'priority' => 'high',
'show_names' => true, 'show_names' => true,
'fields' => $this->get_fields( $prefix ), 'fields' => $this->get_fields( $prefix ),
@ -153,7 +153,6 @@ class Opalestate_Agency_MetaBox extends Opalestate_User_MetaBox {
'type' => 'text_email', 'type' => 'text_email',
'description' => esc_html__( 'Enter contact name that allow user contact you via the contact form of website.', 'opalestate-pro' ), 'description' => esc_html__( 'Enter contact name that allow user contact you via the contact form of website.', 'opalestate-pro' ),
], ],
[ [
'id' => "{$prefix}phone", 'id' => "{$prefix}phone",
'name' => esc_html__( 'Phone', 'opalestate-pro' ), 'name' => esc_html__( 'Phone', 'opalestate-pro' ),

View File

@ -1,15 +1,9 @@
<?php <?php
/** /**
* $Desc$ * OpalEstate_Agency
* *
* @version $Id$
* @package opalestate * @package opalestate
* @author Opal Team <info@wpopal.com > * @author Opal Team <info@wpopal.com >
* @copyright Copyright (C) 2019 wpopal.com. All Rights Reserved.
* @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
*
* @website http://www.wpopal.com
* @support http://www.wpopal.com/support/forum.html
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
@ -54,7 +48,6 @@ class OpalEstate_Agency {
* Constructor * Constructor
*/ */
public function __construct( $post_id = null ) { public function __construct( $post_id = null ) {
global $post; global $post;
$this->post = $post; $this->post = $post;
@ -99,9 +92,7 @@ class OpalEstate_Agency {
* Get url of user avatar by agency id * Get url of user avatar by agency id
*/ */
public static function get_avatar_url( $userID ) { public static function get_avatar_url( $userID ) {
return get_post_meta( $userID, OPALESTATE_AGENCY_PREFIX . "avatar", true ); return get_post_meta( $userID, OPALESTATE_AGENCY_PREFIX . "avatar", true );
} }
/** /**
@ -164,8 +155,9 @@ class OpalEstate_Agency {
$team = []; $team = [];
$ids = get_post_meta( $this->post_id, OPALESTATE_AGENCY_PREFIX . 'team', true ); $ids = get_post_meta( $this->post_id, OPALESTATE_AGENCY_PREFIX . 'team', true );
if ( $ids ) {
foreach ( $ids as $id ) { foreach ( $ids as $id ) {
$user = get_user_by( 'id', $id ); // echo '<pre>' . print_r( $user, 1 );die; $user = get_user_by( 'id', $id );
$team[] = [ $team[] = [
'id' => $user->ID, 'id' => $user->ID,
'name' => $user->display_name, 'name' => $user->display_name,
@ -174,6 +166,7 @@ class OpalEstate_Agency {
'description' => 'okokok', 'description' => 'okokok',
]; ];
} }
}
return $team; return $team;
} }
@ -241,10 +234,11 @@ class OpalEstate_Agency {
} }
/** /**
* Update user data.
* *
* @param $user_id User ID.
*/ */
public static function update_user_data( $user_id ) { public static function update_user_data( $user_id ) {
$fields = self::metaboxes_fields(); $fields = self::metaboxes_fields();
$others = [ $others = [
@ -254,7 +248,7 @@ class OpalEstate_Agency {
foreach ( $fields as $key => $field ) { foreach ( $fields as $key => $field ) {
$kpos = $field['id']; $kpos = $field['id'];
$tmp = str_replace( OPALESTATE_AGENCY_PREFIX, "", $field['id'] ); $tmp = str_replace( OPALESTATE_AGENCY_PREFIX, '', $field['id'] );
if ( isset( $_POST[ $kpos ] ) && $tmp ) { if ( isset( $_POST[ $kpos ] ) && $tmp ) {
$data = is_string( $_POST[ $kpos ] ) ? sanitize_text_field( $_POST[ $kpos ] ) : $_POST[ $kpos ]; $data = is_string( $_POST[ $kpos ] ) ? sanitize_text_field( $_POST[ $kpos ] ) : $_POST[ $kpos ];
update_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . $tmp, $data ); update_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . $tmp, $data );
@ -272,20 +266,20 @@ class OpalEstate_Agency {
} }
/** /**
* Update data from user.
* *
* @param $related_id Post ID
*/ */
public static function update_data_from_user( $related_id ) { public static function update_data_from_user( $related_id ) {
$fields = self::metaboxes_fields(); $fields = self::metaboxes_fields();
$others = [ $others = [
'avatar_id' => '', 'avatar_id' => '',
'map' => '', 'map' => '',
]; ];
foreach ( $fields as $key => $field ) {
$tmp = str_replace( OPALESTATE_AGENCY_PREFIX, "", $field['id'] ); foreach ( $fields as $key => $field ) {
$tmp = str_replace( OPALESTATE_AGENCY_PREFIX, '', $field['id'] );
$kpos = OPALESTATE_USER_PROFILE_PREFIX . $tmp; $kpos = OPALESTATE_USER_PROFILE_PREFIX . $tmp;
if ( isset( $_POST[ $kpos ] ) && $tmp ) { if ( isset( $_POST[ $kpos ] ) && $tmp ) {

View File

@ -1,15 +1,9 @@
<?php <?php
/** /**
* $Desc$ * OpalEstate_Agent
* *
* @version $Id$
* @package opalestate * @package opalestate
* @author Opal Team <info@wpopal.com > * @author Opal Team <info@wpopal.com >
* @copyright Copyright (C) 2019 wpopal.com. All Rights Reserved.
* @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
*
* @website http://www.wpopal.com
* @support http://www.wpopal.com/support/forum.html
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
@ -41,7 +35,6 @@ class OpalEstate_Agent {
* Constructor * Constructor
*/ */
public function __construct( $post_id = null ) { public function __construct( $post_id = null ) {
global $post; global $post;
if ( $post ) { if ( $post ) {
@ -151,8 +144,19 @@ class OpalEstate_Agent {
return array_merge_recursive( $fields, $metabox->get_social_fields( OPALESTATE_AGENT_PREFIX ) ); return array_merge_recursive( $fields, $metabox->get_social_fields( OPALESTATE_AGENT_PREFIX ) );
} }
public static function update_user_data( $user_id ) { /**
* @return mixed
*/
public function get_trusted() {
return $this->is_trusted;
}
/**
* Update user data.
*
* @param $user_id User ID.
*/
public static function update_user_data( $user_id ) {
$fields = self::metaboxes_fields(); $fields = self::metaboxes_fields();
$others = [ $others = [
@ -160,6 +164,7 @@ class OpalEstate_Agent {
'opalestate_agt_map' => '', 'opalestate_agt_map' => '',
'map' => '', 'map' => '',
]; ];
foreach ( $fields as $key => $field ) { foreach ( $fields as $key => $field ) {
$kpos = $field['id']; $kpos = $field['id'];
$tmp = str_replace( OPALESTATE_AGENT_PREFIX, '', $field['id'] ); $tmp = str_replace( OPALESTATE_AGENT_PREFIX, '', $field['id'] );
@ -180,27 +185,20 @@ class OpalEstate_Agent {
} }
/** /**
* Update data from user.
* *
*/ * @param $related_id Post ID.
public function get_trusted() {
return $this->is_trusted;
}
/**
*
*/ */
public static function update_data_from_user( $related_id ) { public static function update_data_from_user( $related_id ) {
$fields = self::metaboxes_fields(); $fields = self::metaboxes_fields();
$others = [ $others = [
'avatar_id' => '', 'avatar_id' => '',
'map' => '', 'map' => '',
]; ];
foreach ( $fields as $key => $field ) {
$tmp = str_replace( OPALESTATE_AGENT_PREFIX, "", $field['id'] ); foreach ( $fields as $key => $field ) {
$tmp = str_replace( OPALESTATE_AGENT_PREFIX, '', $field['id'] );
$kpos = OPALESTATE_USER_PROFILE_PREFIX . $tmp; $kpos = OPALESTATE_USER_PROFILE_PREFIX . $tmp;
if ( isset( $_POST[ $kpos ] ) && $tmp ) { if ( isset( $_POST[ $kpos ] ) && $tmp ) {
@ -273,5 +271,3 @@ class OpalEstate_Agent {
return 4; return 4;
} }
} }
?>

View File

@ -107,6 +107,7 @@ class OpalEstate_Nocaptcha_Recaptcha {
'off' => esc_html__( 'No', 'opalestate-pro' ), 'off' => esc_html__( 'No', 'opalestate-pro' ),
'on' => esc_html__( 'Yes', 'opalestate-pro' ), 'on' => esc_html__( 'Yes', 'opalestate-pro' ),
], ],
'default' => 'on',
], ],
[ [

View File

@ -18,8 +18,16 @@ if ( ! class_exists( 'OpalEstate_User' ) ) {
} }
get_header( 'no-sidebar' ); get_header( 'no-sidebar' );
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$user_info = "<span class='display-name'>{$current_user->display_name}</span>";
if ( $current_user->display_name !== $current_user->user_login ) {
$user_info .= "<span class='username'>{$current_user->user_login}</span>";
}
?> ?>
<?php if ( get_current_user_id() ): ?> <?php if ( $user_id ): ?>
<div class="dashboard-navbar"> <div class="dashboard-navbar">
<div class="clearfix"> <div class="clearfix">
<div class="pull-left navbar-left"> <div class="pull-left navbar-left">
@ -52,12 +60,13 @@ get_header( 'no-sidebar' );
<ul class="list-inline"> <ul class="list-inline">
<li> <li>
<div class="opalestate-user-greeting opalestate-popup hover-align-right"> <div class="opalestate-user-greeting opalestate-popup hover-align-right">
<div class="popup-head"><a href="#"><?php $user_id = get_current_user_id(); ?> <span class="howdy"><?php printf( __( 'Howdy, %s', 'opalestate-pro' ), '<span class="display-name">' . $current_user->display_name . '</span>' ); ?></span>
<div class="popup-head">
<a href="#">
<div class="opalestate-user-image"> <div class="opalestate-user-image">
<img src="<?php echo esc_url( OpalEstate_User::get_author_picture( $user_id ) ); ?>" alt="<?php esc_attr_e( 'Avatar image', 'opalestate-pro' ); ?>"/> <img src="<?php echo esc_url( OpalEstate_User::get_author_picture( $user_id ) ); ?>" alt="<?php esc_attr_e( 'Avatar image', 'opalestate-pro' ); ?>"/>
</div> </div>
<span class="notify active"></span> <span class="notify active"></span>
</a> </a>
</div> </div>
<div class="popup-body"> <div class="popup-body">

View File

@ -1,5 +1,4 @@
<?php <?php
$agency = OpalEstate_Agency::get_instance( $post_id ); $agency = OpalEstate_Agency::get_instance( $post_id );
$users = $agency->get_members(); $users = $agency->get_members();
@ -7,42 +6,37 @@ $users = $agency->get_members();
$sender_id = ''; $sender_id = '';
$prefix = ''; $prefix = '';
$fields = array( $fields = [
[
array( 'id' => 'sender_id',
'id' => "sender_id",
'name' => esc_html__( 'Sender ID', 'opalestate-pro' ), 'name' => esc_html__( 'Sender ID', 'opalestate-pro' ),
'type' => 'hidden', 'type' => 'hidden',
'default' => "", ],
'description' => "", [
),
array(
'id' => "{$prefix}user_id", 'id' => "{$prefix}user_id",
'name' => esc_html__( 'Name', 'opalestate-pro' ), 'name' => esc_html__( 'Name', 'opalestate-pro' ),
'type' => 'select', 'type' => 'select',
'class' => 'form-control opalesate-find-user', 'class' => 'form-control opalesate-find-user',
'default' => "",
'required' => 'required', 'required' => 'required',
'description' => "", ],
), ];
);
$form = OpalEstate()->html->render_form( $fields ); $form = OpalEstate()->html->render_form( $fields );
$id = 'agency-add-member'; $id = 'agency-add-member';
?> ?>
<div class="opalestate-agency-team"> <div class="opalestate-agency-team">
<h3><?php esc_html_e( 'Agency Team' , 'opalestate-pro' ); ?></h3> <h3><a href="<?php echo esc_url( get_the_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( get_the_title( $post_id ) ); ?>" target="_blank"><?php esc_html_e( 'Agency Team', 'opalestate-pro' );
?></a></h3>
<div class="opal-row"> <div class="opal-row">
<div class="col-lg-4 col-md-3"> <div class="col-lg-4 col-md-3">
<div class="agency-add-team"> <div class="agency-add-team">
<p><?php esc_html_e( "As an author, you can add other users to your agency.", "opalestate" ); ?></p> <p><?php esc_html_e( 'As an author, you can add other users to your agency.', 'opalestate-pro' ); ?></p>
<p><?php esc_html_e( "Add someone to your agency, please enter extractly username in below input:", "opalestate" ); ?></p> <p><?php esc_html_e( 'Add someone to your agency, please enter extractly username in below input:', 'opalestate-pro' ); ?></p>
<form method="post" id="opalestate-add-team-form"> <form method="post" id="opalestate-add-team-form">
<?php echo $form; ?> <?php echo $form; ?>
<?php wp_nonce_field( $id, 'add_team_action' ); ?> <?php wp_nonce_field( $id, 'add_team_action' ); ?>
<button class="button btn btn-primary btn-3d" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> <?php esc_html_e( 'Processing', 'opalestate-pro' ); ?>" type="submit" name="contact-form"><?php echo esc_html__( 'Send message', 'opalestate-pro' ); ?></button> <button class="button btn btn-primary btn-3d" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> <?php esc_html_e( 'Processing', 'opalestate-pro' ); ?>" type="submit"
name="contact-form"><?php esc_html_e( 'Add', 'opalestate-pro' ); ?></button>
</form> </form>
</div> </div>
</div> </div>
@ -51,29 +45,34 @@ $id = 'agency-add-member';
<div class="agency-listing-team"> <div class="agency-listing-team">
<table> <table>
<tr> <tr>
<th><?php esc_html_e('Users in your team'); ?></th> <th><?php esc_html_e( 'Users in your team', 'opalestate-pro' ); ?></th>
<th width="100"><?php esc_html_e('Action'); ?></th> <th width="100"><?php esc_html_e( 'Action', 'opalestate-pro' ); ?></th>
</tr> </tr>
<?php foreach( $users as $user ): // echo '<pre>' . print_r( $user, 1);die; ?> <?php foreach ( $users as $user ) : ?>
<?php
$agent_id = get_user_meta( $user['id'], OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
$url = $agent_id ? get_the_permalink( $agent_id ) : '#';
?>
<tr> <tr>
<td> <td>
<div class="media"> <div class="media">
<img src="<?php echo $user['avatar_url'];?>" width="80"> <a href="<?php echo esc_url( $url ); ?>" title="<?php echo esc_attr( $user['name'] ); ?>" target="_blank">
<div class="fullname"><?php echo $user['name']; ?> (<?php echo $user['username']; ?> )</div> <img src="<?php echo esc_url( $user['avatar_url'] ); ?>" width="80">
<div class="fullname"><?php echo esc_html( $user['name'] ); ?> (<?php echo esc_html( $user['username'] ); ?> )</div>
</a>
</div> </div>
</td> </td>
<td> <td>
<a href="<?php echo opalestate_get_user_management_page_uri( array('tab' => 'agency_team', 'remove_id' => $user['id'] ) ); ?>" title="<?php esc_html_e( "Remove" , "opalestate" ); ?>"> <a href="<?php echo opalestate_get_user_management_page_uri( [ 'tab' => 'agency_team', 'remove_id' => $user['id'] ] ); ?>"
title="<?php esc_html_e( 'Remove', 'opalestate-pro' ); ?>">
<i class="fa fa-trash"></i> <i class="fa fa-trash"></i>
</a> </a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,7 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="property-submission-form"> <div class="property-submission-form">
<?php if ( ! empty( $_SESSION['messages'] ) ) : ?> <?php if ( ! empty( $_SESSION['messages'] ) ) : ?>
<div class="opalesate_messages"> <div class="opalesate_messages">
<?php foreach ( $_SESSION['messages'] as $message ) : ?> <?php foreach ( $_SESSION['messages'] as $message ) : ?>
@ -11,7 +14,8 @@
<?php printf( '%s', $msg ) ?> <?php printf( '%s', $msg ) ?>
</div> </div>
<?php endforeach; unset( $_SESSION['messages'] ); ?> <?php endforeach;
unset( $_SESSION['messages'] ); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
@ -19,16 +23,23 @@
<div class="opalestate-admin-box"> <div class="opalestate-admin-box">
<div class="box-content"> <div class="box-content">
<h3><?php esc_html_e( 'Edit User Profile', 'opalestate-pro' ); ?></h3> <?php
$current_user = wp_get_current_user();
$user_info = '';
if ( $current_user->display_name !== $current_user->user_login ) {
$user_info = "<span class='username'>({$current_user->user_login})</span>";
}
?>
<h3><?php esc_html_e( 'Edit User Profile', 'opalestate-pro' ); ?>&nbsp;<?php echo wp_kses_post( $user_info ); ?></h3>
<?php <?php
do_action( 'opalestate_profile_form_before' ); do_action( 'opalestate_profile_form_before' );
if ( function_exists( 'cmb2_get_metabox_form' ) ) { if ( function_exists( 'cmb2_get_metabox_form' ) ) {
echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_USER_PROFILE_PREFIX . 'front' ], $user_id, array( echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_USER_PROFILE_PREFIX . 'front' ], $user_id, [
'form_format' => '<form action="//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '" class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<input type="submit" name="submit-cmb" value="%4$s" class="button-primary btn btn-primary"></form>', 'form_format' => '<form action="//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '" class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<input type="submit" name="submit-cmb" value="%4$s" class="button-primary btn btn-primary"></form>',
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ), 'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
) ); ] );
} }
do_action( 'opalestate_profile_form_after' ); do_action( 'opalestate_profile_form_after' );
@ -53,8 +64,6 @@
do_action( 'opalestate_profile_form_after' ); do_action( 'opalestate_profile_form_after' );
?> ?>
</div> </div>
</div> </div>
</div> </div>