• Resolved nathanmfarrugia

    (@nathanmfarrugia)


    I’m seeing the notice:

    At least one of your theme header templates does not support Schema markup of the webpage head section. The <head> element in your theme’s header templates should include a function / action / filter call for its attributes. WPSSO can update your theme header templates automatically to change the default <head> element to:
    <head <?php do_action( ‘add_head_attributes’ ); ?>>
    Click here to update theme header templates automatically or update the theme templates yourself manually.

    I’m using the Salient WordPress theme, which is a popular theme sold on Themeforest.

    I’ve tried adding in the suggested tag to my child theme’s header.php, however it blocks my website from loading. Can I ask why this is suggested? After a thorough Google search, I can’t see mention of this practice anywhere. So I’m a bit confused.

    I’d also be happy to manually add the Schema tags into my header.php, if I knew what they were.

    Thanks in advance!

    https://www.ads-software.com/plugins/wpsso/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author JS Morisset

    (@jsmoriss)

    Blocks your website from loading? Are you getting a blank page, timeout, error? Is there an error in your web server log files? Did you enable WP_DEBUG to check for WordPress / PHP errors? Here’s more info on enabling WP_DEBUG and where to find the debug.log file: https://wpsso.com/codex/plugins/wpsso/installation/debugging-and-problem-solving/

    js.

    Thread Starter nathanmfarrugia

    (@nathanmfarrugia)

    Apologies for not testing this, thanks for the suggestion.

    I found no issues currently – at least not what I was describing. Perhaps a recent theme update has resolved this. However I have noticed that it blocks at least one of my fonts from loading. My fonts are called through localstorage.

    With the head tag suggested above, the font does not appear. No errors are generated, debugging or in Chrome’s Developer Tools. If I revert to the normal <head> tag, the font displays correctly.

    If you’re curious, here is the localstorage script I use, which might be conflicting with the head tag somehow:

    <script>function loadFont(a,b,c,d){function e(){if(!window.FontFace)return!1;var a=new FontFace("t",'url("data:application/font-woff2,") format("woff2")',{}),b=a.load();try{b.then(null,function(){})}catch(c){}return"loading"===a.status}var f=navigator.userAgent,g=!window.addEventListener||f.match(/(Android (2|3|4.0|4.1|4.2|4.3))|(Opera (Mini|Mobi))/)&&!f.match(/Chrome/);if(!g){var h={};try{h=localStorage||{}}catch(i){}var j="x-font-"+a,k=j+"url",l=j+"css",m=h[k],n=h[l],o=document.createElement("style");if(o.rel="stylesheet",document.head.appendChild(o),!n||m!==b&&m!==c){var p=c&&e()?c:b,q=new XMLHttpRequest;q.open("GET",p),q.onload=function(){q.status>=200&&q.status<400&&(h[k]=p,h[l]=q.responseText,d||(o.textContent=q.responseText))},q.send()}else o.textContent=n}}</script>
    <script>
    	loadFont('fonts', 'https://cdn.nathanmfarrugia.com/wp-content/themes/nathanv2/css/fonts/woff.css', 'https://cdn.nathanmfarrugia.com/wp-content/themes/nathanv2/css/fonts/woff2.css');
    </script>

    Regards,
    Nathan

    Thread Starter nathanmfarrugia

    (@nathanmfarrugia)

    Sorry, that code didn’t wrap on this page properly. Here it is as normal text:

    <script>function loadFont(a,b,c,d){function e(){if(!window.FontFace)return!1;var a=new FontFace(“t”,’url(“data:application/font-woff2,”) format(“woff2”)’,{}),b=a.load();try{b.then(null,function(){})}catch(c){}return”loading”===a.status}var f=navigator.userAgent,g=!window.addEventListener||f.match(/(Android (2|3|4.0|4.1|4.2|4.3))|(Opera (Mini|Mobi))/)&&!f.match(/Chrome/);if(!g){var h={};try{h=localStorage||{}}catch(i){}var j=”x-font-“+a,k=j+”url”,l=j+”css”,m=h[k],n=h[l],o=document.createElement(“style”);if(o.rel=”stylesheet”,document.head.appendChild(o),!n||m!==b&&m!==c){var p=c&&e()?c:b,q=new XMLHttpRequest;q.open(“GET”,p),q.onload=function(){q.status>=200&&q.status<400&&(h[k]=p,h[l]=q.responseText,d||(o.textContent=q.responseText))},q.send()}else o.textContent=n}}</script>
    <script>
    loadFont(‘fonts’, ‘https://cdn.nathanmfarrugia.com/wp-content/themes/nathanv2/css/fonts/woff.css&#8217;, ‘https://cdn.nathanmfarrugia.com/wp-content/themes/nathanv2/css/fonts/woff2.css&#8217;);
    </script>

    Plugin Author JS Morisset

    (@jsmoriss)

    I don’t see why there would be any issue. The ‘add_head_attributes’ action simply calls a filter to add head attributes. How is the javascript added to your webpage? Is it hard-coded in your header template, or hooked into an action or filter? If so, which one? And if it’s an action or filter, can you include your code here? If you have a URL to an example webpage, that would probably help. ??

    js.

    Thread Starter nathanmfarrugia

    (@nathanmfarrugia)

    Sure!

    The code above is stored as a separate file: localStorage-fonts.script.

    It’s called from my header.php:

    <!--Fast loading of WOFF2 fonts in localstorage -->
    <?php // _e(file_get_contents('/home/nathanmf/public_html/wp-content/themes/nathanv2/localStorage-fonts.script')) ?>

    Unfortunately this script is hooked into a function where it fires after Autoptimize minifies JS. I tried to unhook it for you, but it won’t work at all (and then my fonts simply won’t load). So here is the function that loads the script after Autoptimize has processed the JS. This function also preloads a couple of images for me.

    function custom_autoptimize_html_after_minify($content) {
    	$search = '<head>';
    	$replace = '';
    	$is_home = (function_exists('is_front_page') && is_front_page()) || is_home();
    	if ($is_home) $replace .= '<img src="https://cdn.nathanmfarrugia.com/wp-content/uploads/2014/03/nathanheaderv3.jpg" style="display: none !important;" /></script>';
    	if ($is_home) $replace .= '<img src="https://cdn.nathanmfarrugia.com/wp-content/uploads/2014/04/blur.jpg" style="display: none !important;" /></script>';
    	$replace .= file_get_contents('/home/nathanmf/public_html/wp-content/themes/nathanv2/localStorage-fonts.script');
    	$replace = $search . $replace;
    	$content = str_replace($search, $replace, $content);
    	$search = '</body>';
    	$replace = '<script>jQuery(".home.page .vc_span2.wpb_column.column_container.col.padding-2-percent").eq(3).addClass("clearOnUnder1000");</script>';
    	$content = str_replace($search, $replace, $content);
    	return $content;
    }
    
    add_filter('autoptimize_html_after_minify', 'custom_autoptimize_html_after_minify', 10, 1);

    If I disable this function, the add head attributes tag works fine. But with this function enabled, the add head attributes tag seems to override it. So my website still loads, but the images aren’t preloaded and my fonts won’t load.

    And then we have the debug error as mentioned:
    Warning: Cannot modify header information - headers already sent by (output started at /home/nathanmf/public_html/wp-content/plugins/post-types-order/include/cpto-class.php:3) in /home/nathanmf/public_html/wp-content/themes/nathanv2/functions.php on line 348

    Line 348 refers to the function I quoted above.

    The website in question:
    https://nathanmfarrugia.com

    Thanks for looking into it, much appreciated! Would be at least interesting to know what exactly is causing the conflict, even if it can’t be fixed.

    Nathan

    hiya guys;
    i’m autoptimize’s developer, nice to see you using that filter Nathan ??

    the problem more then likely is that you’re searching and replacing <head>, but do_action( 'add_head_attributes' ); allows WPSSO to change that into <head attribute="here">, so you’ll probably have to change your search-string.

    have fun,
    frank

    Thread Starter nathanmfarrugia

    (@nathanmfarrugia)

    Thanks Frank!

    That should be all I need to fix my script and resolve the conflict. Makes sense now.

    A big fan of both Autoptimize and WPSSO, by the way!

    Nathan

    HI I am me too ..
    But I add: define ('WP_DEBUG', true); by wpsso
    Message as follows:
    WPSSO Notice HTML debug mode is active (transient cache use is disabled). Informational debug messages are being added as hidden HTML comments.

    2.I have add for my header.php

    <!--[if !(IE 7) & !(IE 8)]><!-->
    <html <?php language_attributes(); ?>>
    <!--<![endif]-->
    <head <?php echo apply_filters( 'head_attributes', '' ); ?>>

    but
    Checking https://pppdog.me/10457/勞力士-rolex-台南-高雄-買賣二手名錶.html webpage header for duplicate meta tags (see Theme Integration settings).
    I do not know what went wrong
    Can see here…
    Thank you
    pppdog

    Plugin Author JS Morisset

    (@jsmoriss)

    Are you asking about this notice message?

    “Checking https://pppdog.me/10457/勞力士-rolex-台南-高雄-買賣二手名錶.html webpage header for duplicate meta tags (see Theme Integration settings).”

    It’s just informational – it’s not an error. ??

    js.

    Thank you
    pppdog

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘"Header templates does not support Schema markup"’ is closed to new replies.