Merge branch 'master' of https://github.com/wpopal/opal-estate-pro
This commit is contained in:
commit
0877d8865e
0
.gitignore
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
0
assets/3rd/.DS_Store
vendored
Normal file → Executable file
0
assets/3rd/.DS_Store
vendored
Normal file → Executable file
0
assets/3rd/fontawesome/.DS_Store
vendored
Normal file → Executable file
0
assets/3rd/fontawesome/.DS_Store
vendored
Normal file → Executable file
0
assets/3rd/fontawesome/css/.DS_Store
vendored
Normal file → Executable file
0
assets/3rd/fontawesome/css/.DS_Store
vendored
Normal file → Executable file
0
assets/3rd/fontawesome/css/all.min.css
vendored
Normal file → Executable file
0
assets/3rd/fontawesome/css/all.min.css
vendored
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.eot
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.eot
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.svg
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.svg
Normal file → Executable file
Before Width: | Height: | Size: 684 KiB After Width: | Height: | Size: 684 KiB |
0
assets/3rd/fontawesome/webfonts/fa-brands-400.ttf
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.ttf
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.woff
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.woff
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.woff2
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-brands-400.woff2
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.eot
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.eot
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.svg
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.svg
Normal file → Executable file
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 141 KiB |
0
assets/3rd/fontawesome/webfonts/fa-regular-400.ttf
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.ttf
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.woff
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.woff
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.woff2
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-regular-400.woff2
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.eot
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.eot
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.svg
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.svg
Normal file → Executable file
Before Width: | Height: | Size: 823 KiB After Width: | Height: | Size: 823 KiB |
0
assets/3rd/fontawesome/webfonts/fa-solid-900.ttf
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.ttf
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.woff
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.woff
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.woff2
Normal file → Executable file
0
assets/3rd/fontawesome/webfonts/fa-solid-900.woff2
Normal file → Executable file
0
assets/images/.DS_Store
vendored
Normal file → Executable file
0
assets/images/.DS_Store
vendored
Normal file → Executable file
0
assets/scss/admin.scss
Executable file → Normal file
0
assets/scss/admin.scss
Executable file → Normal file
0
assets/scss/bootstrap/_grid.scss
Executable file → Normal file
0
assets/scss/bootstrap/_grid.scss
Executable file → Normal file
0
assets/scss/bootstrap/_mixins.scss
Executable file → Normal file
0
assets/scss/bootstrap/_mixins.scss
Executable file → Normal file
0
assets/scss/bootstrap/_unlities.scss
Executable file → Normal file
0
assets/scss/bootstrap/_unlities.scss
Executable file → Normal file
0
assets/scss/bootstrap/_variables.scss
Executable file → Normal file
0
assets/scss/bootstrap/_variables.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_clearfix.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_clearfix.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_grid-framework.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_grid-framework.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_grid.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_grid.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_opacity.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_opacity.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_resize.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_resize.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_size.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_size.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_vendor-prefixes.scss
Executable file → Normal file
0
assets/scss/bootstrap/mixins/_vendor-prefixes.scss
Executable file → Normal file
0
assets/scss/cmb2-front.scss
Executable file → Normal file
0
assets/scss/cmb2-front.scss
Executable file → Normal file
0
assets/scss/cmb2/cmb2-display.scss
Executable file → Normal file
0
assets/scss/cmb2/cmb2-display.scss
Executable file → Normal file
0
assets/scss/cmb2/cmb2-front.scss
Executable file → Normal file
0
assets/scss/cmb2/cmb2-front.scss
Executable file → Normal file
0
assets/scss/cmb2/cmb2.scss
Executable file → Normal file
0
assets/scss/cmb2/cmb2.scss
Executable file → Normal file
0
assets/scss/cmb2/index.html
Executable file → Normal file
0
assets/scss/cmb2/index.html
Executable file → Normal file
0
assets/scss/cmb2/index.php
Executable file → Normal file
0
assets/scss/cmb2/index.php
Executable file → Normal file
0
assets/scss/cmb2/partials/_collapsible_ui.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_collapsible_ui.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_context_metaboxes.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_context_metaboxes.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_display.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_display.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_front.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_front.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_jquery_ui.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_jquery_ui.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_main_wrap.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_main_wrap.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_misc.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_misc.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_mixins.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_mixins.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_new_term.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_new_term.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_options-page.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_options-page.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_post_metaboxes.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_post_metaboxes.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_sidebar_placements.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_sidebar_placements.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_variables.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/_variables.scss
Executable file → Normal file
0
assets/scss/cmb2/partials/index.php
Executable file → Normal file
0
assets/scss/cmb2/partials/index.php
Executable file → Normal file
0
assets/scss/components/_grid.scss
Executable file → Normal file
0
assets/scss/components/_grid.scss
Executable file → Normal file
0
assets/scss/components/_mixins.scss
Executable file → Normal file
0
assets/scss/components/_mixins.scss
Executable file → Normal file
0
assets/scss/components/_variables.scss
Executable file → Normal file
0
assets/scss/components/_variables.scss
Executable file → Normal file
0
assets/scss/components/mixins/_functions.scss
Executable file → Normal file
0
assets/scss/components/mixins/_functions.scss
Executable file → Normal file
0
assets/scss/components/mixins/_rtl.scss
Executable file → Normal file
0
assets/scss/components/mixins/_rtl.scss
Executable file → Normal file
0
assets/scss/components/mixins/_template-mixins.scss
Executable file → Normal file
0
assets/scss/components/mixins/_template-mixins.scss
Executable file → Normal file
0
assets/scss/components/vars/_elements.scss
Executable file → Normal file
0
assets/scss/components/vars/_elements.scss
Executable file → Normal file
0
assets/scss/components/vars/_form.scss
Executable file → Normal file
0
assets/scss/components/vars/_form.scss
Executable file → Normal file
0
assets/scss/components/vars/_layout.scss
Executable file → Normal file
0
assets/scss/components/vars/_layout.scss
Executable file → Normal file
0
assets/scss/components/vars/_nav.scss
Executable file → Normal file
0
assets/scss/components/vars/_nav.scss
Executable file → Normal file
0
assets/scss/components/vars/_widget.scss
Executable file → Normal file
0
assets/scss/components/vars/_widget.scss
Executable file → Normal file
0
assets/scss/opalestate.scss
Executable file → Normal file
0
assets/scss/opalestate.scss
Executable file → Normal file
0
assets/scss/opalestate/_3rd.scss
Executable file → Normal file
0
assets/scss/opalestate/_3rd.scss
Executable file → Normal file
0
assets/scss/opalestate/_agency-loop.scss
Executable file → Normal file
0
assets/scss/opalestate/_agency-loop.scss
Executable file → Normal file
0
assets/scss/opalestate/_archive.scss
Executable file → Normal file
0
assets/scss/opalestate/_archive.scss
Executable file → Normal file
0
assets/scss/opalestate/_dashboard.scss
Executable file → Normal file
0
assets/scss/opalestate/_dashboard.scss
Executable file → Normal file
0
assets/scss/opalestate/_elements.scss
Executable file → Normal file
0
assets/scss/opalestate/_elements.scss
Executable file → Normal file
0
assets/scss/opalestate/_form.scss
Executable file → Normal file
0
assets/scss/opalestate/_form.scss
Executable file → Normal file
0
assets/scss/opalestate/_layout.scss
Executable file → Normal file
0
assets/scss/opalestate/_layout.scss
Executable file → Normal file
0
assets/scss/opalestate/_modules.scss
Executable file → Normal file
0
assets/scss/opalestate/_modules.scss
Executable file → Normal file
0
assets/scss/opalestate/_page.scss
Executable file → Normal file
0
assets/scss/opalestate/_page.scss
Executable file → Normal file
0
assets/scss/opalestate/_properties-loop.scss
Executable file → Normal file
0
assets/scss/opalestate/_properties-loop.scss
Executable file → Normal file
0
assets/scss/opalestate/_shortcodes.scss
Executable file → Normal file
0
assets/scss/opalestate/_shortcodes.scss
Executable file → Normal file
0
assets/scss/opalestate/_single.scss
Executable file → Normal file
0
assets/scss/opalestate/_single.scss
Executable file → Normal file
0
assets/scss/opalestate/_styles.scss
Executable file → Normal file
0
assets/scss/opalestate/_styles.scss
Executable file → Normal file
0
assets/scss/opalestate/_vars.scss
Executable file → Normal file
0
assets/scss/opalestate/_vars.scss
Executable file → Normal file
0
assets/scss/submission.scss
Executable file → Normal file
0
assets/scss/submission.scss
Executable file → Normal file
BIN
inc/.DS_Store
vendored
BIN
inc/.DS_Store
vendored
Binary file not shown.
@ -72,11 +72,18 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'My Account Page', 'opalestate-pro' ),
|
'name' => esc_html__( 'My Account Page', 'opalestate-pro' ),
|
||||||
'desc' => esc_html__( 'This is page use User login and register an account, or reset password.', 'opalestate-pro' ),
|
'desc' => esc_html__( 'This is page used for login and register an account, or reset password.', 'opalestate-pro' ),
|
||||||
'id' => 'user_myaccount_page',
|
'id' => 'user_myaccount_page',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'options' => $pages,
|
'options' => $pages,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => esc_html__( 'Terms and Conditions Page', 'opalestate-pro' ),
|
||||||
|
'desc' => esc_html__( 'This is page used for terms and conditions.', 'opalestate-pro' ),
|
||||||
|
'id' => 'user_terms_page',
|
||||||
|
'type' => 'select',
|
||||||
|
'options' => $pages,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Enable Message Database', 'opalestate-pro' ),
|
'name' => esc_html__( 'Enable Message Database', 'opalestate-pro' ),
|
||||||
'desc' => esc_html__( 'Allow User send message Contact/Equire via email and saved into database to exchange theirs message direct in User Message Management',
|
'desc' => esc_html__( 'Allow User send message Contact/Equire via email and saved into database to exchange theirs message direct in User Message Management',
|
||||||
|
@ -17,4 +17,226 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|||||||
|
|
||||||
class Opalestate_Agency_Query extends OpalEstate_Abstract_Query {
|
class Opalestate_Agency_Query extends OpalEstate_Abstract_Query {
|
||||||
|
|
||||||
|
public $count = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default query arguments.
|
||||||
|
*
|
||||||
|
* Not all of these are valid arguments that can be passed to WP_Query. The ones that are not, are modified before
|
||||||
|
* the query is run to convert them to the proper syntax.
|
||||||
|
*
|
||||||
|
* @since 2.5.0
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @param $args array The array of arguments that can be passed in and used for setting up this form query.
|
||||||
|
*/
|
||||||
|
public function __construct( $args = array() ) {
|
||||||
|
|
||||||
|
$defaults = array(
|
||||||
|
'output' => 'collection',
|
||||||
|
'post_type' => array( 'opaljob_job' ),
|
||||||
|
'number' => 20,
|
||||||
|
'offset' => 0,
|
||||||
|
'paged' => 1,
|
||||||
|
'orderby' => 'id',
|
||||||
|
'order' => 'DESC'
|
||||||
|
);
|
||||||
|
|
||||||
|
$args['update_post_meta_cache'] = false;
|
||||||
|
|
||||||
|
$this->args = $this->_args = wp_parse_args( $args, $defaults );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render Sidebar
|
||||||
|
*
|
||||||
|
* Display Sidebar on left side and next is main content
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_query_object() {
|
||||||
|
/* @var WP_Query $query */
|
||||||
|
$query = new WP_Query( $this->args );
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render Sidebar
|
||||||
|
*
|
||||||
|
* Display Sidebar on left side and next is main content
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_list () {
|
||||||
|
|
||||||
|
$output = array(
|
||||||
|
'founds' => 0 ,
|
||||||
|
'collection' => []
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = $this->get_query_object();
|
||||||
|
if ( $query ) {
|
||||||
|
$i = 0;
|
||||||
|
$collection = array();
|
||||||
|
if( $query->have_posts() ) {
|
||||||
|
while( $query->have_posts() ){ $query->the_post(); global $post;
|
||||||
|
$collection[] = new OpalEstate_Agency( $post->ID );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wp_reset_postdata();
|
||||||
|
$output['collection'] = $collection;
|
||||||
|
$output['found'] = $query->found_posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render Sidebar
|
||||||
|
*
|
||||||
|
* Display Sidebar on left side and next is main content
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_api_list () {
|
||||||
|
$output = array(
|
||||||
|
'founds' => 0 ,
|
||||||
|
'collection' => []
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = $this->get_query_object();
|
||||||
|
if ( $query ) {
|
||||||
|
$i = 0;
|
||||||
|
$collection = array();
|
||||||
|
if( $query->have_posts() ) {
|
||||||
|
while( $query->have_posts() ){ $query->the_post(); global $post;
|
||||||
|
$collection[] = $this->get_agency_data( $post );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wp_reset_postdata();
|
||||||
|
$output['collection'] = $collection;
|
||||||
|
$output['found'] = $query->found_posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $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
|
||||||
|
*
|
||||||
|
* @return array Array of post data to return back in the API
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function get_agency_data( $agency_info ){
|
||||||
|
|
||||||
|
$agency = new OpalEstate_Agency( $agency_info->ID );
|
||||||
|
|
||||||
|
$ouput = array();
|
||||||
|
|
||||||
|
$ouput['info']['id'] = $agency_info->ID;
|
||||||
|
$ouput['info']['slug'] = $agency_info->post_name;
|
||||||
|
$ouput['info']['title'] = $agency_info->post_title;
|
||||||
|
$ouput['info']['status'] = $agency_info->post_status;
|
||||||
|
$ouput['info']['link'] = html_entity_decode( $agency_info->guid );
|
||||||
|
$ouput['info']['content'] = $agency_info->post_content;
|
||||||
|
$ouput['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $agency_info->ID ) );
|
||||||
|
|
||||||
|
$agency = new OpalEstate_Agency( $agency_info->ID );
|
||||||
|
|
||||||
|
$ouput['info']['featured'] = (int)$agency->is_featured();
|
||||||
|
$ouput['info']['trusted'] = $agency->get_meta( 'trusted' );
|
||||||
|
$ouput['info']['avatar'] = $agency->get_meta( 'avatar' );
|
||||||
|
$ouput['info']['web'] = $agency->get_meta( 'web' );
|
||||||
|
$ouput['info']['phone'] = $agency->get_meta( 'phone' );
|
||||||
|
$ouput['info']['mobile'] = $agency->get_meta( 'mobile' );
|
||||||
|
$ouput['info']['fax'] = $agency->get_meta( 'fax' );
|
||||||
|
$ouput['info']['email'] = $agency->get_meta( 'email' );
|
||||||
|
$ouput['info']['address'] = $agency->get_meta( 'address' );
|
||||||
|
$ouput['info']['map'] = $agency->get_meta( 'map' );
|
||||||
|
|
||||||
|
$terms = wp_get_post_terms( $agency_info->ID, 'opalestate_agency_location' );
|
||||||
|
$ouput['info']['location'] = $terms && !is_wp_error($terms) ? $terms : array();
|
||||||
|
|
||||||
|
$ouput['socials'] = $agency->get_socials();
|
||||||
|
|
||||||
|
$ouput['category'] = $agency->get_category_tax();
|
||||||
|
|
||||||
|
return apply_filters( 'opalestate_api_agency', $ouput );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get search query base on user request to filter collection of Agents
|
||||||
|
*/
|
||||||
|
public static function get_search_agencies_query( $args = [] ) {
|
||||||
|
$s = isset( $_GET['search_text'] ) ? sanitize_text_field( $_GET['search_text'] ) : null;
|
||||||
|
|
||||||
|
$paged = ( get_query_var( 'paged' ) == 0 ) ? 1 : get_query_var( 'paged' );
|
||||||
|
$default = [
|
||||||
|
'post_type' => 'opalestate_agency',
|
||||||
|
'posts_per_page' => apply_filters( 'opalestate_agency_per_page', 12 ),
|
||||||
|
'paged' => $paged,
|
||||||
|
];
|
||||||
|
$args = array_merge( $default, $args );
|
||||||
|
|
||||||
|
$tax_query = [];
|
||||||
|
|
||||||
|
|
||||||
|
if ( isset( $_GET['location'] ) && $_GET['location'] != -1 ) {
|
||||||
|
$tax_query[] =
|
||||||
|
[
|
||||||
|
'taxonomy' => 'opalestate_location',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => sanitize_text_field( $_GET['location'] ),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset( $_GET['types'] ) && $_GET['types'] != -1 ) {
|
||||||
|
$tax_query[] =
|
||||||
|
[
|
||||||
|
'taxonomy' => 'opalestate_types',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => sanitize_text_field( $_GET['types'] ),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $tax_query ) {
|
||||||
|
$args['tax_query'] = [ 'relation' => 'AND' ];
|
||||||
|
$args['tax_query'] = array_merge( $args['tax_query'], $tax_query );
|
||||||
|
}
|
||||||
|
|
||||||
|
$args['meta_query'] = [ 'relation' => 'AND' ];
|
||||||
|
|
||||||
|
|
||||||
|
return new WP_Query( $args );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Query Object to display list of agents
|
||||||
|
*/
|
||||||
|
public static function get_agencies( $args = [], $featured = false ) {
|
||||||
|
$default = [
|
||||||
|
'post_type' => 'opalestate_agency',
|
||||||
|
'posts_per_page' => 10,
|
||||||
|
];
|
||||||
|
$args = array_merge( $default, $args );
|
||||||
|
if ( $featured ) {
|
||||||
|
$args['meta_key'] = OPALESTATE_AGENCY_PREFIX . 'featured';
|
||||||
|
$args['meta_value'] = 1;
|
||||||
|
$args['meta_compare'] = '=';
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WP_Query( $args );
|
||||||
|
}
|
||||||
}
|
}
|
@ -24,6 +24,20 @@ class OpalEstate_Agency {
|
|||||||
*/
|
*/
|
||||||
protected $author_name;
|
protected $author_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var String $author_name
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
public $post_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var String $author_name
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
public $author;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Boolean $is_featured
|
* @var Boolean $is_featured
|
||||||
*
|
*
|
||||||
@ -43,12 +57,15 @@ class OpalEstate_Agency {
|
|||||||
return $_instance;
|
return $_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct( $post_id = null ) {
|
public function __construct( $post_id = null ) {
|
||||||
global $post;
|
global $post ;
|
||||||
|
|
||||||
|
if( $post == null ) {
|
||||||
|
$post = WP_Post::get_instance( $post_id );
|
||||||
|
}
|
||||||
|
|
||||||
$this->post = $post;
|
$this->post = $post;
|
||||||
$this->post_id = $post_id ? $post_id : get_the_ID();
|
$this->post_id = $post_id ? $post_id : get_the_ID();
|
||||||
@ -58,6 +75,12 @@ class OpalEstate_Agency {
|
|||||||
$this->is_trusted = $this->get_meta( 'trusted' );
|
$this->is_trusted = $this->get_meta( 'trusted' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function get_id() {
|
public function get_id() {
|
||||||
return $this->post_id;
|
return $this->post_id;
|
||||||
}
|
}
|
||||||
@ -129,7 +152,12 @@ class OpalEstate_Agency {
|
|||||||
return $this->is_featured;
|
return $this->is_featured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function render_avatar() {
|
public function render_avatar() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -141,16 +169,32 @@ class OpalEstate_Agency {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function get_gallery() {
|
public function get_gallery() {
|
||||||
return $this->get_meta( 'gallery' );
|
return $this->get_meta( 'gallery' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function get_trusted() {
|
public function get_trusted() {
|
||||||
return $this->is_trusted;
|
return $this->is_trusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function get_members() {
|
public function get_members() {
|
||||||
$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 );
|
||||||
@ -171,6 +215,12 @@ class OpalEstate_Agency {
|
|||||||
return $team;
|
return $team;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public static function get_link( $agency_id ) {
|
public static function get_link( $agency_id ) {
|
||||||
$agency = get_post( $agency_id );
|
$agency = get_post( $agency_id );
|
||||||
$url = self::get_avatar_url( $agency_id );
|
$url = self::get_avatar_url( $agency_id );
|
||||||
@ -182,6 +232,12 @@ class OpalEstate_Agency {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public static function metaboxes_fields() {
|
public static function metaboxes_fields() {
|
||||||
$metabox = new Opalestate_Agency_MetaBox();
|
$metabox = new Opalestate_Agency_MetaBox();
|
||||||
$fields = $metabox->metaboxes_admin_fields();
|
$fields = $metabox->metaboxes_admin_fields();
|
||||||
@ -219,6 +275,12 @@ class OpalEstate_Agency {
|
|||||||
return $this->get_meta( 'review_count' ) ? $this->get_meta( 'review_count' ) : 0;
|
return $this->get_meta( 'review_count' ) ? $this->get_meta( 'review_count' ) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function get_rating_count_stats() {
|
public function get_rating_count_stats() {
|
||||||
return $this->get_meta( 'rating_count_stats' ) ? $this->get_meta( 'rating_count_stats' ) : [
|
return $this->get_meta( 'rating_count_stats' ) ? $this->get_meta( 'rating_count_stats' ) : [
|
||||||
5 => 0,
|
5 => 0,
|
||||||
@ -229,6 +291,22 @@ class OpalEstate_Agency {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function get_category_tax ( ) {
|
||||||
|
return wp_get_post_terms( $this->post_id, 'opalestate_agency_cat' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rating count.
|
||||||
|
*
|
||||||
|
* @param string $context What the value is for. Valid values are view and edit.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function get_rating_average_stats() {
|
public function get_rating_average_stats() {
|
||||||
return $this->get_meta( 'rating_average_stats' );
|
return $this->get_meta( 'rating_average_stats' );
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,13 @@ class OpalEstate_Agent {
|
|||||||
*/
|
*/
|
||||||
protected $is_featured;
|
protected $is_featured;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Boolean $is_featured
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
public $post_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
110
inc/api/class-api-auth.php
Executable file
110
inc/api/class-api-auth.php
Executable file
@ -0,0 +1,110 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Api_Auth class for authorizing to access api resources
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @package Opal_Job
|
||||||
|
* @subpackage Opal_Job/API
|
||||||
|
*/
|
||||||
|
class Api_Auth extends Base_API {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register user endpoints.
|
||||||
|
*
|
||||||
|
* to check post method need authorization to continue completing action
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return avoid
|
||||||
|
*/
|
||||||
|
public function register_routes() {
|
||||||
|
// check all request must to have public key and token
|
||||||
|
register_rest_route( $this->namespace, '/job/list', array(
|
||||||
|
'methods' => 'GET',
|
||||||
|
'permission_callback' => array( $this, 'validate_request' ),
|
||||||
|
), 9 );
|
||||||
|
|
||||||
|
////////////////// Check User Authorizcation must to have account logined
|
||||||
|
// check authorcation for all delete in route
|
||||||
|
register_rest_route($this->namespace, '/(?P<path>[\S]+)/delete', array(
|
||||||
|
'methods' => 'GET',
|
||||||
|
'callback' => array( $this, 'check' ),
|
||||||
|
));
|
||||||
|
// check authorcation for all delete in route
|
||||||
|
register_rest_route($this->namespace, '/(?P<path>[\S]+)/edit', array(
|
||||||
|
'methods' => 'GET',
|
||||||
|
'callback' => array( $this, 'check' ),
|
||||||
|
));
|
||||||
|
// check authorcation for all delete in route
|
||||||
|
register_rest_route($this->namespace, '/(?P<path>[\S]+)/create', array(
|
||||||
|
'methods' => 'GET',
|
||||||
|
'callback' => array( $this, 'check' ),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check authorization
|
||||||
|
*
|
||||||
|
* check user request having passing username and password, then check them be valid or not.
|
||||||
|
*
|
||||||
|
* @param WP_REST_Request $request
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
|
*/
|
||||||
|
public function check( WP_REST_Request $request ) {
|
||||||
|
$response = array();
|
||||||
|
|
||||||
|
$default = array(
|
||||||
|
'username' => '',
|
||||||
|
'password' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
$parameters = $request->get_params();
|
||||||
|
$parameters = array_merge( $default, $parameters );
|
||||||
|
|
||||||
|
$username = sanitize_text_field( $parameters['username'] );
|
||||||
|
$password = sanitize_text_field( $parameters['password'] );
|
||||||
|
|
||||||
|
// Error Handling.
|
||||||
|
$error = new WP_Error();
|
||||||
|
if ( empty( $username ) ) {
|
||||||
|
$error->add(
|
||||||
|
400,
|
||||||
|
__( "Username field is required", 'rest-api-endpoints' ),
|
||||||
|
array( 'status' => 400 )
|
||||||
|
);
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
if ( empty( $password ) ) {
|
||||||
|
$error->add(
|
||||||
|
400,
|
||||||
|
__( "Password field is required", 'rest-api-endpoints' ),
|
||||||
|
array( 'status' => 400 )
|
||||||
|
);
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
$user = wp_authenticate( $username, $password );
|
||||||
|
|
||||||
|
// If user found
|
||||||
|
if ( ! is_wp_error( $user ) ) {
|
||||||
|
$response['status'] = 200;
|
||||||
|
$response['user'] = $user;
|
||||||
|
} else {
|
||||||
|
// If user not found
|
||||||
|
$error->add( 406, esc_html_e( 'User not found. Check credentials', 'rest-api-endpoints' ) );
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
return new WP_REST_Response( $response );
|
||||||
|
}
|
||||||
|
}
|
194
inc/api/class-base-api.php
Executable file
194
inc/api/class-base-api.php
Executable file
@ -0,0 +1,194 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
//// call http://domain.com/wp-json/job-api/v1/jobs
|
||||||
|
/**
|
||||||
|
* Abstract class to define/implement base methods for all controller classes
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @package Opal_Job
|
||||||
|
* @subpackage Opal_Job/controllers
|
||||||
|
*/
|
||||||
|
abstract class Base_API {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique identifier of this plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @access protected
|
||||||
|
* @var string $plugin_base_name The string used to uniquely identify this plugin.
|
||||||
|
*/
|
||||||
|
public $base ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique identifier of this plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @access protected
|
||||||
|
* @var string $plugin_base_name The string used to uniquely identify this plugin.
|
||||||
|
*/
|
||||||
|
public $namespace = 'estate-api/v1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Definition
|
||||||
|
*
|
||||||
|
* Register all Taxonomy related to Job post type as location, category, Specialism, Types
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return avoid
|
||||||
|
*/
|
||||||
|
public function __construct () {
|
||||||
|
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Definition
|
||||||
|
*
|
||||||
|
* Register all Taxonomy related to Job post type as location, category, Specialism, Types
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return avoid
|
||||||
|
*/
|
||||||
|
public function register_routes() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_response ( $code, $output ) {
|
||||||
|
|
||||||
|
$response = array();
|
||||||
|
|
||||||
|
$response['status'] = $code;
|
||||||
|
$response = array_merge( $response, $output );
|
||||||
|
|
||||||
|
return new WP_REST_Response( $response );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function output ( $code ) {
|
||||||
|
|
||||||
|
$this->data['status'] = $code;
|
||||||
|
return new WP_REST_Response( $this->data );
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Validate the API request
|
||||||
|
*
|
||||||
|
* Checks for the user's public key and token against the secret key
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @global object $wp_query WordPress Query
|
||||||
|
* @uses Opaljob_API::get_user()
|
||||||
|
* @uses Opaljob_API::invalid_key()
|
||||||
|
* @uses Opaljob_API::invalid_auth()
|
||||||
|
* @since 1.1
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function validate_request( WP_REST_Request $request ) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
$response = array();
|
||||||
|
|
||||||
|
// Make sure we have both user and api key
|
||||||
|
$api_admin = API_Admin::get_instance();
|
||||||
|
|
||||||
|
if ( empty( $request['token'] ) || empty( $request['key'] ) ) {
|
||||||
|
return $this->missing_auth();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the user by public API key and ensure they exist
|
||||||
|
if ( ! ( $user = $api_admin->get_user( $request['key'] ) ) ) {
|
||||||
|
|
||||||
|
$this->invalid_key();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$token = urldecode( $request['token'] );
|
||||||
|
$secret = $api_admin->get_user_secret_key( $user );
|
||||||
|
$public = urldecode( $request['key'] );
|
||||||
|
|
||||||
|
if ( hash_equals( md5( $secret . $public ), $token ) ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->invalid_auth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get page number
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @since 1.1
|
||||||
|
* @global $wp_query
|
||||||
|
* @return int $wp_query->query_vars['page'] if page number returned (default: 1)
|
||||||
|
*/
|
||||||
|
public function get_paged() {
|
||||||
|
global $wp_query;
|
||||||
|
|
||||||
|
return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of results to display per page
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @since 1.1
|
||||||
|
* @global $wp_query
|
||||||
|
* @return int $per_page Results to display per page (default: 10)
|
||||||
|
*/
|
||||||
|
public function per_page() {
|
||||||
|
global $wp_query;
|
||||||
|
|
||||||
|
$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
|
||||||
|
|
||||||
|
return apply_filters( 'opalestate_api_results_per_page', $per_page );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a missing authentication error if all the parameters aren't
|
||||||
|
* provided
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return WP_Error with message key rest_forbidden
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
private function missing_auth() {
|
||||||
|
return new WP_Error( 'rest_forbidden', esc_html__( 'You must specify both a token and API key!' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays an authentication failed error if the user failed to provide valid
|
||||||
|
* credentials
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @since 1.1
|
||||||
|
* @uses Opaljob_API::output()
|
||||||
|
* @return WP_Error with message key rest_forbidden
|
||||||
|
*/
|
||||||
|
private function invalid_auth() {
|
||||||
|
return new WP_Error( 'rest_forbidden', esc_html__( 'Your request could not be authenticated!', 'opaljob' ), array( 'status' => 403 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays an invalid API key error if the API key provided couldn't be
|
||||||
|
* validated
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @since 1.1
|
||||||
|
* @return WP_Error with message key rest_forbidden
|
||||||
|
*/
|
||||||
|
private function invalid_key() {
|
||||||
|
return new WP_Error( 'rest_forbidden', esc_html__( 'Invalid API key!' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
|
}
|
||||||
|
}
|
1367
inc/api/class-opalestate-api-remove.php
Executable file
1367
inc/api/class-opalestate-api-remove.php
Executable file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
140
inc/api/v1/agency.php
Normal file
140
inc/api/v1/agency.php
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?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
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @package Opal_Job
|
||||||
|
* @subpackage Opal_Job/controllers
|
||||||
|
*/
|
||||||
|
class Agency_Api extends Base_Api {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique identifier of the route resource.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @access public
|
||||||
|
* @var string $base.
|
||||||
|
*/
|
||||||
|
public $base = '/agency';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register Routes
|
||||||
|
*
|
||||||
|
* Register all CURD actions with POST/GET/PUT and calling function for each
|
||||||
|
*
|
||||||
|
* @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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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' ),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get List Of Job
|
||||||
|
*
|
||||||
|
* Based on request to get collection
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
|
*/
|
||||||
|
public function get_list ( $request ) {
|
||||||
|
|
||||||
|
$query = new Opalestate_Agency_Query(
|
||||||
|
array(
|
||||||
|
'post_type' => 'opalestate_agency',
|
||||||
|
'posts_per_page' => $this->per_page(),
|
||||||
|
'suppress_filters' => true,
|
||||||
|
'paged' => $this->get_paged()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = $query->get_api_list();
|
||||||
|
$response['collection'] = $data['collection'];
|
||||||
|
$response['found'] = $data['found'];
|
||||||
|
$response['current'] = 1;
|
||||||
|
|
||||||
|
return $this->get_response( 200, $response );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete job
|
||||||
|
*
|
||||||
|
* Based on request to get collection
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
|
*/
|
||||||
|
public function delete( ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function reviews () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function categories () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tags () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
209
inc/api/v1/agent.php
Normal file
209
inc/api/v1/agent.php
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
<?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
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @package Opal_Job
|
||||||
|
* @subpackage Opal_Job/controllers
|
||||||
|
*/
|
||||||
|
class Agent_Api extends Base_Api {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique identifier of the route resource.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @access public
|
||||||
|
* @var string $base.
|
||||||
|
*/
|
||||||
|
public $base = '/agent';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register Routes
|
||||||
|
*
|
||||||
|
* Register all CURD actions with POST/GET/PUT and calling function for each
|
||||||
|
*
|
||||||
|
* @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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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' ),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get List Of Job
|
||||||
|
*
|
||||||
|
* Based on request to get collection
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
|
*/
|
||||||
|
public function get_list ( $request ) {
|
||||||
|
|
||||||
|
$agents = array();
|
||||||
|
$error = array();
|
||||||
|
$agent = null;
|
||||||
|
if ( $agent == null ) {
|
||||||
|
$agents['agents'] = array();
|
||||||
|
|
||||||
|
$property_list = get_posts( array(
|
||||||
|
'post_type' => 'opalestate_agent',
|
||||||
|
'posts_per_page' => $this->per_page(),
|
||||||
|
'suppress_filters' => true,
|
||||||
|
'paged' => $this->get_paged()
|
||||||
|
) );
|
||||||
|
|
||||||
|
if ( $property_list ) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ( $property_list as $agent_info ) {
|
||||||
|
$agents['agents'][ $i ] = $this->get_agent_data( $agent_info );
|
||||||
|
$i ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( get_post_type( $agent ) == 'opalestate_property' ) {
|
||||||
|
$agent_info = get_post( $agent );
|
||||||
|
|
||||||
|
$agents['agents'][0] = $this->get_agent_data( $agent_info );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$error['error'] = sprintf(
|
||||||
|
/* translators: %s: property */
|
||||||
|
esc_html__( 'Form %s not found!', 'opalestate-pro' ),
|
||||||
|
$agent
|
||||||
|
);
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response['collection'] = $agents['agents'];
|
||||||
|
$response['pages'] = 4;
|
||||||
|
$response['current'] = 1;
|
||||||
|
return $this->get_response( 200, $response );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opalestaten a opalestate_property post object, generate the data for the API output
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
|
*
|
||||||
|
* @param object $property_info The Download Post Object
|
||||||
|
*
|
||||||
|
* @return array Array of post data to return back in the API
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function get_agent_data( $agent_info ){
|
||||||
|
$ouput = array();
|
||||||
|
|
||||||
|
$ouput['info']['id'] = $agent_info->ID;
|
||||||
|
$ouput['info']['slug'] = $agent_info->post_name;
|
||||||
|
$ouput['info']['title'] = $agent_info->post_title;
|
||||||
|
$ouput['info']['create_date'] = $agent_info->post_date;
|
||||||
|
$ouput['info']['modified_date'] = $agent_info->post_modified;
|
||||||
|
$ouput['info']['status'] = $agent_info->post_status;
|
||||||
|
$ouput['info']['link'] = html_entity_decode( $agent_info->guid );
|
||||||
|
$ouput['info']['content'] = $agent_info->post_content;
|
||||||
|
$ouput['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $agent_info->ID ) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$agent = new OpalEstate_Agent( $agent_info->ID );
|
||||||
|
|
||||||
|
$ouput['info']['featured'] = (int)$agent->is_featured();
|
||||||
|
$ouput['info']['email'] = get_post_meta( $agent_info->ID, OPALESTATE_AGENT_PREFIX . 'email', true );
|
||||||
|
$ouput['info']['address'] = get_post_meta( $agent_info->ID, OPALESTATE_AGENT_PREFIX . 'address', true );
|
||||||
|
|
||||||
|
$terms = wp_get_post_terms( $agent_info->ID, 'opalestate_agent_location' );
|
||||||
|
$ouput['info']['location'] = $terms && !is_wp_error($terms) ? $terms : array();
|
||||||
|
|
||||||
|
$ouput['socials'] = $agent->get_socials();
|
||||||
|
|
||||||
|
$ouput['levels'] = wp_get_post_terms( $agent_info->ID, 'opalestate_agent_level' );
|
||||||
|
|
||||||
|
|
||||||
|
return apply_filters( 'opalestate_api_agents', $ouput );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete job
|
||||||
|
*
|
||||||
|
* Based on request to get collection
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
|
*/
|
||||||
|
public function delete( ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function reviews () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function categories () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tags () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
264
inc/api/v1/property.php
Executable file
264
inc/api/v1/property.php
Executable file
@ -0,0 +1,264 @@
|
|||||||
|
<?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
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @package Opal_Job
|
||||||
|
* @subpackage Opal_Job/controllers
|
||||||
|
*/
|
||||||
|
class Property_Api extends Base_Api {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique identifier of the route resource.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @access public
|
||||||
|
* @var string $base.
|
||||||
|
*/
|
||||||
|
public $base = '/property';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register Routes
|
||||||
|
*
|
||||||
|
* Register all CURD actions with POST/GET/PUT and calling function for each
|
||||||
|
*
|
||||||
|
* @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' ),
|
||||||
|
));
|
||||||
|
|
||||||
|
/// 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/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' ),
|
||||||
|
));
|
||||||
|
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
/// 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' ),
|
||||||
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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' ),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_featured_list() {
|
||||||
|
$properties = array();
|
||||||
|
$error = array();
|
||||||
|
|
||||||
|
$property = null;
|
||||||
|
|
||||||
|
if ( $property == null ) {
|
||||||
|
$properties = array();
|
||||||
|
|
||||||
|
$property_list = get_posts( array(
|
||||||
|
'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()
|
||||||
|
) );
|
||||||
|
|
||||||
|
if ( $property_list ) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ( $property_list as $property_info ) {
|
||||||
|
$properties[ $i ] = $this->get_property_data( $property_info );
|
||||||
|
$i ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( get_post_type( $property ) == 'opalestate_property' ) {
|
||||||
|
$property_info = get_post( $property );
|
||||||
|
|
||||||
|
$properties[0] = $this->get_property_data( $property_info );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$error['error'] = sprintf(
|
||||||
|
/* translators: %s: property */
|
||||||
|
esc_html__( 'Form %s not found!', 'opalestate-pro' ),
|
||||||
|
$property
|
||||||
|
);
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
|
*/
|
||||||
|
public function get_list ( $request ) {
|
||||||
|
|
||||||
|
$properties = array();
|
||||||
|
$error = array();
|
||||||
|
|
||||||
|
$property = null;
|
||||||
|
|
||||||
|
if ( $property == null ) {
|
||||||
|
$properties = array();
|
||||||
|
|
||||||
|
$property_list = get_posts( array(
|
||||||
|
'post_type' => 'opalestate_property',
|
||||||
|
'posts_per_page' => $this->per_page(),
|
||||||
|
'suppress_filters' => true,
|
||||||
|
'paged' => $this->get_paged()
|
||||||
|
) );
|
||||||
|
|
||||||
|
if ( $property_list ) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ( $property_list as $property_info ) {
|
||||||
|
$properties[ $i ] = $this->get_property_data( $property_info );
|
||||||
|
$i ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( get_post_type( $property ) == 'opalestate_property' ) {
|
||||||
|
$property_info = get_post( $property );
|
||||||
|
|
||||||
|
$properties[0] = $this->get_property_data( $property_info );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$error['error'] = sprintf(
|
||||||
|
/* translators: %s: property */
|
||||||
|
esc_html__( 'Form %s not found!', 'opalestate-pro' ),
|
||||||
|
$property
|
||||||
|
);
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response['collection'] = $properties;
|
||||||
|
$response['pages'] = 4;
|
||||||
|
$response['current'] = 1;
|
||||||
|
return $this->get_response( 200, $response );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opalestaten a opalestate_property post object, generate the data for the API output
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
|
*
|
||||||
|
* @param object $property_info The Download Post Object
|
||||||
|
*
|
||||||
|
* @return array Array of post data to return back in the API
|
||||||
|
*/
|
||||||
|
private function get_property_data( $property_info ) {
|
||||||
|
|
||||||
|
$property = array();
|
||||||
|
|
||||||
|
$property['info']['id'] = $property_info->ID;
|
||||||
|
$property['info']['slug'] = $property_info->post_name;
|
||||||
|
$property['info']['title'] = $property_info->post_title;
|
||||||
|
$property['info']['create_date'] = $property_info->post_date;
|
||||||
|
$property['info']['modified_date'] = $property_info->post_modified;
|
||||||
|
$property['info']['status'] = $property_info->post_status;
|
||||||
|
$property['info']['link'] = html_entity_decode( $property_info->guid );
|
||||||
|
$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();
|
||||||
|
$property['info']['address'] = $data->get_address();
|
||||||
|
$property['meta'] = $data->get_meta_shortinfo();
|
||||||
|
|
||||||
|
$property['status'] = $data->get_status();
|
||||||
|
$property['locations'] = $data->get_locations();
|
||||||
|
$property['amenities'] = $data->get_amenities();
|
||||||
|
$property['types'] = $data->get_types_tax();
|
||||||
|
|
||||||
|
return apply_filters( 'opalestate_api_properties_property', $property );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete job
|
||||||
|
*
|
||||||
|
* Based on request to get collection
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
* @return WP_REST_Response is json data
|
||||||
|
*/
|
||||||
|
public function delete( ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function reviews () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function categories () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tags () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -23,14 +23,23 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
class OpalEstate_User_Message {
|
class OpalEstate_User_Message {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ID of current user id
|
||||||
*
|
*
|
||||||
|
* @return user_id
|
||||||
*/
|
*/
|
||||||
protected $user_id = 0;
|
protected $user_id = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets types.
|
||||||
|
*
|
||||||
|
* @return boolean $is_log
|
||||||
|
*/
|
||||||
protected $is_log;
|
protected $is_log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets a instance of this object.
|
||||||
*
|
*
|
||||||
|
* @return OpalEstate_User_Message
|
||||||
*/
|
*/
|
||||||
public static function get_instance() {
|
public static function get_instance() {
|
||||||
static $_instance;
|
static $_instance;
|
||||||
@ -41,6 +50,11 @@ class OpalEstate_User_Message {
|
|||||||
return $_instance;
|
return $_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets types.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function get_types() {
|
public function get_types() {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -153,7 +153,7 @@ class Opalestate_Property {
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ( $keys as $key ) {
|
foreach ( $keys as $key ) {
|
||||||
$this->property_settings[ $key ] = opalestate_get_option( 'enable_single_' . $key );
|
$this->property_settings[ $key ] = opalestate_get_option( 'enable_single_' . $key, 'on' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ function opalestate_single_property_layout_default() {
|
|||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
||||||
|
|
||||||
// add_action( 'opalestate_single_property_sidebar', 'opalestate_property_request_viewing_button', 7 );
|
// add_action( 'opalestate_single_property_sidebar', 'opalestate_property_request_viewing_button', 7 );
|
||||||
if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
|
if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) {
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ function opalestate_single_property_layout_v2() {
|
|||||||
|
|
||||||
|
|
||||||
/// /// sidebar ////////
|
/// /// sidebar ////////
|
||||||
if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
|
if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) {
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ function opalestate_single_property_layout_v3() {
|
|||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
||||||
|
|
||||||
if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
|
if ( opalestate_get_option( 'enable_single_mortgage' , 'on' ) == 'on' ) {
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage' );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ function opalestate_single_property_layout_v4() {
|
|||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
||||||
|
|
||||||
if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
|
if ( opalestate_get_option( 'enable_single_mortgage' , 'on' ) == 'on' ) {
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ function opalestate_single_property_layout_v5() {
|
|||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 );
|
||||||
|
|
||||||
if ( opalestate_get_option( 'enable_single_mortgage' ) ) {
|
if ( opalestate_get_option( 'enable_single_mortgage' ,'on' ) == 'on' ) {
|
||||||
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,18 @@ if( !class_exists( 'CMB2_Switch_Button' ) ) {
|
|||||||
public function __construct() {
|
public function __construct() {
|
||||||
add_action( 'cmb2_render_switch', array( $this, 'callback' ), 10, 5 );
|
add_action( 'cmb2_render_switch', array( $this, 'callback' ), 10, 5 );
|
||||||
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
||||||
|
|
||||||
|
add_filter( 'cmb2_sanitize_switch', array( $this, 'sanitize' ), 10, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sanitize ( $override_value, $value, $object_id, $field_args ) {
|
||||||
|
|
||||||
|
if( $value != "on" ) {
|
||||||
|
$value = 'off';
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
public function callback($field, $escaped_value, $object_id, $object_type, $field_type_object) {
|
public function callback($field, $escaped_value, $object_id, $object_type, $field_type_object) {
|
||||||
$field_name = $field->_name();
|
$field_name = $field->_name();
|
||||||
|
|
||||||
|
0
inc/vendors/cmb2-plugins/custom-fields/iconpicker/iconpicker.php
vendored
Executable file → Normal file
0
inc/vendors/cmb2-plugins/custom-fields/iconpicker/iconpicker.php
vendored
Executable file → Normal file
0
inc/vendors/cmb2-plugins/custom-fields/user/user.php
vendored
Executable file → Normal file
0
inc/vendors/cmb2-plugins/custom-fields/user/user.php
vendored
Executable file → Normal file
0
languages/opalestate-pro-backup-201909030250570.pot~
Executable file → Normal file
0
languages/opalestate-pro-backup-201909030250570.pot~
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user