formButtons = false; } // Method called on the settings of the plugin on the admin area public function form() { global $L; $html = '
'; $html .= ''; $html .= ''.Theme::sitemapUrl().''; $html .= '
'; return $html; } private function createXML() { global $site; global $pages; $xml = ''; $xml .= ''; $xml .= ''; $xml .= ''.$site->url().''; $xml .= ''; // Get DB $pageNumber = 1; $amountOfItems = -1; $onlyPublished = true; $list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished); foreach($list as $pageKey) { try { // Create the page object from the page key $page = new Page($pageKey); $xml .= ''; $xml .= ''.$page->permalink().''; $xml .= ''.$page->dateRaw(SITEMAP_DATE_FORMAT).''; $xml .= 'daily'; $xml .= ''; } catch (Exception $e) { // Continue } } $xml .= ''; // New DOM document $doc = new DOMDocument(); $doc->formatOutput = true; $doc->loadXML($xml); $doc->save($this->workspace().'sitemap.xml'); } public function install($position=0) { parent::install($position); $this->createXML(); } public function post() { // Call the method parent::post(); // After POST request $this->createXML(); } public function afterPageCreate() { $this->createXML(); } public function afterPageModify() { $this->createXML(); } public function afterPageDelete() { $this->createXML(); } public function beforeAll() { $webhook = 'sitemap.xml'; if( $this->webhook($webhook) ) { // Send XML header header('Content-type: text/xml'); $doc = new DOMDocument(); // Workaround for a bug https://bugs.php.net/bug.php?id=62577 libxml_disable_entity_loader(false); // Load XML $doc->load($this->workspace().'sitemap.xml'); libxml_disable_entity_loader(true); // Print the XML echo $doc->saveXML(); // Terminate the run successfully exit(0); } } }