This commit is contained in:
Hoang Huu 2019-10-01 14:04:57 +07:00
commit ff39207b86
13 changed files with 245 additions and 236 deletions

View File

@ -61,9 +61,9 @@ class Opalestate_Agency_Front {
add_filter( 'opalestate_management_user_menu', [ $this, 'render_extra_profile_link' ] );
add_action( "opalestate_user_content_agency_profile_page", [ $this, 'render_profile' ] );
add_action( "opalestate_user_content_agency_team_page", [ $this, 'render_team' ] );
add_action( "opalestate_user_init", [ $this, 'process_action_member' ] );
add_action( 'opalestate_user_content_agency_profile_page', [ $this, 'render_profile' ] );
add_action( 'opalestate_user_content_agency_team_page', [ $this, 'render_team' ] );
add_action( 'opalestate_user_init', [ $this, 'process_action_member' ] );
$this->register_shortcodes();
}
@ -153,7 +153,6 @@ class Opalestate_Agency_Front {
unset( $_POST[ $prefix . 'title' ] );
unset( $_POST[ $prefix . 'text' ] );
if ( $data['ID'] > 0 ) {
$post_id = wp_update_post( $data, true );
} else {
@ -309,8 +308,8 @@ class Opalestate_Agency_Front {
*/
public function register_shortcodes() {
$this->shortcodes = [
'search_agencies' => [ 'code' => 'search_agencies', 'label' => esc_html__( 'Search Agencies', 'opalestate-pro' ) ],
'agency_carousel' => [ 'code' => 'agency_carousel', 'label' => esc_html__( 'Agency Carousel', 'opalestate-pro' ) ],
'search_agencies' => [ 'code' => 'search_agencies', 'label' => esc_html__( 'Search Agencies', 'opalestate-pro' ) ],
'agency_carousel' => [ 'code' => 'agency_carousel', 'label' => esc_html__( 'Agency Carousel', 'opalestate-pro' ) ],
];
foreach ( $this->shortcodes as $shortcode ) {
@ -318,51 +317,59 @@ class Opalestate_Agency_Front {
}
}
public function agency_carousel ( $atts ) {
public function agency_carousel( $atts ) {
$atts = is_array( $atts ) ? $atts : [];
$atts = is_array( $atts ) ? $atts : [];
$default = array(
'current_uri' => null,
'column' => 3,
'limit' => 12,
'paged' => 1,
'onlyfeatured' => 0,
);
$default = [
'current_uri' => null,
'column' => 3,
'limit' => 12,
'paged' => 1,
'onlyfeatured' => 0,
];
$atts = array_merge( $default, $atts );
return opalestate_load_template_path( 'shortcodes/agency-carousel' , $atts );
return opalestate_load_template_path( 'shortcodes/agency-carousel', $atts );
}
/**
*
*/
public function search_agencies ( $atts=[] ) {
public function search_agencies( $atts = [] ) {
$atts = is_array( $atts ) ? $atts : [];
$layout = 'search-agency-form';
$atts = is_array( $atts ) ? $atts : [];
$layout = 'search-agency-form';
$default = array(
'current_uri' => null,
'form' => $layout
);
$default = [
'current_uri' => null,
'form' => $layout,
];
$atts = array_merge( $default, $atts );
return opalestate_load_template_path( 'shortcodes/search-agencies' , $atts );
return opalestate_load_template_path( 'shortcodes/search-agencies', $atts );
}
/**
*
*/
public function render_profile() {
$user_id = get_current_user_id();
$post_id = OpalEstate_User::get_member_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" );
// Check if have not any relationship, create a new then update this meta value.
if ( ! $post_id || $post_id < 0 ) {
static::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' || $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 );
@ -446,15 +453,12 @@ class Opalestate_Agency_Front {
}
public static function on_set_role( $user_id ) {
if ( $user_id ) {
$args = [
'post_type' => 'opalestate_agency',
'posts_per_page' => 10,
];
$args['meta_key'] = OPALESTATE_AGENCY_PREFIX . 'user_id';
$args['meta_value'] = $user_id;
$args['meta_compare'] = '=';
@ -477,6 +481,8 @@ class Opalestate_Agency_Front {
public static function create_agency( $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,
@ -495,9 +501,14 @@ class Opalestate_Agency_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 );
}
$agency_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' => 'empty description',
'post_excerpt' => 'empty excerpt',
'post_type' => 'opalestate_agency',

View File

@ -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 );
$post = get_post( $post_id );
// 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 );
}
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" );
$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' || $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_agent_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';
$atts = is_array( $atts ) ? $atts : [];
$layout = 'search-agency-form';
$default = array(
'current_uri' => null,
'column' => 4,
'limit' => 12,
'paged' => 1,
'onlyfeatured' => 0,
'form' => $layout
);
$default = [
'current_uri' => null,
'column' => 4,
'limit' => 12,
'paged' => 1,
'onlyfeatured' => 0,
'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;

202
inc/api/v1/property.php Executable file → Normal file
View File

@ -1,118 +1,111 @@
<?php
/**
* Define
* Note: only use for internal purpose.
*
* @package OpalJob
* @copyright Copyright (c) 2019, WpOpal <https://www.wpopal.com>
* @license https://opensource.org/licenses/gpl-license GNU Public License
* @since 1.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @class Job_Api
* Property_Api
*
* @since 1.0.0
* @package Opal_Job
* @subpackage Opal_Job/controllers
* @package Property_Api
*/
class Property_Api extends Base_Api {
class Property_Api extends Base_Api {
/**
* The unique identifier of the route resource.
*
* @since 1.0.0
* @access public
* @var string $base.
* @var string $base .
*/
public $base = '/property';
/**
/**
* Register Routes
*
* Register all CURD actions with POST/GET/PUT and calling function for each
*
* @return avoid
* @since 1.0
*
* @return avoid
*/
public function register_routes ( ) {
/// call http://domain.com/wp-json/job-api/v1/job/list ////
register_rest_route( $this->namespace, $this->base.'/list', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_list' ),
'permission_callback' => array( $this, 'validate_request' ),
));
public function register_routes() {
/// call http://domain.com/wp-json/estate-api/v1/estate/list ////
register_rest_route( $this->namespace, $this->base . '/list', [
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_list' ],
'permission_callback' => [ $this, 'validate_request' ],
] );
/// call http://domain.com/wp-json/job-api/v1/job/featured ////
register_rest_route( $this->namespace, $this->base.'/featured', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_featured_list' ),
'permission_callback' => array( $this, 'validate_request' ),
));
/// call http://domain.com/wp-json/estate-api/v1/estate/featured ////
register_rest_route( $this->namespace, $this->base . '/featured', [
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_featured_list' ],
'permission_callback' => [ $this, 'validate_request' ],
] );
/// call http://domain.com/wp-json/job-api/v1/job/1 ////
register_rest_route( $this->namespace, $this->base.'/(?P<id>\d+)', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_job' ),
'permission_callback' => array( $this, 'validate_request' ),
));
register_rest_route( $this->namespace, $this->base . '/(?P<id>\d+)', [
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_job' ],
'permission_callback' => [ $this, 'validate_request' ],
] );
/// call http://domain.com/wp-json/job-api/v1/job/create ////
register_rest_route( $this->namespace, $this->base.'/create', array(
'methods' => 'GET',
'callback' => array( $this, 'create' ),
'permission_callback' => array( $this, 'validate_request' ),
));
register_rest_route( $this->namespace, $this->base . '/create', [
'methods' => 'GET',
'callback' => [ $this, 'create' ],
'permission_callback' => [ $this, 'validate_request' ],
] );
/// call http://domain.com/wp-json/job-api/v1/job/edit ////
register_rest_route( $this->namespace, $this->base.'/edit', array(
'methods' => 'GET',
'callback' => array( $this, 'edit' ),
));
register_rest_route( $this->namespace, $this->base . '/edit', [
'methods' => 'GET',
'callback' => [ $this, 'edit' ],
] );
/// call http://domain.com/wp-json/job-api/v1/job/delete ////
register_rest_route( $this->namespace, $this->base.'/delete', array(
'methods' => 'GET',
'callback' => array( $this, 'delete' ),
'permission_callback' => array( $this, 'validate_request' ),
));
register_rest_route( $this->namespace, $this->base . '/delete', [
'methods' => 'GET',
'callback' => [ $this, 'delete' ],
'permission_callback' => [ $this, 'validate_request' ],
] );
/**
* List job by tags and taxonmies
*/
/// call http://domain.com/wp-json/job-api/v1/jobs ////
register_rest_route( $this->namespace, $this->base.'/tags', array(
'methods' => 'GET',
'callback' => array( $this, 'delete' ),
'permission_callback' => array( $this, 'validate_request' ),
));
register_rest_route( $this->namespace, $this->base . '/tags', [
'methods' => 'GET',
'callback' => [ $this, 'delete' ],
'permission_callback' => [ $this, 'validate_request' ],
] );
}
public function get_featured_list() {
$properties = array();
$error = array();
public function get_featured_list() {
$properties = [];
$error = [];
$property = null;
if ( $property == null ) {
$properties = array();
$properties = [];
$property_list = get_posts( array(
$property_list = get_posts( [
'post_type' => 'opalestate_property',
'posts_per_page' => $this->per_page(),
'suppress_filters' => true,
'meta_key' => OPALESTATE_PROPERTY_PREFIX . 'featured',
'meta_value' => 'on',
'paged' => $this->get_paged()
) );
'meta_key' => OPALESTATE_PROPERTY_PREFIX . 'featured',
'meta_value' => 'on',
'paged' => $this->get_paged(),
] );
if ( $property_list ) {
$i = 0;
foreach ( $property_list as $property_info ) {
$properties[ $i ] = $this->get_property_data( $property_info );
$i ++;
$i++;
}
}
} else {
@ -123,7 +116,7 @@ class Property_Api extends Base_Api {
} else {
$error['error'] = sprintf(
/* translators: %s: property */
/* translators: %s: property */
esc_html__( 'Form %s not found!', 'opalestate-pro' ),
$property
);
@ -132,44 +125,44 @@ class Property_Api extends Base_Api {
}
}
$response['collection'] = $properties;
$response['pages'] = 4;
$response['current'] = 1;
$response['collection'] = $properties;
$response['pages'] = 4;
$response['current'] = 1;
return $this->get_response( 200, $response );
}
}
/**
* Get List Of Job
*
* Based on request to get collection
*
* @return WP_REST_Response is json data
* @since 1.0
*
* @return WP_REST_Response is json data
*/
public function get_list ( $request ) {
public function get_list( $request ) {
$properties = array();
$error = array();
$properties = [];
$error = [];
$property = null;
if ( $property == null ) {
$properties = array();
$properties = [];
$property_list = get_posts( array(
$property_list = get_posts( [
'post_type' => 'opalestate_property',
'posts_per_page' => $this->per_page(),
'suppress_filters' => true,
'paged' => $this->get_paged()
) );
'paged' => $this->get_paged(),
] );
if ( $property_list ) {
$i = 0;
foreach ( $property_list as $property_info ) {
$properties[ $i ] = $this->get_property_data( $property_info );
$i ++;
$i++;
}
}
} else {
@ -180,7 +173,7 @@ class Property_Api extends Base_Api {
} else {
$error['error'] = sprintf(
/* translators: %s: property */
/* translators: %s: property */
esc_html__( 'Form %s not found!', 'opalestate-pro' ),
$property
);
@ -189,9 +182,10 @@ class Property_Api extends Base_Api {
}
}
$response['collection'] = $properties;
$response['pages'] = 4;
$response['current'] = 1;
$response['collection'] = $properties;
$response['pages'] = 4;
$response['current'] = 1;
return $this->get_response( 200, $response );
}
@ -199,15 +193,15 @@ class Property_Api extends Base_Api {
/**
* Opalestaten a opalestate_property post object, generate the data for the API output
*
* @since 1.1
*
* @param object $property_info The Download Post Object
* @param object $property_info The Download Post Object
*
* @return array Array of post data to return back in the API
* @since 1.1
*
*/
private function get_property_data( $property_info ) {
$property = array();
$property = [];
$property['info']['id'] = $property_info->ID;
$property['info']['slug'] = $property_info->post_name;
@ -219,24 +213,24 @@ class Property_Api extends Base_Api {
$property['info']['content'] = $property_info->post_content;
$property['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $property_info->ID ) );
$data = opalesetate_property( $property_info->ID );
$gallery = $data->get_gallery();
$property['info']['gallery'] = isset($gallery[0]) && !empty($gallery[0]) ? $gallery[0]: array();
$property['info']['price'] = opalestate_price_format( $data->get_price() );
$property['info']['map'] = $data->get_map();
$data = opalesetate_property( $property_info->ID );
$gallery = $data->get_gallery();
$property['info']['gallery'] = isset( $gallery[0] ) && ! empty( $gallery[0] ) ? $gallery[0] : [];
$property['info']['price'] = opalestate_price_format( $data->get_price() );
$property['info']['map'] = $data->get_map();
$property['info']['address'] = $data->get_address();
$property['meta'] = $data->get_meta_shortinfo();
$property['meta'] = $data->get_meta_shortinfo();
$property['is_featured'] = $data->is_featured();
$property['status'] = $data->get_status();
$property['labels'] = $data->get_labels();
$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();
$property['is_featured'] = $data->is_featured();
$property['status'] = $data->get_status();
$property['labels'] = $data->get_labels();
$property['locations'] = $data->get_locations();
$property['amenities'] = $data->get_amenities();
$property['types'] = $data->get_types_tax();
return apply_filters( 'opalestate_api_properties_property', $property );
}
/**
@ -244,24 +238,24 @@ class Property_Api extends Base_Api {
*
* Based on request to get collection
*
* @return WP_REST_Response is json data
* @since 1.0
*
* @return WP_REST_Response is json data
*/
public function delete( ) {
public function delete() {
}
public function reviews () {
public function reviews() {
}
public function categories () {
public function categories() {
}
public function tags () {
public function tags() {
}
}

View File

@ -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 );

View File

@ -186,8 +186,8 @@ class Opalestate_User_Form_Handler {
if ( $password !== $password1 ) {
throw new Exception( '<strong>' . esc_html__( 'ERROR', 'opalestate-pro' ) . ':</strong> ' . esc_html__( 'Re-Password is not match.', 'opalestate-pro' ) );
}
$credentials['user_pass'] = $password;
$credentials['user_pass'] = $password;
/* create new user */
$user_id = opalestate_create_user( $credentials );
@ -195,8 +195,7 @@ class Opalestate_User_Form_Handler {
if ( is_wp_error( $user_id ) ) {
throw new Exception( '<strong>' . esc_html__( 'ERROR', 'opalestate-pro' ) . ':</strong> ' . $user_id->get_error_message() );
} else {
/* after register successfully */
/* After register successfully */
do_action( 'opalestate_after_register_successfully', $user_id );
$redirect = home_url();
@ -213,7 +212,7 @@ class Opalestate_User_Form_Handler {
$redirect = apply_filters( 'opalestate_register_redirect_url', $redirect );
/* is ajax request */
/* Is ajax request */
if ( opalestate_is_ajax_request() ) {
wp_send_json( [ 'status' => true, 'redirect' => $redirect ] );
} else {

View File

@ -185,20 +185,24 @@ class OpalEstate_User {
}
/**
* On Register user.
*
* @param int $user_id User ID
*/
public function on_regiser_user( $user_id ) {
if ( isset( $_POST['role'] ) ) {
$roles = opalestate_user_roles_by_user_id( $user_id );
// Fetch the WP_User object of our user.
$u = new WP_User( $user_id );
$u->remove_role( 'subscriber' );
// Replace the current role with 'editor' role
$u->set_role( sanitize_text_field( $_POST['role'] ) );
$roles = opalestate_user_roles_by_user_id( $user_id );
if ( $roles && in_array( $_POST['role'], $roles ) ) {
$role = str_replace( 'opalestate_', '', sanitize_text_field( $_POST['role'] ) );
do_action( 'opalestate_on_set_role_' . $role, $user_id );
}
}

View File

@ -29,7 +29,7 @@ $property = opalesetate_property( get_the_ID() );
<?php endif; ?>
</div>
<p class="property-description">
<?php echo opalestate_fnc_excerpt( 14, '...' ); ?>
<?php echo opalestate_fnc_excerpt( 38, '...' ); ?>
</p>
</div>
</div><!-- .entry-content -->

View File

@ -50,7 +50,8 @@ 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">
@ -59,5 +60,3 @@ switch ( $type ) {
</div>
</div>
</div>

View File

@ -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">

View File

@ -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">

View File

@ -6,10 +6,8 @@
$prefix = OPALESTATE_USER_PROFILE_PREFIX;
}
$user_id = $author->ID;
$is_sticky = get_user_meta( $user_id, $prefix . 'sticky', true );
$user_id = $author->ID;
$is_sticky = get_user_meta( $user_id, $prefix . 'sticky', true );
$desciption = get_user_meta( $user_id, 'description', true );
$roles = opalestate_user_roles_by_user_id( $user_id );
@ -75,7 +73,6 @@
</div>
</div><!-- /.agent-preview -->
<div class="agent-box-meta">
<h4 class="agent-box-title">
<a href="<?php echo esc_url( $link ); ?>"><?php echo esc_html( $author_name ); ?></a>
@ -143,11 +140,8 @@
<?php if ( $linkedIn && $linkedIn != "#" && ! empty( $linkedIn ) ) { ?>
<a class="opalestate-social-white radius-x" href="<?php echo esc_url( $linkedIn ); ?>"> <i class="fab fa-linkedIn"></i></a>
<?php } ?>
</div>
</div><!-- /.agent-box-content -->
</div><!-- /.agent-box-->
</div>
<?php endif; ?>

View File

@ -1,40 +1,39 @@
<div class="property-submission-form">
<?php if ( ! empty( $_SESSION['messages'] ) ) : ?>
<div class="opalesate_messages">
<div class="opalesate_messages">
<?php foreach ( $_SESSION['messages'] as $message ) : ?>
<?php $status = isset( $message[0] ) ? $message[0] : 'success'; ?>
<?php $msg = isset( $message[1] ) ? $message[1] : ''; ?>
<div class="opalesate_message_line <?php echo esc_attr( $status ) ?>">
<div class="opalesate_message_line <?php echo esc_attr( $status ) ?>">
<?php printf( '%s', $msg ) ?>
</div>
</div>
<?php endforeach; unset( $_SESSION['messages'] ); ?>
</div>
<?php endforeach;
unset( $_SESSION['messages'] ); ?>
</div>
<?php endif; ?>
<div class="opalestate-admin-box">
<div class="opalestate-admin-box">
<div class="box-content">
<h3><?php esc_html_e( 'Edit Agency Profile', 'opalestate-pro' ); ?></h3>
<div class="box-content">
<h3><?php esc_html_e( 'Edit Agency Profile', 'opalestate-pro' ); ?></h3>
<?php
do_action( 'opalestate_profile_agency_form_before' );
// echo '<Pre>'.print_r( $metaboxes ,1 );die;
do_action( 'opalestate_profile_agency_form_before' );
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
echo cmb2_get_metabox_form( $metaboxes[OPALESTATE_AGENCY_PREFIX.'front'], $post_id, array(
'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<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
) );
}
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_AGENCY_PREFIX . 'front' ], $post_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<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
] );
}
do_action( 'opalestate_profile_agency_form_after' );
do_action( 'opalestate_profile_agency_form_after' );
?>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,27 +1,26 @@
<div class="property-submission-form">
<div class="opalestate-admin-box">
<div class="opalestate-admin-box">
<div class="box-content">
<h3><?php esc_html_e( 'Edit Agent Profile', 'opalestate-pro' ); ?></h3>
<div class="box-content">
<h3><?php esc_html_e( 'Edit Agent Profile', 'opalestate-pro' ); ?></h3>
<?php if( isset($metaboxes[OPALESTATE_AGENT_PREFIX.'front']) ): ?>
<?php
do_action( 'opalestate_profile_agency_form_before' );
<?php if ( isset( $metaboxes[ OPALESTATE_AGENT_PREFIX . 'front' ] ) ): ?>
<?php
do_action( 'opalestate_profile_agent_form_before' );
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_AGENT_PREFIX . 'front' ], $post_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<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
] );
}
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_AGENT_PREFIX . 'front' ], $post_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<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
] );
}
do_action( 'opalestate_profile_agency_form_after' );
?>
?>
<?php else : ?>
<div class="alert alert-danger"><?php esc_html_e( 'Agent edit profile form is not avariable', 'opalestate-pro' ); ?></div>
<div class="alert alert-danger"><?php esc_html_e( 'Agent edit profile form is not avariable', 'opalestate-pro' ); ?></div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>