Created
April 28, 2017 16:10
-
-
Save johnReeve/3ad454f3e41b6652a92b37aad4fd8544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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