• Resolved Zade

    (@nothin7)


    Would you mind fixing your /includes/class-settings.php file (lines 907–916) so it outputs valid HTML? Or at least allow the HTML to be filtered? In HTML, <p> tags cannot be nested, so a simple fix would be changing the outer <p> to a <div>:

    <p class="ctct-optin-wrapper" style="padding: 0 0 1em 0;">
    <p><?php echo esc_attr( $label ); ?></p>
    <?php foreach ( $lists as $key => $list ) { ?>
    <label for="ctct_optin_<?php echo esc_attr( $key ); ?>">
    <input type="checkbox" value="<?php echo esc_attr( $key ); ?>" class="checkbox" id="ctct_optin_<?php echo esc_attr( $key ); ?>" name="ctct_optin_list[]" /> <?php echo esc_attr( $list ); ?>
    </label>
    <br/>
    <?php } ?>
    <?php echo wp_kses_post( constant_contact()->get_display()->get_disclose_text() ); ?>
    </p>

    As it stands, modern browsers simply close the p.ctct-optin-wrapper, which means the entire block cannot easily be styled, and there’s a hanging empty paragraph at the end as well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Zade

    (@nothin7)

    P.S. In case this is useful to anyone else, here’s a temporary workaround. This plugin uses the list name as the checkbox label, but I don’t have multiple lists, so I wanted a simple checkbox label: “Subscribe to our newsletter”.

    // Move Constant Contact opt in before Post Comment (submit) button with clean HTML
    function pd_cc_optin() {
    if ( ! function_exists( 'constant_contact' ) ) return;
    $settings = constant_contact()->get_settings();
    // Remove from 'comment_form' (fires after submit button)
    remove_action( 'comment_form', [ $settings, 'optin_form_field_comment' ] );
    // Prepend clean opt-in HTML before the submit button (works for both logged-in and logged-out)
    add_filter( 'comment_form_submit_field', function( $submit_field ) use ( $settings ) {
    // Respect the plugin's own "show on comment form" setting and API connection check
    if ( ! $settings->check_if_optin_should_show( 'comment_form' ) ) {
    return $submit_field;
    }
    if ( ! constant_contact()->get_api()->is_connected() ) {
    return $submit_field;
    }
    // Get configured lists
    $list_ids = constant_contact_get_option( '_ctct_optin_list', [] );
    if ( empty( $list_ids ) ) {
    return $submit_field;
    }
    // Get the label (falls back to default)
    $label = constant_contact_get_option( '_ctct_optin_label', '' );
    if ( empty( $label ) ) {
    $label = __( 'Subscribe to our newsletter', 'constant-contact-forms' );
    }
    // Build clean HTML with first configured list
    $list_id = reset( $list_ids );
    $html = sprintf(
    '<p class="ctct-optin-wrapper">
    <label for="ctct_optin_%1$s">
    <input type="checkbox" value="%1$s" class="checkbox" id="ctct_optin_%1$s" name="ctct_optin_list[]">
    %2$s
    </label>
    </p>',
    esc_attr( $list_id ),
    esc_html( $label )
    );
    return $html . $submit_field;
    });
    }
    add_action( 'init', 'pd_cc_optin', 20 );
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Definitely will want to get that fixed up, and I’m filing tickets for this internally.

    I’m a little surprised this is the first time any sort of issue has come up, since I checked the history on this spot and it’s about 5 years old or so.

    Regardless, thanks for reporting this spot.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    We’ll be including these fixes in the 2.19.0 release which is in progress.

    Thanks again for chiming in with the detail.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.