| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web20/web/wp-content/themes/drogentest-online/inc/ |
Upload File : |
<?php
/**
* Sitemap-Provider für das Suchtberatungs-Verzeichnis.
* Speist Bundesland-, Stadt- und Einzelstellen-URLs in die wp-sitemap.xml ein.
*
* @package drogentest-online
*/
if ( ! defined( 'ABSPATH' ) || ! class_exists( 'WP_Sitemaps_Provider' ) ) {
return;
}
class DGT_SB_Sitemap_Provider extends WP_Sitemaps_Provider {
public function __construct() {
$this->name = 'suchtberatung';
$this->object_type = 'suchtberatung';
}
/** Alle URLs (gecacht innerhalb des Requests). */
private function all_urls() {
static $urls = null;
if ( null !== $urls ) {
return $urls;
}
global $wpdb;
$urls = array();
// Bundesland-Übersichtsseiten.
foreach ( dgt_sb_bundeslaender() as $slug => $name ) {
$urls[] = array( 'loc' => dgt_sb_bundesland_url( $slug ) );
}
// Einzelne Beratungsstellen (Bundesland aus PLZ abgeleitet).
$c = dgt_sb_table();
$a = dgt_sb_table( 'address' );
$rows = $wpdb->get_results( "SELECT c.slug, a.zipcode FROM {$c} c JOIN {$a} a ON a.entry_id = c.id WHERE c.status='approved' AND c.visibility='public' AND c.slug <> '' GROUP BY c.id", ARRAY_A ); // phpcs:ignore
foreach ( (array) $rows as $r ) {
$bl = dgt_sb_bundesland_from_plz( $r['zipcode'] );
$urls[] = array( 'loc' => dgt_sb_single_url( $r['slug'], $bl ) );
}
return $urls;
}
public function get_url_list( $page_num, $object_subtype = '' ) {
$per = wp_sitemaps_get_max_urls( $this->object_type );
$offset = ( max( 1, (int) $page_num ) - 1 ) * $per;
return array_slice( $this->all_urls(), $offset, $per );
}
public function get_max_num_pages( $object_subtype = '' ) {
$per = wp_sitemaps_get_max_urls( $this->object_type );
return (int) max( 1, ceil( count( $this->all_urls() ) / $per ) );
}
}