CLear
This commit is contained in:
parent
225def65e2
commit
880961f5e2
@ -1,23 +1,14 @@
|
|||||||
<?php
|
<?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.
|
// Exit if accessed directly.
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Job_Api
|
* Property_Api
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @package Opal_Job
|
* @package Property_Api
|
||||||
* @subpackage Opal_Job/controllers
|
|
||||||
*/
|
*/
|
||||||
class Property_Api extends Base_Api {
|
class Property_Api extends Base_Api {
|
||||||
|
|
||||||
@ -35,78 +26,80 @@ class Property_Api extends Base_Api {
|
|||||||
*
|
*
|
||||||
* Register all CURD actions with POST/GET/PUT and calling function for each
|
* Register all CURD actions with POST/GET/PUT and calling function for each
|
||||||
*
|
*
|
||||||
|
* @return avoid
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*
|
*
|
||||||
* @return avoid
|
|
||||||
*/
|
*/
|
||||||
public function register_routes() {
|
public function register_routes() {
|
||||||
/// call http://domain.com/wp-json/job-api/v1/job/list ////
|
/// call http://domain.com/wp-json/estate-api/v1/estate/list ////
|
||||||
register_rest_route( $this->namespace, $this->base.'/list', array(
|
register_rest_route( $this->namespace, $this->base . '/list', [
|
||||||
'methods' => WP_REST_Server::READABLE,
|
'methods' => WP_REST_Server::READABLE,
|
||||||
'callback' => array( $this, 'get_list' ),
|
'callback' => [ $this, 'get_list' ],
|
||||||
'permission_callback' => array( $this, 'validate_request' ),
|
'permission_callback' => [ $this, 'validate_request' ],
|
||||||
));
|
] );
|
||||||
|
|
||||||
/// call http://domain.com/wp-json/job-api/v1/job/featured ////
|
/// call http://domain.com/wp-json/estate-api/v1/estate/featured ////
|
||||||
register_rest_route( $this->namespace, $this->base.'/featured', array(
|
register_rest_route( $this->namespace, $this->base . '/featured', [
|
||||||
'methods' => WP_REST_Server::READABLE,
|
'methods' => WP_REST_Server::READABLE,
|
||||||
'callback' => array( $this, 'get_featured_list' ),
|
'callback' => [ $this, 'get_featured_list' ],
|
||||||
'permission_callback' => array( $this, 'validate_request' ),
|
'permission_callback' => [ $this, 'validate_request' ],
|
||||||
));
|
] );
|
||||||
|
|
||||||
/// call http://domain.com/wp-json/job-api/v1/job/1 ////
|
/// call http://domain.com/wp-json/job-api/v1/job/1 ////
|
||||||
register_rest_route( $this->namespace, $this->base.'/(?P<id>\d+)', array(
|
register_rest_route( $this->namespace, $this->base . '/(?P<id>\d+)', [
|
||||||
'methods' => WP_REST_Server::READABLE,
|
'methods' => WP_REST_Server::READABLE,
|
||||||
'callback' => array( $this, 'get_job' ),
|
'callback' => [ $this, 'get_job' ],
|
||||||
'permission_callback' => array( $this, 'validate_request' ),
|
'permission_callback' => [ $this, 'validate_request' ],
|
||||||
));
|
] );
|
||||||
|
|
||||||
/// call http://domain.com/wp-json/job-api/v1/job/create ////
|
/// call http://domain.com/wp-json/job-api/v1/job/create ////
|
||||||
register_rest_route( $this->namespace, $this->base.'/create', array(
|
register_rest_route( $this->namespace, $this->base . '/create', [
|
||||||
'methods' => 'GET',
|
'methods' => 'GET',
|
||||||
'callback' => array( $this, 'create' ),
|
'callback' => [ $this, 'create' ],
|
||||||
'permission_callback' => array( $this, 'validate_request' ),
|
'permission_callback' => [ $this, 'validate_request' ],
|
||||||
));
|
] );
|
||||||
|
|
||||||
/// call http://domain.com/wp-json/job-api/v1/job/edit ////
|
/// call http://domain.com/wp-json/job-api/v1/job/edit ////
|
||||||
register_rest_route( $this->namespace, $this->base.'/edit', array(
|
register_rest_route( $this->namespace, $this->base . '/edit', [
|
||||||
'methods' => 'GET',
|
'methods' => 'GET',
|
||||||
'callback' => array( $this, 'edit' ),
|
'callback' => [ $this, 'edit' ],
|
||||||
));
|
] );
|
||||||
|
|
||||||
/// call http://domain.com/wp-json/job-api/v1/job/delete ////
|
/// call http://domain.com/wp-json/job-api/v1/job/delete ////
|
||||||
register_rest_route( $this->namespace, $this->base.'/delete', array(
|
register_rest_route( $this->namespace, $this->base . '/delete', [
|
||||||
'methods' => 'GET',
|
'methods' => 'GET',
|
||||||
'callback' => array( $this, 'delete' ),
|
'callback' => [ $this, 'delete' ],
|
||||||
'permission_callback' => array( $this, 'validate_request' ),
|
'permission_callback' => [ $this, 'validate_request' ],
|
||||||
));
|
] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List job by tags and taxonmies
|
* List job by tags and taxonmies
|
||||||
*/
|
*/
|
||||||
/// call http://domain.com/wp-json/job-api/v1/jobs ////
|
/// call http://domain.com/wp-json/job-api/v1/jobs ////
|
||||||
register_rest_route( $this->namespace, $this->base.'/tags', array(
|
register_rest_route( $this->namespace, $this->base . '/tags', [
|
||||||
'methods' => 'GET',
|
'methods' => 'GET',
|
||||||
'callback' => array( $this, 'delete' ),
|
'callback' => [ $this, 'delete' ],
|
||||||
'permission_callback' => array( $this, 'validate_request' ),
|
'permission_callback' => [ $this, 'validate_request' ],
|
||||||
));
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_featured_list() {
|
public function get_featured_list() {
|
||||||
$properties = array();
|
$properties = [];
|
||||||
$error = array();
|
$error = [];
|
||||||
|
|
||||||
$property = null;
|
$property = null;
|
||||||
|
|
||||||
if ( $property == null ) {
|
if ( $property == null ) {
|
||||||
$properties = array();
|
$properties = [];
|
||||||
|
|
||||||
$property_list = get_posts( array(
|
$property_list = get_posts( [
|
||||||
'post_type' => 'opalestate_property',
|
'post_type' => 'opalestate_property',
|
||||||
'posts_per_page' => $this->per_page(),
|
'posts_per_page' => $this->per_page(),
|
||||||
'suppress_filters' => true,
|
'suppress_filters' => true,
|
||||||
'meta_key' => OPALESTATE_PROPERTY_PREFIX . 'featured',
|
'meta_key' => OPALESTATE_PROPERTY_PREFIX . 'featured',
|
||||||
'meta_value' => 'on',
|
'meta_value' => 'on',
|
||||||
'paged' => $this->get_paged()
|
'paged' => $this->get_paged(),
|
||||||
) );
|
] );
|
||||||
|
|
||||||
if ( $property_list ) {
|
if ( $property_list ) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -144,26 +137,26 @@ class Property_Api extends Base_Api {
|
|||||||
*
|
*
|
||||||
* Based on request to get collection
|
* Based on request to get collection
|
||||||
*
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*
|
*
|
||||||
* @return WP_REST_Response is json data
|
|
||||||
*/
|
*/
|
||||||
public function get_list( $request ) {
|
public function get_list( $request ) {
|
||||||
|
|
||||||
$properties = array();
|
$properties = [];
|
||||||
$error = array();
|
$error = [];
|
||||||
|
|
||||||
$property = null;
|
$property = null;
|
||||||
|
|
||||||
if ( $property == null ) {
|
if ( $property == null ) {
|
||||||
$properties = array();
|
$properties = [];
|
||||||
|
|
||||||
$property_list = get_posts( array(
|
$property_list = get_posts( [
|
||||||
'post_type' => 'opalestate_property',
|
'post_type' => 'opalestate_property',
|
||||||
'posts_per_page' => $this->per_page(),
|
'posts_per_page' => $this->per_page(),
|
||||||
'suppress_filters' => true,
|
'suppress_filters' => true,
|
||||||
'paged' => $this->get_paged()
|
'paged' => $this->get_paged(),
|
||||||
) );
|
] );
|
||||||
|
|
||||||
if ( $property_list ) {
|
if ( $property_list ) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -192,6 +185,7 @@ class Property_Api extends Base_Api {
|
|||||||
$response['collection'] = $properties;
|
$response['collection'] = $properties;
|
||||||
$response['pages'] = 4;
|
$response['pages'] = 4;
|
||||||
$response['current'] = 1;
|
$response['current'] = 1;
|
||||||
|
|
||||||
return $this->get_response( 200, $response );
|
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
|
* 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
|
* @return array Array of post data to return back in the API
|
||||||
|
* @since 1.1
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
private function get_property_data( $property_info ) {
|
private function get_property_data( $property_info ) {
|
||||||
|
|
||||||
$property = array();
|
$property = [];
|
||||||
|
|
||||||
$property['info']['id'] = $property_info->ID;
|
$property['info']['id'] = $property_info->ID;
|
||||||
$property['info']['slug'] = $property_info->post_name;
|
$property['info']['slug'] = $property_info->post_name;
|
||||||
@ -221,12 +215,11 @@ class Property_Api extends Base_Api {
|
|||||||
|
|
||||||
$data = opalesetate_property( $property_info->ID );
|
$data = opalesetate_property( $property_info->ID );
|
||||||
$gallery = $data->get_gallery();
|
$gallery = $data->get_gallery();
|
||||||
$property['info']['gallery'] = isset($gallery[0]) && !empty($gallery[0]) ? $gallery[0]: array();
|
$property['info']['gallery'] = isset( $gallery[0] ) && ! empty( $gallery[0] ) ? $gallery[0] : [];
|
||||||
$property['info']['price'] = opalestate_price_format( $data->get_price() );
|
$property['info']['price'] = opalestate_price_format( $data->get_price() );
|
||||||
$property['info']['map'] = $data->get_map();
|
$property['info']['map'] = $data->get_map();
|
||||||
$property['info']['address'] = $data->get_address();
|
$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['is_featured'] = $data->is_featured();
|
||||||
$property['status'] = $data->get_status();
|
$property['status'] = $data->get_status();
|
||||||
$property['labels'] = $data->get_labels();
|
$property['labels'] = $data->get_labels();
|
||||||
@ -237,7 +230,6 @@ class Property_Api extends Base_Api {
|
|||||||
$property['author_data'] = $data->get_author_link();
|
$property['author_data'] = $data->get_author_link();
|
||||||
|
|
||||||
return apply_filters( 'opalestate_api_properties_property', $property );
|
return apply_filters( 'opalestate_api_properties_property', $property );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -245,9 +237,9 @@ class Property_Api extends Base_Api {
|
|||||||
*
|
*
|
||||||
* Based on request to get collection
|
* Based on request to get collection
|
||||||
*
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*
|
*
|
||||||
* @return WP_REST_Response is json data
|
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ switch ( $type ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="opalestate-box-content property-agent-section property-author-v2">
|
<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">
|
||||||
@ -59,5 +60,3 @@ switch ( $type ) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
$user_id = $author->ID;
|
$user_id = $author->ID;
|
||||||
$is_sticky = get_user_meta( $user_id, $prefix . 'sticky', true );
|
$is_sticky = get_user_meta( $user_id, $prefix . 'sticky', true );
|
||||||
|
|
||||||
|
|
||||||
$desciption = get_user_meta( $user_id, 'description', true );
|
$desciption = get_user_meta( $user_id, 'description', true );
|
||||||
|
|
||||||
$roles = opalestate_user_roles_by_user_id( $user_id );
|
$roles = opalestate_user_roles_by_user_id( $user_id );
|
||||||
@ -75,7 +73,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div><!-- /.agent-preview -->
|
</div><!-- /.agent-preview -->
|
||||||
|
|
||||||
|
|
||||||
<div class="agent-box-meta">
|
<div class="agent-box-meta">
|
||||||
<h4 class="agent-box-title">
|
<h4 class="agent-box-title">
|
||||||
<a href="<?php echo esc_url( $link ); ?>"><?php echo esc_html( $author_name ); ?></a>
|
<a href="<?php echo esc_url( $link ); ?>"><?php echo esc_html( $author_name ); ?></a>
|
||||||
@ -143,11 +140,8 @@
|
|||||||
<?php if ( $linkedIn && $linkedIn != "#" && ! empty( $linkedIn ) ) { ?>
|
<?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>
|
<a class="opalestate-social-white radius-x" href="<?php echo esc_url( $linkedIn ); ?>"> <i class="fab fa-linkedIn"></i></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div><!-- /.agent-box-content -->
|
</div><!-- /.agent-box-content -->
|
||||||
|
|
||||||
</div><!-- /.agent-box-->
|
</div><!-- /.agent-box-->
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user