Commit 07bfccc2 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add more intelligent content name determination

parent 500b9838
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -79,10 +79,11 @@ function fscoli_regex_match_group($regex, $str, $group) {
 * Helper function: Builds a consent prompt (HTML and JS) using the given parameters, that already have to be extracted
 * from somewhere.
 */
function fscoli_get_consent_prompt($embed_html, $width_attr, $height_attr, $provider_url, $provider_domain, $privacy_policy_url) {
function fscoli_get_consent_prompt($embed_html, $width_attr, $height_attr, $content_name, $provider_url, $provider_domain, $privacy_policy_url) {
    $embed_html = esc_html($embed_html);
    $width_attr = esc_attr($width_attr);
    $height_attr = esc_attr($height_attr);
    $content_name = esc_html($content_name);
    $provider_url = esc_url($provider_url);
    $provider_domain = esc_html($provider_domain);
    
@@ -108,7 +109,7 @@ function fscoli_get_consent_prompt($embed_html, $width_attr, $height_attr, $prov
        </div>

        <section class="privacy-consent-prompt">
            <button onclick="givePrivacyConsent(this.parentElement.parentElement)">Inhalt anzeigen</button>
            <button onclick="givePrivacyConsent(this.parentElement.parentElement)">$content_name anzeigen</button>
            <p>Dabei werden Daten an <a href="$provider_url">$provider_domain</a> (und ggfs. weitere Anbieter) übertragen. Es gilt die $privacy_policy_link.</p>
        </section>
    </div>
@@ -139,11 +140,13 @@ function fscoli_show_embed_privacy_consent_prompt($embed_html) {
    $provider_domain    = fscoli_regex_match_group('#src ?= ?["\'](https?://(.*?))/.*?["\']#', $embed_html, 2);

    $privacy_policy_url = null;
    $content_name = "Inhalt";
    if($provider_domain === "umap.openstreetmap.de") {
        $privacy_policy_url = "https://www.fossgis.de/datenschutzerkl%C3%A4rung";
        $content_name = "Karte";
    }

    return fscoli_get_consent_prompt($embed_html, $width, $height, $provider_url, $provider_domain, $privacy_policy_url);   
    return fscoli_get_consent_prompt($embed_html, $width, $height, $content_name, $provider_url, $provider_domain, $privacy_policy_url);   
}

// To disable the privacy consent prompts (and always show the content directly), just remove this line