1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function epl_register_custom_post_type_rental() {
$archives = defined( 'EPL_RENTAL_DISABLE_ARCHIVE' ) && EPL_RENTAL_DISABLE_ARCHIVE ? false : true;
$slug = defined( 'EPL_RENTAL_SLUG' ) ? EPL_RENTAL_SLUG : 'rental';
$rewrite = defined( 'EPL_RENTAL_DISABLE_REWRITE' ) && EPL_RENTAL_DISABLE_REWRITE ? false : array(
'slug' => $slug,
'with_front' => false,
);
$rest = defined( 'EPL_RENTAL_DISABLE_REST' ) && EPL_RENTAL_DISABLE_REST ? false : true;
$labels = apply_filters(
'epl_rental_labels',
array(
'name' => __( 'Rentals', 'easy-property-listings' ),
'singular_name' => __( 'Rental', 'easy-property-listings' ),
'menu_name' => __( 'Rentals', 'easy-property-listings' ),
'add_new' => __( 'Add New', 'easy-property-listings' ),
'add_new_item' => __( 'Add New Rental', 'easy-property-listings' ),
'edit_item' => __( 'Edit Rental', 'easy-property-listings' ),
'new_item' => __( 'New Rental', 'easy-property-listings' ),
'update_item' => __( 'Update Rental', 'easy-property-listings' ),
'all_items' => __( 'All Rentals', 'easy-property-listings' ),
'view_item' => __( 'View Rental', 'easy-property-listings' ),
'view_items' => __( 'View Rentals', 'easy-property-listings' ),
'search_items' => __( 'Search Rentals', 'easy-property-listings' ),
'not_found' => __( 'Rental Not Found', 'easy-property-listings' ),
'not_found_in_trash' => __( 'Rental Not Found in Trash', 'easy-property-listings' ),
'parent_item_colon' => __( 'Parent Rental:', 'easy-property-listings' ),
)
);
$rental_args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => $rewrite,
'menu_icon' => 'dashicons-admin-home',
'capability_type' => 'post',
'has_archive' => $archives,
'hierarchical' => false,
'menu_position' => '26.5',
'show_in_rest' => $rest,
'taxonomies' => array( 'location', 'tax_feature' ),
'supports' => apply_filters( 'epl_rental_supports', array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) ),
);
epl_register_post_type( 'rental', 'Rental', apply_filters( 'epl_rental_post_type_args', $rental_args ) );
}
add_action( 'init', 'epl_register_custom_post_type_rental', 0 );
if ( is_admin() ) {
function epl_manage_rental_columns_heading( $columns ) {
global $epl_settings;
$columns = array(
'cb' => '<input type="checkbox" />',
'property_featured' => '<span class="dashicons dashicons-star-half"></span><span class="epl-manage-featured">' . __( 'Featured', 'easy-property-listings' ) . '</span>',
'property_thumb' => __( 'Image', 'easy-property-listings' ),
'property_rent' => __( 'Rent', 'easy-property-listings' ),
'title' => __( 'Address', 'easy-property-listings' ),
'listing' => __( 'Listing Details', 'easy-property-listings' ),
'listing_id' => __( 'Unique ID', 'easy-property-listings' ),
'geo' => __( 'Geocoded', 'easy-property-listings' ),
'property_status' => __( 'Status', 'easy-property-listings' ),
'agent' => __( 'Agent', 'easy-property-listings' ),
'date' => __( 'Date', 'easy-property-listings' ),
) + $columns;
unset( $columns['author'] );
unset( $columns['comments'] );
if ( 1 !== (int) epl_get_option( 'debug', 0 ) ) {
unset( $columns['geo'] );
}
if ( 1 !== (int) epl_get_option( 'admin_unique_id', 0 ) ) {
unset( $columns['listing_id'] );
}
return apply_filters( 'epl_post_type_rental_admin_columns', $columns );
}
add_filter( 'manage_edit-rental_columns', 'epl_manage_rental_columns_heading' );
function epl_manage_rental_columns_value( $column, $post_id ) {
switch ( $column ) {
case 'property_featured':
do_action( 'epl_manage_listing_column_featured' );
break;
case 'property_thumb':
do_action( 'epl_manage_listing_column_property_thumb' );
break;
case 'listing':
do_action( 'epl_manage_listing_column_listing' );
break;
case 'listing_id':
do_action( 'epl_manage_listing_column_listing_id' );
break;
case 'geo':
do_action( 'epl_manage_listing_column_geo' );
break;
case 'property_rent':
do_action( 'epl_manage_listing_column_price' );
break;
case 'property_status':
do_action( 'epl_manage_listing_column_property_status' );
break;
case 'agent':
do_action( 'epl_manage_listing_column_agent' );
break;
default:
break;
}
}
add_action( 'manage_rental_posts_custom_column', 'epl_manage_rental_columns_value', 10, 2 );
}