1: <?php
2: /**
3: * Register post type :: Land
4: *
5: * @package EPL
6: * @subpackage PostTypes/Land
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 Land custom post type.
19: *
20: * @since 1.0
21: * @since 3.5.1 View Land Listings added for plural.
22: *
23: * @return void
24: */
25: function epl_register_custom_post_type_land() {
26:
27: $archives = defined( 'EPL_LAND_DISABLE_ARCHIVE' ) && EPL_LAND_DISABLE_ARCHIVE ? false : true;
28: $slug = defined( 'EPL_LAND_SLUG' ) ? EPL_LAND_SLUG : 'land';
29: $rewrite = defined( 'EPL_LAND_DISABLE_REWRITE' ) && EPL_LAND_DISABLE_REWRITE ? false : array(
30: 'slug' => $slug,
31: 'with_front' => false,
32: );
33: $rest = defined( 'EPL_LAND_DISABLE_REST' ) && EPL_LAND_DISABLE_REST ? false : true;
34:
35: $labels = apply_filters(
36: 'epl_land_labels',
37: array(
38: 'name' => __( 'Land', 'easy-property-listings' ),
39: 'singular_name' => __( 'Land', 'easy-property-listings' ),
40: 'menu_name' => __( 'Land', 'easy-property-listings' ),
41: 'add_new' => __( 'Add New', 'easy-property-listings' ),
42: 'add_new_item' => __( 'Add New Land Listing', 'easy-property-listings' ),
43: 'edit_item' => __( 'Edit Land Listing', 'easy-property-listings' ),
44: 'new_item' => __( 'New Land Listing', 'easy-property-listings' ),
45: 'update_item' => __( 'Update Land Listing', 'easy-property-listings' ),
46: 'all_items' => __( 'All Land Listings', 'easy-property-listings' ),
47: 'view_item' => __( 'View Land Listing', 'easy-property-listings' ),
48: 'view_items' => __( 'View Land Listings', 'easy-property-listings' ),
49: 'search_items' => __( 'Search Land Listing', 'easy-property-listings' ),
50: 'not_found' => __( 'Land Listing Not Found', 'easy-property-listings' ),
51: 'not_found_in_trash' => __( 'Land Listing Not Found in Trash', 'easy-property-listings' ),
52: 'parent_item_colon' => __( 'Parent Land Listing:', 'easy-property-listings' ),
53: )
54: );
55:
56: $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.3',
69: 'show_in_rest' => $rest,
70: 'taxonomies' => array( 'location', 'tax_feature' ),
71: 'supports' => apply_filters( 'epl_land_supports', array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) ),
72: );
73: epl_register_post_type( 'land', 'Land', apply_filters( 'epl_land_post_type_args', $land_args ) );
74: }
75: add_action( 'init', 'epl_register_custom_post_type_land', 0 );
76:
77: /**
78: * Manage Admin Land Post Type Columns.
79: *
80: * @since 1.0
81: * @return void
82: */
83: if ( is_admin() ) {
84: /**
85: * Manage Admin 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_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: 'agent' => __( 'Agent', 'easy-property-listings' ),
106: 'date' => __( 'Date', 'easy-property-listings' ),
107: ) + $columns;
108:
109: // unset author columns as duplicate of agent column.
110: unset( $columns['author'] );
111: unset( $columns['comments'] );
112:
113: // Geocode Column.
114: if ( 1 !== (int) epl_get_option( 'debug', 0 ) ) {
115: unset( $columns['geo'] );
116: }
117:
118: // Listing ID Column.
119: if ( 1 !== (int) epl_get_option( 'admin_unique_id', 0 ) ) {
120: unset( $columns['listing_id'] );
121: }
122:
123: return apply_filters( 'epl_post_type_land_admin_columns', $columns );
124: }
125: add_filter( 'manage_edit-land_columns', 'epl_manage_land_columns_heading' );
126:
127: /**
128: * Manage Admin Land Post Type Columns: Row Contents.
129: *
130: * @since 1.0
131: * @param string $column column.
132: * @param int $post_id post id.
133: */
134: function epl_manage_land_columns_value( $column, $post_id ) {
135:
136: switch ( $column ) {
137:
138: // If displaying the 'Featured Star' column.
139: case 'property_featured':
140: do_action( 'epl_manage_listing_column_featured' );
141:
142: break;
143:
144: // If displaying the 'Featured' image column.
145: case 'property_thumb':
146: do_action( 'epl_manage_listing_column_property_thumb' );
147:
148: break;
149:
150: // If displaying the 'Listing Details' column.
151: case 'listing':
152: do_action( 'epl_manage_listing_column_listing' );
153:
154: break;
155:
156: // If displaying the 'Listing ID' column.
157: case 'listing_id':
158: do_action( 'epl_manage_listing_column_listing_id' );
159:
160: break;
161:
162: // If displaying the 'Geocoding' column.
163: case 'geo':
164: do_action( 'epl_manage_listing_column_geo' );
165:
166: break;
167:
168: // If displaying the 'Price' column.
169: case 'property_price':
170: do_action( 'epl_manage_listing_column_price' );
171:
172: break;
173: // If displaying the 'status' column.
174: case 'property_status':
175: do_action( 'epl_manage_listing_column_property_status' );
176:
177: break;
178:
179: // If displaying the 'agent' column.
180: case 'agent':
181: do_action( 'epl_manage_listing_column_agent' );
182:
183: break;
184:
185: // Just break out of the switch statement for everything else.
186: default:
187: break;
188: }
189: }
190: add_action( 'manage_land_posts_custom_column', 'epl_manage_land_columns_value', 10, 2 );
191: }
192: