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);
                 }
             }
         }
     }
 }
예제 #2
0
 public function add_dashboard_widgets()
 {
     $menu_label = __('rtBiz');
     $contact_labels = rtbiz_get_contact_labels();
     //$contact_group_labels = rtbiz_get_contact_group_labels();
     add_meta_box('rtbiz-activity', __($menu_label . ' Activity', RTBIZ_TEXT_DOMAIN), array($this, 'dashboard_site_activity'), $this->screen_id, 'column1');
     add_meta_box('rtbiz-team-by-contacts', $contact_labels['name'] . ' ' . __('by Team', RTBIZ_TEXT_DOMAIN), array($this, 'team_by_contacts'), $this->screen_id, 'column2');
     /*add_meta_box( 'rtbiz-contact-type-by-contacts', $contact_labels['name'] . ' ' . __( 'by', RTBIZ_TEXT_DOMAIN ) . ' ' . $contact_group_labels['name'], array(
     			$this,
     			'contact_type_wise_contacts'
     		), $this->screen_id, 'column3' );*/
     //todo: product move into rtbiz
     //			if ( isset( $settings['product_plugin'] ) && 'none' != $settings['product_plugin'] ) {
     add_meta_box('rtbiz-product-wise-contacts', $contact_labels['name'] . ' ' . __('by Products', RTBIZ_TEXT_DOMAIN), array($this, 'product_wise_contacts'), $this->screen_id, 'column5');
     //			}
     //todo: create function to get all attribute in attribute class
     $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(rtbiz_get_contact_post_type());
     foreach ($relations as $r) {
         $attr = $rtbiz_attributes_model->get_attribute($r->attr_id);
         if ('taxonomy' == $attr->attribute_store_as) {
             add_meta_box('rtbiz-people-by-' . $attr->attribute_name, $contact_labels['name'] . __(' by ') . $attr->attribute_label, array($this, 'dashboard_widget_content'), $this->screen_id, 'column4', 'default', array('attribute_id' => $attr->id));
         }
     }
 }