1: <?php
2: /**
3: * Register post type :: Commercial Land
4: *
5: * @package EPL
6: * @subpackage PostTypes/CommercialLand
7: * @copyright Copyright (c) 2020, 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 Commercial Land custom post type.
19: *
20: * @since 1.0
21: * @since 3.5.1 View Commercial Land Listings added for plural.
22: *
23: * @return void
24: */
25: function epl_register_custom_post_type_commercial_land() {
26:
27: $archives = defined( 'EPL_COMMERCIAL_LAND_DISABLE_ARCHIVE' ) && EPL_COMMERCIAL_LAND_DISABLE_ARCHIVE ? false : true;
28: $slug = defined( 'EPL_COMMERCIAL_LAND_SLUG' ) ? EPL_COMMERCIAL_LAND_SLUG : 'commercial-land';
29: $rewrite = defined( 'EPL_COMMERCIAL_LAND_DISABLE_REWRITE' ) && EPL_COMMERCIAL_LAND_DISABLE_REWRITE ? false : array(
30: 'slug' => $slug,
31: 'with_front' => false,
32: );
33: $rest = defined( 'EPL_COMMERCIAL_LAND_DISABLE_REST' ) && EPL_COMMERCIAL_LAND_DISABLE_REST ? false : true;
34:
35: $labels = apply_filters(
36: 'epl_commercial_land_labels',
37: array(
38: 'name' => __( 'Commercial Land Listings', 'easy-property-listings' ),
39: 'singular_name' => __( 'Commercial Land Listing', 'easy-property-listings' ),
40: 'menu_name' => __( 'Commercial Land', 'easy-property-listings' ),
41: 'add_new' => __( 'Add New', 'easy-property-listings' ),
42: 'add_new_item' => __( 'Add New Commercial Land Listing', 'easy-property-listings' ),
43: 'edit_item' => __( 'Edit Commercial Land Listing', 'easy-property-listings' ),
44: 'new_item' => __( 'New Commercial Land Listing', 'easy-property-listings' ),
45: 'update_item' => __( 'Update Commercial Land Listing', 'easy-property-listings' ),
46: 'all_items' => __( 'All Commercial Land Listings', 'easy-property-listings' ),
47: 'view_item' => __( 'View Commercial Land Listing', 'easy-property-listings' ),
48: 'view_items' => __( 'View Commercial Land Listings', 'easy-property-listings' ),
49: 'search_items' => __( 'Search Commercial Land Listing', 'easy-property-listings' ),
50: 'not_found' => __( 'Commercial Land Listing Not Found', 'easy-property-listings' ),
51: 'not_found_in_trash' => __( 'Commercial Land Listing Not Found in Trash', 'easy-property-listings' ),
52: 'parent_item_colon' => __( 'Parent Commercial Land Listing:', 'easy-property-listings' ),
53: )
54: );
55:
56: $commercial_land_args = array(
57: 'labels' => $labels,
58: 'public' => true,
59: 'publicly_queryable' => true,
60: 'show_ui' => true,
61: 'show_in_menu' => true,
62: 'query_var' => true,
63: 'rewrite' => $rewrite,
64: 'menu_icon' => 'dashicons-image-crop',
65: 'capability_type' => 'post',
66: 'has_archive' => $archives,
67: 'hierarchical' => false,
68: 'menu_position' => '26.8',
69: 'show_in_rest' => $rest,
70: 'taxonomies' => array( 'location', 'tax_feature' ),
71: 'supports' => apply_filters( 'epl_commercial_land_supports', array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) ),
72: );
73: epl_register_post_type( 'commercial_land', 'Commercial Land', apply_filters( 'epl_commercial_land_post_type_args', $commercial_land_args ) );
74: }
75: add_action( 'init', 'epl_register_custom_post_type_commercial_land', 0 );
76:
77: /**
78: * Manage Admin Commercial Land Post Type Columns.
79: *
80: * @since 1.0
81: * @return void
82: */
83: if ( is_admin() ) {
84: /**
85: * Manage Admin Commercial Land Post Type Columns: Heading.
86: *
87: * @param array $columns Column array.
88: *
89: * @return mixed|void $columns with epl_post_type_commercial_land_admin_columns filter.
90: * @since 1.0
91: */
92: function epl_manage_commercial_land_columns_heading( $columns ) {
93: global $epl_settings;
94:
95: $columns = array(
96: 'cb' => '<input type="checkbox" />',
97: 'property_featured' => '<span class="dashicons dashicons-star-half"></span><span class="epl-manage-featured">' . __( 'Featured', 'easy-property-listings' ) . '</span>',
98: 'property_thumb' => __( 'Image', 'easy-property-listings' ),
99: 'property_price' => __( 'Price', 'easy-property-listings' ),
100: 'title' => __( 'Address', 'easy-property-listings' ),
101: 'listing' => __( 'Listing Details', 'easy-property-listings' ),
102: 'listing_id' => __( 'Unique ID', 'easy-property-listings' ),
103: 'geo' => __( 'Geo', 'easy-property-listings' ),
104: 'property_status' => __( 'Status', 'easy-property-listings' ),
105: 'listing_type' => __( 'Sale/Lease', 'easy-property-listings' ),
106: 'agent' => __( 'Agent', 'easy-property-listings' ),
107: 'date' => __( 'Date', 'easy-property-listings' ),
108: ) + $columns;
109:
110: // unset author columns as duplicate of agent column.
111: unset( $columns['author'] );
112: unset( $columns['comments'] );
113:
114: // Geocode Column.
115: if ( 1 !== (int) epl_get_option( 'debug', 0 ) ) {
116: unset( $columns['geo'] );
117: }
118:
119: // Listing ID Column.
120: if ( 1 !== (int) epl_get_option( 'admin_unique_id', 0 ) ) {
121: unset( $columns['listing_id'] );
122: }
123:
124: return apply_filters( 'epl_post_type_commercial_land_admin_columns', $columns );
125: }
126: add_filter( 'manage_edit-commercial_land_columns', 'epl_manage_commercial_land_columns_heading' );
127:
128: /**
129: * Manage Admin Commercial Land Post Type Columns: Row Contents.
130: *
131: * @since 1.0
132: * @param string $column column.
133: * @param int $post_id post id.
134: */
135: function epl_manage_commercial_land_columns_value( $column, $post_id ) {
136:
137: switch ( $column ) {
138:
139: // If displaying the 'Featured Star' column.
140: case 'property_featured':
141: do_action( 'epl_manage_listing_column_featured' );
142:
143: break;
144:
145: // If displaying the 'Featured' image column.
146: case 'property_thumb':
147: do_action( 'epl_manage_listing_column_property_thumb' );
148:
149: break;
150:
151: // If displaying the 'Listing Details' column.
152: case 'listing':
153: do_action( 'epl_manage_listing_column_listing' );
154:
155: break;
156:
157: // If displaying the 'Listing ID' column.
158: case 'listing_id':
159: do_action( 'epl_manage_listing_column_listing_id' );
160:
161: break;
162:
163: // If displaying the 'Geocoding' column.
164: case 'geo':
165: do_action( 'epl_manage_listing_column_geo' );
166:
167: break;
168:
169: // If displaying the 'Price' column.
170: case 'property_price':
171: do_action( 'epl_manage_listing_column_price' );
172:
173: break;
174:
175: // If displaying the 'Commercial Land Listing Type' column.
176: case 'listing_type':
177: do_action( 'epl_manage_listing_column_listing_type' );
178:
179: break;
180:
181: // If displaying the 'status' column.
182: case 'property_status':
183: do_action( 'epl_manage_listing_column_property_status' );
184:
185: break;
186:
187: // If displaying the 'agent' column.
188: case 'agent':
189: do_action( 'epl_manage_listing_column_agent' );
190:
191: break;
192:
193: // Just break out of the switch statement for everything else.
194: default:
195: break;
196: }
197: }
198: add_action( 'manage_commercial_land_posts_custom_column', 'epl_manage_commercial_land_columns_value', 10, 2 );
199: }
200: