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