Zustimmung einfügen (ohne Plugin)

Hinweis:
Diese Methode ist nur für erfahrene Webmaster geeignet.


Wer das Plugin “WP H-HappyForms Tools” nicht verwenden will, kann den nachfolgenden PHP-Code auch in die Datei „functions.php“ (Childtheme empfohlen) oder in ein geeignetes Snippet Plugin (z. B. Code Snippets) einfügen:

// Credits/Special thanks: Ignazio Setti https://thethemefoundry.com/ 
add_shortcode( 'happyforms_link', function( $atts, $content = '' ) {
    $atts = shortcode_atts( array( 'href' => '#' ), $atts );
    $atts['href'] = str_replace( '"', '', $atts['href'] );
    $link = "<a href=\"{$atts['href']}\" target=\"_blank\">{$content}</a>";

    return $link;
}, 10, 2 );

add_action( 'happyforms_part_before', function( $part ) {
    if ( 'checkbox' !== $part['type'] ) {
        return;
    }

    ob_start();
} );

add_action( 'happyforms_part_after', function( $part ) {
    if ( 'checkbox' !== $part['type'] ) {
        return;
    }
    
    echo do_shortcode( ob_get_clean() );
} );

Die weiteren Eingaben im Formular sind hier beschrieben.