my-language-skills / simple-metadata

Simple metadata use the default WP data to show to google as structured data.
GNU General Public License v3.0
2 stars 2 forks source link

Echo to json_encode #27

Closed davideC00 closed 4 years ago

davideC00 commented 5 years ago

Please give us a description of what happened.

Now, for printing json metadata to html, each plugin use the function echo.

Using this approach leads to:

Describe the solution you'd like

  1. There is a single array passed to each plugin
  2. Each plugin adds their metadata to it
  3. The array is printed with json_encode
    
    printf( '<script type="application/ld+json">%s</script>', json_encode( $array, JSON_PRETTY_PRINT) );

 json_encode format the metatags automatically with JSON_PRETTY_PRINT.
this is a common solution used by others plugin like Pressbook, Framework Seo ecc...
davideC00 commented 4 years ago

Solved 7e52ae4ecdc91e28c604a1be0dd8278ae4676c59