Merge pull request #11 from wpopal/develop

Develop
This commit is contained in:
wpopal 2019-10-29 15:45:03 +07:00 committed by GitHub
commit d9951b46af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 90 additions and 127 deletions

View File

@ -291,7 +291,7 @@ class Opalestate_Property_MetaBox {
[ [
'name' => esc_html__( 'Built year', 'opalestate-pro' ), 'name' => esc_html__( 'Built year', 'opalestate-pro' ),
'id' => $prefix . 'builtyear', 'id' => $prefix . 'builtyear',
'type' => 'text_date', 'type' => 'text',
'description' => esc_html__( 'Enter built year', 'opalestate-pro' ), 'description' => esc_html__( 'Enter built year', 'opalestate-pro' ),
'before_row' => '<div class="row-group-features group-has-three group-property-info clearfix"><h3>' . ( is_admin() ? "" : esc_html__( 'Property Information', 'opalestate-pro' ) ) . '</h3>', 'before_row' => '<div class="row-group-features group-has-three group-property-info clearfix"><h3>' . ( is_admin() ? "" : esc_html__( 'Property Information', 'opalestate-pro' ) ) . '</h3>',

View File

@ -184,14 +184,18 @@ class Opalestate_Property {
} }
$opt_values = $tmp; $opt_values = $tmp;
} }
$value = implode( ", ", $opt_values ); $value = implode( ', ', $opt_values );
} else { } else {
$value = get_post_meta( $this->post_id, $field['id'], true ); $value = get_post_meta( $this->post_id, $field['id'], true );
} }
$value = isset( $field['unit'] ) && $field['unit'] ? $value . ' ' . $field['unit'] : $value; $value = isset( $field['unit'] ) && $field['unit'] ? $value . ' ' . $field['unit'] : $value;
$this->metabox_info[ $id ] = [ 'label' => $field['name'], 'value' => $value ]; $this->metabox_info[ $id ] = [
'label' => $field['name'],
'value' => $value,
'icon' => opalestate_get_property_meta_icon( $id ),
];
} }
} }

View File

