&lt;?php
/**
 * Sway functions file
 *
 * @package sway
 * by KeyDesign
 */

 add_action( &#039;wp_enqueue_scripts&#039;, &#039;kd_enqueue_parent_theme_style&#039;, 5 );
 if ( ! function_exists( &#039;kd_enqueue_parent_theme_style&#039; ) ) {
     function kd_enqueue_parent_theme_style() {
         wp_enqueue_style( &#039;bootstrap&#039; );
         wp_enqueue_style( &#039;keydesign-style&#039;, get_template_directory_uri() . &#039;/style.css&#039;, array( &#039;bootstrap&#039; ) );
         wp_enqueue_style( &#039;child-style&#039;, get_stylesheet_directory_uri() . &#039;/style.css&#039;, array(&#039;keydesign-style&#039;) );
     }
 }

 add_action( &#039;after_setup_theme&#039;, &#039;kd_child_theme_setup&#039; );
 if ( ! function_exists( &#039;kd_child_theme_setup&#039; ) ) {
     function kd_child_theme_setup() {
         load_child_theme_textdomain( &#039;sway&#039;, get_stylesheet_directory() . &#039;/languages&#039; );
     }
 }

 // -------------------------------------
 // Edit below this line
 // -------------------------------------

// ========================================
// SEO &amp; GEO Enhancements – Care Talent Scouts
// Added: 2026-04-15
// ========================================

// 1. Geo Meta Tags
add_action( &#039;wp_head&#039;, &#039;cts_geo_meta_tags&#039;, 1 );
function cts_geo_meta_tags() {
    echo &#039;&lt;meta name=&quot;geo.region&quot; content=&quot;DE-BY&quot; /&gt;&#039; . &quot;\n&quot;;
    echo &#039;&lt;meta name=&quot;geo.placename&quot; content=&quot;Deutschland&quot; /&gt;&#039; . &quot;\n&quot;;
    echo &#039;&lt;meta name=&quot;geo.position&quot; content=&quot;51.1657;10.4515&quot; /&gt;&#039; . &quot;\n&quot;;
    echo &#039;&lt;meta name=&quot;ICBM&quot; content=&quot;51.1657, 10.4515&quot; /&gt;&#039; . &quot;\n&quot;;
    echo &#039;&lt;meta name=&quot;language&quot; content=&quot;de-DE&quot; /&gt;&#039; . &quot;\n&quot;;
}

// 2. LocalBusiness Schema (only on front page)
add_action( &#039;wp_head&#039;, &#039;cts_localbusiness_schema&#039;, 5 );
function cts_localbusiness_schema() {
    if ( ! is_front_page() ) return;
    $schema = array(
        &#039;@context&#039;      =&gt; &#039;https://schema.org&#039;,
        &#039;@type&#039;         =&gt; &#039;ProfessionalService&#039;,
        &#039;@id&#039;           =&gt; &#039;https://care-ts.de/#organization&#039;,
        &#039;name&#039;          =&gt; &#039;Care Talent Scouts&#039;,
        &#039;alternateName&#039; =&gt; &#039;Care-TS GmbH&#039;,
        &#039;url&#039;           =&gt; &#039;https://care-ts.de&#039;,
        &#039;logo&#039;          =&gt; &#039;https://care-ts.de/wp-content/uploads/2024/01/cropped-Website-180x180.png&#039;,
        &#039;description&#039;   =&gt; &#039;Faire und rechtssichere Vermittlung internationaler Pflegefachkraefte nach Deutschland.&#039;,
        &#039;telephone&#039;     =&gt; &#039;+491604522544&#039;,
        &#039;email&#039;         =&gt; &#039;info@care-ts.com&#039;,
        &#039;address&#039;       =&gt; array(
            &#039;@type&#039;          =&gt; &#039;PostalAddress&#039;,
            &#039;addressCountry&#039; =&gt; &#039;DE&#039;,
        ),
        &#039;areaServed&#039;    =&gt; array(
            array( &#039;@type&#039; =&gt; &#039;Country&#039;, &#039;name&#039; =&gt; &#039;Deutschland&#039; ),
        ),
        &#039;serviceType&#039;   =&gt; array(
            &#039;Personalvermittlung Pflege&#039;,
            &#039;Internationale Pflegekraefte&#039;,
            &#039;Physiotherapeuten Vermittlung&#039;,
        ),
        &#039;knowsLanguage&#039; =&gt; array( &#039;de&#039;, &#039;en&#039;, &#039;ro&#039;, &#039;pl&#039;, &#039;hr&#039;, &#039;sr&#039; ),
    );
    echo &#039;&lt;script type=&quot;application/ld+json&quot;&gt;&#039; . wp_json_encode( $schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT ) . &#039;&lt;/script&gt;&#039; . &quot;\n&quot;;
}

// ========================================
// Security &amp; Performance – Care Talent Scouts
// Added: 2026-04-15
// ========================================

// 1. Security Headers
add_action( &#039;send_headers&#039;, &#039;cts_security_headers&#039; );
function cts_security_headers() {
    if ( is_admin() ) return;
    header( &#039;X-Frame-Options: SAMEORIGIN&#039; );
    header( &#039;X-Content-Type-Options: nosniff&#039; );
    header( &#039;X-XSS-Protection: 1; mode=block&#039; );
    header( &#039;Referrer-Policy: strict-origin-when-cross-origin&#039; );
    header( &#039;Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=()&#039; );
    header( &#039;Strict-Transport-Security: max-age=31536000; includeSubDomains&#039; );
}

// 2. Remove X-Powered-By and WP version exposure
remove_action( &#039;wp_head&#039;, &#039;wp_generator&#039; );
add_filter( &#039;the_generator&#039;, &#039;__return_empty_string&#039; );

add_filter( &#039;wp_headers&#039;, function( $headers ) {
    unset( $headers[&#039;X-Powered-By&#039;] );
    return $headers;
});

// 3. Disable XML-RPC (security)
add_filter( &#039;xmlrpc_enabled&#039;, &#039;__return_false&#039; );
add_filter( &#039;xmlrpc_methods&#039;, function( $methods ) { return array(); } );

// 4. Remove WP version from scripts/styles
add_filter( &#039;style_loader_src&#039;,  &#039;cts_remove_version_query&#039;, 10, 2 );
add_filter( &#039;script_loader_src&#039;, &#039;cts_remove_version_query&#039;, 10, 2 );
function cts_remove_version_query( $src ) {
    if ( strpos( $src, &#039;ver=&#039; ) !== false ) {
        $src = remove_query_arg( &#039;ver&#039;, $src );
    }
    return $src;
}

// 5. Disable file editing in WP Admin (security)
if ( ! defined( &#039;DISALLOW_FILE_EDIT&#039; ) ) {
    define( &#039;DISALLOW_FILE_EDIT&#039;, false );
}

// 6. Limit login attempts protection – hide login errors
add_filter( &#039;login_errors&#039;, function() {
    return &#039;Ungültige Anmeldedaten.&#039;;
} );

// 7. Remove Really Simple Discovery link (RSD)
remove_action( &#039;wp_head&#039;, &#039;rsd_link&#039; );
remove_action( &#039;wp_head&#039;, &#039;wlwmanifest_link&#039; );
remove_action( &#039;wp_head&#039;, &#039;wp_shortlink_wp_head&#039; );

// 8. Disable REST API for non-logged-in users (selective)
add_filter( &#039;rest_authentication_errors&#039;, function( $result ) {
    if ( ! empty( $result ) ) return $result;
    if ( ! is_user_logged_in() ) {
        // Allow Yoast + block pure user enumeration
        $route = isset( $_SERVER[&#039;REQUEST_URI&#039;] ) ? $_SERVER[&#039;REQUEST_URI&#039;] : &#039;&#039;;
        if ( strpos( $route, &#039;/wp/v2/users&#039; ) !== false ) {
            return new WP_Error( &#039;rest_forbidden&#039;, &#039;Keine Berechtigung.&#039;, array( &#039;status&#039; =&gt; 401 ) );
        }
    }
    return $result;
} );


// ========================================
// Comment Spam Protection – Care Talent Scouts
// Added: 2026-04-15
// ========================================

// 1. Honeypot field – bots fill it, humans don&#039;t
add_action( &#039;comment_form_after_fields&#039;, &#039;cts_honeypot_field&#039; );
function cts_honeypot_field() {
    echo &#039;&lt;p style=&quot;display:none!important&quot; aria-hidden=&quot;true&quot;&gt;&#039;;
    echo &#039;&lt;label for=&quot;cts_hp_email&quot;&gt;Website (nicht ausfüllen)&lt;/label&gt;&#039;;
    echo &#039;&lt;input type=&quot;text&quot; name=&quot;cts_hp_email&quot; id=&quot;cts_hp_email&quot; value=&quot;&quot; autocomplete=&quot;off&quot; tabindex=&quot;-1&quot;&gt;&#039;;
    echo &#039;&lt;/p&gt;&#039;;
}

// 2. Block comment if honeypot filled
add_filter( &#039;preprocess_comment&#039;, &#039;cts_honeypot_check&#039; );
function cts_honeypot_check( $commentdata ) {
    if ( ! empty( $_POST[&#039;cts_hp_email&#039;] ) ) {
        wp_die( &#039;Spam erkannt.&#039;, &#039;Kommentar abgelehnt&#039;, array( &#039;response&#039; =&gt; 403 ) );
    }
    return $commentdata;
}

// 3. Block comments with too many URLs
add_filter( &#039;preprocess_comment&#039;, &#039;cts_block_link_spam&#039; );
function cts_block_link_spam( $commentdata ) {
    $content = $commentdata[&#039;comment_content&#039;];
    $url_count = preg_match_all( &#039;/https?:///i&#039;, $content );
    if ( $url_count &gt; 2 ) {
        wp_die( &#039;Zu viele Links.&#039;, &#039;Kommentar abgelehnt&#039;, array( &#039;response&#039; =&gt; 403 ) );
    }
    return $commentdata;
}

// 4. Block comments submitted too fast (&lt; 5 seconds after page load)
add_action( &#039;comment_form_before&#039;, &#039;cts_comment_timer_start&#039; );
function cts_comment_timer_start() {
    echo &#039;&lt;input type=&quot;hidden&quot; name=&quot;cts_form_time&quot; value=&quot;&#039; . time() . &#039;&quot;&gt;&#039;;
}

add_filter( &#039;preprocess_comment&#039;, &#039;cts_comment_timer_check&#039; );
function cts_comment_timer_check( $commentdata ) {
    if ( isset( $_POST[&#039;cts_form_time&#039;] ) ) {
        $elapsed = time() - (int) $_POST[&#039;cts_form_time&#039;];
        if ( $elapsed &lt; 5 ) {
            wp_die( &#039;Bitte warten Sie kurz.&#039;, &#039;Kommentar abgelehnt&#039;, array( &#039;response&#039; =&gt; 403 ) );
        }
    }
    return $commentdata;
}

// 5. Disable comments on pages (only allow on blog posts)
add_action( &#039;init&#039;, &#039;cts_disable_comments_on_pages&#039; );
function cts_disable_comments_on_pages() {
    foreach ( array( &#039;page&#039; ) as $post_type ) {
        if ( post_type_supports( $post_type, &#039;comments&#039; ) ) {
            remove_post_type_support( $post_type, &#039;comments&#039; );
            remove_post_type_support( $post_type, &#039;trackbacks&#039; );
        }
    }
}

// 6. Block comment REST API for non-logged users
add_filter( &#039;rest_pre_insert_comment&#039;, &#039;cts_rest_comment_check&#039;, 10, 2 );
function cts_rest_comment_check( $prepared, $request ) {
    if ( ! is_user_logged_in() ) {
        return new WP_Error( &#039;rest_forbidden&#039;, &#039;Nicht erlaubt.&#039;, array( &#039;status&#039; =&gt; 403 ) );
    }
    return $prepared;
}


// Virtual page: serve portal at /kandidaten-portal/
add_action(&#039;init&#039;,&#039;cts_portal_rewrite&#039;);
function cts_portal_rewrite(){
  add_rewrite_rule(&#039;^kandidaten-portal/?$&#039;,&#039;index.php?cts_portal=1&#039;,&#039;top&#039;);
}
add_filter(&#039;query_vars&#039;,&#039;cts_portal_query_var&#039;);
function cts_portal_query_var($vars){$vars[]=&#039;cts_portal&#039;;return $vars;}
add_action(&#039;template_redirect&#039;,&#039;cts_portal_serve&#039;);
function cts_portal_serve(){
  if(!get_query_var(&#039;cts_portal&#039;))return;
  $file = WP_CONTENT_DIR.&#039;/uploads/cts-portal/portal.html&#039;;
  if(file_exists($file)){
    header(&#039;Content-Type: text/html; charset=UTF-8&#039;);
    header(&#039;X-Robots-Tag: noindex, nofollow&#039;);
    readfile($file);
    exit;
  }
  wp_die(&#039;Portal nicht verfügbar.&#039;);
}<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//care-ts.de/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://care-ts.de/post-sitemap.xml</loc>
		<lastmod>2024-03-26T14:15:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://care-ts.de/page-sitemap.xml</loc>
		<lastmod>2026-04-15T00:46:05+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://care-ts.de/portfolio-sitemap.xml</loc>
		<lastmod>2020-08-04T16:46:42+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://care-ts.de/category-sitemap.xml</loc>
		<lastmod>2024-03-26T14:15:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://care-ts.de/post_tag-sitemap.xml</loc>
		<lastmod>2024-03-26T14:15:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://care-ts.de/portfolio-category-sitemap.xml</loc>
		<lastmod>2020-08-04T16:46:42+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://care-ts.de/author-sitemap.xml</loc>
		<lastmod>2026-04-14T22:43:40+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->