/** * Get translated home URL * * @access public * @param string $locale Language locale * @return string Translated home URL */ public function getTranslatedHomeURL($locale) { // get original home URL if (function_exists('get_home_url')) { $url = KocujSitemapPluginInternalCacheInterface::getClass()->get_home_url(); } else { $url = KocujSitemapPluginInternalCacheInterface::getClass()->get_bloginfo('home'); } $origURL = $url; // get translated home URL $url = $this->processCallback('$data[\'instance\']->getTranslatedHomeURL', array($origURL, $locale)); if (empty($url)) { $url = $origURL; } // exit return $url; }
/** * Add pages from parent to sitemap * * @access private * @param int $parentId Page parent id * @param bool &$first It is first position in list (true) or not (false) * @param string $locale Language locale - default: empty * @return string Sitemap string */ private function addSitemapPagesFromParent($parentId, &$first, $locale = '') { // initialize $output = ''; // show start of list if (empty($parentId)) { $output .= '<ul>'; } // get pages KocujSitemapPluginMultiLang::getInstance()->beforeGetPages($locale); $pages = KocujSitemapPluginInternalCacheInterface::getClass()->get_pages(array('parent' => $parentId, 'sort_column' => 'menu_order', 'sord_order' => 'ASC', 'post_type' => 'page', 'post_status' => 'publish', 'hierarchical' => 0, 'number' => '')); KocujSitemapPluginMultiLang::getInstance()->afterGetPages($locale); if (!empty($pages)) { if (!empty($parentId)) { $output .= '<ul>'; } foreach ($pages as $page) { KocujSitemapPluginMultiLang::getInstance()->beforeGetPageItem($page->ID, $locale); $output .= '<li>'; $output .= '<a href="' . esc_url(KocujSitemapPluginMultiLang::getInstance()->getTranslatedPageURL(get_permalink($page->ID), $page->ID, $locale)) . '">' . apply_filters('kocujsitemap_linktitle', KocujSitemapPluginMultiLang::getInstance()->getTranslatedPageTitle($page->post_title, $page->ID, $locale), $page->ID, 'page', $locale) . '</a>'; $output .= $this->addSitemapPagesFromParent($page->ID, $first, $locale); $output .= '</li>'; KocujSitemapPluginMultiLang::getInstance()->afterGetPageItem($page->ID, $locale); } if (!empty($parentId)) { $output .= '</ul>'; } } // show end of list if (empty($parentId)) { $output .= '</ul>'; } // exit return $output; }