Skip to content

Instantly share code, notes, and snippets.

@johnReeve
Created April 28, 2017 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnReeve/3ad454f3e41b6652a92b37aad4fd8544 to your computer and use it in GitHub Desktop.
Save johnReeve/3ad454f3e41b6652a92b37aad4fd8544 to your computer and use it in GitHub Desktop.
<?php
// this sample is in MU-plugins. It's just a sample
// pattern about how you can use a namespaced class to
// decrease how much is injected into the global name space
namespace Materiell;
class Google_AMP_Mods {
public function __construct() {
add_filter('amp_post_template_metadata', [$this, 'filter_meta'], 100, 2);
}
// make sure that the schema metadata is correct
public function filter_meta ($metadata, $post) {
if (
isset($metadata['author'])
&& isset($metadata['publisher'])
) {
$metadata['author'] = $metadata['publisher'];
if (!isset($metadata['publisher']['logo'])) {
$metadata['publisher']['logo'] = [
'type' => 'ImageObject',
'url' => 'https://draxe.com/wp-content/themes/draxe2014/images/draxe-logo.png',
'width' => '167',
'height' => '119',
];
}
}
return $metadata;
}
}
$mat_google_AMP_mods = new Google_AMP_Mods();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment