/** * Define our custom columns shown in admin. * @param string $column */ public function custom_columns($column) { global $post, $propertyhive, $the_property; if (empty($the_property) || $the_property->ID != $post->ID) { $the_property = new PH_Property($post->ID); } switch ($column) { case 'thumb': $thumb_src = $the_property->get_main_photo_src(); echo '<a href="' . get_edit_post_link($post->ID) . '">'; if ($thumb_src !== FALSE) { echo '<img src="' . $thumb_src . '" alt="" width="50">'; } else { // placeholder image } echo '</a>'; break; case 'address': $edit_link = get_edit_post_link($post->ID); //$title = _draft_or_post_title(); $title = $the_property->get_formatted_summary_address(); if (empty($title)) { $title = __('(no address entered)'); } $post_type_object = get_post_type_object($post->post_type); $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID); echo '<strong><a class="row-title" href="' . esc_url($edit_link) . '">' . $title . '</a>'; $post_status = get_post_status($post->ID); $post_title_output = ''; if ($post_status == 'draft' || $post_status == 'private') { $post_title_output = ucfirst($post_status); } $post_title_output = apply_filters('propertyhive_admin_property_column_post_address_output', $post_title_output); if ($post_title_output != '') { echo ' - ' . $post_title_output; } echo '</strong>'; // Excerpt view if (isset($_GET['mode']) && 'excerpt' == $_GET['mode']) { echo apply_filters('the_excerpt', $post->post_excerpt); } // Get actions $actions = array(); $actions['ref'] = 'Ref: ' . $the_property->_reference_number; //$actions['id'] = 'ID: ' . $post->ID; if ($can_edit_post && 'trash' != $post->post_status) { $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item', 'propertyhive')) . '">' . __('Edit', 'propertyhive') . '</a>'; } if (current_user_can($post_type_object->cap->delete_post, $post->ID)) { if ('trash' == $post->post_status) { $actions['untrash'] = '<a title="' . esc_attr(__('Restore this item from the Trash', 'propertyhive')) . '" href="' . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . '">' . __('Restore', 'propertyhive') . '</a>'; } elseif (EMPTY_TRASH_DAYS) { //$actions['trash'] = '<a class="submitdelete" title="' . esc_attr( __( 'Move this item to the Trash', 'propertyhive' ) ) . '" href="' . get_delete_post_link( $post->ID ) . '">' . __( 'Trash', 'propertyhive' ) . '</a>'; } if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) { $actions['delete'] = '<a class="submitdelete" title="' . esc_attr(__('Delete this item permanently', 'propertyhive')) . '" href="' . get_delete_post_link($post->ID, '', true) . '">' . __('Delete Permanently', 'propertyhive') . '</a>'; } } if ($post_type_object->public) { if (in_array($post->post_status, array('pending', 'draft', 'future'))) { if ($can_edit_post) { $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview “%s”', 'propertyhive'), $title)) . '" rel="permalink">' . __('Preview', 'propertyhive') . '</a>'; } } elseif ('trash' != $post->post_status) { $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”', 'propertyhive'), $title)) . '" rel="permalink">' . __('View', 'propertyhive') . '</a>'; } } $actions = apply_filters('post_row_actions', $actions, $post); echo '<div class="row-actions">'; $i = 0; $action_count = sizeof($actions); foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo '<span class="' . $action . '">' . $link . $sep . '</span>'; } echo '</div>'; /*get_inline_data( $post );*/ /* Custom inline data for propertyhive */ /*echo ' <div class="hidden" id="propertyhive_inline_' . $post->ID . '"> <div class="menu_order">' . $post->menu_order . '</div> </div> ';*/ break; case 'size': $floor_area = $the_property->get_formatted_floor_area(); if ($floor_area != '') { echo 'Floor Area: ' . $floor_area . '<br>'; } $site_area = $the_property->get_formatted_site_area(); if ($site_area != '') { echo 'Site Area: ' . $site_area; } if ($floor_area == '' && $site_area == '') { echo '-'; } break; case 'price': $price = $the_property->get_formatted_price(); if ($price == '') { $price = '-'; } echo $price; break; case 'status': $term_list = wp_get_post_terms($post->ID, 'availability', array("fields" => "names")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { echo $term_list[0] . '<br>'; } if (isset($the_property->_on_market) && $the_property->_on_market == 'yes') { echo 'On The Market'; } else { echo 'Not On The Market'; } if (isset($the_property->_featured) && $the_property->_featured == 'yes') { echo '<br>Featured'; } break; case 'owner': $owner_contact_id = $the_property->_owner_contact_id; if ($owner_contact_id != '' && $owner_contact_id != 0) { echo get_the_title($owner_contact_id) . '<br>'; echo '<div class="row-actions">'; echo 'T: ' . get_post_meta($owner_contact_id, '_telephone_number', TRUE) . '<br>'; echo 'E: ' . get_post_meta($owner_contact_id, '_email_address', TRUE); echo '</div>'; } break; case 'negotiator_office': $user_info = get_userdata($the_property->_negotiator_id); if ($user_info !== FALSE) { echo $user_info->display_name . '<br>'; } if ($the_property->_office_id != '') { echo get_the_title($the_property->_office_id); } break; default: break; } }
/** * Output the metabox */ public static function output($post) { echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; // Get children posts/properties $args = array('post_parent' => $post->ID, 'post_type' => 'property', 'nopaging' => true, 'orderby' => 'title'); $unit_query = new WP_Query($args); if ($unit_query->have_posts()) { echo '<table style="width:100%"> <thead> <tr> <th style="text-align:left;">Unit Address</th> <th style="text-align:left;">Size</th> <th style="text-align:left;">Price</th> <th style="text-align:left;">Availability</th> </tr> </thead> <tbody>'; while ($unit_query->have_posts()) { $unit_query->the_post(); $the_property = new PH_Property(get_the_ID()); echo '<tr>'; echo '<td style="text-align:left;"><a href="' . get_edit_post_link(get_the_ID()) . '">' . $the_property->get_formatted_summary_address() . '</a></td>'; echo '<td style="text-align:left;">'; $floor_area = $the_property->get_formatted_floor_area(); if ($floor_area != '') { echo 'Floor Area: ' . $floor_area . '<br>'; } $site_area = $the_property->get_formatted_site_area(); if ($site_area != '') { echo 'Site Area: ' . $site_area; } if ($floor_area == '' && $site_area == '') { echo '-'; } echo '</td>'; echo '<td style="text-align:left;">'; $price = $the_property->get_formatted_price(); if ($price == '') { $price = '-'; } echo $price; echo '</td>'; echo '<td style="text-align:left;">'; $term_list = wp_get_post_terms($post->ID, 'availability', array("fields" => "names")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { echo $term_list[0] . '<br>'; } if (isset($the_property->_on_market) && $the_property->_on_market == 'yes') { echo 'On The Market'; } else { echo 'Not On The Market'; } if (isset($the_property->_featured) && $the_property->_featured == 'yes') { echo '<br>Featured'; } echo '</td>'; echo '</tr>'; } echo ' </tbody> </table> <br>'; } else { echo '<p>' . __('No units currently exist for this property', 'propertyhive') . '</p>'; } wp_reset_postdata(); echo '<a href="' . admin_url('post-new.php?post_type=property&post_parent=' . $post->ID) . '" class="button">' . __('Add New Unit', 'propertyhive') . '</a>'; do_action('propertyhive_property_commercial_units_fields'); echo '</div>'; echo '</div>'; }