From 052037d02501c52f582a159a6c092baaa58993e3 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Tue, 29 Oct 2019 15:02:04 +0700 Subject: [PATCH] Update taxonomies. --- inc/taxonomies/class-taxomony-amenities.php | 5 + inc/taxonomies/class-taxonomy-city.php | 5 + inc/taxonomies/class-taxonomy-labels.php | 5 + inc/taxonomies/class-taxonomy-locations.php | 5 + .../class-taxonomy-neighborhood.php | 114 ------------------ inc/taxonomies/class-taxonomy-state.php | 5 + inc/taxonomies/class-taxonomy-status.php | 5 + inc/taxonomies/class-taxonomy-types.php | 5 + opal-estate-pro.php | 1 - 9 files changed, 35 insertions(+), 115 deletions(-) delete mode 100755 inc/taxonomies/class-taxonomy-neighborhood.php diff --git a/inc/taxonomies/class-taxomony-amenities.php b/inc/taxonomies/class-taxomony-amenities.php index 10169d62..70316edf 100755 --- a/inc/taxonomies/class-taxomony-amenities.php +++ b/inc/taxonomies/class-taxomony-amenities.php @@ -28,6 +28,11 @@ class Opalestate_Taxonomy_Amenities { public function __construct() { add_action( 'init', [ $this, 'definition' ] ); 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; + } ); } /** diff --git a/inc/taxonomies/class-taxonomy-city.php b/inc/taxonomies/class-taxonomy-city.php index c71a6b07..1e16044b 100755 --- a/inc/taxonomies/class-taxonomy-city.php +++ b/inc/taxonomies/class-taxonomy-city.php @@ -29,6 +29,11 @@ class Opalestate_Taxonomy_City { public static function init() { add_action( 'init', [ __CLASS__, 'definition' ] ); 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; + } ); } /** diff --git a/inc/taxonomies/class-taxonomy-labels.php b/inc/taxonomies/class-taxonomy-labels.php index db1f9728..fb2fd8db 100755 --- a/inc/taxonomies/class-taxonomy-labels.php +++ b/inc/taxonomies/class-taxonomy-labels.php @@ -29,6 +29,11 @@ class Opalestate_Taxonomy_Label { add_action( 'init', [ $this, 'definition' ] ); add_filter( 'opalestate_taxomony_label_metaboxes', [ $this, 'metaboxes' ] ); 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; + } ); } /** diff --git a/inc/taxonomies/class-taxonomy-locations.php b/inc/taxonomies/class-taxonomy-locations.php index 69f9e105..8dfc72ba 100755 --- a/inc/taxonomies/class-taxonomy-locations.php +++ b/inc/taxonomies/class-taxonomy-locations.php @@ -29,6 +29,11 @@ class Opalestate_Taxonomy_Location { add_action( 'init', [ $this, 'definition' ] ); add_filter( 'opalestate_taxomony_location_metaboxes', [ $this, '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; + } ); } /** diff --git a/inc/taxonomies/class-taxonomy-neighborhood.php b/inc/taxonomies/class-taxonomy-neighborhood.php deleted file mode 100755 index 3913e26b..00000000 --- a/inc/taxonomies/class-taxonomy-neighborhood.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @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(); \ No newline at end of file diff --git a/inc/taxonomies/class-taxonomy-state.php b/inc/taxonomies/class-taxonomy-state.php index 773fcd57..2e379259 100755 --- a/inc/taxonomies/class-taxonomy-state.php +++ b/inc/taxonomies/class-taxonomy-state.php @@ -29,6 +29,11 @@ class Opalestate_Taxonomy_State { add_action( 'init', [ $this, 'definition' ] ); add_filter( 'opalestate_taxomony_state_metaboxes', [ $this, '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; + } ); } /** diff --git a/inc/taxonomies/class-taxonomy-status.php b/inc/taxonomies/class-taxonomy-status.php index fab5f875..5ed483d4 100755 --- a/inc/taxonomies/class-taxonomy-status.php +++ b/inc/taxonomies/class-taxonomy-status.php @@ -30,6 +30,11 @@ class Opalestate_Taxonomy_Status { add_action( 'init', [ $this, 'definition' ] ); add_filter( 'opalestate_taxomony_status_metaboxes', [ $this, '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; + } ); } /** diff --git a/inc/taxonomies/class-taxonomy-types.php b/inc/taxonomies/class-taxonomy-types.php index 95025f3b..899c71c7 100755 --- a/inc/taxonomies/class-taxonomy-types.php +++ b/inc/taxonomies/class-taxonomy-types.php @@ -28,6 +28,11 @@ class Opalestate_Taxonomy_Type { public function __construct() { add_action( 'init', [ $this, 'definition' ] ); 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; + } ); } /** diff --git a/opal-estate-pro.php b/opal-estate-pro.php index a3375faf..32ede352 100755 --- a/opal-estate-pro.php +++ b/opal-estate-pro.php @@ -322,7 +322,6 @@ if ( ! class_exists( 'OpalEstate' ) ) { 'taxonomies/class-taxonomy-labels.php', 'taxonomies/class-taxonomy-status.php', 'taxonomies/class-taxonomy-types.php', - 'taxonomies/class-taxonomy-neighborhood.php', 'taxonomies/class-taxonomy-locations.php', 'taxonomies/class-taxonomy-city.php', 'taxonomies/class-taxonomy-state.php',