• Resolved generosus

    (@generosus)


    Hi there,

    I’m getting the PHP warnings noted below. With the given warnings, how can I identify the code snippet that is causing them?

    Thank you!

    [15-Oct-2024 17:40:08 UTC] PHP Warning: DOMDocument::loadHTML(): error parsing attribute name in Entity, line: 1 in /home/customer/www/mysite.com/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()'d code on line 34
    [15-Oct-2024 17:40:08 UTC] PHP Warning: DOMDocument::loadHTML(): Tag xml invalid in Entity, line: 1 in /home/customer/www/mysite.com/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()'d code on line 34
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter generosus

    (@generosus)

    Update:

    Found the code snippet (see below). Based on the above warnings, any idea how to fix it?

    Thank you!

    add_filter( 'gform_submit_button', 'gf_change_submit_button_text', 10, 2 );
    function gf_change_submit_button_text( $button, $form ) {
    $dom = new DOMDocument();
    $dom->loadHTML( '<xml encoding="utf-8" ?>' . $button );
    $input = $dom->getElementsByTagName( 'input' )->item(0);
    $onclick = $input->getAttribute( 'onclick' );
    $onclick .= " this.value='Sending...'"; // Change button text when clicked.
    $input->setAttribute( 'onclick', $onclick );
    return $dom->saveHtml( $input );
    }
    Plugin Author Shea Bunge

    (@bungeshea)

    From the errors, it sounds like the issue isn’t with your snippet, but with the XML you’re getting it to parse.

    Given that you’re just trying to augment the onclick attribute of a button, perhaps you could achieve the same thing with some basic JavaScript elsewhere on the page?

    Thread Starter generosus

    (@generosus)

    Hi @bungeshea,

    Thanks for the review and suggestion. Although I’m gettting the above PHP warning, everything is working on our site and not getting any console errors. So … not sure what the implications of the warning are at this time.

    Perhaps I just need to review and/or change the code line below and see if that helps.

    $dom->loadHTML( '<xml encoding="utf-8" ?>' . $button );

    Again, thank you.

    Thread Starter generosus

    (@generosus)

    Issue Solved:

    Warning caused by a missing “?” in front of xml.

    Above line should be:

    $dom->loadHTML( '<?xml encoding="utf-8" ?>' . $button );

    Cheers!

    Reference: PHP DOMDocument loadHTML not encoding UTF-8 correctly

    • This reply was modified 4 months, 3 weeks ago by generosus.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.