Easy-digital-downloads: Switch schema markup method from microdata to JSON-LD

Created on 22 Nov 2016  ·  16Comments  ·  Source: easydigitaldownloads/easy-digital-downloads

After doing some research, I'm finding some compelling reasons to implement an alternate structured data markup method. Specifically switching from microdata (current method) to JSON-LD. Here's my case:

First off, we have some minor issues with our structured data already. I'll open another issue shortly but here for example we're outputting the currency and price together which isn't recommended.

Secondly, JSON-LD is potentially easier to manage and less problematic from a theme perspective. It separates the data from the markup thereby making our templates much simpler.

WooCommerce just did it two months ago. Long discussion about it over there with lots of great information. Really sounds like a good move. Also it being recommended by Google gives it serious weight.

scope-ui type-feature

Most helpful comment

@brashrebel Did you see my JSON-LD plugin? https://gitlab.com/caldera-labs/caldera-jsonld It's lacking a UI and isn't PHP5-friendly, but please to borrow code.

All 16 comments

Doing this would get rid of the infamous "HTML characters in titles" title we get all the time due to improper use of the_title() in attributes.

Would love to see this!

Want me to try and tackle this?

Go for it!

On Tue, Nov 22, 2016 at 2:10 PM, Kyle [email protected] wrote:

Want me to try and tackle this?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/easydigitaldownloads/easy-digital-downloads/issues/5240#issuecomment-262351977,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_HfSRpQkpqz8nv8rUHzCw5h2CYxyfnks5rA0xJgaJpZM4K47Fr
.

Here's what I think we need to do to make this happen:

  • Introduce new class-edd-structured-data.php file
  • Build a class which generates the JSON for our data types
  • Output the data on wp_footer
  • Remove schema markup from templates
  • Deprecate edd_add_schema_microdata() or use that to hook into wp_footer and output the JSON

Looking for input to make sure I'm thinking about this correctly and not missing anything important.

@brashrebel that approach seems right to me!

@brashrebel Did you see my JSON-LD plugin? https://gitlab.com/caldera-labs/caldera-jsonld It's lacking a UI and isn't PHP5-friendly, but please to borrow code.

@brashrebel Would love to see this! 👍

We also need to add support for Fragments, which would help theme developers as well: https://github.com/json-ld/json-ld.org/issues/107 h/t @inetbiz

@cklosowski I've looked into fragments but not sure how it would apply to us?

@sunnyratilal not apply to you. When WE add json+ld, we can reference that hash id.

@amdrew As we've deprecated the existing schema functions, we'll need to push out an update to Themedd as it makes use of the edd_add_schema_microdata function.

@SDavisMedia The same applies for Vendd as well.

@sunnyratilal this looks really good! Working great for me. Couple things:

  1. Prolly not a priority now but we do have a Purchase Limits extension which would necessitate adding a filter to the value of availability.
  2. We're outputting '<script type="application/ld+json">' . $output_data . '</script>' on every page no matter what. Should that be revised to only be echoed when applicable? I just get <script type="application/ld+json">[]</script> on every non-download page.
  3. What happens if another plugin or theme tries to add that same script? Just curious, is there a way to enqueue it or check for it first? I don't actually know if that makes any sense.
  4. We might also need to have a filter for seller because FES 😄

Some or all of these can be separate issues so let me know how you feel about them and I'll make that happen if needed.

  1. There's a edd_generate_download_structured_data filter that could be used by extensions. Personally, I think we should keep it to one filter in case changes in the future and renames the available key to something else because that would make a edd_structured_data_available filter be semantically incorrect.
  2. I'll get this fixed. It _should_ only output on download pages.
  3. According to the JSON-LD specification, multiple <script> elements containing JSON-LD are valid so this shouldn't be an issue.
  4. Same as point 1.

Merged!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mindctrl picture mindctrl  ·  4Comments

michaelbeil picture michaelbeil  ·  5Comments

SDavisMedia picture SDavisMedia  ·  3Comments

zackkatz picture zackkatz  ·  5Comments

mikeyhoward1977 picture mikeyhoward1977  ·  5Comments