示例#1
0
 /**
  * UI for group List View custom Columns for products
  *
  * @param type $display
  * @param type $column
  * @param type $term_id
  *
  * @return type
  */
 function manage_product_column_body($display, $column, $term_id)
 {
     $t = get_term($term_id, Rt_Products::$product_slug);
     $content = '';
     switch ($column) {
         case 'product_detail':
             $product_id = Rt_Lib_Taxonomy_Metadata\get_term_meta($term_id, self::$term_product_id_meta_key, true);
             $product_plugin = Rt_Lib_Taxonomy_Metadata\get_term_meta($term_id, self::$term_product_from_meta_key, true);
             if (!empty($product_id) || !empty($product_plugin)) {
                 $content = '<span>' . ucfirst($product_plugin) . '</span> ';
                 $content .= '<a class="post-edit-link" href="' . get_edit_post_link($product_id) . '">#' . $product_id . '</a>';
             } else {
                 echo '-';
             }
             break;
         case 'product_count':
             $posttypes = $this->post_types;
             if (isset($_REQUEST['post_type']) && in_array($_REQUEST['post_type'], $posttypes)) {
                 $posttypes = array($_REQUEST['post_type']);
             }
             foreach ($posttypes as $posttype) {
                 $posts = new WP_Query(array('post_type' => $posttype, 'post_status' => 'any', 'nopaging' => true, Rt_Products::$product_slug => $t->slug));
                 $posttype_lable = explode('_', $posttype);
                 $posttype_lable = $posttype_lable[count($posttype_lable) - 1];
                 $content .= ucfirst($posttype_lable . 's') . " -  <a href='edit.php?post_type={$posttype}&" . Rt_Products::$product_slug . '=' . $t->slug . "'>" . count($posts->posts) . '</a><br/>';
             }
             break;
     }
     return apply_filters('rt_product_column_content', $content, $column, $term_id);
 }
示例#2
0
 /**
  * get meta for team
  *
  * @param string $key
  * @param int $term_id
  *
  * @return bool
  */
 function get_team_meta($key = '', $term_id = 0)
 {
     if (isset($_GET['tag_ID'])) {
         $term_id = $_GET['tag_ID'];
     }
     if (empty($term_id)) {
         return false;
     }
     $term_meta = Rt_Lib_Taxonomy_Metadata\get_term_meta($term_id, '_' . self::$slug . '_meta', true);
     if (!empty($term_meta)) {
         if (!empty($key)) {
             return isset($term_meta[$key]) ? $term_meta[$key] : false;
         } else {
             return $term_meta;
         }
     }
     return false;
 }