/** * @param DlePost $objDlePost The DB ORM object to process */ protected function process_object($objDlePost) { $objWpTermsArray = $objDlePost->LoadWpTermsArray(); if ($objWpTermsArray) { $this->intDleTermRelationshipsCount += count($objWpTermsArray); } else { return; } $objWpPosts = $objDlePost->LoadWpPosts(); if (!$objWpPosts) { return; } foreach ($objWpTermsArray as $objWpTerms) { $objWpTermTaxonomy = WpTermTaxonomy::LoadByTermIdTaxonomy($objWpTerms->TermId, "category"); if (!$objWpTermTaxonomy) { continue; } $objWpTermRelationships = WpTermRelationships::LoadByObjectIdTermTaxonomyId($objWpPosts->Id, $objWpTermTaxonomy->TermTaxonomyId); // check if already copied if (!$objWpTermRelationships) { $objWpTermRelationships = new WpTermRelationships(); $objWpTermRelationships->Initialize(); // set defaults $objWpTermRelationships->ObjectId = $objWpPosts->Id; $objWpTermRelationships->TermTaxonomyId = $objWpTermTaxonomy->TermTaxonomyId; $objWpTermRelationships->TermOrder = 0; $objWpTermRelationships->Save(); $this->intTermRelationshipsCount++; } } }