• Resolved stevenbradley

    (@stevenbradley)


    Hello, I have some post pages that have errors being reported by the plugin for example invalid_attribute : [null]

    The errors do not show on any validation tool and the code is being used without issue on other valid AMP sites.

    When I choose to accept these errors I guess they are being stripped out of the code which then breaks the functionality of the form on the page.

    Is there a way to still force AMP on pages with reported errors that I choose as “rejected”?

    Seems like there should be a setting other than accept or reject that will allow the offending code to remain and allow AMP to still be enabled.

Viewing 14 replies - 1 through 14 (of 14 total)
  • @stevenbradley If you want to share your URLs with the form we can take a look, or alternatively share the validation error and details.

    With regards the validation options only URLs with no errors will serve as valid AMP documents. Along with the accept and reject options the plugin highlights the offending code, allow you to debug. But please share your URL and we can hopefully assist.

    Thread Starter stevenbradley

    (@stevenbradley)

    Well the problem is that the code that is being reported as having AMP errors doesn’t really have any according to google’s own AMP validation tool.

    So when I choose accept it removes what it thinks is bad code and then the form on the page doesn’t work right. The form uses AMP states (bind) to change certain values.

    Below is output for one of the errors, it looks like another plugin may be marking this as an error and then the AMP plugin is following that?

    <input … result1.liens=”” …>
    code
    invalid_attribute
    element_attributes
    type: text
    role: textbox
    class: calc-input
    id: liens
    name: liens
    null
    result1.liens
    :
    node_name
    parent_name
    input
    type
    html_attribute_error
    sources

    [
    {
    “type”: “plugin”,
    “name”: “wordpress-seo-premium”,
    “function”: “WPSEO_Frontend::flush_cache”,
    “hook”: “wp_footer”
    }
    ]

    Thread Starter stevenbradley

    (@stevenbradley)

    I would say after further research/testing this is a Yoast SEO plugin issue conflicting with the AMP plugin and not a core issue with the AMP plugin itself.

    All but 1 error comes from Yoast SEO Premium, so that plugin is reporting validation errors where there are none.

    I wish there was a way to just choose to ignore those errors and have AMP still be enabled. Yoast doesn’t know what they are talking about (as usual).

    Below is a link to an image of the errors

    https://reverse.mortgage/imgs/screenshot-2019-07-18-09-46-14.png

    Plugin Author Weston Ruter

    (@westonruter)

    It seems there may be an HTML parsing problem with the HTML coming from the Yoast Premium plugin. The null attribute and the : attribute seems to indicate a problem with XML namespaces. Can you look in the Yoast Premium plugin source code to try to find where this is coming from and what the original markup is? Apparently it is in WPSEO_Frontend::flush_cache()

    Thread Starter stevenbradley

    (@stevenbradley)

    I’m nowhere near being an expert with plugins, but I don’t see where any conflicts could be coming from in the code for that function. It does work with the output so maybe that is where things are going wrong:

    /* Used in the force rewrite functionality this retrieves the output, replaces the title with the proper SEO* title and then flushes the output.*/

    public function flush_cache() {

    global $wp_query;

    if ( $this->ob_started !== true ) {
    return false;
    }

    $content = ob_get_clean();

    $old_wp_query = $wp_query;

    wp_reset_query();

    // Only replace the debug marker when it is hooked.
    if ( $this->show_debug_marker() ) {
    $title = $this->title( ” );
    $debug_mark = $this->get_debug_mark();

    /*
    * Find all titles, strip them out and add the new one in within the debug marker,
    * so it’s easily identified whether a site uses force rewrite.
    */
    $content = preg_replace( ‘/<title.*?\/title>/i’, ”, $content );
    $content = str_replace( $debug_mark, $debug_mark . “\n” . ‘<title>’ . esc_html( $title ) . ‘</title>’, $content );
    }

    $GLOBALS[‘wp_query’] = $old_wp_query;

    echo $content;

    return true;
    }

    Plugin Author Weston Ruter

    (@westonruter)

    It looks like that code gets queued up to run here: https://github.com/Yoast/wordpress-seo/blob/df07d44941d947db4ab3946d5b633f1cf8a7bbdd/frontend/class-frontend.php#L138-L142

    Notice this condition:

    if ( WPSEO_Options::get( 'forcerewritetitle', false ) && ! current_theme_supports( 'title-tag' ) ) {

    Does your theme not support title-tag? Changing that would fix this.

    Also, disabling the forcerewritetitle should also fix this.

    Thread Starter stevenbradley

    (@stevenbradley)

    Looks like the issue has been resolved. I added support for title tag via the functions.php file of the theme and now no more false errors are being reported.

    I guess not having title tag enabled caused SEO premium to not output everything correctly to the html head.

    Thanks for your help, issue resolved ??

    Thread Starter stevenbradley

    (@stevenbradley)

    Ok, maybe it’s not fixed, it’s showing errors but not from SEO premium now.

    https://reverse.mortgage/testing-post-testing

    This page uses a form built by me and it uses AMP bind to go through each step and add values to the form on the final step. It’s saying there are issues with the form fields using bind to set their values.

    This is legitimate AMP code and doesn’t have errors so not sure why the AMP plugin is reporting them as such.

    Thread Starter stevenbradley

    (@stevenbradley)

    Here’s one of many lines of code that it seems to have issues with:

    <input type=”hidden” name=”liens” [value]=”result1.liens” />

    I guess it’s not respecting the [value] as an attribute so it’s marking it as an error?

    Plugin Author Weston Ruter

    (@westonruter)

    The AMP plugin is reporting a validation error with this code? Can you share a screenshot of the error?

    Thread Starter stevenbradley

    (@stevenbradley)

    Here’s a text input field that is being marked as an error

    <input type=”text” role=”textbox” class=”calc-input” id=”liens” name=”liens” [value]=”(result1 != null) ? result1.liens : ‘verifying…'” />

    This is a screenshot of the corresponding error in the AMP plugin

    https://reverse.mortgage/imgs/screenshot-AMP.png

    Plugin Author Weston Ruter

    (@westonruter)

    Thank you. I was able to reproduce the problem when I tested with that. (And I made sure the curly quotes were made non-curly.)

    <input type="text" role="textbox" class="calc-input" id="liens" name="liens" [value]="(result1 != null) ? result1.liens : 'verifying...'" />

    It appears there is a bug in the AMP plugin here with how it is handling the bound attributes in elements that have self-closing slashes. I find that if I just remove the final / then the issue goes away:

    <input type="text" role="textbox" class="calc-input" id="liens" name="liens" [value]="(result1 != null) ? result1.liens : 'verifying...'">

    I’ll look into this bug, but this should fix the issue in the short term. There is no need for the self-closing slash because this is HTML not XML (or XHTML).

    Thread Starter stevenbradley

    (@stevenbradley)

    Great, that seems to have fixed the form and it runs as expected now. That was the last place I would have looked for the bug/error.

    No more errors reported anywhere. Thank you for all your help.

    Plugin Author Weston Ruter

    (@westonruter)

    Here’s a pull request to fix with an amp.zip build for testing: https://github.com/ampproject/amp-wp/pull/2854

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Keep AMP enabled even with “rejected” errors’ is closed to new replies.