@ -145,14 +145,13 @@ class OpalEstate_Search {
} }
$sarg = apply_filters( 'opalestate_search_field_query_' . $key, $fieldquery ); $sarg = apply_filters( 'opalestate_search_field_query_' . $key, $fieldquery );
$metaquery[] = $sarg; $metaquery[] = $sarg;
} }
} }
$args['meta_query'] = array_merge( $args['meta_query'], $metaquery ); $args['meta_query'] = array_merge( $args['meta_query'], $metaquery );
} }
if ( $search_min_price != '' && $search_min_price != '' && is_numeric( $search_min_price ) && is_numeric( $search_max_price ) ) { if ( $search_min_price != '' && $search_max_price != '' && is_numeric( $search_min_price ) && is_numeric( $search_max_price ) ) {
if ( $search_min_price ) { if ( $search_min_price ) {
array_push( $args['meta_query'], [ array_push( $args['meta_query'], [
@ -195,7 +194,7 @@ class OpalEstate_Search {
] ); ] );
} }
if ( $search_min_area != '' && $search_min_area != '' && is_numeric( $search_min_area ) && is_numeric( $search_max_area ) ) { if ( $search_min_area != '' && $search_max_area != '' && is_numeric( $search_min_area ) && is_numeric( $search_max_area ) ) {
array_push( $args['meta_query'], [ array_push( $args['meta_query'], [
'key' => OPALESTATE_PROPERTY_PREFIX . 'areasize', 'key' => OPALESTATE_PROPERTY_PREFIX . 'areasize',
'value' => [ $search_min_area, $search_max_area ], 'value' => [ $search_min_area, $search_max_area ],
@ -237,9 +236,9 @@ class OpalEstate_Search {
$ksearchs = []; $ksearchs = [];
if ( isset( $_REQUEST['opalsortable'] ) && ! empty( $_REQUEST['opalsortable'] ) ) { if ( isset( $_REQUEST['opalsortable'] ) && ! empty( $_REQUEST['opalsortable'] ) ) {
$ksearchs = explode( "_", $_REQUEST['opalsortable'] ); $ksearchs = explode( '_', $_REQUEST['opalsortable'] );
} elseif ( isset( $_SESSION['opalsortable'] ) && ! empty( $_SESSION['opalsortable'] ) ) { } elseif ( isset( $_SESSION['opalsortable'] ) && ! empty( $_SESSION['opalsortable'] ) ) {
$ksearchs = explode( "_", $_SESSION['opalsortable'] ); $ksearchs = explode( '_', $_SESSION['opalsortable'] );
} }
if ( ! empty( $ksearchs ) && count( $ksearchs ) == 2 ) { if ( ! empty( $ksearchs ) && count( $ksearchs ) == 2 ) {
@ -248,8 +247,46 @@ class OpalEstate_Search {
$args['order'] = $ksearchs[1]; $args['order'] = $ksearchs[1];
} }
$args = apply_filters( 'opalestate_get_search_results_query_args', $args ); $metas = Opalestate_Property_MetaBox::metaboxes_info_fields();
foreach ( $metas as $meta ) {
if ( $meta['id'] == OPALESTATE_PROPERTY_PREFIX . 'areasize' ) {
continue;
}
$request = str_replace( OPALESTATE_PROPERTY_PREFIX, '', $meta['id'] );
$setting_search_type = opalestate_options( $meta['id'] . '_search_type', 'select' );
if ( 'range' === $setting_search_type ) {
$min_request = isset( $_GET[ 'min_' . $request ] ) ? sanitize_text_field( $_GET[ 'min_' . $request ] ) : '';
$max_request = isset( $_GET[ 'max_' . $request ] ) ? sanitize_text_field( $_GET[ 'max_' . $request ] ) : '';
if ( $min_request != '' && $max_request != '' && is_numeric( $min_request ) && is_numeric( $max_request ) ) {
array_push( $args['meta_query'], [
'key' => $meta['id'],
'value' => [ $min_request, $max_request ],
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
] );
} elseif ( $min_request != '' && is_numeric( $min_request ) ) {
array_push( $args['meta_query'], [
'key' => $meta['id'],
'value' => $min_request,
'compare' => '>=',
'type' => 'NUMERIC',
] );
} elseif ( $max_request != '' && is_numeric( $max_request ) ) {
array_push( $args['meta_query'], [
'key' => $meta['id'],
'value' => $max_request,
'compare' => '<=',
'type' => 'NUMERIC',
] );
}
}
}
$args = apply_filters( 'opalestate_get_search_results_query_args', $args );
$query = new WP_Query( $args ); $query = new WP_Query( $args );
wp_reset_postdata(); wp_reset_postdata();

View File

@ -238,7 +238,7 @@ class Opalestate_Property_MetaBox_Submission {
[ [
'name' => esc_html__( 'Built year', 'opalestate-pro' ), 'name' => esc_html__( 'Built year', 'opalestate-pro' ),
'id' => $prefix . 'builtyear', 'id' => $prefix . 'builtyear',
'type' => 'text_date', 'type' => 'text',
'description' => esc_html__( 'Enter built year', 'opalestate-pro' ), 'description' => esc_html__( 'Enter built year', 'opalestate-pro' ),
'before_row' => '<div id="opalestate-submission-information" class="opalestate-tab-content"><div class="field-row-2">', 'before_row' => '<div id="opalestate-submission-information" class="opalestate-tab-content"><div class="field-row-2">',

View File

@ -28,6 +28,11 @@ class Opalestate_Taxonomy_Amenities {
public function __construct() { public function __construct() {
add_action( 'init', [ $this, 'definition' ] ); add_action( 'init', [ $this, 'definition' ] );
add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ], 999 ); add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ], 999 );
add_filter( 'get_opalestate_amenities', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
} }
/** /**

View File

@ -29,6 +29,11 @@ class Opalestate_Taxonomy_City {
public static function init() { public static function init() {
add_action( 'init', [ __CLASS__, 'definition' ] ); add_action( 'init', [ __CLASS__, 'definition' ] );
add_action( 'cmb2_admin_init', [ __CLASS__, 'taxonomy_metaboxes' ] ); add_action( 'cmb2_admin_init', [ __CLASS__, 'taxonomy_metaboxes' ] );
add_filter( 'get_opalestate_city', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
} }
/** /**

View File

@ -29,6 +29,11 @@ class Opalestate_Taxonomy_Label {
add_action( 'init', [ $this, 'definition' ] ); add_action( 'init', [ $this, 'definition' ] );
add_filter( 'opalestate_taxomony_label_metaboxes', [ $this, 'metaboxes' ] ); add_filter( 'opalestate_taxomony_label_metaboxes', [ $this, 'metaboxes' ] );
add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ], 999 ); add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ], 999 );
add_filter( 'get_opalestate_label', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
} }
/** /**

View File

@ -29,6 +29,11 @@ class Opalestate_Taxonomy_Location {
add_action( 'init', [ $this, 'definition' ] ); add_action( 'init', [ $this, 'definition' ] );
add_filter( 'opalestate_taxomony_location_metaboxes', [ $this, 'metaboxes' ] ); add_filter( 'opalestate_taxomony_location_metaboxes', [ $this, 'metaboxes' ] );
add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] ); add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] );
add_filter( 'get_opalestate_location', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
} }
/** /**

View File

@ -1,114 +0,0 @@
<?php
/**
* $Desc$
*
* @version $Id$
* @package opalestate
* @author Opal Team <info@wpopal.com >
* @copyright Copyright (C) 2019 wpopal.com. All Rights Reserved.
* @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
*
* @website http://www.wpopal.com
* @support http://www.wpopal.com/support/forum.html
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Opalestate_Taxonomy_Neighborhood{
/**
*
*/
public static function init(){
add_action( 'init', array( $this, 'definition' ), 99 );
add_action( 'cmb2_admin_init', array( $this, 'taxonomy_metaboxes' ), 9 );
}
/**
* Hook in and add a metabox to add fields to taxonomy terms
*/
public function taxonomy_metaboxes() {
$prefix = 'opalestate_nb_';
/**
* Metabox to add fields to categories and tags
*/
$cmb_term = new_cmb2_box( array(
'id' => $prefix . 'edit',
'title' => esc_html__( 'Type Metabox', 'opalestate-pro' ), // Doesn't output for term boxes
'object_types' => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta
'taxonomies' => array( 'opalestate_neighborhoods' ), // Tells CMB2 which taxonomies should have these fields
// 'new_term_section' => true, // Will display in the "Add New Category" section
) );
$cmb_term->add_field( array(
'name' => esc_html__( 'Icon', 'opalestate-pro' ),
'desc' => esc_html__( 'This image will display in google map', 'opalestate-pro' ),
'id' => $prefix . 'icon',
'type' => 'file',
'preview_size' => 'small',
'options' => array(
'url' => false, // Hide the text input for the url
)
) );
}
/**
*
*/
public function definition(){
$labels = array(
'name' => esc_html__( 'Neighborhoods', 'opalestate-pro' ),
'singular_name' => esc_html__( 'Properties By Neighborhood', 'opalestate-pro' ),
'search_items' => esc_html__( 'Search Neighborhoods', 'opalestate-pro' ),
'all_items' => esc_html__( 'All Neighborhoods', 'opalestate-pro' ),
'parent_item' => esc_html__( 'Parent Neighborhood', 'opalestate-pro' ),
'parent_item_colon' => esc_html__( 'Parent Neighborhood:', 'opalestate-pro' ),
'edit_item' => esc_html__( 'Edit Neighborhood', 'opalestate-pro' ),
'update_item' => esc_html__( 'Update Neighborhood', 'opalestate-pro' ),
'add_new_item' => esc_html__( 'Add New Neighborhood', 'opalestate-pro' ),
'new_item_name' => esc_html__( 'New Neighborhood', 'opalestate-pro' ),
'menu_name' => esc_html__( 'Neighborhoods', 'opalestate-pro' ),
);
register_taxonomy( 'opalestate_neighborhoods', array( 'opalestate_property' ) , array(
'labels' => apply_filters( 'opalestate_taxomony_neighborhoods_labels', $labels ),
'hierarchical' => true,
'query_var' => 'property-neighborhood',
'rewrite' => array( 'slug' => esc_html__( 'property-neighborhood', 'opalestate-pro' ) ),
'public' => true,
'show_ui' => true,
) );
}
public static function metaboxes(){
}
public static function dropdown_list( $selected=0 ){
$id = "opalestate_neighborhoods".rand();
$args = array(
'show_option_none' => esc_html__( 'Select Neighborhoods', 'opalestate-pro' ),
'id' => $id,
'class' => 'form-control',
'show_count' => 0,
'hierarchical' => '',
'name' => 'neighborhoods',
'selected' => $selected,
'value_field' => 'slug',
'taxonomy' => 'opalestate_neighborhoods'
);
return wp_dropdown_categories( $args );
}
}
new Opalestate_Taxonomy_Neighborhood();

View File

@ -29,6 +29,11 @@ class Opalestate_Taxonomy_State {
add_action( 'init', [ $this, 'definition' ] ); add_action( 'init', [ $this, 'definition' ] );
add_filter( 'opalestate_taxomony_state_metaboxes', [ $this, 'metaboxes' ] ); add_filter( 'opalestate_taxomony_state_metaboxes', [ $this, 'metaboxes' ] );
add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] ); add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] );
add_filter( 'get_opalestate_state', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
} }
/** /**

View File

@ -30,6 +30,11 @@ class Opalestate_Taxonomy_Status {
add_action( 'init', [ $this, 'definition' ] ); add_action( 'init', [ $this, 'definition' ] );
add_filter( 'opalestate_taxomony_status_metaboxes', [ $this, 'metaboxes' ] ); add_filter( 'opalestate_taxomony_status_metaboxes', [ $this, 'metaboxes' ] );
add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] ); add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] );
add_filter( 'get_opalestate_status', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
} }
/** /**

View File

@ -28,6 +28,11 @@ class Opalestate_Taxonomy_Type {
public function __construct() { public function __construct() {
add_action( 'init', [ $this, 'definition' ] ); add_action( 'init', [ $this, 'definition' ] );
add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] ); add_action( 'cmb2_admin_init', [ $this, 'taxonomy_metaboxes' ] );
add_filter( 'get_opalestate_types', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
} }
/** /**

View File

@ -322,7 +322,6 @@ if ( ! class_exists( 'OpalEstate' ) ) {
'taxonomies/class-taxonomy-labels.php', 'taxonomies/class-taxonomy-labels.php',
'taxonomies/class-taxonomy-status.php', 'taxonomies/class-taxonomy-status.php',
'taxonomies/class-taxonomy-types.php', 'taxonomies/class-taxonomy-types.php',
'taxonomies/class-taxonomy-neighborhood.php',
'taxonomies/class-taxonomy-locations.php', 'taxonomies/class-taxonomy-locations.php',
'taxonomies/class-taxonomy-city.php', 'taxonomies/class-taxonomy-city.php',
'taxonomies/class-taxonomy-state.php', 'taxonomies/class-taxonomy-state.php',

View File

@ -31,8 +31,10 @@ The plugin will not make you disappointed with ease of use, friendly & flexible
= Add-ons for Opal Estate Pro = = Add-ons for Opal Estate Pro =
* Please visit and download [all add-ons](https://wordpress.org/plugins/tags/opalestate_addon/ "Opal Estate Pro add-ons") for Opal Estate Pro, they are free 100%* * Please visit and download [all add-ons](https://wordpress.org/plugins/tags/opalestate_addon/ "Opal Estate Pro add-ons") for Opal Estate Pro, they are free 100%*
1. *[ Opal Membership](https://wordpress.org/plugins/opal-membership/ "Opal Membership")* 1. *[ Opal Membership](https://wordpress.org/plugins/opal-membership/ "Opal Membership")*: Manage membership packages, users.
2. *[ Opal Estate Packages](https://wordpress.org/plugins/opal-estate-packages/ "Opal Estate Packages")* 2. *[ Opal Estate Packages](https://wordpress.org/plugins/opal-estate-packages/ "Opal Estate Packages")*: Manage membership packages connects with Woocommerce to benefit from all variety of Woocommerce extensions and payment gateways.
3. *[ Opal Estate Custom Fields](https://wordpress.org/plugins/opal-estate-custom-fields/ "Opal Estate Custom Fields")*: Create custom fields and allow you control and manage fields and used for
searchable.
= Features = = Features =