예제 #1
0
 /**
  * get cats and taxanomies data from the category id's
  */
 public static function getCatAndTaxData($catIDs)
 {
     if (is_string($catIDs)) {
         $catIDs = trim($catIDs);
         if (empty($catIDs)) {
             return array("tax" => "", "cats" => "");
         }
         $catIDs = explode(",", $catIDs);
     }
     $strCats = "";
     $arrTax = array();
     foreach ($catIDs as $cat) {
         if (strpos($cat, "option_disabled") === 0) {
             continue;
         }
         $pos = strrpos($cat, "_");
         $taxName = substr($cat, 0, $pos);
         $catID = substr($cat, $pos + 1, strlen($cat) - $pos - 1);
         //translate catID to current language if wpml exists
         $catID = Essential_Grid_Wpml::change_cat_id_by_lang($catID, $taxName);
         $arrTax[$taxName] = $taxName;
         if (!empty($strCats)) {
             $strCats .= ",";
         }
         $strCats .= $catID;
     }
     $strTax = "";
     foreach ($arrTax as $taxName) {
         if (!empty($strTax)) {
             $strTax .= ",";
         }
         $strTax .= $taxName;
     }
     $output = array("tax" => $strTax, "cats" => $strCats);
     return $output;
 }