1: <?php
2: /**
3: * TAXONOMY :: Location
4: *
5: * @package EPL
6: * @subpackage Taxonomy/Location
7: * @copyright Copyright (c) 2019, Merv Barrett
8: * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9: * @since 1.0
10: */
11:
12: // Exit if accessed directly.
13: if ( ! defined( 'ABSPATH' ) ) {
14: exit;
15: }
16:
17: /**
18: * Registers and sets up the tax_location taxonomy
19: *
20: * @since 1.0
21: * @return void
22: */
23: function epl_register_taxonomy_location() {
24: $location_label = epl_tax_location_label();
25: $location_slug = sanitize_title( $location_label );
26: $hierarchical = defined( 'EPL_LOCATION_HIERARCHICAL' ) && EPL_LOCATION_HIERARCHICAL ? true : false;
27: $rest = defined( 'EPL_LOCATION_DISABLE_REST' ) && EPL_LOCATION_DISABLE_REST ? false : true;
28: // Add define ('EPL_LOCATION_HIERARCHICAL', 'true'); into theme functions.php for hierarchical location taxonomy.
29:
30: $labels = array(
31: 'name' => $location_label,
32: 'singular_name' => $location_label,
33: 'menu_name' => $location_label, /* translators: %s: Location. */
34: 'all_items' => sprintf( __( 'All %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
35: 'parent_item' => sprintf( __( 'Parent %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
36: 'parent_item_colon' => sprintf( __( 'Parent %s :', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
37: 'new_item_name' => sprintf( __( 'New %s Name', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
38: 'add_new_item' => sprintf( __( 'Add New %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
39: 'edit_item' => sprintf( __( 'Edit %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
40: 'update_item' => sprintf( __( 'Update %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
41: 'separate_items_with_commas' => sprintf( __( 'Separate %s with commas', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
42: 'search_items' => sprintf( __( 'Search %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
43: 'add_or_remove_items' => sprintf( __( 'Add or remove %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
44: 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
45: 'not_found' => sprintf( __( '%s Not Found', 'easy-property-listings' ), $location_label ), /* translators: %s: Location. */
46: );
47: $rewrite = array(
48: 'slug' => $location_slug,
49: 'with_front' => true,
50: 'hierarchical' => $hierarchical,
51: );
52: $args = array(
53: 'labels' => $labels,
54: 'hierarchical' => $hierarchical,
55: 'public' => true,
56: 'show_ui' => true,
57: 'show_admin_column' => true,
58: 'show_in_nav_menus' => true,
59: 'show_tagcloud' => true,
60: 'show_in_rest' => $rest,
61: 'rewrite' => $rewrite,
62: );
63: register_taxonomy( 'location', array( 'property', 'rental', 'land', 'rural', 'business', 'commercial', 'commercial_land', 'testimonial', 'location' ), $args );
64: }
65: add_action( 'init', 'epl_register_taxonomy_location', 0 );
66: