public function restrict_entity_by_attributes() { global $typenow, $wp_query, $rtbiz_rt_attributes; $post_types = array(rtbiz_get_contact_post_type(), rtbiz_get_company_post_type()); if (in_array($typenow, $post_types)) { $rtbiz_attributes_model = new RT_Attributes_Model(); $rtbiz_attributes_relationship_model = new RT_Attributes_Relationship_Model(); $relations = $rtbiz_attributes_relationship_model->get_relations_by_post_type($typenow); foreach ($relations as $r) { $attr = $rtbiz_attributes_model->get_attribute($r->attr_id); if ('taxonomy' == $attr->attribute_store_as) { $tax = get_taxonomy($rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name)); if (!empty($tax)) { $args = array('show_option_all' => __("Show All {$tax->label}"), 'taxonomy' => $rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name), 'name' => $rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name), 'orderby' => 'name', 'hierarchical' => true, 'depth' => 3, 'show_count' => false, 'hide_empty' => true); if (isset($wp_query->query[$rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name)])) { $args['selected'] = $wp_query->query[$rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name)]; } wp_dropdown_categories($args); } } } } }
public function dashboard_widget_content($obj, $args) { global $rtbiz_rt_attributes; $rtbiz_attributes_model = new RT_Attributes_Model(); $attribute_id = $args['args']['attribute_id']; $attr = $rtbiz_attributes_model->get_attribute($attribute_id); $taxonomy = $rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name); $post_type = rtbiz_get_contact_post_type(); $terms = get_terms($taxonomy); $data_source = array(); $cols = array($attr->attribute_label, __('People')); $rows = array(); $total = 0; if (!$terms instanceof WP_Error) { foreach ($terms as $t) { $posts = new WP_Query(array('post_type' => $post_type, 'post_status' => 'any', 'nopaging' => true, $taxonomy => $t->slug)); $rows[] = array($t->name, count($posts->posts)); $total += count($posts->posts); } } $posts = new WP_Query(array('post_type' => $post_type, 'post_status' => 'any', 'nopaging' => true)); $rows[] = array(__('Others'), $this->get_post_count_excluding_tax($taxonomy, $post_type)); $data_source['cols'] = $cols; $data_source['rows'] = $rows; $this->charts[] = array('id' => $args['id'], 'chart_type' => 'pie', 'data_source' => $data_source, 'dom_element' => 'rtbiz_pie_' . $args['id'], 'options' => array('title' => $args['title'])); ?> <div id="<?php echo 'rtbiz_pie_' . $args['id']; ?> "></div> <?php }